feat: workspace source-of-truth hard cut

This commit is contained in:
Mohamed Boudra
2026-03-03 23:28:16 +07:00
parent f3796e2ba5
commit cb92f39e73
20 changed files with 1813 additions and 945 deletions
@@ -0,0 +1,9 @@
export function projectDisplayNameFromProjectId(projectId: string): string {
const githubRemotePrefix = "remote:github.com/";
if (projectId.startsWith(githubRemotePrefix)) {
return projectId.slice(githubRemotePrefix.length) || projectId;
}
const segments = projectId.split(/[\\/]/).filter(Boolean);
return segments[segments.length - 1] || projectId;
}
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import type { SidebarProjectEntry, SidebarWorkspaceEntry } from "@/hooks/use-sidebar-agents-list";
import type { SidebarProjectEntry, SidebarWorkspaceEntry } from "@/hooks/use-sidebar-workspaces-list";
import { buildSidebarWorkspaceViewModel } from "./sidebar-shortcuts";
@@ -7,11 +7,9 @@ function workspace(serverId: string, cwd: string): SidebarWorkspaceEntry {
return {
workspaceKey: `${serverId}:${cwd}`,
serverId,
cwd,
branchName: null,
createdAt: null,
isMainCheckout: false,
isPaseoOwnedWorktree: false,
workspaceId: cwd,
name: cwd,
activityAt: null,
statusBucket: "done",
};
}
@@ -20,11 +18,11 @@ function project(projectKey: string, workspaces: SidebarWorkspaceEntry[]): Sideb
return {
projectKey,
projectName: projectKey,
iconWorkingDir: workspaces[0]?.cwd ?? "",
iconWorkingDir: workspaces[0]?.workspaceId ?? "",
statusBucket: "done",
activeCount: 0,
totalCount: workspaces.length,
latestCreatedAt: null,
totalWorkspaces: workspaces.length,
latestActivityAt: null,
workspaces,
};
}
+2 -2
View File
@@ -1,7 +1,7 @@
import type {
SidebarProjectEntry,
SidebarWorkspaceEntry,
} from '@/hooks/use-sidebar-agents-list'
} from '@/hooks/use-sidebar-workspaces-list'
export interface SidebarShortcutWorkspaceTarget {
serverId: string
@@ -58,7 +58,7 @@ export function buildSidebarWorkspaceViewModel(input: {
if (shortcutNumber !== null) {
shortcutTargets.push({
serverId: workspace.serverId,
workspaceId: workspace.cwd,
workspaceId: workspace.workspaceId,
})
shortcutIndexByWorkspaceKey.set(workspace.workspaceKey, shortcutNumber)
}