Skip to content

fix(terminal): watch instead of attaching from an out-of-use tab - #1130

Merged
devswha merged 1 commit into
mainfrom
fix/902-out-of-use-watch
Oct 14, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/902-out-of-use-watch

Conversation

@devswha

@devswha devswha commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Change

Closes #902.

Problem. A fresh keep_size attach still spawns the PTY sidecar at the layout rectangle, or 80x24 when no rectangle is available. That spawn resizes the pane before the client can leave it alone. The layout is not the pane's current geometry, and herdr exposes no authoritative current-size API.

Behavior. A tab that is not visible or lacks document focus watches the pane read-only before acquiring a new attachment, independently of releasePaneAway. This covers loads/reloads, background reconnects, and replacement panes. PaneTerminal reuses the released/watch lifecycle; the socket lets it decide before attach replay. Focus, pointerdown, or eligible terminal key input resumes attachment. No server or wire-protocol change.

Exceptions and ownership:

  • queueWaits preserves the attachment for retained, in-flight, queued, or sending messages; one pane's queue does not confer ownership on its replacement.
  • Mirrored panes keep their existing attach/mirror path. An away pane waits for machine identity when health arrives after the roster, so it does not briefly start a watch on a mirrored PC.
  • Embedded pages, including the demo, retain their attachment behavior.
  • A server without the watch feature retains the existing keep_size attach behavior after capability discovery.
  • Joining an existing attachment also watches conservatively while away: the client cannot atomically distinguish a safe join from a fresh spawn if the last holder disconnects. Existing active attachments are not released solely by this fix.

The setting remains necessary. releasePaneAway still releases a previously active, existing desktop attachment one second after blur/hidden and watches instead. This fix only avoids acquiring a new attachment while away. #699 made release opt-in because unfocused windows, including visible second-monitor terminals, stopped updating and appeared frozen. #700 added read-only watching, but older bridges still pause and reattachment still changes the stream and geometry. Keep the setting and its default off in this fix; evaluating default-on is a separate usability decision, not grounds to remove it here.

The obsolete canvas-wide inherited-release flag is removed because each fresh pane now makes its own decision. A changelog fragment is included. scripts/fixed-sleeps.json decreases from 6 to 5 for chat-size-regression.ts: the background-reload assertion now waits for observable watch state rather than a fixed delay. No new fixed sleep was added.

Validation

  • bun run typecheck: exit 0.
  • HERDR_TEST_MODE=unit bun test ./src/lib/ws.test.ts ./src/lib/machineSession.test.ts ./src/lib/settings.test.ts: 132 pass, 0 fail.
  • bun run test:unit: 3,718 pass, 0 fail, 8 skip, across 291 files. Rerun after correcting the required fixed-sleep ratchet.
  • HERDR_TEST_MODE=unit bun test ./scripts/conventions.test.ts ./scripts/changelog-fold.test.ts: 21 pass, 0 fail on the final fixture; includes the no-new-fixed-sleep and shrinking-baseline checks.
  • bun run check run --build bun scripts/chat-size-regression.ts: 34 pass, 0 fail, exit 0. Its report records unchanged source and an unchanged build produced by the run.
  • bun x tsc --ignoreConfig --noEmit --strict --noUncheckedIndexedAccess --noUnusedLocals --target esnext --module esnext --moduleResolution bundler --allowImportingTsExtensions --skipLibCheck --jsx react-jsx --types bun scripts/chat-size-regression.ts: exit 0.
  • git diff --check: exit 0.

The new mount assertion failed before the fix by observing attach with keep_size: true. Browser coverage verifies preservation of a real 140x40 pane across background loads/reloads and a 132x38 replacement pane, plus reconnects, focus/pointer/key resume, queue ownership, delayed mirror identity, legacy capability fallback, cache transitions, existing-attachment joins, and an embedded iframe. Hidden-load and iframe-policy fixture failures were corrected; the iframe's framing override and loopback permission are test-context-only, with production security headers unchanged.

Verified locally on Linux/Chromium with Bun 1.4.3, Node 24.18.0, and herdr 0.9.3. Not verified on native Windows, macOS, or Safari. Mirror behavior uses controlled identity/geometry fixtures; the deployed demo was not exercised. The build still emits its existing large-chunk warning.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7d839669-c45e-44d5-bd7e-d8ac23e0fa85
📥 Commits

Reviewing files that changed from the base of the PR and between c3a9340 and 0b260b8.

📒 Files selected for processing: 9
  • changelog.d/out-of-use-watch.md
  • scripts/chat-size-regression.ts
  • scripts/fixed-sleeps.json
  • src/App.tsx
  • src/components/PaneCanvas.tsx
  • src/components/PaneTerminal.tsx
  • src/lib/paneAwayContext.ts
  • src/lib/ws.test.ts
  • src/lib/ws.ts
  • 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

Comment @coderabbitai help to get the list of available commands.

@devswha
devswha merged commit 393baae into main Oct 14, 2026
9 checks passed
@devswha
devswha deleted the fix/902-out-of-use-watch branch October 14, 2026 22:32
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.

terminal: a fresh keep_size attach resizes the pane

1 participant