feat(workspaces): add recency-based workspace switching and redirect#4131
feat(workspaces): add recency-based workspace switching and redirect#4131waleedlatif1 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Persists last active workspace via a new Prevents users from deleting their final remaining workspace (server-side 400 + UI disables delete when only one workspace remains), and refactors workspace management UI to rely on React Query mutation pending states and updated cache shape for the new workspaces response metadata. Reviewed by Cursor Bugbot for commit 08400f5. Configure here. |
b22185d to
f13c434
Compare
Greptile SummaryAdds recency-based workspace switching using a hybrid localStorage + server-side Confidence Score: 5/5Safe to merge — all remaining findings are P2 style suggestions The feature is correctly implemented end-to-end: redirect logic has proper fallbacks, the delete guard is enforced server-side, cache shape is fixed, and prior review concerns are resolved. The only open finding is a convention-level style issue (direct apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-management.ts — direct fetch in touchRecency Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant P as workspace/page.tsx
participant LS as WorkspaceRecencyStorage
participant API as GET /api/workspaces
participant WH as WorkspaceHeader
participant UWM as useWorkspaceManagement
participant SAPI as PATCH /api/users/me/settings
U->>P: Navigates to /workspace
P->>API: fetchWorkspaces (useWorkspacesWithMetadata)
API-->>P: { workspaces[], lastActiveWorkspaceId }
P->>LS: getMostRecent()
LS-->>P: localRecentId
P->>P: resolve target = localRecentId ?? lastActiveWorkspaceId ?? workspaces[0]
P->>U: router.replace(/workspace/{target}/home)
U->>WH: Opens workspace switcher dropdown
WH->>UWM: onWorkspaceSwitch(workspace)
UWM->>LS: touch(workspaceId)
Note over UWM,SAPI: debounced 1s
UWM->>SAPI: PATCH lastActiveWorkspaceId
UWM->>UWM: setRecencySortKey(k+1) re-sort dropdown
Reviews (7): Last reviewed commit: "fix(workspaces): skip prune when workspa..." | Re-trigger Greptile |
f13c434 to
2309c9d
Compare
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-management.ts
Show resolved
Hide resolved
2309c9d to
f14fe67
Compare
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-management.ts
Show resolved
Hide resolved
f14fe67 to
2fc98fb
Compare
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-management.ts
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@greptile |
|
@cursor review |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-management.ts
Show resolved
Hide resolved
|
@cursor review |
|
@greptile |
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workspace-management.ts
Show resolved
Hide resolved
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 08400f5. Configure here.

Summary
lastActiveWorkspaceIdcolumn to settings table with debounced server syncuseStateloading booleans with React Querymutation.isPendingonSuccesscache invalidationsetQueryDatacache shape afterfetchWorkspacesreturn type changed toWorkspacesResponseType of Change
Testing
Tested manually
Checklist