Skip to content

Make wta-master the sole WT event subscriber #819

Description

@DDKinger

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

  1. Keep wta-master as the sole consumer of agent_event, connection_state, tab lifecycle, and other global WT events.
  2. Have master publish typed pane/session binding deltas to the owning helper over the existing helper pipe.
  3. 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.
  4. 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.
  5. Remove helper CliChannel::subscribe_events / wtcli listen processes once every helper consumer has a typed master-owned source.
  6. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions