Skip to content

fix(terminal): a window in use no longer sizes the pane again when its health answer comes late - #4444

Merged
devswha merged 1 commit into
mainfrom
fix/pane-size-after-late-health
Nov 21, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/pane-size-after-late-health

Conversation

@devswha

@devswha devswha commented Nov 21, 2026

Copy link
Copy Markdown
Owner

What

A window that is using a pane no longer asks for its own terminal size again when it learns, late, whether herdr can attach. Closes #4378.

The defect

scripts/ui-contexts-regression.ts sometimes failed with a click in the desktop terminal: the pane is 35 47, not 42 121: a PC and a phone show the same pane, the phone has it at its size, a click in the PC's terminal takes it back, and a moment later the pane is at the phone's size again.

It is a product defect, not a test's wait:

  • A page attaches from the server's cached roster before its first /api/health answer arrives. Until then the pane's mirrored prop is null (src/App.tsx).
  • When the answer lands, mirrored becomes false. usePaneAttach ran the presentation hook on any change of cached, watched, presented or mirrored, and for a presented pane in use the hook calls refit(), which sends a forced resize.
  • The server gives the pane to the last window that sends a size. So a phone whose health answer arrived after the PC's click took the pane back without anyone touching the phone.

A person can meet it: open Ovis on a phone, click the PC's terminal before the phone's health answer is in, and the PC's terminal is drawn at the phone's size. It needs a herdr ping slower than about half a second, which is why it was rare and load-dependent.

The fix

src/lib/usePaneAttach.ts: when mirrored is the only one of the four that changed and the pane is neither cached nor released, the hook is not run. Whether herdr can attach decides how a pane that was put away comes back (watch, attach or mirror), so released and cached panes still run it. A pane in use has nothing to assert again. A render that changes presented and mirrored together still runs the hook once, and the mount runs it as before.

Reproduction and checks

  • scripts/chat-size-regression.ts (checkFocusedWindowReclaimsTerminalSize) now holds the phone's /api/health until the PC has taken the pane back, then lets it through and asserts that the phone sends no resize or attach and that the pane stays at the PC's size.
    • Before the fix: failed 2 of 2 runs, the phone sent { type: "resize", cols: 47, rows: 35 } right after its health answer.
    • After the fix: passed 3 of 3 runs (CHAT_SIZE_CASE=reclaim bun scripts/chat-size-regression.ts).
  • src/lib/usePaneAttach.hook.test.ts: three cases (a pane in use that only learns it; a released or cached pane that learns it; a change of presented or cached with or without it). With the fix's one return taken out, the first case fails.
  • bun run check fast: passed (22,319 unit tests, typecheck, build).
  • bun scripts/ui-contexts-regression.ts: passed once, 63 PASS lines, in the isolated test session.

Not covered

  • The other ui-contexts-regression rows of CI flakes: browser scripts that failed or needed a second run #4026 for 2026-11-20/21 are other failures (a Bun.serve() 10 s request timeout inside notification-startup-regression.ts, a branch's own secret-input failure, one lane time limit under load). This change does not touch them.
  • A health answer that later turns mirrored to true (a host where herdr cannot attach) for a pane in use also no longer sends a second resize. The attach already carried the window's grid; I read that path and did not run it on such a host.

🤖 Generated with Claude Code

…s health answer comes late

A page attaches from the server's cached roster before its first /api/health answer says whether
herdr can attach. That answer changed `mirrored` from null to false, which ran the presentation
hook again, and for a pane in use the hook asks for the window's grid: a phone that had just
opened a pane took it back from the PC that had clicked its terminal meanwhile (#4378).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where a desktop terminal could revert to a phone’s size when both opened the same pane in quick succession. Late connection checks no longer cause the desktop terminal to request another size change, preserving the size set by the desktop.

The pane attach hook now avoids a presentation decision when it learns mirror state for an active, uncached pane. Unit and browser regression tests cover the delayed health-response scenario and the resulting pane size.

Changes: Pane size after late health response

Layer / File(s) Summary
Pane attach presentation decision
src/lib/usePaneAttach.ts, src/lib/usePaneAttach.hook.test.ts
The hook tracks prior presentation state and skips the presentation callback when only mirror state changes for an active, uncached pane. Tests cover mirror, release, cache, and presentation transitions.
Late health-response regression
scripts/chat-size-regression.ts, changelog.d/pane-size-after-late-health.md
The browser test delays the phone's initial health response and checks that it causes no attach or resize frames and leaves the pane at the desktop's size. The changelog describes the scenario.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • devswha/ovis#2418: It changes pane attachment lifecycle and size ownership, including cached and released pane states used by this change.

Suggested reviewers: eddieparc

Merge Risk: Minimal · up to 1de33

This change stops a late health response from making a window resend its size and take the pane back from another window. The change is small and targeted, with unit and browser tests for the scenario. I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a window in use no longer re-sends its pane size when its health answer arrives late. It matches the changeset in usePaneAttach.ts, the hook test, and the regression s…
Description check Passed The description follows the repository template. The Change section explains the defect, the cause, the fix, and the behavior. The Validation section lists the commands run (bun run check fast and the…
Linked Issues check Passed Issue #4378 requires that, after a phone's pane-geometry arrives, a click in the desktop terminal restores the pane to 42x121 within 10 s. The reviewed head adds a guard in src/lib/usePaneAttach.ts. W…
Out of Scope Changes check Passed All changed files relate to the fix. src/lib/usePaneAttach.ts holds the guard and the import of useRef it needs. src/lib/usePaneAttach.hook.test.ts covers the new state transitions. scripts/chat-size-…
Full details: Title check

Explanation

The title names the main change: a window in use no longer re-sends its pane size when its health answer arrives late. It matches the changeset in usePaneAttach.ts, the hook test, and the regression script. It is specific and follows the conventional-commit style. It is long (95 characters), but it is still a single clear sentence.

Full details: Description check

Explanation

The description follows the repository template. The Change section explains the defect, the cause, the fix, and the behavior. The Validation section lists the commands run (bun run check fast and the regression scripts) with results and names the checks not covered. It does not state that a changelog entry was added under changelog.d/, and it does not mention contract-test coverage for HTTP changes. The changelog file is in the changeset, so this is a minor gap, not a missing section.

Full details: Linked Issues check

Explanation

Issue #4378 requires that, after a phone's pane-geometry arrives, a click in the desktop terminal restores the pane to 42x121 within 10 s. The reviewed head adds a guard in src/lib/usePaneAttach.ts. When only mirrored changes and the pane is neither cached nor released, the presentation hook (which sends a forced resize through refit) is skipped. The mount path and changes to presented, cached, or watched still run the hook. The mount case holds because the ref is seeded with the initial values, so mirroredAlone is false on mount. This removes the late-health resize that the PR identifies as the cause of the pane moving back to the phone's size. The change is covered by a new hook test (src/lib/usePaneAttach.hook.test.ts) and by a reworked check in scripts/chat-size-regression.ts (checkFocusedWindowReclaimsTerminalSize) that holds the phone's /api/health. The pass counts (2 of 2 failing before, 3 of 3 passing after) and the ui-contexts-regression run are author-reported. I did not run them. The issue itself says the cause is under investigation, so this fix rests on the mechanism the PR identifies from code.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the fix. src/lib/usePaneAttach.ts holds the guard and the import of useRef it needs. src/lib/usePaneAttach.hook.test.ts covers the new state transitions. scripts/chat-size-regression.ts is the reproduction for #4378. changelog.d/pane-size-after-late-health.md documents the fix. The PR does not touch the other #4026 regression rows, and the description says so explicitly. No unrelated change was found in the reviewed diff. The scripts/chat-size-regression.ts diff could not be read from the checkout, so its content rests on the PR summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b25ad20 and 1de3315.

Files selected for processing: 4

  • changelog.d/pane-size-after-late-health.md
  • scripts/chat-size-regression.ts
  • src/lib/usePaneAttach.hook.test.ts
  • src/lib/usePaneAttach.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

@devswha
devswha merged commit c4ee709 into main Nov 21, 2026
16 checks passed
@devswha

devswha commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 1de331552. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit reviewed this head.

@devswha
devswha deleted the fix/pane-size-after-late-health branch November 21, 2026 18:00
devswha added a commit that referenced this pull request Nov 21, 2026
…mmit (#4447)

## What

"Detect changes" reads what a pull request changed from the run's own
merge commit (`HEAD^1..HEAD`) instead of from
`github.event.pull_request.base.sha`.

## The defect

`github.event.pull_request.base.sha` is the base branch as the pull
request last saw it, not the commit the run's merge commit was made on.
Once `main` has moved, `git diff "$BASE_SHA" HEAD` also lists the files
of the pull requests merged in between, and the two skips that depend on
the list stop applying:

- `code=false` (a docs-only pull request skips the heavy jobs), and
- `browser=false` (#4441: a pull request whose paths cannot reach the
Browser regression jobs skips them).

Seen on #4426, which changes `ovis-site/`, two
`scripts/ovis-site*.test.ts` files and a changelog fragment:
`scripts/ci-browser-reach.sh` says `browser=false` for those six paths,
but run 44934012378 ran every browser job. The event's base was
c4ee709 (#4444); the merge commit d36a19d was made on 5197b05
(#4445), so the difference also held #4445's
`scripts/ci-browser-quarantine.ts` and
`scripts/relay-panel-regression.ts`, which keep the browser jobs. With
merges to `main` every few minutes this is the common case, not a rare
one.

The error was always on the safe side (more jobs, never fewer).

## The fix

In the filter step: when `HEAD` is a merge commit, the base is its first
parent. `actions/checkout` checks out `github.sha`, which for a
`pull_request` event is the merge of the head into the base, and
`fetch-depth: 0` is already set, so both parents are there. A `HEAD`
that is no merge commit keeps the event's base as before.

This narrows the list to exactly the pull request's own paths, which is
what both skips were written for. It cannot skip a job for a path the
pull request does change: those paths are in `HEAD^1..HEAD` by
construction.

## Validation

- `scripts/release-ci-reuse.test.ts` runs the filter step in a temp
repository. New cases: the base moved after the pull request saw it and
another pull request's client code was merged meanwhile; a
unit-test-only pull request still gets `browser=false`, a docs-only one
`code=false`, and one that changes client code itself `code=true`,
`browser=true`. With the new line taken out the test fails.
- `bun run check fast`: passed (22,319 unit tests, typecheck, build,
workflow syntax).
- Not shown yet: a real run. #4426, brought up to date after this
merges, is the check (its browser jobs should be skipped and
"Integration and browser" should still report success).

## Merge

This changes when two of a required check's jobs are skipped: it waits
for the maintainer's word.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI flake: a click in the desktop terminal does not take the pane back from the phone (ui-contexts-regression)

1 participant