Skip to content

Commit d5f9cd7

Browse files
committed
Fix: Update old localStorage entries with missing namedWorkspacePath
Old selectedWorkspace entries from localStorage may be missing the namedWorkspacePath field. The validation effect now detects this and updates the workspace with current metadata, preventing errors in command palette and other components that expect the field.
1 parent 5731225 commit d5f9cd7

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/App.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,31 @@ function AppInner() {
250250
}
251251
}, [workspaceMetadata, selectedWorkspace, setSelectedWorkspace]);
252252

253-
// Validate selected workspace exists (clear if workspace was deleted)
253+
// Validate selected workspace exists and has all required fields
254254
useEffect(() => {
255255
if (selectedWorkspace && workspaceMetadata.size > 0) {
256-
const exists = workspaceMetadata.has(selectedWorkspace.workspaceId);
257-
if (!exists) {
256+
const metadata = workspaceMetadata.get(selectedWorkspace.workspaceId);
257+
258+
if (!metadata) {
259+
// Workspace was deleted
258260
console.warn(
259261
`Workspace ${selectedWorkspace.workspaceId} no longer exists, clearing selection`
260262
);
261263
setSelectedWorkspace(null);
262-
// Also clear URL hash if present
263264
if (window.location.hash) {
264265
window.history.replaceState(null, "", window.location.pathname);
265266
}
267+
} else if (!selectedWorkspace.namedWorkspacePath) {
268+
// Old localStorage entry missing namedWorkspacePath - update it
269+
console.log(
270+
`Updating workspace ${selectedWorkspace.workspaceId} with missing fields`
271+
);
272+
setSelectedWorkspace({
273+
workspaceId: metadata.id,
274+
projectPath: metadata.projectPath,
275+
projectName: metadata.projectName,
276+
namedWorkspacePath: metadata.namedWorkspacePath,
277+
});
266278
}
267279
}
268280
}, [selectedWorkspace, workspaceMetadata, setSelectedWorkspace]);

0 commit comments

Comments
 (0)