fix: distinguish missing branch from missing restore support
Split the compound condition so workspace restore gives an accurate
error message when branch metadata is null ("branch metadata is
missing") vs when the workspace plugin lacks a restore method.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4159748416
commit
44db68bb5f
|
|
@ -935,31 +935,33 @@ export function createSessionManager(deps: SessionManagerDeps): SessionManager {
|
|||
|
||||
if (!workspaceExists) {
|
||||
// Try to restore workspace if plugin supports it
|
||||
if (plugins.workspace?.restore && session.branch) {
|
||||
try {
|
||||
const wsInfo = await plugins.workspace.restore(
|
||||
{
|
||||
projectId,
|
||||
project,
|
||||
sessionId,
|
||||
branch: session.branch,
|
||||
},
|
||||
workspacePath,
|
||||
);
|
||||
|
||||
// Run post-create hooks on restored workspace
|
||||
if (plugins.workspace.postCreate) {
|
||||
await plugins.workspace.postCreate(wsInfo, project);
|
||||
}
|
||||
} catch (err) {
|
||||
throw new WorkspaceMissingError(
|
||||
workspacePath,
|
||||
`restore failed: ${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!plugins.workspace?.restore) {
|
||||
throw new WorkspaceMissingError(workspacePath, "workspace plugin does not support restore");
|
||||
}
|
||||
if (!session.branch) {
|
||||
throw new WorkspaceMissingError(workspacePath, "branch metadata is missing");
|
||||
}
|
||||
try {
|
||||
const wsInfo = await plugins.workspace.restore(
|
||||
{
|
||||
projectId,
|
||||
project,
|
||||
sessionId,
|
||||
branch: session.branch,
|
||||
},
|
||||
workspacePath,
|
||||
);
|
||||
|
||||
// Run post-create hooks on restored workspace
|
||||
if (plugins.workspace.postCreate) {
|
||||
await plugins.workspace.postCreate(wsInfo, project);
|
||||
}
|
||||
} catch (err) {
|
||||
throw new WorkspaceMissingError(
|
||||
workspacePath,
|
||||
`restore failed: ${err instanceof Error ? err.message : String(err)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Get launch command — try restore command first, fall back to fresh launch
|
||||
|
|
|
|||
Loading…
Reference in New Issue