Repository navigation
fix(terminal): keep the grid on a desktop that is visible but unfocused - #1095
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
Keep blur as a reconnect-policy change without releasing the visible terminal's server-side grid. Hidden documents and panes still release, and a later Chat transition retains its one-shot release. Add unit and built-app browser regressions for visible blur followed by phone Chat. The old head sends one release and leaves the pty at 33x53; the fix sends none and restores 37x143, with the real shell confirming it in 844 ms. Verify 101 focused unit tests, five release-size contracts, the browser regression, explicit script typecheck, and fast checks with 3576 unit passes. Refs #472 Plan: .omo/plans/issue-sweep-2026-10-14.md
… deadlines, give the follow-up its own changelog fragment
505f915 to
e2dc4e1
Compare
## Problem GitHub-hosted fork CI repeatedly failed `checkChatKeepsTerminalSize` with `no size-5 answer from the pane` (runs 38618468326 and 38624998171). The pane snapshot showed the `size-5` command and the next shell prompt, but not the command's output. Main's self-hosted runs and local runs passed. ## Root cause The send RPCs were not lost or queued: the exact command reached the shell and the prompt returned. Probes also cannot overlap because each `size()` call is awaited until its unique marker resolves or throws. The failure was the observation channel: `pane.read(source: "recent")` reads a screen/history snapshot, and this helper already documents that a concurrent resize can reflow the screen and lose a completed output line. #1095 added a real-PTY restoration probe during the resize but used the screen-backed mode. On slower hosted runners, reflow could erase the marker even though the shell executed it. ## Change Use the helper's existing file-backed mode for `checkChatKeepsTerminalSize`. Each probe remains sequential and still runs `stty size` in the real pane shell, but reads its answer from the fixture directory instead of a reflowing screen snapshot. The two one-second restoration assertions are unchanged; no timeout or fixed sleep was added. Test-only change, so no changelog fragment. ## Validation - `bun run check run --build bun scripts/chat-size-regression.ts` — exit 0 (focused real browser/PTY regression) - `taskset -c 0 bun run check run --build bun scripts/ui-contexts-regression.ts` — exit 0; report verified, source unchanged (build 10.2 s, run 304.7 s) - `taskset -c 0-7 bun run check run --build bun scripts/ui-contexts-regression.ts` — exit 0; report verified, source unchanged (build 4.1 s, run 179.0 s) - `bun run typecheck` — exit 0 on final main base - `HERDR_TEST_MODE=unit bun test ./scripts/conventions.test.ts ./scripts/ci-browser.test.ts` — exit 0 on final main base Two intermediate full-suite attempts exited 1 before reaching chat-size in the pre-existing `checkTabMenu` locator timeout also present in the supplied hosted-CI artifact; no unrelated code was changed.
Refs #472
Follow-up to #1085 (merged), which hands the shared grid back only to a device still showing the terminal.
The regression
In #1085,
PaneTerminal'sleave()sentrelease-sizewhenever the page was out of use, and "in use" meansvisibilityState === "visible" && document.hasFocus(). A desktop window that is still on screen but merely unfocused (a second monitor, alt-tab to another app, using the phone beside the PC) therefore gave its grid away on every blur. When the phone then went back to Chat, no candidate was left, so the visible desktop stayed at phone width.The fix
leave()now releases the grid only when the document is actually hidden:socket.keepSize(pane, document.visibilityState === "hidden").HerdrSocket.keepSize(paneId, releaseGrid = true): withreleaseGrid = falseit changes only the reconnect policy (keep_sizeon the next attach) and sends norelease-size.shown = false) and a document that becomes hidden still release as before.mode !== "interact"check in the server'srelease-sizehandler (noawaitin between, so it was dead), and widens the two 1 swaitFordeadlines in the release-size contract tests to the 5 s their neighbors use.changelog.d/keep-grid-unfocused-desktop.md.Evidence
Failing-first unit test:
src/lib/ws.test.ts> "keeps a visible unfocused grid while changing only its reconnect policy"25b09433and on its squash7776c4fd(origin/main at the time): FAIL, 63 pass / 1 fail, because a release-size frame was sent on blur.Contracts: the 5
release-sizecases inserver/api.contract.test.tspass on an isolated herdr session.Browser QA: Playwright with a real herdr pty. Desktop 1280x800 in the terminal lens, phone 390x844 touch on the same pane.
visibilityState: "visible",hasFocus()returns false, and a windowbluris dispatched.The repo's browser regressions also pass on this branch:
checkChatKeepsTerminalSize(including the new blur block),checkPaneSwitchKeepsTerminalSize,checkBackgroundTabKeepsTerminalSize(#1068 cases, including "a desktop window shown without the focus leaves the shared grid at the phone's 33 53"),checkFocusedWindowReclaimsTerminalSizeandcheckSplitView. Typecheck passes.