Skip to content

fix(tui): preserve shared prompts when scrollback is full - #115165

Merged
steipete merged 1 commit into
mainfrom
codex/tui-stress-third-pass
Jul 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/tui-stress-third-pass

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users sharing a TUI conversation with another client would lose that other client's delayed prompt once the terminal scrollback reached its component limit. The assistant response remained visible, making the synchronized conversation look as if it had no user message.

Why This Change Was Made

The new shared-chat synchronization inserts an authoritative prompt immediately before its already-streaming assistant. At full capacity, ordinary oldest-first eviction immediately removed that newly inserted prompt. Protect both the prompt and its owning assistant during that insertion only, and evict the oldest genuinely unprotected component instead. Keep all other chat-log pruning, run state, and component limits unchanged.

User Impact

Busy, long-running shared TUI sessions retain both the other client's prompt and its live assistant reply in the correct order, without duplicate prompts or unbounded scrollback.

Evidence

Fresh main, before fix:

20-component scrollback + active stream + delayed cross-client prompt
expected: Sent from the other client.
received: Already streaming. (prompt immediately pruned)
result: FAIL

Final regression on the reviewed patch:

delayed prompt stays visible and precedes its active reply: PASS
duplicate authoritative replay appears exactly once: PASS
oldest unprotected notice is evicted: PASS
component count remains exactly 20: PASS
assistant continues streaming after overflow: PASS

Blacksmith Testbox tbx_01kym6yazh45w0wd8we3cfpe9p:

  • complete chat-log regression suite: 35 passing tests;
  • complete TUI suite: 908 passing tests across 35 files;
  • full real-terminal, local-backend, and real-Gateway suite: 61 passing tests;
  • full changed gate, typecheck, formatting, and repository guards: PASS;
  • type-aware TUI lint: PASS;
  • fresh independent autoreview: clean, no accepted or actionable findings;
  • prior fresh-main stress soak: three full-screen terminal-race passes and two real-Gateway race passes, after the full 907-test TUI baseline and 61-case Gateway baseline.

Additional live Gateway contract proof

The actual web and TUI websocket regression in src/gateway/session-message-events.test.ts also passes independently in all three configured Gateway projects on Blacksmith Testbox tbx_01kym6yazh45w0wd8we3cfpe9p. It connects real web and TUI subscribers to one authoritative transcript, persists turns from both clients, verifies matching session.message delivery, reconnects the TUI client, and verifies the complete chat.history result. This supplements the 61 passing full-screen terminal scenarios and proves that the owner-local scrollback fix does not change Gateway synchronization.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete
steipete marked this pull request as ready for review July 28, 2026 11:48
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 7:58 AM ET / 11:58 UTC.

ClawSweeper review

What this changes

The PR changes TUI chat-log pruning so a delayed prompt synchronized from another client remains beside its already-streaming assistant reply when a full scrollback evicts older entries.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open and clear the prior P2 concern: ChatLog clamps its effective scrollback capacity to at least 20, so the previously described one-component overflow cannot occur. The focused pruning change preserves the recovered prompt and streaming reply while retaining the bounded 20-component behavior covered by the regression test.

Likely related people: steipete is the only attributable recent TUI contributor in the supplied commit metadata; confidence is low for broader ownership routing.

Priority: P2
Reviewed head: f7ebe4c93b5b207061b3850c0161a2a090b81e5a

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused implementation with a direct boundary regression and unusually strong reported runtime validation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides after-fix real-terminal and real-Gateway behavior evidence, including bounded scrollback and continued streaming; no visual proof is necessary for this terminal-state change.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides after-fix real-terminal and real-Gateway behavior evidence, including bounded scrollback and continued streaming; no visual proof is necessary for this terminal-state change.
Evidence reviewed 4 items Minimum scrollback capacity: Current main clamps maxComponents to Math.max(20, Math.floor(maxComponents)); a one-component log cannot be constructed through this class, so the earlier all-protected-at-capacity concern does not apply.
Focused overflow regression: The proposed regression fills a 20-component chat log, inserts the delayed shared prompt twice, verifies deduplication and prompt-before-assistant ordering, confirms the oldest unprotected notice is evicted, and asserts the component count remains 20.
Pruning scope: The branch protects only the newly inserted prompt and its matching streaming assistant for this insertion, then evicts the oldest remaining component; ordinary append pruning remains oldest-first.
Findings None None.
Security None None.

How this fits together

The TUI chat log receives local and Gateway-synchronized conversation events, keeps a bounded list of renderable components, and displays them in terminal order. This change applies only when an authoritative shared prompt must be inserted before an existing live assistant response.

flowchart LR
  A[Gateway or local chat event] --> B[TUI chat log]
  B --> C[Find active assistant reply]
  C --> D[Insert shared prompt before reply]
  D --> E[Prune older unprotected entry]
  E --> F[Bounded terminal scrollback]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; refresh the merge result and required checks against the final base before landing.
  • Complete next step (P2) - No repair lane is needed: the only prior blocker is disproved by the existing minimum effective scrollback capacity, while the protected maintainer label keeps final landing under explicit maintainer handling.
Agent review details

Security

None.

PR surface

Source +3, Tests +32. Total +35 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 5 +3
Tests 1 32 0 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 40 5 +35

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Rebase onto current main and land the focused chat-log fix if the final required checks remain green; no capacity-one fallback is needed because the component enforces a minimum capacity of 20.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Rebase onto current main and land the focused chat-log fix if the final required checks remain green; no capacity-one fallback is needed because the component enforces a minimum capacity of 20.

Do we have a high-confidence way to reproduce the issue?

Yes. The regression test gives a high-confidence source-level reproduction: fill the effective 20-component log, retain a streaming assistant, then deliver its delayed authoritative user prompt.

Is this the best way to solve the issue?

Yes. Protecting the inserted prompt and its owning active reply only during that insertion is the narrowest fix; the existing minimum effective capacity of 20 preserves the component-limit invariant.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 89b6d85cdd86.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix real-terminal and real-Gateway behavior evidence, including bounded scrollback and continued streaming; no visual proof is necessary for this terminal-state change.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded TUI synchronization bug that can make a shared conversation appear to lack its user prompt, without evidence of broader runtime or data-loss impact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix real-terminal and real-Gateway behavior evidence, including bounded scrollback and continued streaming; no visual proof is necessary for this terminal-state change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix real-terminal and real-Gateway behavior evidence, including bounded scrollback and continued streaming; no visual proof is necessary for this terminal-state change.

Evidence

What I checked:

  • Minimum scrollback capacity: Current main clamps maxComponents to Math.max(20, Math.floor(maxComponents)); a one-component log cannot be constructed through this class, so the earlier all-protected-at-capacity concern does not apply. (src/tui/components/chat-log.ts:3, 89b6d85cdd86)
  • Focused overflow regression: The proposed regression fills a 20-component chat log, inserts the delayed shared prompt twice, verifies deduplication and prompt-before-assistant ordering, confirms the oldest unprotected notice is evicted, and asserts the component count remains 20. (src/tui/components/chat-log.test.ts:390, f7ebe4c93b5b)
  • Pruning scope: The branch protects only the newly inserted prompt and its matching streaming assistant for this insertion, then evicts the oldest remaining component; ordinary append pruning remains oldest-first. (src/tui/components/chat-log.ts:87, f7ebe4c93b5b)
  • After-fix behavior proof: The PR body reports a real-terminal and real-Gateway after-fix run, including bounded scrollback, active streaming continuity, and Gateway synchronization coverage; the supplied context also marks the proof sufficient. (f7ebe4c93b5b)

Likely related people:

  • steipete: The supplied PR metadata identifies this person as author of the focused chat-log change; no current-main history attribution was available in the review evidence for broader ownership. (role: recent TUI change contributor; confidence: low; commits: f7ebe4c93b5b; files: src/tui/components/chat-log.ts, src/tui/components/chat-log.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-28T11:52:18.609Z sha f7ebe4c :: found issues before merge. :: [P2] Preserve the component limit when every child is protected

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jul 28, 2026
@steipete
steipete merged commit 0f188c8 into main Jul 28, 2026
199 of 217 checks passed
@steipete
steipete deleted the codex/tui-stress-third-pass branch July 28, 2026 12:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant