refactor: transition to opaque workspace identifiers
This commit is contained in:
@@ -27,7 +27,7 @@ import type {
|
||||
AgentSnapshotPayload,
|
||||
WorkspaceDescriptorPayload,
|
||||
} from "@server/shared/messages";
|
||||
import { normalizeWorkspaceIdentity } from "@/utils/workspace-identity";
|
||||
import { normalizeWorkspaceOpaqueId } from "@/utils/workspace-identity";
|
||||
import {
|
||||
createAgentLastActivityCoalescer,
|
||||
type AgentLastActivityCommitter,
|
||||
@@ -130,7 +130,7 @@ export function normalizeWorkspaceDescriptor(
|
||||
payload: WorkspaceDescriptorPayload,
|
||||
): WorkspaceDescriptor {
|
||||
return {
|
||||
id: normalizeWorkspaceIdentity(String(payload.id)) ?? String(payload.id),
|
||||
id: normalizeWorkspaceOpaqueId(String(payload.id)) ?? String(payload.id),
|
||||
projectId: String(payload.projectId),
|
||||
projectDisplayName: payload.projectDisplayName,
|
||||
projectRootPath: payload.projectRootPath,
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
} from "@/stores/workspace-layout-store";
|
||||
|
||||
const SERVER_ID = "server-1";
|
||||
const WORKSPACE_ID = "/repo/worktree";
|
||||
const WORKSPACE_ID = "ws-main";
|
||||
|
||||
function createTab(tabId: string): WorkspaceTab {
|
||||
return {
|
||||
@@ -813,7 +813,7 @@ describe("workspace-layout-store actions", () => {
|
||||
const workspaceKey = createWorkspaceKey();
|
||||
const otherWorkspaceKey = buildWorkspaceTabPersistenceKey({
|
||||
serverId: SERVER_ID,
|
||||
workspaceId: "/repo/other-worktree",
|
||||
workspaceId: "ws-other-worktree",
|
||||
});
|
||||
|
||||
expect(otherWorkspaceKey).toBeTruthy();
|
||||
@@ -849,7 +849,7 @@ describe("workspace-layout-store actions", () => {
|
||||
const workspaceKey = createWorkspaceKey();
|
||||
const otherWorkspaceKey = buildWorkspaceTabPersistenceKey({
|
||||
serverId: SERVER_ID,
|
||||
workspaceId: "/repo/other-worktree",
|
||||
workspaceId: "ws-other-worktree",
|
||||
});
|
||||
|
||||
expect(otherWorkspaceKey).toBeTruthy();
|
||||
|
||||
@@ -23,6 +23,17 @@ import {
|
||||
const SERVER_ID = "server-1";
|
||||
const WORKSPACE_ID = "/repo/worktree";
|
||||
|
||||
describe("buildWorkspaceTabPersistenceKey", () => {
|
||||
it("preserves opaque workspace ids instead of normalizing them like paths", () => {
|
||||
expect(
|
||||
buildWorkspaceTabPersistenceKey({
|
||||
serverId: SERVER_ID,
|
||||
workspaceId: " setup\\workspace\\ ",
|
||||
}),
|
||||
).toBe("server-1:setup\\workspace\\");
|
||||
});
|
||||
});
|
||||
|
||||
describe("workspace-tabs-store retargetTab", () => {
|
||||
beforeEach(() => {
|
||||
useWorkspaceTabsStore.setState({
|
||||
|
||||
@@ -28,10 +28,6 @@ function trimNonEmpty(value: string | null | undefined): string | null {
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
function normalizeWorkspaceId(value: string): string {
|
||||
return value.trim().replace(/\\/g, "/").replace(/\/+$/, "");
|
||||
}
|
||||
|
||||
export function buildWorkspaceTabPersistenceKey(input: {
|
||||
serverId: string;
|
||||
workspaceId: string;
|
||||
@@ -41,7 +37,7 @@ export function buildWorkspaceTabPersistenceKey(input: {
|
||||
if (!serverId || !workspaceId) {
|
||||
return null;
|
||||
}
|
||||
return `${serverId}:${normalizeWorkspaceId(workspaceId)}`;
|
||||
return `${serverId}:${workspaceId}`;
|
||||
}
|
||||
|
||||
function normalizeTabOrder(list: unknown): string[] {
|
||||
|
||||
Reference in New Issue
Block a user