fix: harden desktop turn recovery - #46837
Conversation
c27b95d to
8fe1e76
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the recovery work. The reconnect and terminal-error direction is useful, but one failed-turn path remains unprotected.
Problems
tui_gateway/server.py:9140-9174classifies a returnedresult["error"]asstatus="error", emitsmessage.complete, then clearsinflight_turn. The PR's newterminal_error_emittedguard only becomes true in the exception handler, so a normal returned error result still has no replay state if its terminal frame is lost during reconnect.
Suggested changes
- Route returned error results through the retained terminal-error path as well, preserving any
rawor streamed partial text, and add a regression test coveringrun_conversation()returning an error result followed bysession.resume. - Port the Desktop portions onto the current split hooks (
use-prompt-actions/submit.ts,use-session-actions/index.ts, anduse-message-stream/gateway-event.ts) rather than applying the pre-split files.
Automated hermes-sweeper review.
| @@ -6089,7 +6188,8 @@ def _stream(delta): | |||
| with session["history_lock"]: | |||
| session["running"] = False | |||
| session["last_active"] = time.time() | |||
There was a problem hiding this comment.
This guard only retains state after an exception. A normal run_conversation() result with error still takes the regular completion path, leaves terminal_error_emitted false, and clears inflight_turn; retain that logical-error path too so reconnect can replay it.
|
Superseded by #71184, which re-authors the tui_gateway failed-turn retention onto current main and also routes the returned-error result path through retention (the gap flagged in review), with regression tests for both paths. The desktop portions were rebuilt onto the split hooks. Thanks @Reza2kn, credited via Co-authored-by. |
Summary
message.completeerror frames with recoverable partial state when turns failReliability coverage
inflight_turnreplay/retentionTest Plan
uv run --extra dev --extra messaging python -m pytest tests/tui_gateway/test_protocol.py tests/test_tui_gateway_ws.py -o 'addopts=' -qnpm run lint --workspace apps/desktopnpm run typecheck --workspace apps/desktopnpm run test:ui --workspace apps/desktopnpm run test:desktop:platforms --workspace apps/desktop