Skip to content

Commit 92a35df

Browse files
committed
Fix: Use workspace ID for metadata lookup, not path
The sortedWorkspacesByProject was building a path-based lookup map, but workspaceMetadata is keyed by workspace ID. This caused all workspaces to be filtered out when building the sorted list. Now we directly look up by ws.id from the config.
1 parent eb80283 commit 92a35df

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/App.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,11 @@ function AppInner() {
337337
// Use stable reference to prevent sidebar re-renders when sort order hasn't changed
338338
const sortedWorkspacesByProject = useStableReference(
339339
() => {
340-
// Build path-to-metadata lookup map internally
341-
const pathToMetadata = new Map<string, FrontendWorkspaceMetadata>();
342-
for (const metadata of workspaceMetadata.values()) {
343-
pathToMetadata.set(metadata.stableWorkspacePath, metadata);
344-
pathToMetadata.set(metadata.namedWorkspacePath, metadata);
345-
}
346-
347340
const result = new Map<string, FrontendWorkspaceMetadata[]>();
348341
for (const [projectPath, config] of projects) {
349-
// Transform Workspace[] to FrontendWorkspaceMetadata[] and filter nulls
342+
// Transform Workspace[] to FrontendWorkspaceMetadata[] using workspace ID
350343
const metadataList = config.workspaces
351-
.map((ws) => pathToMetadata.get(ws.path))
344+
.map((ws) => (ws.id ? workspaceMetadata.get(ws.id) : undefined))
352345
.filter((meta): meta is FrontendWorkspaceMetadata => meta !== undefined);
353346

354347
// Sort by recency

src/hooks/useWorkspaceManagement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function useWorkspaceManagement({
4242
// NOTE: onMetadata sends all current metadata immediately upon subscription,
4343
// then sends updates as they happen (e.g., from renames)
4444
const unsubscribe = window.api.workspace.onMetadata((event: { workspaceId: string; metadata: FrontendWorkspaceMetadata }) => {
45-
console.log("[useWorkspaceManagement] Metadata event received:", event.workspaceId);
45+
console.log("[useWorkspaceManagement] Metadata event received:", event.workspaceId, event.metadata);
4646
setWorkspaceMetadata((prev) => {
4747
const updated = new Map(prev);
4848
updated.set(event.workspaceId, event.metadata);

0 commit comments

Comments
 (0)