Skip to content

fix(tui): prevent stale session actions from mutating replacement conversations - #129681

Merged
steipete merged 1 commit into
mainfrom
codex/tui-preserve-session-incarnations-and-output
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/tui-preserve-session-incarnations-and-output

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where terminal users resetting a session could see an older in-flight abort, setting change, or reset mutate the replacement conversation even though it kept the same session key. This could incorrectly expose the replacement session's tool output through a delayed verbose setting, erase its usage preferences or pending prompt, resurrect an obsolete session, and display stale abort errors. It also fixes terminal help advertising thinking levels unsupported by the selected session and indented tool output being misinterpreted as Markdown headings, quotes, or lists.

Why This Change Was Made

Treat a session's selected owner, lifecycle generation, and initially-bound session ID as one authoritative incarnation before applying delayed operations; reuse the same ownership rule already required for chat sends. Keep slash-command completions and help on the same session-provided thinking-level resolver, and preserve tool-result whitespace until the real Markdown renderer interprets it.

User Impact

Session resets no longer inherit old abort notices, stale model/thinking/verbosity/usage changes, removed pending prompts, or obsolete reset results. Terminal help now matches the levels the active model session actually accepts, while literal indented tool output remains literal for both streaming and completed tool cards.

Evidence

  • Red-first owner-boundary proof: 15 new tests failed before the fixes, including three stale abort outcomes, four delayed setting outcomes, authoritative thinking-level help, and six indented partial/final tool-result cases. A separate focused regression also proved an old reset response could replace the newer same-key session.
  • Full TUI owner and sibling coverage: 1,348 passing tests across 46 files.
  • Real runTui() terminal proof: the fake-backend PTY now asserts /help shows only the active session's supported max thinking level and verifies literal # / > tool output remains an indented code block in both streaming and final terminal frames.
  • Full real-terminal PTY harness: 63 passing scenarios, including reconnect, Unicode input, approvals, rendering, error visibility, session switching, and command/settings flows.
  • Dedicated session-identity and reset-transition PTY lanes: 10 passing scenarios across two files, including remembered global sessions, stale restores, same-session active streams, and preserving overlapping input through a reset.
  • Independent authenticated autoreview: clean, no accepted/actionable findings.
  • Production change: +47/-31 lines (net +16), required for session-incarnation ownership across independent abort and command-action boundaries; test and PTY fixture growth are separate. No public API, configuration, protocol, provider, persistence, or schema change.
  • AI-assisted (Codex).
OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.tui.config.ts --configLoader runner src/tui

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.tui-pty.config.ts --configLoader runner \
  src/tui/tui-pty-harness.e2e.test.ts

OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.tui-pty.config.ts --configLoader runner \
  src/tui/tui-reset-transition-pty.e2e.test.ts \
  src/tui/tui-session-identity-pty.e2e.test.ts

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 23:45
@steipete
steipete merged commit c07d0e4 into main Aug 26, 2026
265 checks passed
@steipete
steipete deleted the codex/tui-preserve-session-incarnations-and-output branch August 26, 2026 00:06
@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 size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant