fix(desktop): hoist mutation hooks out of Dialog to fix stale sidebar after workspace creation#2441
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis change consolidates workspace and worktree management actions through a modal draft context. Four hooks (createWorkspace, createFromPr, openTrackedWorktree, openExternalWorktree) are centralized in a context provider and accessed via useNewWorkspaceModalDraft, replacing scattered individual hook imports across components. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
runAsyncActioncloses the Dialog immediately. Radix Dialog unmounts its content, destroyinguseMutationobservers insidePromptGroup,BranchesGroup,IssuesGroup, andPullRequestsGroup. If the mutation completes after unmount,onSuccess(containingutils.workspaces.invalidate()+ navigation) is skipped — leaving the sidebar stale.useCreateWorkspace,useCreateFromPr,useOpenTrackedWorktree, anduseOpenExternalWorktreeintoNewWorkspaceModalDraftProvider, which wraps the Dialog and stays mounted. Content components now consume mutations from context.openTrackedWorktreemutation fromBranchesGroupintouseOpenTrackedWorktreehook.resolveInitialCommandsfrom auseCreateWorkspacehook option to a per-callPendingSetupOverridesparameter so the hook can be called without per-component options.Test plan
Summary by cubic
Fixes stale sidebar after creating or importing a workspace from the New Workspace modal by moving mutation hooks out of the Dialog so onSuccess always runs. The sidebar now refreshes and navigation works without a reload.
Bug Fixes
Refactors
Written for commit 450a6cd. Summary will update on new commits.
Summary by CodeRabbit