Skip to content

Commit 8d67e9a

Browse files
committed
Fix: Restore workspace from URL hash after metadata loads
The restore effect ran on mount before workspaceMetadata was loaded, so it always failed to find the workspace. Now it waits for metadata to be loaded and only restores once.
1 parent 9e122ee commit 8d67e9a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/App.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,18 @@ function AppInner() {
225225

226226
// Restore workspace from URL on mount (if valid)
227227
useEffect(() => {
228+
// Wait for metadata to load before attempting restore
229+
if (workspaceMetadata.size === 0) return;
230+
231+
// Only restore once - if workspace is already selected, skip
232+
if (selectedWorkspace) return;
233+
228234
const hash = window.location.hash;
229235
if (hash.startsWith("#workspace=")) {
230236
const workspaceId = decodeURIComponent(hash.substring("#workspace=".length));
231237

232238
// Find workspace in metadata
233-
const metadata = Array.from(workspaceMetadata.values()).find((ws) => ws.id === workspaceId);
239+
const metadata = workspaceMetadata.get(workspaceId);
234240

235241
if (metadata) {
236242
// Find project for this workspace (metadata now includes projectPath)
@@ -242,9 +248,7 @@ function AppInner() {
242248
});
243249
}
244250
}
245-
// Only run on mount
246-
// eslint-disable-next-line react-hooks/exhaustive-deps
247-
}, []);
251+
}, [workspaceMetadata, selectedWorkspace, setSelectedWorkspace]);
248252

249253
// Validate selected workspace exists (clear if workspace was deleted)
250254
useEffect(() => {

0 commit comments

Comments
 (0)