Skip to content

fix(tui): prevent startup sends to the wrong session - #126046

Merged
steipete merged 1 commit into
mainfrom
fix-tui-startup-session-gate
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
fix-tui-startup-session-gate

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users launching the TUI without --session could immediately press Enter and silently send to the default main session before the remembered session finished restoring. The viewport would then switch to the remembered session, hiding that the message and resulting transcript were stored elsewhere.

Why This Change Was Made

Connection readiness now remains owned by the existing connection generation until remembered-session selection and history loading settle. Input during that window is visibly rejected and remains editable; no second readiness flag or message queue is introduced.

User Impact

No-session TUI launches and reconnects cannot send against an unstable session identity. Explicit --session, /session, /new, and /reset behavior is unchanged; failed remembered lookup still falls back to main.

Evidence

Pre-fix real PTY/Gateway oracle: delayed sessions.list accepted the marker as agent:tui-pty-validation:main, then rendered the remembered session header; isolated SQLite contained the marker under main only.

Post-fix real PTY/Gateway oracle:

[behavior-evidence] tui-startup-session-gate {"sentKey":"agent:tui-pty-validation:tui-pty-resume-1","headerSession":"agent:tui-pty-validation:tui-pty-resume-1","sqliteRows":[{"sessionKey":"agent:tui-pty-validation:tui-pty-resume-1","eventCount":1}]}

Validated:

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts src/tui/tui-session-identity-pty.e2e.test.ts (7/7)
  • targeted isolated live Gateway + real PTY + SQLite test
  • full fake-backend PTY shard; one unrelated xAI rendering timeout passed its exact standalone rerun
  • node scripts/check-changed.mjs
  • pnpm build
  • source-blind behavior validation: all clauses passed
  • autoreview: clean, no accepted/actionable findings

Production LOC: +3/-12 (net -9). Tests and test support: +549/-13.

@clawsweeper

clawsweeper Bot commented Aug 18, 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: L maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 22:05
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head a3751db49d546b9c66a56ac139e84e9405673d21:

  • Frozen-base PTY repro sent the marker to agent:main:main before switching the viewport to the remembered session.
  • Seven focused real-runTui PTY cases pass: delayed lookup, delayed history, reconnect history, explicit session, lookup fallback, generation rollover, and exactly-once retry.
  • Isolated live Gateway + real PTY + SQLite proof reports the same remembered session for send, header, and the sole persisted marker row.
  • node scripts/check-changed.mjs passed.
  • pnpm build passed.
  • Autoreview and source-blind behavior validation passed with no findings.
  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/32191019634

Production LOC is +3/-12 (net -9); tests and test support are +549/-13. ClawSweeper's exact-head worker run completed successfully, but its public comment remains the started placeholder, so no Rank-up moves: are available to apply or skip; per repository policy, publisher delay is not a landing blocker.

@steipete
steipete merged commit 0f08ba4 into main Aug 18, 2026
287 checks passed
@steipete
steipete deleted the fix-tui-startup-session-gate branch August 18, 2026 22:21
@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: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant