fix(terminal): let the active viewport reclaim PTY sizing - #191
Conversation
Ark0N
commented
Aug 5, 2026
Hi Lior, closing this one as part of a cleanup of the seventeen PRs currently open from you. The full explanation is in #173, and I would rather you read that one than this note, because it is the honest version and it is not a dismissal of your work. The short form: sixteen PRs opened in a single day, roughly 42,000 added lines in total, landing mostly on the same few files (nine touch Going forward, please keep no more than three open PRs at a time, each one a single behavior change that stands on its own, with a test that fails on master and passes with the fix. #214 and #215, merged today, are good models. If this particular change fixes something that genuinely annoys you in daily use, it is a good candidate to be the first one you reopen on its own, rebased on current master. I will review it properly. Thanks for the effort you put in, and sorry to close it this way. |
Summary
Make shared terminal sizing follow the viewport that is actively being used, without letting background restores or reconnects steal the PTY size.
This fixes the mobile-to-desktop recovery failure where the desktop canvas could remain constrained to a prior phone or keyboard layout until the user manually forced a redraw.
Root cause
A Codeman session has one PTY size even when several browser viewports are connected. The previous arbitration treated a desktop WebSocket connection as active simply because it existed, while the browser could also send automatic resizes during restore and tab loading. That made presence, layout announcement, and real user activity indistinguishable.
The browser also repeated
fitAddon.fit()during the same keyboard or tab transition, exposing intermediate xterm layouts and adding avoidable visual stutter.What changed
takeControlresize option to the session API and WebSocket protocol.Commit structure
feat(terminal): add explicit viewport sizing ownershipAdds the server arbitration contract, HTTP/WS protocol support, per-socket dimension reassertion, and focused route/unit coverage.
fix(terminal): let active viewport reclaim PTY sizingAdds browser ownership signals, keyboard-aware layout recovery, reduced redundant fitting, and isolated Playwright coverage.
Validation
npx vitest run --config config/vitest.config.ts test/session-resize-arbitration.test.ts test/routes/session-routes.test.ts test/routes/ws-routes.test.ts- 126 passednpx vitest run --config config/vitest.config.ts test/terminal-touch-tap.test.ts- 20 passedtest/mobile/keyboard.test.tsviewport-control case - 1 passednpx vitest run --config config/vitest.config.ts test/terminal-viewport-ownership.test.ts- 3 passednpm run check:frontend-syntaxnpm run check:public-assetsnpm run typechecknpm run lintnpm run buildgit diff --checkThe complete mobile keyboard file is not claimed green: it currently has four unrelated baseline failures covering the existing accessory list, toolbar transform, CJK/local echo, and SGR tap behavior. The new viewport-control case passes independently.
Scope
This PR is limited to shared PTY viewport ownership and layout recovery. It does not include mobile navigation controls, terminal input persistence, bounded history streaming, response viewing, repository browsing, or session lifecycle caching.