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
fix(windows): don't enable tmux mouse tracking on session-host co-attach joiners
review3fd9c4119e59
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex 0e7282b15..83d37bd0a 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -2485,23 +2485,27 @@ export class PtyManager {// server returns that one itself when the socket drains. Scoped to THIS view: the other view's// (e.g. the still-open modal's) renderer pause is untouched.this.releaseFlow(existing, sub, 'renderer')+ // ONE gate for the three "a real tmux client is behind this join" answers, so they cannot drift:+ // `tmuxBacked` alone is not it — a session-host session (Windows) is ALSO recorded tmuxBacked+ // and carries a persistKey, but there is no tmux behind it, and the pty IS the shell.+ const realTmuxClient = existing.tmuxBacked && !existing.sessionHost// A tmux-backed join needs the mouse-tracking mode-enable sequences tmux only emits at its own// attach — a mid-stream subscriber missed them, and neither the `screen` capture nor a SIGWINCH// redraw re-sends them, so without this the joiner can't wheel-scroll tmux history until a- // keystroke. `persistKey` is set iff tmux-backed (local or remote), which is exactly the gate:- // our tmux always runs `mouse on`, so enabling these unconditionally matches its client state.+ // keystroke. Our tmux always runs `mouse on`, so enabling these unconditionally matches its+ // client state. A session-host joiner must NOT get it: nothing there runs `mouse on`, and the+ // enabled tracking would send the wheel and drags to the shell as SGR reports instead of+ // scrolling and selecting (it was gated on `persistKey`, which session-host sessions carry).// Rides `base` so it reaches the renderer on BOTH the resized and screen-painted branches.- const coAttachMouse = existing.persistKey ? true : undefined- // Alt-screen: tmux-backed ONLY, and `tmuxBacked` alone is not that gate — a session-host session- // is also recorded tmuxBacked (and carries a persistKey), and switching it (or a plain shell) to- // the alternate buffer would hide its only scrollback. See PtyCreateResult.coAttachAltScreen.- const coAttachAltScreen = existing.tmuxBacked && !existing.sessionHost ? true : undefined- // Same source, different question (and different consumer): a joiner needs to know whether the- // session it landed on survives losing a client, because its own unmount may park it.+ const coAttachMouse = realTmuxClient ? true : undefined+ // Alt-screen: same gate — switching a session-host session (or a plain shell) to the alternate+ // buffer would hide its only scrollback. See PtyCreateResult.coAttachAltScreen.+ const coAttachAltScreen = realTmuxClient ? true : undefined+ // Different question (and different consumer): a joiner needs to know whether the session it+ // landed on survives losing a client, because its own unmount may park it.const persistent = !!existing.persistKey- // The resync repaint's question, asked of every session (PtyCreateResult.tmuxClient) — for a- // join it is the alt-screen gate verbatim.- const tmuxClient = coAttachAltScreen+ // The resync repaint's question, asked of every session (PtyCreateResult.tmuxClient).+ const tmuxClient = realTmuxClient ? true : undefinedconst base: PtyCreateResult = existing.accountFallback? {sessionId: existingId,diff --git a/src/core/pty-session-host.test.ts b/src/core/pty-session-host.test.tsindex 3774abde6..60a8b6e58 100644--- a/src/core/pty-session-host.test.ts+++ b/src/core/pty-session-host.test.ts@@ -644,6 +644,31 @@ describe('PtyManager session-host contracts', () => {expect(joined.tmuxClient).toBeUndefined()})+ it('never tells a session-host joiner to enable tmux mouse tracking (no tmux runs `mouse on` there)', async () => {+ // Was gated on `persistKey`, which a session-host session carries: the joiner (card modal,+ // reloaded node, teammate) entered ?1000/?1002/?1006 tracking with no tmux behind it, so the+ // wheel and drags went to the shell as SGR reports instead of scrolling and selecting.+ backend.create.mockReturnValue(fakeSessionHostPty())+ const m = await makeManager()+ m.registerIpc()+ const create = host.handlers[IPC.ptyCreate]+ const options = { cols: 80, rows: 24, persistKey: 'node-mouse' }++ await create(7, options)+ const joined = (await create(8, options)) as {+ fresh: boolean+ persistent?: boolean+ coAttachMouse?: boolean+ coAttachAltScreen?: boolean+ tmuxClient?: boolean+ }+ expect(joined.fresh).toBe(false)+ expect(joined.persistent).toBe(true) // still a session that outlives its clients…+ expect(joined.coAttachMouse).toBeUndefined() // …but with no tmux mouse to turn on+ expect(joined.coAttachAltScreen).toBeUndefined()+ expect(joined.tmuxClient).toBeUndefined()+ })+it('leaves the live generation joinable when the confirmed backend kill rejects', async () => {const active = fakeSessionHostPty()backend.create.mockReturnValue(active)diff --git a/src/shared/types.ts b/src/shared/types.tsindex 679d2e87a..5f708030e 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -299,7 +299,9 @@ export interface PtyCreateResult {* is set. Since our tmux is always `mouse on` (local and remote), enabling these unconditionally* on a tmux-backed join matches tmux's own invariant client state; the enable is idempotent.* Set on BOTH join branches (screen-painted and resized) — the resize does not deliver them.- * Absent for a plain-shell join (no tmux ⇒ no tmux mouse) and for the solo spawn path.+ * Absent for a plain-shell join (no tmux ⇒ no tmux mouse), for a session-host (Windows) join —+ * same gate as `coAttachAltScreen`: no tmux runs `mouse on` there, and enabled tracking would+ * hand the wheel and drags to the shell — and for the solo spawn path.*/coAttachMouse?: boolean/**