fix: isolate git snapshot errors per workspace in fetch_workspaces

A single workspace failing to load git data (e.g. empty repo, corrupt
git state) was crashing the entire fetch_workspaces response, leaving
all users with an unusable app. Now errors are caught per-workspace
and logged as warnings, returning the workspace without git data.
This commit is contained in:
Mohamed Boudra
2026-04-14 20:54:11 +07:00
parent 25fd93d7e2
commit f0ac632732

View File

@@ -5443,7 +5443,17 @@ export class Session {
projectRecord?: PersistedProjectRecord | null,
): Promise<WorkspaceDescriptorPayload> {
const base = await this.describeWorkspaceRecord(workspace, projectRecord);
const snapshot = await this.workspaceGitService.getSnapshot(workspace.cwd);
let snapshot: WorkspaceGitRuntimeSnapshot;
try {
snapshot = await this.workspaceGitService.getSnapshot(workspace.cwd);
} catch (error) {
this.sessionLogger.warn(
{ err: error, cwd: workspace.cwd },
"Failed to load git snapshot for workspace",
);
return base;
}
const checkout = checkoutLiteFromGitSnapshot(workspace.cwd, snapshot.git);
const displayName = deriveWorkspaceDisplayName({ cwd: workspace.cwd, checkout });