Key workspace status and ownership by ID, not directory
Multiple workspaces can share one checkout directory. Agent and terminal status, sidebar tabs, and ownership now attribute strictly by workspace ID, so a running or blocked agent in one workspace no longer shows up on its same-directory siblings. A one-time startup migration backfills workspace IDs onto legacy agents, and every agent and terminal is created with one thereafter. Directory lookups remain only for genuinely folder-derived git facts (branch, diff) and the archive-by-path adapter.
This commit is contained in:
@@ -32,6 +32,9 @@ export function useIsLastWorktreeReference(workspace: SidebarWorkspaceEntry): bo
|
||||
if (candidate.id === workspace.workspaceId) {
|
||||
continue;
|
||||
}
|
||||
// Git-fact: comparing directories to detect a sibling worktree reference on
|
||||
// disk, not attributing ownership. The disk-deletion decision is about the
|
||||
// backing directory, which same-cwd siblings genuinely share.
|
||||
if (normalizeWorkspacePath(candidate.workspaceDirectory) === directory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ function target(input?: Partial<WorkspaceArchiveTarget>): WorkspaceArchiveTarget
|
||||
return {
|
||||
serverId: SERVER_ID,
|
||||
workspaceId: base.id,
|
||||
workspaceDirectory: base.workspaceDirectory,
|
||||
...input,
|
||||
};
|
||||
}
|
||||
@@ -107,7 +106,6 @@ describe("archiveWorkspaceOptimistically", () => {
|
||||
isWorkspaceArchivePending({
|
||||
serverId: SERVER_ID,
|
||||
workspaceId: archived.id,
|
||||
workspaceDirectory: archived.workspaceDirectory,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
@@ -178,10 +176,7 @@ describe("archiveWorkspacesOptimistically", () => {
|
||||
|
||||
const failures = await archiveWorkspacesOptimistically({
|
||||
client,
|
||||
workspaces: [
|
||||
target({ workspaceId: first.id, workspaceDirectory: first.workspaceDirectory }),
|
||||
target({ workspaceId: second.id, workspaceDirectory: second.workspaceDirectory }),
|
||||
],
|
||||
workspaces: [target({ workspaceId: first.id }), target({ workspaceId: second.id })],
|
||||
});
|
||||
|
||||
expect(failures).toHaveLength(1);
|
||||
|
||||
@@ -8,7 +8,6 @@ import { resolveWorkspaceMapKeyByIdentity } from "@/utils/workspace-identity";
|
||||
export interface WorkspaceArchiveTarget {
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
workspaceDirectory?: string | null;
|
||||
}
|
||||
|
||||
interface WorkspaceArchiveClient {
|
||||
@@ -46,7 +45,6 @@ function hideWorkspaceOptimistically(
|
||||
markWorkspaceArchivePending({
|
||||
serverId: workspace.serverId,
|
||||
workspaceId: workspace.workspaceId,
|
||||
workspaceDirectory: workspace.workspaceDirectory,
|
||||
});
|
||||
useSessionStore.getState().removeWorkspace(workspace.serverId, workspace.workspaceId);
|
||||
return { workspace: snapshot };
|
||||
|
||||
Reference in New Issue
Block a user