MCPcopy
hub / github.com/coder/mux / markInterruptedTaskRunning

Method markInterruptedTaskRunning

src/node/services/taskService.ts:7297–7339  ·  view source on GitHub ↗

* If a preserved descendant task workspace was previously interrupted and the user manually * resumes it, restore taskStatus=running so stream-end finalization can proceed normally. * * Returns true only when a state transition happened.

(workspaceId: string)

Source from the content-addressed store, hash-verified

7295 * Returns true only when a state transition happened.
7296 */
7297 async markInterruptedTaskRunning(workspaceId: string): Promise<boolean> {
7298 assert(workspaceId.length > 0, "markInterruptedTaskRunning: workspaceId must be non-empty");
7299
7300 const configAtStart = this.config.loadConfigOrDefault();
7301 const entryAtStart = findWorkspaceEntry(configAtStart, workspaceId);
7302 if (!entryAtStart?.workspace.parentWorkspaceId) {
7303 return false;
7304 }
7305 if (entryAtStart.workspace.taskStatus !== "interrupted") {
7306 return false;
7307 }
7308
7309 let transitionedToRunning = false;
7310 await this.editWorkspaceEntry(
7311 workspaceId,
7312 (ws) => {
7313 // Only descendant task workspaces have task lifecycle status.
7314 if (!ws.parentWorkspaceId) {
7315 return;
7316 }
7317 if (ws.taskStatus !== "interrupted") {
7318 return;
7319 }
7320
7321 // Preserve taskPrompt here: interrupted queued tasks store their only initial
7322 // prompt in config. If send/resume fails, restoreInterruptedTaskAfterResumeFailure
7323 // must be able to retain that original prompt for inspection/retry.
7324 ws.taskStatus = "running";
7325 // A user-initiated resume is a fresh chance: clear the recovery budget so a
7326 // breaker-tripped task doesn't instantly re-fail on its first recovery prompt.
7327 delete ws.taskRecoveryAttempts;
7328 transitionedToRunning = true;
7329 },
7330 { allowMissing: true }
7331 );
7332
7333 if (!transitionedToRunning) {
7334 return false;
7335 }
7336
7337 await this.emitWorkspaceMetadata(workspaceId);
7338 return true;
7339 }
7340
7341 /**
7342 * Revert a pre-stream interrupted->running transition when send/resume fails to start

Callers 3

sendMessageMethod · 0.80
resumeStreamMethod · 0.80

Calls 5

editWorkspaceEntryMethod · 0.95
emitWorkspaceMetadataMethod · 0.95
findWorkspaceEntryFunction · 0.90
loadConfigOrDefaultMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected