Problem
Each wta-helper currently starts its own wtcli listen subscription to the Terminal COM event broadcast. The master now owns authoritative agent_event routing, so helpers no longer forward agent CLI hooks; however, every helper still receives and parses every window-wide WT event to maintain synchronous pane-local state for:
- pane → agent-session binding (
is_agent_pane, key_for_pane, origin_for_pane)
- shell-agent exit inference from
OSC 133;A
- pane-local Autofix classification and target selection
With N tabs, one event is still delivered and parsed N times. Most cross-tab events are discarded only after they have crossed the COM/process boundary.
Goal
Make the master the only window-wide WT event subscriber. Helpers should receive only owner-scoped, typed state/events from master rather than subscribing independently to the global COM stream.
Proposed direction
- Keep
wta-master as the sole consumer of agent_event, connection_state, tab lifecycle, and other global WT events.
- Have master publish typed pane/session binding deltas to the owning helper over the existing helper pipe.
- Preserve the helper's synchronous local lookup model — update its local
AgentSessionRegistry from those typed master notifications before pane-local input/UI decisions need the data.
- Replace the high-volume raw
vt_sequence dependency for shell-agent exit detection with either:
- a narrow master-routed
shell_prompt_started event emitted by Terminal for OSC 133;A, or
- an owner-scoped notification from master after it filters the global VT stream.
- Remove helper
CliChannel::subscribe_events / wtcli listen processes once every helper consumer has a typed master-owned source.
- Consider replacing the master's
wtcli listen child process with an in-process COM ITerminalProtocol::Subscribe client so subscription readiness and lifetime are owned in one process.
Constraints
- Do not make helper UI/input wait on a synchronous round-trip to master; pane binding must remain locally queryable.
- Preserve per-tab and per-window identity. Never broadcast a pane mutation to unrelated helpers.
- Preserve shell-pane Gemini
/exit detection when the pane remains alive and no SessionEnd hook arrives.
- Preserve graceful degradation: if the authoritative event subscriber is unavailable, chat, Autofix, history listing and resume remain operational; only real-time session status may be stale until reconnection.
- Do not regress hook failure isolation: agent CLI hooks must remain silent and exit 0 when Terminal is unavailable.
Acceptance criteria
- One WT event causes one global parse/routing operation in master, not one per helper.
- A helper receives only events/deltas relevant to its owner tab/window.
- No helper owns a
wtcli listen child process.
- Shell-agent
OSC 133;A exit detection, connection failures, pane close, Autofix targeting, tab drag/rename, and session focus/resume continue to pass their existing unit and ItE2E suites.
- A multi-tab ItE2E proves that an event in tab A does not cross into helpers for tabs B/C while tab A's local pane binding updates before its next decision.
Problem
Each
wta-helpercurrently starts its ownwtcli listensubscription to the Terminal COM event broadcast. The master now owns authoritativeagent_eventrouting, so helpers no longer forward agent CLI hooks; however, every helper still receives and parses every window-wide WT event to maintain synchronous pane-local state for:is_agent_pane,key_for_pane,origin_for_pane)OSC 133;AWith N tabs, one event is still delivered and parsed N times. Most cross-tab events are discarded only after they have crossed the COM/process boundary.
Goal
Make the master the only window-wide WT event subscriber. Helpers should receive only owner-scoped, typed state/events from master rather than subscribing independently to the global COM stream.
Proposed direction
wta-masteras the sole consumer ofagent_event,connection_state, tab lifecycle, and other global WT events.AgentSessionRegistryfrom those typed master notifications before pane-local input/UI decisions need the data.vt_sequencedependency for shell-agent exit detection with either:shell_prompt_startedevent emitted by Terminal forOSC 133;A, orCliChannel::subscribe_events/wtcli listenprocesses once every helper consumer has a typed master-owned source.wtcli listenchild process with an in-process COMITerminalProtocol::Subscribeclient so subscription readiness and lifetime are owned in one process.Constraints
/exitdetection when the pane remains alive and noSessionEndhook arrives.Acceptance criteria
wtcli listenchild process.OSC 133;Aexit detection, connection failures, pane close, Autofix targeting, tab drag/rename, and session focus/resume continue to pass their existing unit and ItE2E suites.