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(relay): answer every phone size report on a session-host session (#914)
reviewa535899e9b50
diff --git a/CLAUDE.md b/CLAUDE.mdindex 1d16ed130..9dc3944a8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -872,9 +872,12 @@ empty band and no explanation. `latestClaimSize` (`core/pty-size.ts`) picks thehighest recency — bumped by an attach, a claim that CHANGES, and a write that is not an emulator'sautomatic answer (`core/terminal-reports.ts`; every attached xterm answers a DA/CPR/OSC query, andcounting those would hand the session to whoever answered last). Three rules, each load-bearing:-(1) a viewer that cannot adapt is a CEILING — today's phone ignores `OP.Resized`, and a pty wider-than its screen wraps into garbage, so a relay sink is `bounding` unless `pty.attach` said-`resizedFrames: true`; (2) the real size flows back to every viewer (`SessionHostPty.onSize` →+(1) a viewer that cannot adapt is a CEILING — a pty wider than the phone's screen would wrap into+garbage there (or, rendered at the pty's size, be clipped to its left ~45 columns), so a relay sink is+`bounding` unless `pty.attach` said `resizedFrames: true`. The iOS app deliberately does NOT send it:+it reads `OP.Resized` only to show a "Sized to another screen · Fit this screen" hint, and every+phone report is ANSWERED (the sink's `sinkShown` is forgotten on each report) because the phone+clears that hint whenever it sends a size; (2) the real size flows back to every viewer (`SessionHostPty.onSize` →`PtyManager.applyBackendSize` → `pty:size`, and `OP.Resized` to the sink), and a session-host`Session`'s `applySize` only VOTES; (3) the host's `geometry` push is NEGOTIATED at `hello`(`SESSION_HOST_FEATURES`) and sent only to sockets that asked — an older client reads everydiff --git a/docs/windows-session-host.md b/docs/windows-session-host.mdindex 9427054e4..b11c78785 100644--- a/docs/windows-session-host.md+++ b/docs/windows-session-host.md@@ -271,10 +271,15 @@ every attached xterm answers a DA/CPR/OSC query, and counting those would hand twhoever answered last). Three rules come with it:- **A viewer that cannot adapt is a ceiling.** Every renderer view renders the size it is told- (`pty:size`: letterbox a smaller grid, clip a larger one, as a tmux client does). The phone today- does not — it ignores `OP.Resized` — and a pty wider than its screen would wrap into garbage, so a- relay sink is `bounding` unless `pty.attach` carried `resizedFrames: true`, and the chosen size is- clamped componentwise to every bounding claim.+ (`pty:size`: letterbox a smaller grid, clip a larger one, as a tmux client does). A pty wider than+ the phone's screen would wrap into garbage there, or — rendered at the pty's size — be clipped to+ its left ~45 columns, so a relay sink is `bounding` unless `pty.attach` carried+ `resizedFrames: true`, and the chosen size is clamped componentwise to every bounding claim. The+ iOS app keeps it that way on purpose: it reads `OP.Resized` only to explain the empty band+ ("Sized to another screen") and to offer "Fit this screen", which re-claims the size with a+ rows+1 → rows wiggle (an unchanged claim is not activity). Because the phone clears that hint+ every time it sends a size, the host ANSWERS every sink report, unchanged or not — the sink's+ `sinkShown` is forgotten on each report.- **The pty's real size flows back to every viewer.** `SessionHostPty.onSize` → `PtyManager``applyBackendSize` → `pty:size` to each view whose xterm is not already at it, and `OP.Resized`(payload = `OP.Resize`'s, 2× uint16 LE) to the relay sink. A session-host `Session` only VOTES indiff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex a1b210ae3..4ad2356bf 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -3978,8 +3978,12 @@ export class PtyManager {} else {const size = normalizeSize(cols, rows)session.sizes.set(sub, size)- // The sink's viewer fits itself too; that fit is what it is rendering until told otherwise.- if (sub === null) session.sinkShown = size+ // A sink that reports a size is owed an ANSWER to that report, even an unchanged one: the+ // phone clears its "sized to another screen" hint whenever it sends a size (it cannot tell+ // on its own whether it just became the active viewer), and a `Resized` that was already in+ // flight would otherwise re-raise the hint with nothing coming to correct it. So forget what+ // the sink was last told; the backend's next answer is forwarded unconditionally.+ if (sub === null) session.sinkShown = undefined// The view's own xterm fits itself locally (as it always has), so its fit — not the last// authoritative size we sent it — is what it is rendering right now. If that fit isn't the// effective size, applySize() below corrects it straight back.diff --git a/src/core/pty-session-host.test.ts b/src/core/pty-session-host.test.tsindex 9ba1fc1e2..0abcf8038 100644--- a/src/core/pty-session-host.test.ts+++ b/src/core/pty-session-host.test.ts@@ -176,6 +176,20 @@ describe('PtyManager session-host contracts', () => {bounded.emitSize(45, 30)expect(phoneSizes).toEqual([{ cols: 45, rows: 30 }])+ // Every report from the phone is answered, even when the answer has not changed: the phone+ // clears its "sized to another screen" hint on each resize it sends and needs the host to+ // restate the truth — here an unchanged vote, re-answered from the last backend size.+ m.resize(null, sid, 45, 40)+ expect(phoneSizes).toEqual([+ { cols: 45, rows: 30 },+ { cols: 45, rows: 30 }+ ])+ // A changed vote is answered by the backend, and forwarded even when it equals the report.+ m.resize(null, sid, 45, 38)+ bounded.emitSize(45, 38)+ expect(phoneSizes.at(-1)).toEqual({ cols: 45, rows: 38 })+ expect(phoneSizes).toHaveLength(3)+const other = m.createDetached({ cols: 80, rows: 24, persistKey: 'node-phone-2' },{ onData: () => {}, onExit: () => {}, adaptsToSize: true }