Skip to content

fix(server): continue threads whose background tasks outlived the turn - #48

Open
macodev00 wants to merge 1 commit into
mainfrom
cursor/continue-live-background-tasks-redo-a904
Open

macodev00 wants to merge 1 commit into
mainfrom
cursor/continue-live-background-tasks-redo-a904

Conversation

@macodev00

Copy link
Copy Markdown
Owner

What Changed

Restart continuation treats open background tasks the same as an interrupted turn.

markRunningProviderSessionsForContinuation and reconcileProviderSessions now notice unterminated task.* rows (the persisted form of Claude liveTaskIds). When "Continue threads after restarts" is on, the thread is continued with a prompt that names the stopped tasks. When it is off, or continuation fails, those tasks are settled as stopped and the thread gets the existing restart notice.

This also covers the three restart-recovery cases that blocked the previous attempt:

  1. A retry from a persisted starting session restores recorded task names whenever the continuation marker is present, including after settleStoppedTasks has already written task.completed rows. Promptless providers still receive the named tasks instead of { continuation: true }.
  2. listUnterminatedTasks skips activity rows whose payload_json is not valid JSON, so one malformed payload cannot abort continuation for every thread.
  3. Plan and dream tasks stay excluded when any decisive row for that task has taskType plan or dream, even if a later status update omits taskType.

Why

A Claude thread whose turn has already finished can still be running subagents or background shells. The session is ready with no active turn, so a restart neither continued it nor told the user the work was lost.

Fixes pingdotgg#13400

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes
Open in Web Open in Cursor 

A thread can finish its turn while subagents or background shells are still running. Restart continuation only resumed sessions that were still running with an active turn, so those threads stayed ready and the work disappeared.

Startup now treats unterminated task rows like an interrupted turn. When continue-after-restart is on, the continuation prompt names the stopped tasks. Otherwise those tasks are settled as stopped and the thread gets the existing restart notice.

A retry after those tasks were already settled restores the recorded names from the continuation marker. Malformed activity payloads are skipped, and plan or dream tasks stay excluded when a later status row omits taskType.

Fixes pingdotgg#13400

Grok 4.7 via Cursor cloud agent.

Co-authored-by: maco <macodev00@users.noreply.github.com>
@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Sep 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restart continuation skips threads whose turn ended while Claude subagents or background shells were still running

1 participant