Skip to content

fix(desktop): prevent InitGitDialog errors from being hidden by navigation#1272

Merged
Kitenite merged 2 commits intomainfrom
fix/init-git-dialog-error-navigation
Feb 7, 2026
Merged

fix(desktop): prevent InitGitDialog errors from being hidden by navigation#1272
Kitenite merged 2 commits intomainfrom
fix/init-git-dialog-error-navigation

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 7, 2026

Summary

  • Cherry-picks the race condition fix that defers navigation until the InitGitDialog closes, and extracts processOpenNewResults utility
  • Fixes a bug where InitGitDialog.onError sets error state but the subsequent onClose navigates away before the user sees the error banner — now onError also clears pendingNavigateProjectId so no navigation occurs on error

Follow-up to #1248

Test plan

  • Select mix of git + non-git folders → git init fails → error banner stays visible, no navigation
  • Select mix of git + non-git folders → git init succeeds → navigates to first project
  • bun run typecheck passes

Summary by CodeRabbit

  • New Features

    • Enhanced multi-project opening workflow with consolidated notifications for all operation outcomes—successes, errors, and Git initialization requirements.
    • Improved navigation handling when Git repository initialization is required before accessing opened projects.
  • Bug Fixes

    • Project opening errors now display actual error details instead of generic failure messages.

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Router type refactoring
apps/desktop/src/lib/trpc/routers/projects/projects.ts
Inlined OpenNewResult and OpenNewMultiResult type definitions, removed FolderOutcome export, and changed error handling to propagate actual error messages instead of static "Failed to open project" text.
Multi-result utility
apps/desktop/src/renderer/react-query/projects/processOpenNewResults.ts
New module that categorizes multi-project open results into successes, needsGitInit, and errors, emitting appropriate toasts and returning a CategorizedResults object.
Utility export
apps/desktop/src/renderer/react-query/projects/index.ts
Added export of processOpenNewResults function from the new utility module.
Component refactoring
apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx, apps/desktop/src/renderer/screens/main/components/StartView/index.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebarFooter.tsx
Replaced inline multi-result handling with calls to processOpenNewResults; StartView additionally adds pendingNavigateProjectId state for deferred navigation after git initialization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 We hop through results with grace, ✨
Extract and sort at steady pace,
No more scattered toast and cheer—
One helper function crystal clear! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(desktop): prevent InitGitDialog errors from being hidden by navigation' directly addresses the main bug fix in the changeset: clearing pendingNavigateProjectId in onError to ensure errors remain visible.
Description check ✅ Passed The description covers all critical sections: Summary outlines the race condition fix and utility extraction, Test plan specifies reproducible steps with clear pass/fail criteria, and PR objectives explain the motivation and scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/init-git-dialog-error-navigation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Kitenite Kitenite merged commit 203beb1 into main Feb 7, 2026
5 of 6 checks passed
@Kitenite Kitenite deleted the fix/init-git-dialog-error-navigation branch February 7, 2026 02:00
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 7, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🔴 Critical

Drag-and-drop path doesn't set pendingNavigateProjectId for the needsGitInit case – after git init succeeds, the dialog closes with no navigation.

When a user drops a non-git folder, openFromPath returns needsGitInit and the InitGitDialog opens (line 169), but pendingNavigateProjectId is never set. The InitGitDialog creates the project and workspace asynchronously, then calls onClose() (line 155 in InitGitDialog.tsx). The parent's onClose handler checks pendingNavigateProjectId (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 have InitGitDialog pass the created project ID back to the parent via a callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant