Skip to content

fix(tui): keep session modes scoped on switch - #117658

Merged
steipete merged 2 commits into
mainfrom
codex/autoqa-tui-footer-modes-20260801
Aug 1, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/autoqa-tui-footer-modes-20260801

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Closes #117654

What Problem This Solves

Fixes an issue where switching TUI sessions could retain the previous session's fast, verbose, trace, and reasoning modes, leaving the footer and subsequent turns bound to stale session behavior.

Why This Change Was Made

The session-selection owner now clears selection-scoped mode overrides before rendering and loading the new history. Same-session patches keep their existing sparse-merge behavior. One footer formatter now renders the authoritative session modes, including trace, plus the process-fixed delivery mode; existing model, goal, and token information is preserved.

User Impact

Operators can switch sessions without inheriting another session's execution/display modes. The footer now makes effective trace and delivery behavior visible, so it accurately describes the session and launch mode used by the next turn.

Evidence

Release-note context: TUI session switches now clear stale per-session modes, and the footer reports trace plus fixed delivery state.

AI-assisted: yes. The session-selection owner, sparse patch semantics, footer renderer, PTY lifecycle, direct pi-tui contract, current-main history, and sibling same-session behavior were independently reviewed. No agent transcript is attached.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 22:04
@steipete steipete self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 6:10 PM ET / 22:10 UTC.

ClawSweeper review

What this changes

This PR clears fast, verbose, trace, and reasoning overrides when the terminal UI changes sessions, preserves sparse same-session patches, and renders trace plus launch-fixed delivery state in the footer.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR is still necessary: current main retains the pre-fix session-selection path, while the branch clears the leaked session-mode projection at its owner and proves both switch and same-session behavior. It should remain open for maintainer handling because it is assigned and carries the protected maintainer label; no actionable patch defect was found.

Priority: P2
Reviewed head: fd2a561f2483deeb04a8fd33e3ca234cda6dfe70

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with source-proven regression coverage and convincing real TUI-loop evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies final-head Testbox evidence, and the branch contains a real fake-backend PTY scenario that visibly switches sessions, clears stale modes, changes trace, and proves launch-owned delivery; the evidence is appropriately scoped to the TUI loop.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies final-head Testbox evidence, and the branch contains a real fake-backend PTY scenario that visibly switches sessions, clears stale modes, changes trace, and proves launch-owned delivery; the evidence is appropriately scoped to the TUI loop.
Evidence reviewed 7 items Current-main defect remains: The current-main TUI path has no changes from the reported pre-fix revision, and the pre-fix setSession reset only the session id and freshness before rendering/loading the newly selected sparse session snapshot.
Owner-boundary repair: The branch clears only fast, verbose, trace, and reasoning mode fields when selection actually changes, before the footer update and history load; same-session changes do not take this reset path.
Sparse-patch invariant preserved: The extracted helper resets only selection-owned modes, while the patch application path still updates mode fields only when the backend result supplies them. This avoids converting sparse same-session patches into destructive replacements.
Findings None None.
Security None None.

How this fits together

The terminal UI switches an active session before loading a sparse backend snapshot. That projection drives both the visible footer and subsequent terminal commands, so retained fields can make the selected session inherit another session’s modes.

flowchart LR
  A[Session command or picker] --> B[Session-selection action]
  B --> C[Clear prior session modes]
  C --> D[Load sparse session snapshot]
  D --> E[Active session projection]
  E --> F[Compact TUI footer]
  E --> G[Next session command]
  H[Launch delivery setting] --> F
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; the supplied context reports it cleanly mergeable, but landing should use the final three-way merge result and exact-head required checks rather than the earlier Testbox run alone.
Agent review details

Security

None.

PR surface

Source +44, Tests +177. Total +221 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 127 83 +44
Tests 3 215 38 +177
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 342 121 +221

Review metrics

None.

Stored data model

Persistent data-model change detected: database schema: src/tui/tui-formatters.test.ts, serialized state: src/tui/tui-session-actions.ts, serialized state: src/tui/tui-session-info.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #117654
Summary: This PR is the direct candidate repair for the linked report: both describe stale session-specific TUI modes surviving a switch to a sparse target snapshot.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused session-owner repair once the exact merge result has the required checks, retaining the regression pair that distinguishes a true session switch from a sparse same-session patch.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the focused session-owner repair once the exact merge result has the required checks, retaining the regression pair that distinguishes a true session switch from a sparse same-session patch.

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

Yes. Current-main source establishes the stale sparse-merge mechanism, and the branch’s focused fake-backend PTY case exercises the real runTui() transition from an enabled source session to a target session with omitted modes.

Is this the best way to solve the issue?

Yes. The session-selection action owns the invalid carry-over, so clearing only selection-owned overrides there while retaining sparse same-session merge semantics is the narrowest maintainable repair.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: A deterministic TUI session switch can show and retain another session’s execution/display modes, but the blast radius is limited to operators switching terminal sessions.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies final-head Testbox evidence, and the branch contains a real fake-backend PTY scenario that visibly switches sessions, clears stale modes, changes trace, and proves launch-owned delivery; the evidence is appropriately scoped to the TUI loop.
  • 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 (live_output): The PR body supplies final-head Testbox evidence, and the branch contains a real fake-backend PTY scenario that visibly switches sessions, clears stale modes, changes trace, and proves launch-owned delivery; the evidence is appropriately scoped to the TUI loop.

Label justifications:

  • P2: A deterministic TUI session switch can show and retain another session’s execution/display modes, but the blast radius is limited to operators switching terminal sessions.
  • 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 (live_output): The PR body supplies final-head Testbox evidence, and the branch contains a real fake-backend PTY scenario that visibly switches sessions, clears stale modes, changes trace, and proves launch-owned delivery; the evidence is appropriately scoped to the TUI loop.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies final-head Testbox evidence, and the branch contains a real fake-backend PTY scenario that visibly switches sessions, clears stale modes, changes trace, and proves launch-owned delivery; the evidence is appropriately scoped to the TUI loop.

Evidence

What I checked:

  • Current-main defect remains: The current-main TUI path has no changes from the reported pre-fix revision, and the pre-fix setSession reset only the session id and freshness before rendering/loading the newly selected sparse session snapshot. (src/tui/tui-session-actions.ts:662, f620c19a936e)
  • Owner-boundary repair: The branch clears only fast, verbose, trace, and reasoning mode fields when selection actually changes, before the footer update and history load; same-session changes do not take this reset path. (src/tui/tui-session-actions.ts:627, a39b4f8db23d)
  • Sparse-patch invariant preserved: The extracted helper resets only selection-owned modes, while the patch application path still updates mode fields only when the backend result supplies them. This avoids converting sparse same-session patches into destructive replacements. (src/tui/tui-session-info.ts:45, a39b4f8db23d)
  • Focused regression coverage: Tests cover both sides of the state invariant: switching to a session with omitted overrides clears all four stale values, while a same-session patch preserves untouched mode values. (src/tui/tui-session-actions.test.ts:1289, fd2a561f2483)
  • Real TUI-loop proof: The focused fake-backend PTY test drives the real runTui() loop through an enabled source session, a sparse target session, an interactive trace change, and a sent turn. It asserts that source modes disappear and launch-owned delivery remains enabled; the scoped TUI policy appropriately limits this proof to TUI behavior rather than gateway or persistence behavior. (src/tui/tui-pty-harness.e2e.test.ts:135, fd2a561f2483)
  • Footer uses authoritative state: The new formatter receives the active session projection and process-fixed launch delivery value in one render path, removing the duplicated footer assembly that omitted trace and delivery state. (src/tui/tui.ts:1221, a39b4f8db23d)

Likely related people:

  • steipete: Git history attributes the current TUI session-action ownership refactor to Peter Steinberger, and the same account authored the repair and its final PTY behavior evidence. (role: recent area contributor and feature author; confidence: high; commits: d876a8338722, a39b4f8db23d, fd2a561f2483; files: src/tui/tui-session-actions.ts, src/tui/tui.ts, src/tui/tui-pty-harness.e2e.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.

@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for fd2a561f2483deeb04a8fd33e3ca234cda6dfe70:

  • Root cause: a real session switch retained four selection-owned mode fields in the shared TUI projection, so a sparse target snapshot could inherit the previous session's fast, verbose, trace, and reasoning behavior.
  • Canonical repair: the session-selection owner clears only those fields before footer render/history load; same-session sparse patches remain unchanged. The single footer formatter now reports authoritative trace state plus launch-fixed delivery mode.
  • Blacksmith Testbox run 30720064361: 146 focused unit tests, all 52 PTY scenarios, and the complete changed gate passed on the exact head.
  • Source-blind PTY validation 30720366855: source modes visible, target modes cleared, trace transition visible, and fixed delivery propagated to the sent turn.
  • Exact-head CI 30720496736: final openclaw/ci-gate passed with no required failures.
  • Fresh Codex autoreview 019fbf59-1e6a-7c03-8a7e-05a2227d4604: clean, zero findings, 0.99 confidence.
  • ClawSweeper: no findings; best-fix verdict is the focused session-owner repair. Its behind-main rank-up move is satisfied by the native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 117658 gate, which completed successfully against current main without changing the PR head.

Risk is low: no config, storage, protocol, auth, provider, or delivery-policy contract changes. Production delta is +109/-79; the positive delta is the tested footer formatter plus the session-info owner split required to keep the existing session-actions module below its enforced line ceiling.

@steipete
steipete merged commit 08ea9cc into main Aug 1, 2026
186 of 194 checks passed
@steipete
steipete deleted the codex/autoqa-tui-footer-modes-20260801 branch August 1, 2026 22:39
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
* fix(tui): keep session footer modes truthful

* test(tui): record footer behavior evidence
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: M 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.

[Bug]: TUI footer retains modes across session switches

1 participant