Skip to content

fix: let the owner retry an interrupted connection action - #135

Open
DerekChia wants to merge 1 commit into
CopilotKit:mainfrom
DerekChia:fix/interrupted-action-retry
Open

DerekChia wants to merge 1 commit into
CopilotKit:mainfrom
DerekChia:fix/interrupted-action-retry

Conversation

@DerekChia

Copy link
Copy Markdown

Fixes #134.

User workflow

An owner approves a gated connected-service action and the server stops before the result is saved (crash, restart, deploy). Today that card shows "Running" forever with no retry path, and every approval attempt returns 409 This action is already running. After this change, the card shows "Interrupted" with a Retry action button once the claim is demonstrably stale, and retrying runs the already-stored request exactly once.

Change

  • Add ACTION_TTL_MS (10 min; a claimed action settles in ~60s since MCP calls are bounded, so a result-less older claim cannot belong to a live run).
  • claimAction reclaims an expired result-less claim atomically (conditional UPDATE, so concurrent reclaimers serialize and only one executes); finishAction no longer overwrites a saved result.
  • The action receipt reports interrupted for an expired result-less claim; the POST path lets the same approval reclaim it.
  • The approval binding is unchanged: fresh running rows still 409, saved results still return only to their own approval, and a different approval can never steal the claim.
  • The action card stops its 2s poll on interrupted, labels it, explains the retry, and offers "Retry action".

Verification

  • New regression tests in tests/connections.test.ts: retry-after-interruption runs the stored request exactly once (receipt interrupted → POST 200 → receipt done), fresh claims still 409, and a stale claim under a different approval still 409s. The retry test failed on the base commit (receipt stayed running, POST stayed 409) and passes with the fix.
  • Full suite: 48 files, 304 tests passed. npm run check-format, npm run lint, npm run typecheck, and npm run build all green (Node v22.23.1).
  • UI change is text and status-branch only on the existing card (same buttons/layout, no new controls); keyboard access and narrow-screen layout are unaffected.

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.

Approval-gated action interrupted before its result is saved can never be retried

1 participant