Skip to content

Fix runs stuck on Starting that Stop could not end - #255

Merged
danielehrhardt merged 1 commit into
mainfrom
fix/stuck-run-stop
Oct 28, 2026
Merged

danielehrhardt merged 1 commit into
mainfrom
fix/stuck-run-stop

Conversation

@danielehrhardt

Copy link
Copy Markdown
Contributor

Problem

A chat on the second Mac showed a run as "Starting…" for over 12 hours, and pressing Stop only showed "Stopping the agent…" without anything happening.

Cause: on 10-27 21:24 the second Mac woke from sleep and started a follow-up in a chat the primary had just taken over. 30 s later it handed the chat back and cancelled the run, but its run.finished event was dropped because the chat had changed computers in between. Both databases had the run as cancelled, while the app's live store still held it as running. Stop went to the runner, which saw an already-ended run and returned ok silently, so the UI never heard of the end.

Fix

  • Desktop: every minute, runs the live store has shown as busy for over two minutes that are not among the server's queued/running/paused runs are read once (GET /api/runs/:id); one that is over is dropped as if run.finished had arrived.
  • Desktop chat Stop: after the cancel request the run is read again; an ended run disappears right away ("That run had already ended").
  • Mobile: api.runs.cancel does the same, so every Stop button in the phone app clears such a run.

No server change: re-emitting run.finished on the server would trigger follow-ups, heartbeats, tickets and notices a second time, and for runner chats the cancel is forwarded to the runner anyway.

Checks

  • tsc clean for desktop and mobile.
  • Verified against the real case: run_cQuD9PYRN4o3Spcy is cancelled on both Macs, which this sweep would drop.

A run whose end was announced while its chat changed computers kept
showing as Starting in the app forever, and Stop did nothing because the
server already counted it as cancelled. The desktop app now asks for runs
that look busy for over two minutes but are not among the working ones,
and both apps re-read a run after Stop and drop it when it is over.
@danielehrhardt
danielehrhardt merged commit e3af776 into main Oct 28, 2026
8 checks passed
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