Repository navigation
fix(tui): recover assistant responses after reconnecting to replacement runs - #128221
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 9:12 AM ET / 13:12 UTC. ClawSweeper reviewWhat this changesThe PR makes TUI reconnect recovery follow the active run restored from session history and adds unit and PTY coverage for replacement and newly appeared runs. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer landing review. Current main still skips reconnect recovery when restored history replaces the active run; the patch repairs that owner boundary without a blocking correctness finding. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherAfter a Gateway reconnect, the terminal UI reloads session history and must recover any active assistant response. The recovered run is passed to the lifecycle watchdog, which either waits for its response or renders a terminal outcome. flowchart LR
A[Gateway reconnect] --> B[Reload session history]
B --> C[Identify active or terminal run]
C --> D[Reconnect recovery]
D --> E[Streaming watchdog]
E --> F[Terminal conversation]
Decision needed
Why: The protected maintainer label requires explicit maintainer handling; the remaining choice is landing readiness, not product direction. Before merge
Agent review detailsSecurityNone. PR surfaceSource +59, Tests +32. Total +91 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the active-versus-terminal distinction at the history-to-lifecycle handoff and land through the normal exact-head merge validation path. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main skips reconciliation when history replaces the run ID, and the committed PTY scenario exercises replacement and newly appeared runs. This read-only review did not execute the scenario. Is this the best way to solve the issue? Yes: the repair belongs where authoritative history has already updated active TUI state but before lifecycle recovery consumes it, rather than adding a downstream watchdog workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 066176351ebd. LabelsLabel 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)
|
|
Maintainer landing review: the ClawSweeper rank-up move is satisfied because the native merge does not change the reviewed TUI owner boundary; if the resulting merge changes those TUI paths, the focused reconnect PTY scenario must be rerun before landing. The reported ClawSweeper live-verification failure is an observer timeout, not a failing terminal regression. Its observer stops waiting at 30 seconds, while this test intentionally exercises the unchanged production 30-second watchdog and passes after approximately 33 seconds. The genuine focused PTY run passed on the reviewed commit and again after rebasing, covering unchanged active, replacement active, newly appeared active, interrupted, failed, and completed reconnect outcomes. All 342 owner-boundary tests and the exact-head required CI gate also pass. This proof uses the real terminal and production TUI lifecycle with a fake backend; it does not claim live authenticated Gateway or provider transport. Production timeout, session-generation guards, connection ownership, and terminal-outcome ownership remain unchanged. |
|
Merged via squash.
|
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where users reconnecting the terminal interface would see a replacement or newly started assistant run remain stuck at
streamingindefinitely when that run appeared while the Gateway connection was interrupted.Why This Change Was Made
Reconnect history is the authoritative owner of the current in-flight run, but the reconnect coordinator only reconciled runs whose identifier still matched the run captured before loading that history. When history adopted a replacement run, or discovered a run after an idle disconnect, the old watchdog stayed attached to the obsolete run and silently exited without recovering the visible conversation.
The reconnect owner now reconciles the active run reported by authoritative history while retaining the original owner check for terminal outcomes. Existing session/connection-generation guards, failed or unloaded history handling, and unchanged-run behavior remain intact; no protocol, auth, configuration, storage, timeout, or public API contracts change. Production growth is two executable lines plus two required invariant-comment lines.
User Impact
After reconnecting, terminal users recover the current assistant response even when the Gateway replaced the previous run or started one while the terminal was disconnected. Existing completed, interrupted, and failed-run outcomes continue to render normally.
Evidence
streamingand times out after approximately 37 seconds waiting forPTY_RECONNECT_RECOVERED.OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-tui-reconnect-vitest-cache-20260823 node scripts/run-vitest.mjs run --config test/vitest/vitest.tui.config.ts --configLoader runner src/tui/tui-event-handlers.test.ts src/tui/tui-session-actions.test.ts src/tui/tui-session-run-coordinator.test.ts src/tui/tui.test.ts— 342 tests across four owner-boundary suites pass.OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-tui-reconnect-vitest-cache-20260823 node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts --configLoader runner src/tui/tui-pty-harness.e2e.test.ts -t 'reconciles active, replacement, and terminal runs after reconnect history'— real PTY reconnect flow passes.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile /private/tmp/openclaw-tui-reconnect-core-20260823.tsbuildinfo— production types pass.node scripts/run-tsgo.mjs -b test/tsconfig/tsconfig.core.test.plugins-platform.json --builders 1— the actual TUI test-type shard passes.