Repository navigation
fix(desktop): release a send the watchdog abandons - #882
Merged
Merged
Conversation
`abandonSend` — the settle watchdog's response to a run row that is already terminal — bumped the send generation and cleared the in-flight lock, but nothing settled the promise the composer had been handed. That promise's only other path to settling is the pipeline's own `await`, and the situation the watchdog exists for is exactly the one where the pipeline's invoke never answers: the webview that would receive the response was suspended. So the composer stayed locked on its pending send (`sendPending`): Enter did nothing and the send button stayed disabled, even after typing a new message, until the conversation was reopened. Hold the release on the send identity itself and call it from `abandonSend`, racing it against the pipeline. The abandon reports *delivery*, not refusal: the run is settled (that is what triggered the abandon) and the watchdog is reloading its persisted reply, so a rejection would put the submitted draft back and duplicate the message the thread is already showing. Unmount deliberately does not release, unlike `abandonSend`: nobody is left waiting (the composer unmounted with the view), and leaving the promise pending keeps the module-level pendingPrompt ownership set holding the staged first message — a remounted instance of the same conversation must not send it a second time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The settle watchdog exists for a send whose invoke never answers — the response
is lost to a suspended webview, so
runSendPipelinenever returns. When thepersisted run row is already terminal, the watchdog calls
abandonSend, whichbumped the send generation and cleared the in-flight lock but settled nothing.
The promise the composer holds only settles when the pipeline does, so it stayed
pending forever.
sendPendingtherefore never cleared: Enter did nothing andthe send button stayed disabled, even after typing a new message, until the
conversation was reopened (a remount). The draft itself is no longer at risk
since #881 clears it on hand-over, but the composer was still wedged.
Fix
Hold the release on the send identity (
LocalSend.releaseDelivery) and call itfrom
abandonSend, racing it against the pipeline inhandleSend.triggered the abandon) and the watchdog is reloading its persisted reply, so a
rejection would put the submitted draft back and duplicate the message the
thread is already showing.
marked handled so an abandoned send cannot raise an unhandled rejection or a
toast for a send the caller already considers delivered.
abandonSend: nobodyis left waiting (the composer unmounted with the view), and leaving the promise
pending keeps the module-level
pendingPromptSendsset holding the stagedfirst message, so a remounted instance of the same conversation cannot send it
twice.
Verification
tsc --noEmit,eslint(0 errors) and the full vitest suite pass — 245 files /3193 tests.
New tests:
useSendMessage: the caller waiting on delivery is released byabandonSend;a later pipeline failure stays silent; abandoning with no send in flight is a
no-op.
useAgentThreadState.lifecycle: the end-to-end regression — focus-drivenwatchdog abandons a hung send and
await first.donereturns while the agent'sreply is still outstanding. Confirmed to hang (test timeout) with the release
line removed, i.e. it fails for the right reason.