Skip to content

fix(desktop): release a send the watchdog abandons - #882

Merged
huichen merged 1 commit into
mainfrom
fix/composer-unlock-abandoned-send
Sep 27, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/composer-unlock-abandoned-send

Conversation

@huichen

@huichen huichen commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

The settle watchdog exists for a send whose invoke never answers — the response
is lost to a suspended webview, so runSendPipeline never returns. When the
persisted run row is already terminal, the watchdog calls abandonSend, which
bumped 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. sendPending therefore never cleared: Enter did nothing and
the 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 it
from abandonSend, racing it against the pipeline in handleSend.

  • 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.
  • Racing means the pipeline can still be running afterwards; a late failure is
    marked handled so an abandoned send cannot raise an unhandled rejection or a
    toast for a send the caller already considers delivered.
  • Unmount deliberately still does not release, unlike abandonSend: nobody
    is left waiting (the composer unmounted with the view), and leaving the promise
    pending keeps the module-level pendingPromptSends set holding the staged
    first 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 by abandonSend;
    a later pipeline failure stays silent; abandoning with no send in flight is a
    no-op.
  • useAgentThreadState.lifecycle: the end-to-end regression — focus-driven
    watchdog abandons a hung send and await first.done returns while the agent's
    reply is still outstanding. Confirmed to hang (test timeout) with the release
    line removed, i.e. it fails for the right reason.

`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.
@huichen
huichen enabled auto-merge (squash) September 27, 2026 08:47
@huichen
huichen merged commit b08b45c into main Sep 27, 2026
12 checks passed
@huichen
huichen deleted the fix/composer-unlock-abandoned-send branch September 27, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant