fix(tui): preserve restart admission after repaint failure - #3686
Conversation
A successful restart suffix write was only recorded after the following viewport repaint. A repaint failure could therefore append the same rows again on the next restart. Advance the durable frontier immediately after the suffix reaches native scrollback and cover the failed repaint retry. Lore-id: tui-restart-admission Confidence: high Scope-risk: narrow Reversibility: trivial Tested: focused TUI render and restart recovery suites
The restart admission fix changes user-visible terminal behavior and must appear in the next package release notes.\n\nLore-id: tui-restart-changelog\nConfidence: high\nScope-risk: narrow\nReversibility: trivial\nTested: packages/tui check
|
Hostile disposition: MERGE_READY — existing TUI owner lane Exact head Hostile review of the restart-admission invariant: rows appended while stopped are admitted to native scrollback before repaint; the durable frontier is advanced at the admission boundary rather than after the repaint write, so a failed/detached repaint cannot cause duplicate suffix append on the next restart. The regression test covers the stop/append/restart, successful suffix append, failed viewport repaint, restore, and second restart sequence. Changelog coverage is present. No #3665 NotificationServer overlap or #3675 ordinary-ask premise scope is introduced; no P0/P1 found. Merge is authorized only after the exact current-head CI is terminal green. No merge performed by this review lane. — |
Follow-up to #3684.
Problem
A temporary TUI stop/start can append rows produced while stopped before repainting the live viewport. The append reaches native scrollback first, but the durable frontier was previously advanced only after the subsequent viewport repaint succeeded.
If that repaint write failed or the terminal detached, a later restart retained the old frontier and appended the already-admitted rows again.
Reproduction
Expected: each stopped row remains admitted exactly once.
Previous behavior: the old durable frontier caused the second restart to emit the stopped suffix again.
Change
Advance both the durable frontier and retained restart baseline immediately after the suffix append write succeeds. The subsequent viewport repaint remains responsible only for displaying the frame; its failure cannot re-admit bytes that already reached native scrollback.
Verification
bun --cwd=packages/tui run checkpassed.Scope
Only
packages/tui/src/tui.tsandpackages/tui/test/render-regressions.test.tschange. This is a follow-up to review feedback after the upstream transcript-loss PR merged; it targets the fork'sdevbranch only.Base:
eacf5345a1e9cf658a58f7cef0c06e79d4448e59Head:
610c256ca386985076f2beee85e7e09b866dd59b