Repository navigation
fix(tui): keep history and sends on the selected session - #159166
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: blocked before merge. Reviewed September 26, 2026, 7:20 PM ET / 23:20 UTC (Revision 2). ClawSweeper reviewWhat this changesThis PR changes how the terminal UI selects session history and admits sends during selection, and updates the related documentation and regression tests. Merge readiness⛔ Blocked before merge - 5 items remain The prior send-during-selection finding is addressed. This PR still needs an upgrade repair: a saved bare Priority: P1 Review scores
Verification
How this fits togetherThe terminal UI takes a selected agent and session key, loads that conversation from the Gateway, and sends messages and session actions back to it. On startup, it also reads the last selected key from local state. flowchart LR
A[Typed or saved session] --> B[TUI selection]
B --> C[Gateway history]
C --> D{History ready?}
D -- Yes --> E[Editor and actions]
E --> F[Gateway send]
F --> G[Stored conversation]
D -- No --> H[Hold draft]
Decision needed
Why: The branch changes the meaning of persisted user state, and the PR body describes the new behavior without an explicit upgrade disposition for users who saved the old selection. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +125, Tests +568, Docs +2. Total +695 across 18 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Home behavior for newly typed bare Do we have a high-confidence way to reproduce the issue? Yes, from source: current main retains the bare Is this the best way to solve the issue? No, not yet. Exact-first history and the readiness guard fit the defect, but saved selectors need an upgrade-safe interpretation before this is the narrowest complete fix. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 122f7c1ef601. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Keep exact qualified sessions and resolve absent global aliases through the existing agent Home selector. Preserve blocked editor input and reject session-dependent actions until history establishes the target, including captured coalesced submissions and literal startup-message refusal.
|
Maintainer disposition: accept the corrected read presentation for saved The saved- The released 2026.9.4 Gateway already resolves per-sender Keeping a saved raw-global selection in the writable TUI would preserve that history/send mismatch. The intended repair is to interpret the saved alias through the same existing Home resolver as typed input, display the conversation the Gateway already writes, and block sends until its history is established. The saved-pointer PTY regression starts from the saved raw string under its existing agent/scope key, holds startup history, verifies the editable blocked draft, and then permits exactly one explicit send to Home. No saved-state schema, storage migration, or Gateway routing change is introduced. This existing-state startup proof and the separate real Gateway cells are complementary; an installed 2026.9.4 driver-to-candidate upgrade cell was not run. Historical raw-global data is retained: the final real proof verifies the same raw session ID and unchanged messages through the existing The screenshot gate is independently verified: all three full native PNGs were inspected as synthetic-only, visibly attached in the originating chat, and checked in the rendered PR with decoded dimensions of 996×614. The reviewer's image-fetch limitation does not leave that delivery gate unverified. The later Measured verification runs: 420 focused tests in 48 seconds, 82 final selector tests in 40 seconds, 22 registered identity PTY tests in 75 seconds, and the four real Gateway/TUI cells in 33 seconds. The full remote build, proof, and native capture took about 8 minutes 15 seconds. The export cleanup separately passed the formerly failing full deadcode scan, 39 focused tests, types, lint, and fresh independent review. |
|
Merged via squash.
|
…9166) * fix(tui): preserve qualified global session selection * fix(tui): wait for resolved session history before sending Keep exact qualified sessions and resolve absent global aliases through the existing agent Home selector. Preserve blocked editor input and reject session-dependent actions until history establishes the target, including captured coalesced submissions and literal startup-message refusal. * fix(tui): keep disconnect formatter private to admission owner
Related: #150153
What Problem This Solves
The TUI discarded an explicit key such as
agent:research:globalbefore loading history. It could display an empty or different conversation and send there. Submitting during a session switch also used the provisional key before history resolved.User Impact
Existing qualified conversations keep their exact history and send target. If the qualified conversation is absent, the legacy selector resolves to the selected agent's Home:
agent:<id>:mainin per-sender scope, orglobalin global scope. Bareglobal, including case and whitespace variants, uses that same Home selection, matching the shipped Gateway send contract.Saved-session upgrade behavior: a saved bare
globalselection in per-sender scope now displays the selected agent's existing Home, where the released Gateway already sends messages. This read-presentation correction is accepted; the send destination is preserved. Historical raw-global session IDs and messages remain retained, and an existing exact qualified conversation still wins. Saved-state coverage seeds the shipped scoped SQLite string in the registered startup flow and complements the real Gateway physical-identity tests; it is not an installed 2026.9.4 driver-to-candidate upgrade cell.Input submitted while selection is unresolved stays in the editor for an explicit Enter after readiness. Session-dependent actions share that readiness decision, including model-picker commits and Escape abort. Failed startup history gives
--messagean explicit not-sent outcome; the literal message retains its existing one-attempt behavior and is not replayed after recovery. No configuration, protocol, or storage migration is required.Why This Change Was Made
History prefers the exact qualified row. Only a successful empty result without session identity permits Home fallback; existing empty rows, archived rows, malformed responses, and errors do not. The existing selection/history owner captures the agent and Home target and revalidates after awaited work. Shared explicit-selection receipt comparison rejects stale results without changing Gateway event aliases.
Admission uses the existing
historyLoadedfact and captured submit state, including coalesced input. It adds no selection manager, queue, or cache. Ordinary refresh of an already loaded conversation remains usable. Historical raw-global history remains readable; in per-sender scope they are distinct from the shipped writable Home alias.Evidence
The subsequent CI cleanup makes the disconnect formatter private to its existing admission module; its function body and internal call are unchanged. The same message assertions now use the production formatter. The formerly failing full deadcode scan, 39 focused tests, types, lint, and fresh review pass. This export-only change preserves the applicability of the behavioral proof and screenshots below.
The original selection defect, immediate-submit race, and uppercase alias bypass were reproduced before their fixes. Focused tests passed (420), followed by all 82 selector tests on the final case-normalization change; these counts overlap. All 22 registered TUI identity PTY tests passed. Final production/test types, scoped lint, line-cap checks, and independent review through P2 passed.
The build at
56e02f9and all four real Gateway/TUI cells passed: qualified-existing and missing-qualified Home fallback in both scopes. The default agent is Main while Research is explicitly selected. Each cell verifies held input, no automatic send, the outgoing physical session ID, rendered reply, and persisted user message on the same conversation. The per-sender historical raw row keeps the same session ID and messages. Direct padded uppercaseGLOBALnavigation returns to the same Home without another send. All owned processes and the Testbox lease were settled.The images below are actual Linux xterm pixels from a synthetic backend: before commit
0a4b6d7, then the behavior-tested56e02f9source. Before, input leaves the editor and sends against a provisional selection. After, it remains editable with a readiness notice; the third image shows the resolved Home history with the draft still waiting for Enter. Both TUI processes exited cleanly and all six source hashes were restored. The separate real Gateway proof covers transport and persistence. All data and the loopback model endpoint are synthetic; no authenticated external provider was used.