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

Method handleActiveWorkspaceLifecycleTurns

src/node/services/taskService.ts:6123–6159  ·  view source on GitHub ↗
(
    ownerWorkspaceId: string,
    resolved: ResolvedWorkspaceLifecycleTarget,
    interruptActive: boolean
  )

Source from the content-addressed store, hash-verified

6121 }
6122
6123 private async handleActiveWorkspaceLifecycleTurns(
6124 ownerWorkspaceId: string,
6125 resolved: ResolvedWorkspaceLifecycleTarget,
6126 interruptActive: boolean
6127 ): Promise<WorkspaceLifecycleResult | null> {
6128 const activeRecords = (
6129 await this.listWorkspaceTurnTasks(ownerWorkspaceId, {
6130 statuses: ["queued", "starting", "running"],
6131 })
6132 ).filter((record) => record.workspaceId === resolved.workspaceId);
6133 const activeTaskIds = activeRecords.map((record) => record.handleId);
6134 if (activeTaskIds.length === 0) {
6135 return null;
6136 }
6137 if (!interruptActive) {
6138 return {
6139 status: "active",
6140 action: resolved.action,
6141 ...this.lifecycleTargetFields(resolved),
6142 activeTaskIds,
6143 };
6144 }
6145
6146 for (const activeTaskId of activeTaskIds) {
6147 const interruptResult = await this.interruptWorkspaceTurn(ownerWorkspaceId, activeTaskId);
6148 if (!interruptResult.success) {
6149 return {
6150 status: "error",
6151 action: resolved.action,
6152 ...this.lifecycleTargetFields(resolved),
6153 activeTaskIds,
6154 error: interruptResult.error,
6155 };
6156 }
6157 }
6158 return null;
6159 }
6160
6161 listDescendantAgentTasks(
6162 workspaceId: string,

Calls 3

lifecycleTargetFieldsMethod · 0.95

Tested by

no test coverage detected