fix(desktop): prevent InitGitDialog errors from being hidden by navigation#1272
fix(desktop): prevent InitGitDialog errors from being hidden by navigation#1272
Conversation
Fix navigate + InitGitDialog race where navigation unmounts StartView before the git-init dialog is shown. Defer navigation until dialog closes. Propagate real error messages instead of static strings, remove dead exported types, extract shared processOpenNewResults utility to deduplicate filtering + toast logic across 3 call sites, and fix pre-existing type narrowing bug with "multi" in result checks.
Clear pendingNavigateProjectId in onError so that the subsequent onClose callback does not navigate away before the user sees the error banner.
📝 WalkthroughWalkthroughThis PR refactors multi-project opening result handling by extracting common logic into a dedicated utility function, inlining type definitions in the router to remove intermediate aliases, and updating error propagation to preserve actual error messages instead of generic text. The same functionality is now consolidated in five consumer components using the new utility. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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)
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/desktop/src/renderer/screens/main/components/StartView/index.tsx (1)
155-191:⚠️ Potential issue | 🔴 CriticalDrag-and-drop path doesn't set
pendingNavigateProjectIdfor theneedsGitInitcase – after git init succeeds, the dialog closes with no navigation.When a user drops a non-git folder,
openFromPathreturnsneedsGitInitand theInitGitDialogopens (line 169), butpendingNavigateProjectIdis never set. TheInitGitDialogcreates the project and workspace asynchronously, then callsonClose()(line 155 in InitGitDialog.tsx). The parent'sonClosehandler checkspendingNavigateProjectId(line 295 in index.tsx) and navigates if set—but since drag-and-drop never sets it, navigation never happens.Compare to the "Open Project" button flow (line 77 in index.tsx), which sets
pendingNavigateProjectId(firstProjectId)before opening the dialog. The drag-and-drop flow should do the same after the project is created in the dialog, or haveInitGitDialogpass the created project ID back to the parent via a callback.
Summary
processOpenNewResultsutilityInitGitDialog.onErrorsets error state but the subsequentonClosenavigates away before the user sees the error banner — nowonErroralso clearspendingNavigateProjectIdso no navigation occurs on errorFollow-up to #1248
Test plan
bun run typecheckpassesSummary by CodeRabbit
New Features
Bug Fixes