fix(desktop): keep clarify dialogs alive while the server bridge is still blocked - #86036
ayushnangia wants to merge 1 commit into
Conversation
|
CI note: the desktop check:lint failure was real and mine — three test fixtures constructed ClarifyRequest without the new fields from the store change (prompts.test.ts, clarify-tool.test.tsx x2). Fixed in 2ce8cbd11 / 3da43b91d / 37f311087. The remaining typecheck errors on this branch are pre-existing main drift (respondToApproval vs @assistant-ui, missing bippy module, fromThreadMessageLike/normalizeMathDelimiters exports) — verified by running the typecheck with this branch's diff stashed: identical errors. They're part of the desktop churn teknium1 is tracking in #76627, not this PR. |
37f3110 to
1f8fdc7
Compare
|
Reopening — this was closed by my account at 11:34Z with no close comment, which looks like an accidental close (the fix and the CI state were both settled by then). Branch is rebased onto current main; the fix stands: server advertises its bridge deadline, client only drops the clarify dialog once the server can no longer be blocked. If a maintainer sees a reason this shouldn't land, happy to hear it — otherwise it's ready for review. |
fix(desktop): keep clarify dialogs alive while the server bridge is still blocked
|
e42691c to
81d9c03
Compare
81d9c03 to
19eedb9
Compare
|
Great catch — and fixed on the current head:
Your invariant is now the contract: transient turn-end/error preserves the dialog while the request is live; explicit cancellation/completion invalidates it immediately. |
session.interrupt's _clear_pending released the pending clarify with an empty answer but told the client nothing — a wait-forever dialog parked on the desktop stayed actionable-but-dead forever (keeltrace's lifecycle review on NousResearch#86036). _clear_pending now emits clarify.cancel for released clarify prompts (scoped to the interrupted session; sudo/approval/secret prompts stay silent as before).
The server now tells the client when a parked clarify's wait is gone (cancel from /stop, expire from the deadline). The desktop clears the parked request immediately — regardless of any client-side deadline — so an actionable-but-dead dialog can never persist (NousResearch#86036 follow-up).
19eedb9 to
9501eb8
Compare
a0f5272 to
b3e726b
Compare
session.interrupt's _clear_pending released the pending clarify with an empty answer but told the client nothing — a wait-forever dialog parked on the desktop stayed actionable-but-dead forever (keeltrace's lifecycle review on NousResearch#86036). _clear_pending now emits clarify.cancel for released clarify prompts (scoped to the interrupted session; sudo/approval/secret prompts stay silent as before).
The server now tells the client when a parked clarify's wait is gone (cancel from /stop, expire from the deadline). The desktop clears the parked request immediately — regardless of any client-side deadline — so an actionable-but-dead dialog can never persist (NousResearch#86036 follow-up).
session.interrupt's _clear_pending released the pending clarify with an empty answer but told the client nothing — a wait-forever dialog parked on the desktop stayed actionable-but-dead forever (keeltrace's lifecycle review on NousResearch#86036). _clear_pending now emits clarify.cancel for released clarify prompts (scoped to the interrupted session; sudo/approval/secret prompts stay silent as before).
The server now tells the client when a parked clarify's wait is gone (cancel from /stop, expire from the deadline). The desktop clears the parked request immediately — regardless of any client-side deadline — so an actionable-but-dead dialog can never persist (NousResearch#86036 follow-up).
b3e726b to
ec24a59
Compare
ec24a59 to
437583f
Compare
Summary
Fixes #83319 (Desktop HUD mode: clarify choice dialog appears, disappears, turn hangs — family E desktop member in the stall triage #84047).
The dialog-vanish and the hang are the same bug: the desktop stream pipeline's turn-end (
message.complete) anderrorhandlers clear the parked clarify dialog unconditionally. The Python side stays blocked onclarify.responduntil the user answers or the server's clarify timeout expires. In HUD mode (separate overlay window with its own stream lifecycle) a spurious turn-end/error event arrives while the bridge is still blocked → dialog wiped → user has nothing to answer → turn hangs until timeout or /stop.Root cause
apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts(~L764, ~L1299):clearClarifyRequest(undefined, sessionId)on turn-end/error with no check of whether the server bridge is still waiting.tool.completehandler only drops theneedsInputflag), so the fix is a deadline-aware guard, not a removal.Changes
tui_gateway/server.py,_block): the blocking-request payload now advertises the bridge deadline —timeout_secondswhen finite, omitted when the server waits forever (clarify_timeout <= 0). Additive field; older renderers ignore unknown fields (same contract as themulti_selecthint).apps/desktop/src/store/clarify.ts):ClarifyRequestgainsreceivedAt+timeoutSeconds; new pure guardclarifyStillBlocking(request, now)— true while a finite server deadline hasn't elapsed, true forever for wait-forever requests, false when nothing is parked.clearClarifyRequestonly when!clarifyStillBlocking(...).Semantics
respondsucceeds (server still waiting)clarify_timeout <= 0)respondfails gracefully; the #84560 interrupt path unblocks the turnValidation
npx vitest run src/store/clarify.test.ts src/app/session/hooks/use-message-stream→ 21 + 79 passed, 0 failed (5 new guard tests: no-request false, pre-deadline true, post-deadline false, wait-forever true, parked survival).scripts/run_tests.sh tests/test_tui_gateway_server.py→ 553 passed, 0 failed (2 new payload tests: finite →timeout_secondsemitted;None→ omitted). One unrelated flaky (test_compute_host_turn_end_updates_metadata_mirror) passes on re-run and is untouched by this diff.Credit to @cycocyco for the HUD-mode reproduction; composes with #84560 (interrupt unblocking) — that PR lets /stop out of the wedge, this one stops the wedge from forming.