fix(desktop): stop workspace delete from crash-remounting the renderer via stale v1 routes
Merged
KI
3mo ago+34+34+01234567890123456789-6-6-0123456789
Fixes SUPER-1814 — reported by Jose Carlos (reacherapp.com) on 1.20.2: every workspace delete "refreshes the whole Superset application" and dumps him on an empty New Workspace screen until a manual reload.
Root cause
Confirmed against his PostHog timeline (the desktop_opened root-mount event re-fires 400ms after each delete, landing on #/new-workspace):
- Deleting the active workspace with no visible sibling falls back to
navigate({ to: "/" }). /redirects to/workspace— the v1 index.- For migrated v2 users, the v1 index restores a stale
lastViewedWorkspaceId(pre-migration v1 row still in the electron localDb) and navigates onto a v1 workspace route. - The dashboard's version-mismatch guard rendered an inline
<Navigate to="/new-workspace" replace />.Navigatere-navigates whenever its props object identity changes, so every layout re-render during the pending navigation re-navigated until React threw error #185. The throw bubbled to the rooterrorComponent, unmounting the entire tree; the settled navigation reset the boundary and remounted the root — the "app reloaded itself" flash.
Only users with pre-migration v1 leftovers hit this, which is why it never reproduced on clean installs. Step 4 is the same hazard class already fixed in routes/page.tsx (#5729).
Fix
- Hoist the version-mismatch
<Navigate>to module scope for stable props identity — kills the #185 loop no matter how a v2 user reaches a v1 route. - Workspace-removal fallback goes straight to
/new-workspaceinstead of detouring through/→ v1 index. - The v1 workspace index redirects v2 users to
/new-workspaceinstead of running v1 restore logic — covers every other path into/(sign-in, create-organization, not-found "Go home"), including the sibling "creating a workspace makes the others disappear" symptom in the same report.
Verification
- Mechanism confirmed in the installed router source:
Navigatere-navigates on props-identity change (useNavigate.js,previousPropsRef.current !== props). bun run typecheck(desktop) clean,bun run lintclean, 1454 renderer tests pass.- No end-to-end CDP repro was run — reproducing requires seeding pre-migration v1 state (stale
lastViewedWorkspaceId+ v1 localDb rows).
Summary by cubic
Fixes SUPER-1814 by stopping the app from remounting after deleting a workspace. V2 users now go straight to /new-workspace, avoiding stale v1 routes and a Navigate re-navigation loop.
- Bug Fixes
- Hoisted version-mismatch
Navigateto module scope to keep props stable and prevent re-navigation (React error 185). - On delete fallback, route directly to
/new-workspaceinstead of"/"→ v1 index. - In the v1 workspace index, detect v2 and redirect to
/new-workspace; skipelectronTrpc.workspaces.getAllGroupedfor v2; isolate the v2 redirect from v1 query churn and memoize the workspace list to avoid redundant effect triggers during navigation.
- Hoisted version-mismatch
Summary by CodeRabbit
-
New Features
- Added automatic navigation to the new workspace setup when no replacement workspace is available.
- Added routing from V2 Cloud workspace dashboards to the new workspace experience.
-
Bug Fixes
- Improved workspace restoration and navigation behavior for existing V1 workspaces.
- Prevented unnecessary workspace reloads during dashboard navigation.