{"record":{"id":"332e24fb5194079e","repo":"stablyai/orca","slug":"the-target-workspace-is-no-longer-available","errorCode":null,"errorMessage":"The target workspace is no longer available.","messagePattern":"The target workspace is no longer available\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/index.ts","lineNumber":2596,"sourceCode":"                run,\n                repo: target.repo\n              })\n            })\n            terminalHandle = created.startupTerminal?.handle ?? ''\n            terminalSessionId = created.startupTerminal?.tabId ?? null\n            terminalPaneKey = created.startupTerminal?.paneKey ?? null\n            terminalPtyId = created.startupTerminal?.ptyId ?? null\n            workspaceId = created.worktree.id\n            workspaceDisplayName = created.worktree.displayName ?? null\n            if (!terminalHandle) {\n              throw new Error(\n                created.warning ||\n                  'Automation workspace was created, but no agent terminal started.'\n              )\n            }\n          } else {\n            if (!automation.workspaceId) {\n              throw new Error('The target workspace is no longer available.')\n            }\n            const terminal = await runtimeService.launchAgentTerminal(\n              `id:${automation.workspaceId}`,\n              {\n                agent: automation.agentId,\n                prompt: automation.prompt,\n                title: run.title\n              }\n            )\n            terminalHandle = terminal.handle\n            terminalSessionId = terminal.tabId ?? null\n            terminalPaneKey = terminal.paneKey ?? null\n            terminalPtyId = terminal.ptyId ?? null\n            workspaceId = terminal.worktreeId\n            const worktree = await runtimeService.showManagedWorktree(`id:${workspaceId}`)\n            workspaceDisplayName = worktree.displayName ?? null\n          }\n","sourceCodeStart":2578,"sourceCodeEnd":2614,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/index.ts#L2578-L2614","documentation":"Thrown when an automation run targets an existing workspace (the else-branch) but automation.workspaceId is falsy — the workspace reference is gone, so launchAgentTerminal cannot be called with `id:<workspaceId>`. The workspace was deleted or its ID was never persisted/cleared between sessions.","triggerScenarios":"Resuming or re-launching an automation run whose workspaceId is null/undefined/empty. Occurs when the worktree was deleted out-of-band, the automation record was partially reset, or the workspace registration failed to persist the ID.","commonSituations":"User deleted the worktree directory manually; a cleanup/GC pass removed the workspace; the automation was migrated between machines and lost its workspace reference; a crash left the automation record half-written.","solutions":["Create a fresh workspace for the automation (re-trigger workspace creation rather than reusing).","If the worktree still exists on disk, re-register it to obtain a workspaceId.","Prevent the race: ensure automation.workspaceId is persisted atomically with workspace creation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasWorkspaceId(automation: { workspaceId?: string | null }): boolean {\n  return typeof automation.workspaceId === 'string' && automation.workspaceId.length > 0\n}","typeGuard":"function hasValidWorkspaceId(a: unknown): a is { workspaceId: string } {\n  return typeof a === 'object' && a !== null && typeof (a as any).workspaceId === 'string' && (a as any).workspaceId.length > 0\n}","tryCatchPattern":"if (!automation.workspaceId) {\n  // create a fresh workspace instead of failing\n  await recreateAutomationWorkspace(automation.id)\n} else {\n  await launchTerminal(automation)\n}","preventionTips":["Persist automation.workspaceId atomically with workspace creation.","Before reuse, verify the workspace still exists via the runtime service.","Handle out-of-band workspace deletion by clearing workspaceId and forcing recreation."],"tags":["automation","workspace","state","lifecycle"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}