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:
Mohamed Boudra
2026-06-16 13:37:58 +07:00
parent ba9f7740a8
commit 9966e49329
102 changed files with 3222 additions and 1932 deletions
@@ -1,10 +1,6 @@
import { describe, expect, it } from "vitest";
import type { WorkspaceDescriptor } from "@/stores/session-store";
import {
resolveWorkspaceIdByDirectory,
resolveWorkspaceMapKeyByIdentity,
resolveWorkspaceRouteId,
} from "./workspace-identity";
import { resolveWorkspaceMapKeyByIdentity, resolveWorkspaceRouteId } from "./workspace-identity";
function createWorkspace(
input: Partial<WorkspaceDescriptor> & Pick<WorkspaceDescriptor, "id">,
@@ -38,42 +34,6 @@ describe("resolveWorkspaceRouteId", () => {
});
});
describe("resolveWorkspaceIdByDirectory", () => {
it("matches workspace directories", () => {
const workspaces = [
createWorkspace({
id: "workspace-1",
projectRootPath: "/repo",
workspaceDirectory: "/repo/.paseo/worktrees/feature",
}),
];
expect(
resolveWorkspaceIdByDirectory({
workspaces,
workspaceDirectory: "/repo/.paseo/worktrees/feature",
}),
).toBe("workspace-1");
});
it("does not match project root metadata", () => {
const workspaces = [
createWorkspace({
id: "workspace-1",
projectRootPath: "/repo",
workspaceDirectory: "/repo/.paseo/worktrees/feature",
}),
];
expect(
resolveWorkspaceIdByDirectory({
workspaces,
workspaceDirectory: "/repo",
}),
).toBeNull();
});
});
describe("resolveWorkspaceMapKeyByIdentity", () => {
it("returns the existing map key when the identity already matches a key", () => {
const workspaces = new Map<string, WorkspaceDescriptor>([