Skip to content

feat(desktop): add import repo option to open workspace dropdown#947

Merged
Kitenite merged 1 commit into
mainfrom
open-workspace-allow-import-repo
Jan 26, 2026
Merged

feat(desktop): add import repo option to open workspace dropdown#947
Kitenite merged 1 commit into
mainfrom
open-workspace-allow-import-repo

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 26, 2026

Summary

  • Add "Import repo" action to the project selector in the Open Workspace modal
  • Users can import a local repository without leaving the workflow
  • Uses DropdownMenu pattern (instead of Select) to properly separate selection items from action items

Test plan

  • Open the "Open Workspace" modal
  • Click the project dropdown
  • Verify projects are listed with checkmarks for selected
  • Click "Import repo" at the bottom (after separator)
  • Verify native file picker opens
  • Select a git repository folder
  • Verify the imported repo becomes the selected project

Summary by CodeRabbit

  • New Features
    • Redesigned project selector with improved dropdown interface.
    • Added "Import repo" option to import projects from external sources.
    • Current project selection now visually indicated with a checkmark.

✏️ Tip: You can customize this high-level summary in your review settings.

Add "Import repo" action to the project selector in the Open Workspace
modal, allowing users to import a local repository without leaving the
workflow. Uses DropdownMenu pattern (instead of Select) to properly
separate selection items from action items.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

The NewWorkspaceModal component's project selector has been refactored from a Select component to a DropdownMenu. A new "Import repo" option with folder-open icon has been added, wired to a handleImportRepo function that manages external project imports using the useOpenNew hook and handles git initialization checks with user feedback via toast messages.

Changes

Cohort / File(s) Summary
NewWorkspaceModal project selector refactor
apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
Replaced Select UI with DropdownMenu for project selection; added "Import repo" option with folder-open icon; implemented handleImportRepo function to manage project imports via useOpenNew hook with error/cancellation handling; introduced selectedProject derived constant; updated component imports to include DropdownMenu components and LuFolderOpen icon

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A dropdown appears, so sleek and so fine,
Where projects now gather in UI divine!
We hop through the folders with "Import" so bold,
Toast messages sing what the future foretold—
The modal grows smarter with each little hop! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 accurately describes the main change: adding an import repo option to the workspace dropdown, which aligns with the primary feature being implemented.
Description check ✅ Passed The description is well-structured with a clear summary and comprehensive test plan. It covers the main changes and user workflow, though it deviates from the template structure by using custom sections instead of the suggested template format.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

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: 1

🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx`:
- Around line 168-187: The component's handleImportRepo
setsSelectedProjectId(result.project.id) but recentProjects (used by
selectedProject derivation) isn't updated yet, causing selectedProject to be
undefined; fix by either invalidating/refetching the getRecents query after a
successful import (add an onSuccess in the openNew mutation or call
trpc.getRecents.invalidate/refetch from the workspace/openNew.ts procedure) or,
simpler in the component, render a fallback using result.project.name when
selectedProject is undefined but selectedProjectId matches result.project.id;
update handleImportRepo and/or the openNew mutation onSuccess to ensure
getRecents is refreshed or show result.project.name as a temporary display until
recents refetches.
🧹 Nitpick comments (2)
apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx (2)

268-271: Consider disabling "Import repo" while the import is in progress.

If the user clicks "Import repo" while openNew is already pending, it could trigger multiple file pickers or race conditions. Consider adding a disabled state:

♻️ Proposed fix
-							<DropdownMenuItem onClick={handleImportRepo}>
+							<DropdownMenuItem
+								onClick={handleImportRepo}
+								disabled={openNew.isPending}
+							>
 								<LuFolderOpen className="size-4" />
 								Import repo
 							</DropdownMenuItem>

254-267: Minor: Separator may appear without items above it.

When recentProjects is empty, the DropdownMenuSeparator will render with no items above it, which may look visually odd. Consider conditionally rendering the separator only when there are projects.

♻️ Proposed fix
 							{recentProjects
 								.filter((project) => project.id)
 								.map((project) => (
 									<DropdownMenuItem
 										key={project.id}
 										onClick={() => setSelectedProjectId(project.id)}
 									>
 										{project.name}
 										{project.id === selectedProjectId && (
 											<HiCheck className="ml-auto size-4" />
 										)}
 									</DropdownMenuItem>
 								))}
-							<DropdownMenuSeparator />
+							{recentProjects.length > 0 && <DropdownMenuSeparator />}
 							<DropdownMenuItem onClick={handleImportRepo}>

Comment on lines +168 to +187
const handleImportRepo = async () => {
try {
const result = await openNew.mutateAsync(undefined);
if (result.canceled) return;
if ("error" in result) {
toast.error("Failed to open project", { description: result.error });
return;
}
if ("needsGitInit" in result) {
toast.error("Selected folder is not a git repository");
return;
}
setSelectedProjectId(result.project.id);
} catch (error) {
toast.error("Failed to open project", {
description:
error instanceof Error ? error.message : "An unknown error occurred",
});
}
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Race condition exists: imported project won't appear in dropdown until getRecents query refetches.

After setSelectedProjectId(result.project.id), the selectedProject derivation (which looks up selectedProjectId in recentProjects) will return undefined until the getRecents query refetches. The mutation handler in apps/desktop/src/main/ipc/trpc/procedures/workspace/openNew.ts does not invalidate the getRecents query, and the component has no onSuccess handler to trigger a refetch.

This causes the button to display "Select project" immediately after import, even though selectedProjectId is set.

Recommend either:

  1. Invalidating the getRecents query in the mutation's onSuccess handler, or
  2. Displaying result.project.name as a fallback when selectedProject is undefined but selectedProjectId is set.
🤖 Prompt for AI Agents
In `@apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx`
around lines 168 - 187, The component's handleImportRepo
setsSelectedProjectId(result.project.id) but recentProjects (used by
selectedProject derivation) isn't updated yet, causing selectedProject to be
undefined; fix by either invalidating/refetching the getRecents query after a
successful import (add an onSuccess in the openNew mutation or call
trpc.getRecents.invalidate/refetch from the workspace/openNew.ts procedure) or,
simpler in the component, render a fallback using result.project.name when
selectedProject is undefined but selectedProjectId matches result.project.id;
update handleImportRepo and/or the openNew mutation onSuccess to ensure
getRecents is refreshed or show result.project.name as a temporary display until
recents refetches.

@Kitenite Kitenite merged commit 05f455a into main Jan 26, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

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

Thank you for your contribution! 🎉

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