Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(windows): session host reports the pane app's mouse-tracking mode (paneModesV1)
review33966fb8afc6
diff --git a/src/core/__fixtures__/no-session-host.ts b/src/core/__fixtures__/no-session-host.tsindex 7f8dc8556..428810ad7 100644--- a/src/core/__fixtures__/no-session-host.ts+++ b/src/core/__fixtures__/no-session-host.ts@@ -48,6 +48,10 @@ export function noSessionHost(): Record<string, unknown> {sessionHostKillSession: async () => {},sessionHostListSessions: async () => [],sessionHostPaneCommand: async () => null,- sessionHostSendKeys: async () => false+ sessionHostSendKeys: async () => false,+ sessionHostMouseTracking: async () => null,+ sessionHostExecuteLaunch: async () => {+ throw new Error('session-host launch in a suite that mocked the backend out')+ }}}diff --git a/src/core/session-host-backend.ts b/src/core/session-host-backend.tsindex 821497f6a..9dac76a8b 100644--- a/src/core/session-host-backend.ts+++ b/src/core/session-host-backend.ts@@ -131,6 +131,13 @@ export async function sessionHostCapture(name: string, full: boolean): Promise<sreturn getClient().capture(name, full)}+/** The pane app's mouse-tracking protocol (`paneModesV1`), null = unknown / older host. */+export async function sessionHostMouseTracking(+ name: string+): Promise<'none' | 'x10' | 'vt200' | 'drag' | 'any' | null> {+ return getClient().mouseTrackingMode(name)+}+/** Execute already-rendered trusted input through the persistent generation's exactly-once* launch ledger. The plan never crosses preload/renderer/relay boundaries. */export async function sessionHostExecuteLaunch(diff --git a/src/core/session-host-client.ts b/src/core/session-host-client.tsindex 451882439..281d560dc 100644--- a/src/core/session-host-client.ts+++ b/src/core/session-host-client.ts@@ -32,6 +32,7 @@ import {type HasSessionResult,type PaneCommandResult,type CaptureResult,+ type PaneModesResult,type KillSessionResult,type ExecuteLaunchResult,type ListSessionsResult,@@ -1645,6 +1646,19 @@ export class SessionHostClient {} catch { return false }}+ /** The pane app's mouse-tracking protocol, or null when unknown: no such session, or an older+ * live host that predates `paneModesV1` (never replaced to learn it). Callers treat null as+ * "the app did not ask for the mouse". */+ async mouseTrackingMode(name: string): Promise<PaneModesResult['mouseTracking'] | null> {+ try {+ const r = await this.request<PaneModesResult | null>({ cmd: 'paneModesV1', name })+ const m = r?.mouseTracking+ return m === 'none' || m === 'x10' || m === 'vt200' || m === 'drag' || m === 'any' ? m : null+ } catch {+ return null+ }+ }+async capture(name: string, full: boolean): Promise<string> {const result = await this.request<CaptureResult>({ cmd: 'capture', name, full })return result.textdiff --git a/src/session-host/host.ts b/src/session-host/host.tsindex a06d1a9d0..b3f59767e 100644--- a/src/session-host/host.ts+++ b/src/session-host/host.ts@@ -29,6 +29,7 @@ import {type HasSessionResult,type PaneCommandResult,type CaptureResult,+ type PaneModesResult,type KillSessionResult,type ListSessionsResult,type ShutdownResult@@ -993,6 +994,13 @@ async function main(): Promise<void> {ok: true,result: await hostMessagePane(() => sessions.get(req.name)).send(req.envelope, req.expected)}+ case 'paneModesV1': {+ const s = sessions.get(req.name)+ if (!s || s.exited) return { ok: true, result: null }+ const mouseTracking = await s.mouseTrackingMode()+ if (s.exited || sessions.get(req.name) !== s) return { ok: true, result: null }+ return { ok: true, result: { mouseTracking } satisfies PaneModesResult }+ }case 'capture': {const s = sessions.get(req.name)if (!s || s.exited) return { ok: true, result: { text: '' } satisfies CaptureResult }diff --git a/src/session-host/protocol.ts b/src/session-host/protocol.tsindex 5bdae9e02..a5ccb0289 100644--- a/src/session-host/protocol.ts+++ b/src/session-host/protocol.ts@@ -99,6 +99,9 @@ export type SessionHostRequest =| { id: number; cmd: 'messagePasteReadyV1'; name: string }| { id: number; cmd: 'messageEnvelopeV1'; name: string; envelope: string; expected: PaneOwner }| { id: number; cmd: 'capture'; name: string; full: boolean }+ /** Additive (the `messageOwnerV1` idiom): an older live host answers `unknown command`, which the+ * client reads as "unknown", never as a reason to replace the host. Result: `PaneModesResult`. */+ | { id: number; cmd: 'paneModesV1'; name: string }| {id: numbercmd: 'executeLaunch'@@ -238,6 +241,10 @@ export interface ExecuteLaunchResult {export interface PaneCommandResult {command: string | null}+/** `result` of `paneModesV1`; `null` result = no such live session. */+export interface PaneModesResult {+ mouseTracking: 'none' | 'x10' | 'vt200' | 'drag' | 'any'+}export interface CaptureResult {text: string}diff --git a/src/session-host/session.ts b/src/session-host/session.tsindex 2a13a88d0..b1388e170 100644--- a/src/session-host/session.ts+++ b/src/session-host/session.ts@@ -297,6 +297,12 @@ export class HostSession {return this.term.bracketedPasteRequested()}+ /** The pane app's mouse-tracking protocol, behind `outputTail` for the same reason. */+ async mouseTrackingMode(): Promise<'none' | 'x10' | 'vt200' | 'drag' | 'any'> {+ await this.outputTail+ return this.term.mouseTrackingMode()+ }+/** Agent messaging's stricter form of the same read: the pane must also still be alive and not* inside a private launch, because the envelope is only ever written as a framed paste. */async messagePasteReady(): Promise<boolean> {diff --git a/src/session-host/terminal-emulator-modes.test.ts b/src/session-host/terminal-emulator-modes.test.tsnew file mode 100644index 000000000..4a1977a78--- /dev/null+++ b/src/session-host/terminal-emulator-modes.test.ts@@ -0,0 +1,23 @@+// `TerminalEmulator.mouseTrackingMode` — the session host's answer to "did the APP in this pane ask+// for the mouse?", read off @xterm/headless fed the pane's own output. The relay's scroll routing+// (`PtyManager.scrollRoute`, via `paneModesV1`) writes a wheel event into a session-host pane only+// when this is not 'none': with no tmux in front, an unrequested wheel is raw text in the prompt.+import { describe, it, expect } from 'vitest'+import { TerminalEmulator } from './terminal-emulator'++describe('TerminalEmulator.mouseTrackingMode', () => {+ it('follows the app’s DECSET / DECRST', async () => {+ const t = new TerminalEmulator({ cols: 80, rows: 24, scrollback: 100 })+ try {+ expect(t.mouseTrackingMode()).toBe('none')+ await t.write('\x1b[?1000h\x1b[?1006h')+ expect(t.mouseTrackingMode()).toBe('vt200')+ await t.write('\x1b[?1002h')+ expect(t.mouseTrackingMode()).toBe('drag')+ await t.write('\x1b[?1002l\x1b[?1000l')+ expect(t.mouseTrackingMode()).toBe('none')+ } finally {+ t.dispose()+ }+ })+})diff --git a/src/session-host/terminal-emulator.ts b/src/session-host/terminal-emulator.tsindex 3f777e253..a90f10e80 100644--- a/src/session-host/terminal-emulator.ts+++ b/src/session-host/terminal-emulator.ts@@ -92,6 +92,18 @@ export class TerminalEmulator {return this.term.modes.bracketedPasteMode}+ /**+ * Which mouse-tracking protocol the app in this pane has requested (`CSI ?1000h` / `?1002h` /+ * `?1003h` / `?9h`), `'none'` when it has asked for none. Same provenance argument as+ * `bracketedPasteRequested`: this emulator is fed the pane's own output, so the mode is the+ * app's, not a client terminal's. The relay's `pty.scroll` asks it before writing a wheel event+ * into a session-host pane (`PtyManager.scrollRoute`) — with no tmux in front, a wheel the app+ * did not ask for lands in the prompt as raw escape text.+ */+ mouseTrackingMode(): 'none' | 'x10' | 'vt200' | 'drag' | 'any' {+ return this.term.modes.mouseTrackingMode+ }+dispose(): void {try {this.serializer.dispose()