Repository navigation
feat(sidebar): add "Open as folder" to nested-repo import - #6902
jtalborough wants to merge 2 commits into
Conversation
|
Ready to review this PR? Stage has broken it down into 5 individual chapters for you: Chapters generated by Stage for commit e34bc80 on Jun 30, 2026 1:12pm UTC. |
When adding a local folder that contains nested git repos, the import review only let you import those repos (separately or as a group) — there was no way to take the parent folder itself as a single project. Add an "Open as folder" action to the nested-repo review that adds the scanned parent as a single non-git folder project (addNonGitFolder), skipping the per-repo import entirely. The button ignores the per-repo selection so it stays usable when nothing is checked. Gated to local scans — addNonGitFolder routes through the local provider only, so SSH/runtime scans don't show the action. Co-Authored-By: Claude Opus 4.8 <[email protected]>
f6d1174 to
45a9969
Compare
📝 WalkthroughWalkthroughThe PR adds an "Open as folder" action to the nested repository import flow. A new 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/AddRepoDialog.tsx (1)
266-267: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why comment for the local-only gate.
!nestedConnectionId && !isRuntimeEnvironmentActiveencodes the PR's “local scans only” rule, but that constraint is not obvious from the boolean alone. A one-line comment here would make it clearer that SSH/runtime nested scans are intentionally excluded.Suggested tweak
- const canOpenNestedAsFolder = !nestedConnectionId && !isRuntimeEnvironmentActive + // Why: "Open as folder" is only valid for local scans; SSH/runtime scans + // must keep the nested-repo import path instead. + const canOpenNestedAsFolder = !nestedConnectionId && !isRuntimeEnvironmentActiveAs per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: eccd15c9-8e10-4fa3-97fa-91d0adb62380
📒 Files selected for processing (10)
src/renderer/src/components/sidebar/AddRepoDialog.tsxsrc/renderer/src/components/sidebar/AddRepoDialogStepContent.tsxsrc/renderer/src/components/sidebar/AddRepoNestedImportStep.test.tsxsrc/renderer/src/components/sidebar/AddRepoNestedImportStep.tsxsrc/renderer/src/components/sidebar/useAddRepoNestedImportFlow.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
| it('keeps the open-as-folder action enabled even when no repos are selected', () => { | ||
| const html = renderStepMarkup({ selectedPaths: new Set(), onOpenAsFolder: vi.fn() }) | ||
|
|
||
| // Why: the folder shortcut ignores the per-repo selection, so it must stay | ||
| // usable when the separate/group buttons are disabled by an empty selection. | ||
| expect(html).toMatch(/<button[^>]*>[^<]*Open as folder<\/button>/) | ||
| expect(html).toMatch(/<button[^>]*disabled=""[^>]*>No, import separately<\/button>/) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
This test never verifies that “Open as folder” is enabled.
The first regex only proves the button is rendered; it would still match if the button had disabled="". A regression that disables this action would still pass here.
Suggested fix
- it('keeps the open-as-folder action enabled even when no repos are selected', () => {
- const html = renderStepMarkup({ selectedPaths: new Set(), onOpenAsFolder: vi.fn() })
-
- // Why: the folder shortcut ignores the per-repo selection, so it must stay
- // usable when the separate/group buttons are disabled by an empty selection.
- expect(html).toMatch(/<button[^>]*>[^<]*Open as folder<\/button>/)
- expect(html).toMatch(/<button[^>]*disabled=""[^>]*>No, import separately<\/button>/)
- })
+ it('keeps the open-as-folder action enabled even when no repos are selected', () => {
+ const host = document.createElement('div')
+ container = host
+ document.body.appendChild(host)
+ root = createRoot(host)
+
+ act(() => {
+ root?.render(
+ <TooltipProvider>
+ <Dialog open>
+ <AddRepoNestedImportStep
+ scan={scan}
+ groupName=""
+ selectedPaths={new Set()}
+ isAdding={false}
+ scanInProgress={false}
+ onGroupNameChange={vi.fn()}
+ onSelectedPathsChange={vi.fn()}
+ onImport={vi.fn()}
+ onOpenAsFolder={vi.fn()}
+ onStopScan={vi.fn()}
+ />
+ </Dialog>
+ </TooltipProvider>
+ )
+ })
+
+ // Why: the folder shortcut ignores the per-repo selection, so it must stay
+ // usable when the separate/group buttons are disabled by an empty selection.
+ expect(findButton(host, 'Open as folder')).not.toBeDisabled()
+ expect(findButton(host, 'No, import separately')).toBeDisabled()
+ })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('keeps the open-as-folder action enabled even when no repos are selected', () => { | |
| const html = renderStepMarkup({ selectedPaths: new Set(), onOpenAsFolder: vi.fn() }) | |
| // Why: the folder shortcut ignores the per-repo selection, so it must stay | |
| // usable when the separate/group buttons are disabled by an empty selection. | |
| expect(html).toMatch(/<button[^>]*>[^<]*Open as folder<\/button>/) | |
| expect(html).toMatch(/<button[^>]*disabled=""[^>]*>No, import separately<\/button>/) | |
| }) | |
| it('keeps the open-as-folder action enabled even when no repos are selected', () => { | |
| const host = document.createElement('div') | |
| container = host | |
| document.body.appendChild(host) | |
| root = createRoot(host) | |
| act(() => { | |
| root?.render( | |
| <TooltipProvider> | |
| <Dialog open> | |
| <AddRepoNestedImportStep | |
| scan={scan} | |
| groupName="" | |
| selectedPaths={new Set()} | |
| isAdding={false} | |
| scanInProgress={false} | |
| onGroupNameChange={vi.fn()} | |
| onSelectedPathsChange={vi.fn()} | |
| onImport={vi.fn()} | |
| onOpenAsFolder={vi.fn()} | |
| onStopScan={vi.fn()} | |
| /> | |
| </Dialog> | |
| </TooltipProvider> | |
| ) | |
| }) | |
| // Why: the folder shortcut ignores the per-repo selection, so it must stay | |
| // usable when the separate/group buttons are disabled by an empty selection. | |
| expect(findButton(host, 'Open as folder')).not.toBeDisabled() | |
| expect(findButton(host, 'No, import separately')).toBeDisabled() | |
| }) |
A non-git folder project has no GitHub remote, so the icon picker's Avatar tab (which fetches a remote avatar) is a dead end for it. Start folder repos on the Icon grid instead. Co-Authored-By: Claude Opus 4.8 <[email protected]>
What
When you add a local folder that contains nested git repositories, the "Import repositories from folder" review only offered to import those repos — either separately (one project each) or as a group. There was no way to take the selected parent folder itself as a single project.
This adds an "Open as folder" action to that review. It adds the scanned parent as a single non-git folder project (
addNonGitFolder) and skips the per-repo import entirely.It also includes a small companion fix so folder projects get a sensible icon picker (see below).
Details
"Open as folder" action
onOpenAsFolderaction onAddRepoNestedImportStep, rendered as an outline button on the left of the footer with a tooltip explaining it.useAddRepoNestedImportFlow(handleOpenNestedAsFolder) and is gated to local scans inAddRepoDialog(!nestedConnectionId && !isRuntimeEnvironmentActive) —addNonGitFolderroutes through the local provider only, so SSH/runtime scans don't show the action.Folder icon-picker default
RepositoryIconPickernow defaults folder repos to the Icon grid instead of Avatar.Tests
AddRepoNestedImportStep.test.tsx: action hidden when no handler is provided, fires the handler without triggering an import, and stays enabled with an empty selection.oxlint, webtsgotypecheck, localization catalog/coverage, and the Add-Project test suite pass.🤖 Generated with Claude Code
ELI5
When importing a folder with nested git repos, you can choose “Open as folder” to add the parent as one non-git project instead of importing every nested repo. Handy when you want the outer folder as a single workspace.