diff options
| author | Igor Soarez <igor@soarez.org> | 2026-10-20 13:04:18 +0300 |
|---|---|---|
| committer | Igor Soarez <igor@soarez.org> | 2026-10-20 13:04:18 +0300 |
| commit | 3731a80384f5e2b7d3343eb3e4999f626bbc7f91 (patch) | |
| tree | f43ecbd02a91555c8c2e87027dc57b3e3f6338db /crates | |
| parent | 4af6a4f625b1965b783c9efb857f8ac665adb8eb (diff) | |
pi extension: identify the pane from TMUX_PANE
the extension asked tmux for "the current pane", which resolves to the
session's active pane, not the pane pi runs in, so agents in background
windows reported their state onto another pane. tmux sets TMUX_PANE for
every process it starts in a pane; use it.
e2e step 12 loads the shipped extension with a fake pi from a pane that
is not its session's active pane and asserts the report lands there; it
fails against the previous extension. hook reports log at info again.
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/dinggerd/assets/pi/pi-agent-state.ts | 21 | ||||
| -rw-r--r-- | crates/dinggerd/src/hooks.rs | 2 |
2 files changed, 5 insertions, 18 deletions
diff --git a/crates/dinggerd/assets/pi/pi-agent-state.ts b/crates/dinggerd/assets/pi/pi-agent-state.ts index 49d4b9c..df9e4e2 100644 --- a/crates/dinggerd/assets/pi/pi-agent-state.ts +++ b/crates/dinggerd/assets/pi/pi-agent-state.ts @@ -3,29 +3,16 @@ // add custom hooks/plugins beside this file instead of editing it. import net from "node:net"; -import path from "node:path"; -import { execSync } from "node:child_process"; // The dingger hook receiver listens here; override with DINGGER_AGENT_SOCKET. const socketPath = process.env.DINGGER_AGENT_SOCKET || `${process.env.HOME}/.local/state/dingger/agent.sock`; -// The extension runs inside a tmux pane, so it finds its own pane id. -function discoverPaneId(): string | undefined { - try { - const out = execSync('tmux display-message -p "#{pane_id}"', { - encoding: "utf8", - stdio: ["ignore", "pipe", "ignore"], - }); - const paneId = out.trim(); - return paneId.startsWith("%") ? paneId : undefined; - } catch { - return undefined; - } -} - -const paneId = process.env.DINGGER_PANE_ID || discoverPaneId(); +// tmux sets TMUX_PANE in the environment of every process it starts in a +// pane, so it names exactly the pane this pi runs in. (Asking tmux for "the +// current pane" is wrong: that is the session's active pane, not ours.) +const paneId = process.env.DINGGER_PANE_ID || process.env.TMUX_PANE; const source = "dingger:pi"; function enabled() { diff --git a/crates/dinggerd/src/hooks.rs b/crates/dinggerd/src/hooks.rs index 40f0f20..524fb2d 100644 --- a/crates/dinggerd/src/hooks.rs +++ b/crates/dinggerd/src/hooks.rs @@ -124,7 +124,7 @@ fn handle_stream(stream: UnixStream) { continue; } }; - debug!(pane = %params.pane_id, ?state, "hook report"); + info!(pane = %params.pane_id, ?state, "hook report"); { let mut reports = reports(); let pane = reports.entry(params.pane_id).or_default(); |
