Skip to content

fix(tasks): Unblock & run can no longer double-spawn; card shows session state (v0.455.0) - #854

Merged
vikasprogrammer merged 1 commit into
mainfrom
feat/unblock-run-dedupe
Oct 6, 2026
Merged

vikasprogrammer merged 1 commit into
mainfrom
feat/unblock-run-dedupe

Conversation

@vikasprogrammer

Copy link
Copy Markdown
Owner

Problem

"Unblock & run" on a Task blocked — needs you card sometimes spawned multiple sessions for one task. Live instapods evidence: tsk_ad11e51… got ses_f2d5… and ses_4291… two seconds apart (two PATCH→todo + dispatch pairs from the same owner).

Cause: POST /api/tasks/:id/dispatch calls dispatchTask(guard:false), and canDispatch skipped the one-live-run check when guard was false. The card re-enabled its buttons after the first action and lingers until the next feed poll, so a second click spawned again; a click while the blocking run was still up did the same.

Fix

  • canDispatch refuses a live current run on every path. guard:false still un-parks blocked and skips the pool/per-agent caution.
  • Dispatch route returns { live: true, sessionId } on that refusal.
  • Blocked-task cards are hydrated with args.run (session id, alive/ended, status) via the new batched TerminalManager.taskRunStates (liveTaskRuns now delegates to it), computed only when such a card is on the page.
  • Card UI shows "session still running / session ended · " with a link, swaps Unblock & run for Open session while the run is live, and keeps buttons disabled after an action lands.

Tests

scripts/unblock-run-dedupe-test.cjs (added to test:governance): 12 checks; 6 of them fail on the old canDispatch. Full npm run test:governance green; typecheck + web build clean.

🤖 Generated with Claude Code

…session's state (v0.455.0)

The console dispatch (guard:false) skipped the one-live-run-per-task check,
so a second click on the blocked-task card — or a click while the blocking
run was still up — spawned a parallel session on the same task. canDispatch
now refuses a live run on every path; the route returns the live session id.
The blocked card is hydrated with the task's current run (alive/ended) and
offers Open session while it is live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vikasprogrammer
vikasprogrammer merged commit c60b95a into main Oct 6, 2026
1 check 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