Skip to content

fix(terminal): end a pane's recovery wait when its terminal leaves it, and cover the recovering edges (#1473) - #1990

Merged
devswha merged 11 commits into
mainfrom
fix/output-recovering-followups
Oct 26, 2026
Merged

devswha merged 11 commits into
mainfrom
fix/output-recovering-followups

Conversation

@devswha

@devswha devswha commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Fixes #1473

What changes for the user

A pane that comes back after herdr could not restore it, or whose terminal herdr replaced, now shows its screen as current again when its attachment recovered meanwhile. Before, such a quiet pane kept its DONE dot until new output arrived.

Items

  1. Server test of the recovering edges: already on main from test(terminal): cover the recovering joiner flag edges #1738 (server/core/terminals.test.ts).
  2. The recovery wait and a pane change: each pane in a layout has had its own keyed PaneTerminal since feat(ui): align pane controls and navigation with herdr TUI #747, and pane frames are filtered per renderer. So a sidebar pane switch never carries the wait over; the issue's "switching panes inside the same terminal component" no longer happens. One renderer still changes pane in two ways, and src/lib/useTerminalMount.ts now handles both:
    • herdr could not restore the pane: the terminal goes to no pane, then attaches afresh when the pane is restored. The mark is now dropped when the renderer leaves its pane (retireOutput); a rejoin is told output-recovering again while the attachment still recovers. Before, the old mark suppressed the healthy replay.
    • herdr replaced the pane's terminal: the mark is kept, keyed by pane (recoveringPane), until the new attach answers:
      • If it announces output-recovering again, the join's replay (joinReplay) is still the screen from before, even when it arrives after the replacement.
      • A replay that output-recovering did not announce (rejoin) joined an attachment that recovered meanwhile. That replay ends the wait and is shown as the current screen, while output queued before it is not.
  3. The regression waits on a signal: in scripts/sidebar-activity-demo-regression.ts, the "recovery" case's two-frame waits now wait until the terminal's output probe shows the text parsed, with nothing queued or in flight (outputParsed).
  4. Docs: docs/terminal-input.md documents output-recovering under "Readiness and failures": what the client does not do with the replay, that output credit is still acknowledged, and how the wait ends.

New demo cases:

  • recovering-restored: the restore round trip.
  • recovering-replaced: the terminal is replaced before the recovering join's replay comes. The late replay stays unshown, and the new attach's replay of the recovered attachment is shown.

The fixture gains hold, attaches, replaceTerminal and unrestored, and marks the recovering replay as replay, as the server does.

Verification

  • bun run typecheck passes, and bun test src/lib server/core/terminals.test.ts passes: 2352 pass, 0 fail (rerun on the C2 fix).
  • bun scripts/sidebar-activity-demo-regression.ts passes: exit 0, 44 PASS lines, including recovery, recovering-joiner, recovering-restored and recovering-replaced (rerun on the C2 fix).
  • The new cases fail without the fix:
    • recovering-restored fails on main's useTerminalMount.ts, and on this branch before the last fix commit (the restored screen never presents).
    • recovering-replaced fails in three variants:
      • On 62f94b3, the replay of the recovered attachment is never shown (C2).
      • With retireOutput always clearing the mark, the late replay is shown.
      • Without the joinReplay consumption, the late replay is shown.
    • The first version's recovering-switch case passed with the fix reverted, so it was replaced.
  • Browser check, recovering-restored at 1440x900 and 390x844: the restored pane's screen shows as current in the terminal lens, with no blank or overlapping area.
  • bun run check fast: passes before the rebase (unit 7188 pass, 0 fail). After the rebase onto 0.4.18, the only failure is the known flake Flaky: grok exact store lookup misses the held session beside an older events file on CI #1994 (server/grok.test.ts, untouched here; 3/3 passes alone). Every other step is ok, and the full demo regression passes again (44 PASS).

Reviews

  • omo-native-code-reviewer:
    • First pass: REQUEST CHANGES. The switch case passed on main, a round trip kept a stale wait, and the same-pane replacement case had no test.
    • Re-review of the fix: APPROVE, with LOW notes only.
    • Review of the C2 fix: APPROVE, with LOW notes only.
  • Codex Sol (gpt-6.1-sol, xhigh) ran on the first version and found the same two MEDIUMs, both fixed here. Codex Sol review did not run (host stall) on the fix commits; the merge pass reviews.

@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 9 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 c69f644.

Files selected for processing: 4
  • changelog.d/restored-pane-output-recovering.md
  • docs/terminal-input.md
  • scripts/sidebar-activity-demo-regression.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 hit its review limit on this PR, so no CodeRabbit review ran. Here are the code-review agent reviews and how each finding was resolved.

omo-native-code-reviewer, first pass (on the earlier recovering-switch version): REQUEST CHANGES

  • HIGH: recovering-switch passed on main. Each pane has its own keyed PaneTerminal (PaneCanvas.tsx key={item.pane_id}, since feat(ui): align pane controls and navigation with herdr TUI #747), so a sidebar switch never reused a renderer. Resolved: the case is replaced by recovering-restored, which drives the one reachable renderer reuse (a restore error sends paneId to null and back). It fails on main and on this branch before the fix commit.
  • MEDIUM: a round trip back to a recovered pane kept a stale wait. Resolved: retireOutput drops the mark when the renderer leaves its pane (e0aa06a).
  • MEDIUM: the same-pane terminal replacement had no test. Resolved: recovering-replaced, which fails when retireOutput clears the mark unconditionally.

omo-native-code-reviewer, re-review of the fix commits: APPROVE. The LOW notes are left as they are:

  • The negative count() === 0 checks rely on React having committed after the parse.
  • A replaced terminal that joins an already-ready attachment waits for new output, as on main. This is deliberate.
  • A restore round trip faster than one network round trip could still take old in-flight frames as current.
  • hold() stores replay fields it never reads.

Codex Sol (gpt-6.1-sol, xhigh): on the earlier version it found the same two MEDIUMs (the round trip, and the switch case not failing without the fix). Both are resolved above. Its re-review of the fix commits did not run because of a host stall.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review of 62f94b3: the Astra gate (omo-native-gate-reviewer, gpt-6-astra) rejected it on one blocker.

What holds: the restore fix itself works. A quiet restored pane whose attachment recovered meanwhile is shown as current again. The server lifecycle tests pass 7/7. Astra also reviewed the mutation logs and the desktop and mobile screenshots.

BLOCKER C2: a recovering pane stays unpresented when its replacement joins an attachment that is already ready (src/lib/useTerminalMount.ts:885-891, :1025-1036, :1046-1067)

  • The case: the pane is recovering, and its terminal is replaced by one that joins an attachment that is already ready.
  • What happens: Chromium showed that the replacement's replay was parsed, but the current-content marker never appeared. The pane is never shown as current until new output arrives, so it can keep a stale DONE.
  • Fix: end the recovery wait, and mark the content current, when a replacement joins an attachment that is already ready. Add a browser regression case for that edge. If you'd rather leave this as a known limitation from before this PR, say so in the PR body and the docs, and I'll take C2 as narrowed.

Astra could not get the full browser run's completion receipt, so it claims no independent full-suite pass. This PR is client only, so it can merge during the release once it is approved and CI is green. The re-review will cover only the new commits.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Re the Astra gate's C2 on 62f94b3: fixed, not narrowed.

Cause: the server announces a recovering join with output-recovering before that join's replay (terminals.ts:357-361). When it joins an attachment that is already ready, it sends only the replay and input-ready. Before this fix, the mark carried over from the old attach suppressed that replay, and input-ready then revoked it.

Change (18ee551, src/lib/useTerminalMount.ts):

  • After a same-pane replacement (rejoin), a replay that output-recovering did not announce ends the wait.
  • It bumps the output lifetime before its own capture. Its parse then presents the current screen, and output queued before it does not.
  • The recovering join's own replay (joinReplay) still counts as the screen from before, even when it arrives after the replacement.

Browser regression: recovering-replaced (1ed9c45) drives that order. The attach is held, output-recovering arrives, the terminal is replaced, a late replay:true frame must stay unshown, and then a new replay:true frame plus input-ready must show, with no new output.

  • It passes on the fix.
  • It fails on 62f94b3's useTerminalMount.ts at the final presentation.
  • It fails at the late-replay assertion when retireOutput always clears the mark.
  • It fails at the late-replay assertion without the joinReplay consumption.

Other evidence:

  • Full sidebar-activity-demo-regression: 44 PASS.
  • bun test src/lib server/core/terminals.test.ts: 2352 pass.
  • The docs (docs/terminal-input.md) and the changelog fragment cover the replaced terminal.
  • omo-native-code-reviewer approved the delta.

Remaining LOW notes (not fixed):

  • If the old join's replay was empty, joinReplay stays set and the new replay is taken as the old one. That brings back the old wait, which fails safe. It is unlikely, because a recovered attachment's replay buffer is not cleared.
  • A ready:false from the old stream landing after the replacement drops rejoin. That needs the attachment to take, end and take again within one round trip.

Codex Sol did not run on this delta (host stall).

mp added 11 commits October 26, 2026 18:56
…terminal still waits (#1473)

Review follow-up: retireOutput also runs when the same pane's terminal is replaced, so clearing the
mark there let that pane's late replay be presented as current before its new attach took. The mark
now names the pane it was received for: the next pane's output is its own, and the same pane keeps
waiting for its attach. The sidebar-activity demo adds a case that opens the next pane after a
recovering one and expects its screen, the recovering-joiner case uses the shared output wait, and
the docs say transport credit is still acknowledged and the input row is not read from the replay.
…pane (#1473)

A pane herdr could not restore takes its terminal to no pane; restored, it attaches afresh, and the server tells it again while the attachment still recovers. The mark kept from before suppressed the healthy replay, so a quiet restored pane kept its DONE dot until new output. A replaced terminal of the same pane still keeps the mark.
…recovery demo cases (#1473)

The recovering-switch case passed with the fix reverted: each pane has its own keyed terminal, so a sidebar switch never reused one. recovering-restored fails on main; recovering-replaced fails when retiring the output always clears the mark.
…recovered meanwhile (#1473)

A recovering pane's replaced terminal attaches again. When that join reaches an attachment that already recovered, the server sends its replay and readiness without output-recovering; the mark carried from the old attach suppressed the replay and the readiness revoked it, so the screen waited for new output. The recovering join's own replay (announced by output-recovering) still stays the screen from before; a replay it did not announce ends the wait.
…s replay, then join a recovered attachment (#1473)
@devswha
devswha force-pushed the fix/output-recovering-followups branch from 9bec42c to c69f644 Compare October 26, 2026 10:03
@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Integration tests on c69f644 failed only on known flake #1948 (WebSocket insert contract, longest line timeout; this PR touches no server code). Please rerun in merge order; I am not rerunning it.

@devswha

devswha commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merge pass review report. Overall: PASSED. This is a client change in the terminal attach path. An Astra gate (omo-native-gate-reviewer, gpt-6-astra) approved 9bec42c on its second round.

What holds: a quiet restored pane whose attachment recovered in the meantime is shown as current again (#1473). The server lifecycle tests pass 7/7.

C2 (62f94b3), fixed in 18ee551 and 1ed9c45:

  • Problem: a recovering pane whose replacement joined an attachment that was already ready stayed unpresented until new output arrived.
  • Fix: the replacement's replay now presents the pane as current and clears DONE.
  • Proof: Astra's Chromium reproduction confirms the fix. The browser regression passes on the new head and fails at the expected presentation wait against the previous client.

Bridge traps still hold: no pane.read for attached panes, scrollback stays 0, and nothing resizes, takes over or moves focus. Typecheck and the adjacent recovery, recovering-joiner and recovering-restored browser cases pass.

Minor note: the rewritten replacement test uses a late frame marked as a replay where the old test used an unmarked one. The production guard is unchanged.

@devswha
devswha merged commit f6ed6d6 into main Oct 26, 2026
19 of 22 checks passed
@devswha
devswha deleted the fix/output-recovering-followups branch October 26, 2026 13:46
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.

Recovering joiner: test the recovering flag edges, reset on pane switch, docs (#1472 follow-ups)

1 participant