fix(terminal): let the active viewport reclaim PTY sizing - #191
Draft
Lint111 wants to merge 2 commits into
Draft
Conversation
This was referenced Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.