Skip to content

fix(tui): keep reset transitions isolated from stale input - #116873

Merged
steipete merged 13 commits into
mainfrom
codex/autoqa-tui-reset-epoch-20260731
Jul 31, 2026
Merged

steipete merged 13 commits into
mainfrom
codex/autoqa-tui-reset-epoch-20260731

Conversation

@steipete

@steipete steipete commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a TUI race where /reset could be rolled back by a slow pre-reset history or session-info read, while prompts entered during the transition could be lost, sent to the retiring session, or overwrite a newer draft.

Why This Change Was Made

/new and /reset now share one canonical session-transition owner. Every submit captures the transition epoch at Enter; delayed burst flushes use that snapshot rather than live state. A blocked submit is restored ahead of any newer editor draft, and replacement-session commit advances the existing history/session-info generations before adopting the replacement identity. No parallel compatibility epoch or fallback path was added.

User Impact

Input typed while /reset is pending remains visible and is preserved with text typed after Enter. Once reset completes, the combined draft can be sent exactly once to the replacement session. Slow pre-reset reads cannot repaint or restore the retired session. /exit and /quit remain available during the transition.

Evidence

  • Exact reviewed head: 081e6603f4be48fe0fe475a8d4c57a1f744fd953.
  • Final Blacksmith Testbox focused + real PTY proof: https://github.com/openclaw/openclaw/actions/runs/30664403665
    • 249/249 TUI command, session, submit-state, and submit-handler tests passed.
    • 10/10 PTY support tests passed.
    • The isolated real PTY reset transition passed after holding reset behind a cross-process release, typing Enter plus a newer draft during the transition, restoring both lines, sending one exact combined message, and rendering the response.
    • Targeted oxlint passed with zero findings. The command's final bare oxfmt lookup was unavailable on Testbox PATH; the pinned repository formatter check passed locally on the exact files.
  • Broad rebased-head scoped gate: https://github.com/openclaw/openclaw/actions/runs/30662100716
    • Focused proof passed 260/260.
    • Format, core/core-test/test-root typecheck, dead-code, import-cycle, database-first, SDK, and related guards passed.
    • Its sole failure was the generic PTY generator's five-line lint ratchet; the final head moved reset-specific wiring into its existing owner module and then passed targeted oxlint.
[behavior-evidence] tui-reset-transition {"terminal":"real PTY","overlappingInputPreserved":true,"resetCompleted":true,"preservedInputDelivered":true,"exactSendCount":1}
  • Final whole-branch autoreview: clean, patch-correct confidence 0.93.
  • Final fixture-extraction review: clean, confidence 0.98.
  • git diff --check: passed.

Release-note context: TUI session reset now preserves overlapping input and ignores stale pre-reset history/session reads.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 31, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 5:12 PM ET / 21:12 UTC.

ClawSweeper review

What this changes

The branch makes /new and /reset use one session-transition boundary so delayed input and stale history/session reads cannot target or repaint the retiring TUI session.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This PR remains necessary: current main has not absorbed its TUI transition boundary, and the exact branch adds source-level protection plus real-PTY proof for overlapping reset input. No discrete correctness defect was found in the exact reviewed head; the protected maintainer label and session-state blast radius leave final landing ownership with a human reviewer.

Priority: P1
Reviewed head: 081e6603f4be48fe0fe475a8d4c57a1f744fd953
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong exact-head terminal evidence and focused invariant coverage support a good patch, with human review retained for the protected session-state surface.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides exact-head real-PTY evidence that visibly exercises the reset boundary, preserves overlapping input, sends one combined message, and renders the response; private data should remain redacted in any future transcript updates.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides exact-head real-PTY evidence that visibly exercises the reset boundary, preserves overlapping input, sends one combined message, and renders the response; private data should remain redacted in any future transcript updates.
Evidence reviewed 6 items Canonical transition owner: The PR records active transition command and epoch in the command-handler owner, then gates regular submissions against that snapshot so a delayed flush cannot send to a retiring session.
Draft preservation at the editor boundary: Blocked chat submissions restore the blocked value before any newer editor-owned draft, preserving both inputs instead of dropping or overwriting either one.
Stale refresh fence: Reset adoption increments the existing history-load generation before session identity changes; the focused test resolves old history and session-info requests afterward and verifies they cannot repaint the replacement session.
Findings None None.
Security None None.

How this fits together

OpenClaw’s terminal UI turns editor input into commands or chat submissions while maintaining the selected agent session. This code sits between editor submission, backend session mutation, history/session refreshes, and the rendered terminal transcript.

flowchart LR
  A[Editor input] --> B[Submit burst handler]
  B --> C[Session transition boundary]
  C --> D{Admission decision}
  D -->|allowed| E[Chat submission]
  D -->|blocked| F[Restore editor draft]
  E --> G[Session and history refresh]
  G --> H[Rendered terminal UI]
Loading

Decision needed

Question Recommendation
Should this protected TUI session-state repair be merged with its exact-head PTY proof after a final current-merge-result check? Merge after final merge-result refresh: Accept the reviewed canonical transition boundary after confirming GitHub’s merge result still matches the proof-reviewed head.

Why: The implementation is source-audited and proof-positive, but the protected maintainer label and changes to session identity/draft restoration require explicit human landing ownership.

Before merge

  • Resolve merge risk (P1) - This alters the shared session identity, stale-read invalidation, and buffered-draft boundary; a merge should retain the exact-head focused PTY proof and confirm the current merge result remains clean.
  • Resolve merge risk (P1) - The fake-backend PTY harness proves the real TUI loop and visible terminal behavior, but scoped TUI policy correctly limits that proof: it does not independently establish Gateway transport, persisted session state, or provider behavior.
Agent review details

Security

None.

PR surface

Source +151, Tests +395. Total +546 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 9 260 109 +151
Tests 8 415 20 +395
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 675 129 +546

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/tui/tui-reset-transition-pty.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Accept the reviewed session-transition design (recommended)
    Merge after a final exact merge-result refresh because the branch carries focused source, test, and real-PTY evidence for the session-state invariant.
  2. Pause for backend-scope confirmation
    Hold the PR only if maintainers need proof that the reported behavior also crosses Gateway or persisted-session boundaries beyond the TUI owner.

Technical review

Best possible solution:

Keep one canonical transition owner in the TUI command handler, preserve blocked drafts at the editor boundary, and land the repair after the owning reviewer accepts the bounded session-state risk on the current merge result.

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

Yes, by source: hold resetSession, submit text through the burst coalescer, type a newer draft, then release reset and verify one combined replacement-session send. This review did not execute the pre-fix path, but the exact-head PTY scenario makes the race boundary concrete.

Is this the best way to solve the issue?

Yes. Centralizing transition ownership where /new and /reset begin, then carrying an admission snapshot into delayed submission, is narrower and more maintainable than downstream send guards or retry/fallback paths.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head real-PTY evidence that visibly exercises the reset boundary, preserves overlapping input, sends one combined message, and renders the response; private data should remain redacted in any future transcript updates.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head real-PTY evidence that visibly exercises the reset boundary, preserves overlapping input, sends one combined message, and renders the response; private data should remain redacted in any future transcript updates.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The repaired race can lose, misroute, or overwrite terminal input during a common session-reset workflow.
  • merge-risk: 🚨 session-state: The patch changes session transition epochs, replacement-session adoption, stale refresh fencing, and editor draft restoration.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head real-PTY evidence that visibly exercises the reset boundary, preserves overlapping input, sends one combined message, and renders the response; private data should remain redacted in any future transcript updates.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head real-PTY evidence that visibly exercises the reset boundary, preserves overlapping input, sends one combined message, and renders the response; private data should remain redacted in any future transcript updates.

Evidence

What I checked:

  • Canonical transition owner: The PR records active transition command and epoch in the command-handler owner, then gates regular submissions against that snapshot so a delayed flush cannot send to a retiring session. (src/tui/tui-command-handlers.ts:172, 081e6603f4be)
  • Draft preservation at the editor boundary: Blocked chat submissions restore the blocked value before any newer editor-owned draft, preserving both inputs instead of dropping or overwriting either one. (src/tui/tui-submit.ts:45, 081e6603f4be)
  • Stale refresh fence: Reset adoption increments the existing history-load generation before session identity changes; the focused test resolves old history and session-info requests afterward and verifies they cannot repaint the replacement session. (src/tui/tui-session-actions.ts:434, 081e6603f4be)
  • Exact-head terminal proof: The added PTY scenario holds reset at a fixture boundary, submits overlapping text, types a newer suffix, releases reset, and asserts exactly one combined replacement-session send and response. (src/tui/tui-reset-transition-pty.e2e.test.ts:47, 081e6603f4be)
  • Current-main and branch provenance: The current checkout is at e73250f; no TUI-path changes appear between the PR base and current main, so the central transition repair is not already present on main. Git history attributes the surrounding TUI session/submit owner path to Peter Steinberger, including the pending-submission lifecycle refactor. (src/tui/tui-command-handlers.ts:172, e73250f54baf)
  • Submitted validation evidence: The PR body identifies the exact head and reports a successful Blacksmith focused run with 249 TUI tests, 10 PTY support tests, and an observed real-PTY transition transcript; GitHub network access was unavailable during this review, so the linked run could not be independently opened. (081e6603f4be)

Likely related people:

  • steipete: Current-main history shows Peter Steinberger carrying the TUI pending-submission lifecycle refactor and multiple session-transition fixes; the PR head also builds directly on that ownership area. (role: recent TUI session and submit-path contributor; confidence: high; commits: b0104bd2cdbf, f18d619c025c, 081e6603f4be; files: src/tui/tui-command-handlers.ts, src/tui/tui-submit.ts, src/tui/tui-session-actions.ts)
  • Vincent Koc: Recent TUI history includes fixes around pending submission behavior and session synchronization, which share the session-state invariant affected here. (role: adjacent TUI lifecycle contributor; confidence: medium; commits: e396ff68d82d, 5a0e67791fdc; files: src/tui/tui-command-handlers.ts, src/tui/tui-session-actions.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the current GitHub merge result still represents the proof-reviewed head before landing.

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 (5 earlier review cycles)
  • reviewed 2026-07-31T14:36:42.995Z sha e6713fc3d03b414c3c2cc66594a8ad13643c06bf :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T16:03:50.092Z sha f6d560d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T16:08:16.975Z sha f6d560d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T18:21:34.432Z sha f6d560d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T21:05:18.748Z sha 081e660 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/autoqa-tui-reset-epoch-20260731 branch from e6713fc to f6d560d Compare July 31, 2026 15:57
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The final head now includes inspectable real-PTY proof requested by the review. Run 30644166554 records overlappingInputRejected:true, resetCompleted:true, and postResetInputDelivered:true after an explicitly synchronized reset boundary; the actual terminal rendered session change in progress; wait for /reset to finish and the unique replacement-session header. The same run completed the scoped changed gate, and the final whole-branch autoreview is clean.

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 31, 2026
@steipete
steipete force-pushed the codex/autoqa-tui-reset-epoch-20260731 branch from f6d560d to 081e660 Compare July 31, 2026 20:57
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now contains the final exact-head real-PTY transcript, focused proof, rebased scoped-gate evidence, and final review results for 081e6603f4be48fe0fe475a8d4c57a1f744fd953.

@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 31, 2026
@steipete
steipete merged commit 262f263 into main Jul 31, 2026
137 of 145 checks passed
@steipete
steipete deleted the codex/autoqa-tui-reset-epoch-20260731 branch July 31, 2026 21:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 31, 2026
* origin/main: (22 commits)
  fix(cron): preserve lazy ownership and bounded notification lifetimes (#117018)
  fix: live updater no-op restarts healthy gateways (#117038)
  fix(bedrock): release streaming clients (#117039)
  fix(google): restore canonical Gemini and Vertex provider invariants (#117042)
  fix(channels): preserve accepted LINE and Mattermost delivery (#117024)
  fix(feishu): unify truthful delivery and media ownership (#117023)
  fix(ui): isolate gateway observer lifecycles (#117017)
  fix(tui): keep reset transitions isolated from stale input (#116873)
  fix(gateway): centralize streamed media descriptor ownership (#117000)
  feat(plugins): externalize OpenCode provider (#117035)
  fix(onboarding): restore skill dependency consent (#116644)
  fix(streaming): preserve incomplete bracket tails in final replies (#116983)
  fix: allow slower gateway readiness after updates (#117032)
  fix(plugin-state): avoid shared SQLite corruption when CLI starts during gateway runtime (#113204)
  fix(cli): keep config file output raw under JSON logging (#116968)
  fix(ai): malformed Anthropic stream frames expose raw event payloads (#116938)
  fix(qa): authenticate actual scenario execution evidence (#117004)
  feat(plugins): externalize NovitaAI provider (#117007)
  fix(text): preserve fenced tool markers in visible-text sanitizer (#116939) (#116971)
  fix(channels): reset metadata memos with plugin lifecycle (#117005)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…116873)

* fix(tui): fence reset session transitions

* fix(tui): explain blocked reset input

* test(tui): isolate reset transition PTY proof

* fix(tui): preserve input across session transitions

* test(tui): synchronize preserved reset draft proof

* test(tui): control reset submit timing

* test(tui): close reset PTY with EOF

* test(tui): exit reset PTY without submit buffering

* test(tui): synchronize reset PTY shutdown

* test(tui): widen reset PTY exit window

* test(tui): stabilize reset transition PTY proof

* test(tui): keep reset PTY harness bounded

* test(tui): split reset PTY fixture wiring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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