Skip to content

fix(terminal): let go of an idle tab's pane beside herdr's own window - #2002

Merged
devswha merged 1 commit into
mainfrom
fix/web-tab-attach-size
Oct 26, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/web-tab-attach-size

Conversation

@devswha

@devswha devswha commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #712.

Problem

herdr keeps a pane at the size of a herdr terminal attach. A browser tab in use holds that
attach, so while it stays open herdr's own window (a TUI in a terminal, on this PC or another)
draws the pane cut off, and typing and clicks there land in the wrong place. Measured on herdr
0.9.5 in an isolated session: a TUI at 80x30 showed the pane at 53x29 while an attach from a
145x39 pty held it at 39x145, and growing the TUI did not take the size back; the pane followed
the TUI only once the attach ended. terminal session observe never resizes the pty.

herdr gives no way to attach with input but without the size: herdrdev/herdr#4682 (attach
without resize authority) is still open, #5553 (client claims size) was closed as not planned and
#5036 as intended. The 0.9.5 API also lists no attached clients and no exact pane size, so the
client cannot tell whether herdr's own window is open. The only lever is to stop holding the
attach when the tab is not typing.

Fix

Client only: server/, shared/, the WS contract and herdr are unchanged. It extends the
existing opt-in Settings -> Terminal -> Use alongside herdr's own window (releasePaneAway,
off by default), which already lets go of the pane a second after the tab goes out of use.
With it off nothing changes.

  • Idle release: a tab in use whose terminal is typed into directly lets go of its pane after
    IDLE_RELEASE_MS (10 s) without a key, click, paste or IME composition in it, through the same
    release machinery: detach, then the read-only watch view at herdr's size. The banner says
    "View only while you are not typing here · type or click to type". 10 s was chosen over 5 s,
    which flipped the size too often while reading output.
  • Taking it back: the next key, click, paste or composition start attaches again (no
    --takeover; a held pane shows the usual "Another app has this pane open").
  • What is typed meanwhile waits for that attach and goes to the pane once, in order, first key
    included, when it takes input within RESUME_INPUT_WAIT_MS (5 s). If the attach is held, fails,
    the pane ends, the connection drops, the attach is given up or the wait runs out, it goes to the
    existing held draft for Send/Discard, never by itself. Keys typed while a masked prompt is on
    screen (including one drawn in the watch view) are never kept (src/AGENTS.md).
  • Skipped where it would not help or would lose state: chat view, input-line mode, mirrored panes,
    a masked prompt, a selection, the find bar, an IME composition, and bridges without watch.
  • Settings and banner text in en/ko/ja/zh; docs/development.md notes the idle case.

Verification

  • scripts/chat-size-regression.ts (checkInactiveAttachLifecycle) adds idle, idle-off,
    idle-held, idle-offline, idle-expired and idle-secret: idle -> detach + watch + banner ->
    the bridge's attach ends -> typed line -> one attach at this window's size -> the line runs
    once, first key included; setting off keeps the attach; held/offline/expired keys go to the
    draft; a password is never held. A mutation (resume buffer disabled) makes idle fail. Full
    chat-size suite passes.
  • Recording (isolated test session i712-3-rec, a herdr TUI client at 100x30 beside a 1280x720 tab;
    the overlay reads the pane's own stty size). Measured in it: herdr's window alone 73x29 -> the
    tab typing 145x33 -> banner "View only while you are not typing here" after 10.3 s and the pane back
    at 73x29 -> the next line typed takes it back at 145x33 and runs once.
  • bun run check fast green.

Reviews before this PR: Codex Sol APPROVE, omo-native-code-reviewer APPROVE WITH NOTES. This
touches attach behaviour and queued input, so it asks for a real review.

UI wording follows the existing Ovis release banner ("View only while you use another window");
no external app's design is copied.

With Settings > Use alongside herdr's own window on, a tab in use that types
straight into the grid lets go of its pane after 10 s without a key, click,
paste or composition in its terminal, so herdr's own window has the pane at
its size again (#712). The next key takes the pane back; keys typed until the
new attach takes input are sent once, in order. If that attach fails, the
connection drops, the attach is given up or 5 s pass, they are held for review
instead, and never kept while a masked prompt is on screen.
@coderabbitai

coderabbitai Bot commented Oct 26, 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 11 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
Commits

Reviewing files that changed from the base of the PR and between 4d2e360 and eb8c508.

Files selected for processing: 13
  • changelog.d/idle-tab-release.md
  • docs/development.md
  • scripts/chat-size-regression.ts
  • src/components/PaneTerminal.tsx
  • src/components/SettingsDialog.tsx
  • src/lib/i18n/settings.ja.ts
  • src/lib/i18n/settings.ko.ts
  • src/lib/i18n/settings.zh.ts
  • src/lib/i18n/terminal.ja.ts
  • src/lib/i18n/terminal.ko.ts
  • src/lib/i18n/terminal.zh.ts
  • src/lib/paneTerminalShared.ts
  • src/lib/useTerminalMount.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 commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit did not review this PR (its "Review limit reached" comment above). This change touches queued input and attach behaviour, so per AGENTS.md two code-review agents' reviews stand in. Both ran on this branch before the push. Their findings and how each was resolved:

Codex Sol, round 1: REQUEST CHANGES

  1. Blocker, password could enter the resume buffer and the persisted draft. A Password: prompt drawn through watch-data while the tab only watched never updated the secret state, so keys typed at it were buffered as non-secret and, on a failed attach, landed in the draft (localStorage). Fixed: parsed watched output now updates the masked-prompt state (screenSecret() in the watch-data handler); keys typed at a detected masked prompt bypass the buffer, and the failure path checks the current secret state before retaining anything. New regression idle-secret checks both the draft and localStorage.
  2. Major, buffered input survived an abandoned attach (type into idle pane A, switch away, come back within 5 s: the next attach's readiness flushed the old command). Fixed: cancelLeave() now ends the pending resume (release, caching, deferred watching, pane cleanup); back() starts a fresh one afterwards, and ended input is retained for review, never sent.
  3. Major, readiness could bypass the 5 s deadline (expiry only checked by a poll). Fixed: flushResume() checks elapsed time against RESUME_INPUT_WAIT_MS before sending, independent of the expiry timer; late input goes to the draft. Covered by idle-expired.
  4. Minor, timing-dependent regressions. Fixed: the page clock stays paused and input-ready is held until the whole typed sequence (or the failure) is in, so ordering and the failure fallbacks cannot pass by timing luck.

Codex Sol, round 2: APPROVE. All four closed; verified by source tracing plus in-memory probes for ordered sending, cancellation, both expiry paths, secret-at-failure and pane replacement.

omo-native-code-reviewer, round 1: REQUEST CHANGES. The buffer could still be sent after an attach error, and the fallback paths had no tests. Fixed: pty-exit/error for the resuming pane and a reconnect call failResume(); idle-held, idle-offline and idle-expired cover the fallbacks.
Round 2: APPROVE WITH NOTES. Its remaining blocker turned out to be a leftover mutation artifact, not branch code. Notes, declined: focus returning within 5 s sends the keys to the draft (the safe side); the late/secret checks at flush are defensive and stay.

Declined after review: keys typed while a resume is cut short by a pane switch are dropped, not sent to the other pane, which is the safe failure. The idle timer still arms with the setting off but never releases.

Evidence: a mutation that disables the resume buffer makes idle fail, and each new fallback case was mutation-checked. The full scripts/chat-size-regression.ts run passed 40/40 before the push. After the push, bun run check fast is green, and idle/idle-off pass again on an isolated herdr session.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review report. Overall: PASSED. This is a client change to the terminal attach lifecycle. The Astra gate (omo-native-gate-reviewer, gpt-6-astra) approved eb8c508.

What it does: while a browser tab holds a pane's attach, herdr keeps the pane at that attach's size, so herdr's own window (a TUI) draws the pane cut off (#712). An idle tab now lets go of the attach, and there is a setting for this.

Gate results:

  • Regression script: all 40 outcomes of scripts/chat-size-regression.ts reproduce. They cover idle release, delivery of the first key after a release, refusal, disconnect, timeout and secret handling.
  • Unit and convention checks: settings, i18n and convention checks pass (128 tests). Typecheck is clean locally.
  • Bridge traps hold: the client never passes --takeover on its own, the attach stream stays the source of truth (no pane.read, scrollback 0), and selecting a pane doesn't move herdr focus.
  • Typed input: nothing typed is lost or sent automatically across a release or re-attach.

Not exercised:

  • Native IME and flicker across several devices weren't recorded separately.
  • CodeRabbit was rate-limited, so it didn't review this PR.

git merge-tree is clean against main and against every PR it shares files with: #1975, #1977, #1981, #1990, #1995 and #1997.

@devswha
devswha merged commit e49276d into main Oct 26, 2026
12 of 13 checks passed
@devswha
devswha deleted the fix/web-tab-attach-size branch October 26, 2026 12:56
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.

A web tab's attach holds the pane's size, so typing and clicks land wrong in herdr's TUI

1 participant