Skip to content

feat(sidebar): add "Open as folder" to nested-repo import - #6902

Open
jtalborough wants to merge 2 commits into
stablyai:mainfrom
jtalborough:feat/add-folder-as-single-project
Open

jtalborough wants to merge 2 commits into
stablyai:mainfrom
jtalborough:feat/add-folder-as-single-project

Conversation

@jtalborough

@jtalborough jtalborough commented Jun 30, 2026 •

Copy link
Copy Markdown

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

  • New optional onOpenAsFolder action on AddRepoNestedImportStep, rendered as an outline button on the left of the footer with a tooltip explaining it.
  • The button ignores the per-repo checklist selection, so it stays usable even when nothing is checked (unlike the import buttons).
  • The handler lives in useAddRepoNestedImportFlow (handleOpenNestedAsFolder) and is gated to local scans in AddRepoDialog (!nestedConnectionId && !isRuntimeEnvironmentActive) — addNonGitFolder routes through the local provider only, so SSH/runtime scans don't show the action.

Folder icon-picker default

  • A non-git folder repo has no GitHub remote, so the icon picker's Avatar tab (which fetches a remote avatar) is a dead end for it. RepositoryIconPicker now defaults folder repos to the Icon grid instead of Avatar.

Tests

  • Added 3 cases to 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, web tsgo typecheck, 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.

@ghost

ghost commented Jun 30, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 5 individual chapters for you:

Title
1 Default to icon tab for folder projects
2 Implement folder import logic in hook
3 Wire folder import through dialog components
4 Add UI and translations for folder action
5 Verify folder import behavior with tests
Open in Stage

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]>
@jtalborough
jtalborough force-pushed the feat/add-folder-as-single-project branch from f6d1174 to 45a9969 Compare June 30, 2026 12:57
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds an "Open as folder" action to the nested repository import flow. A new handleOpenNestedAsFolder callback is added to useAddRepoNestedImportFlow, which calls addNonGitFolder with the scanned path and closes the modal on success, using a generation counter to prevent stale state updates. This handler is threaded through AddRepoDialog and AddRepoDialogStepContent down to AddRepoNestedImportStep, where a conditional button is rendered with an expanded pending state, a tooltip, and a spinner. Localization strings for the new option are added in en, es, ja, ko, and zh JSON files. RepositoryIconPicker also updates its initial tab selection so folder repos without a GitHub remote start on the icon tab.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

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.
Description check ⚠️ Warning The description covers summary and testing, but it omits required template sections for screenshots, AI review, security audit, and notes. Add the missing sections per template, including screenshots or 'No visual change', AI review details, a security audit summary, and notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding an Open as folder action to the nested-repo import flow.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/AddRepoDialog.tsx (1)

266-267: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a short why comment for the local-only gate.

!nestedConnectionId && !isRuntimeEnvironmentActive encodes 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 && !isRuntimeEnvironmentActive

As 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

📥 Commits

Reviewing files that changed from the base of the PR and between be3f30e and 45a9969.

📒 Files selected for processing (10)
  • src/renderer/src/components/sidebar/AddRepoDialog.tsx
  • src/renderer/src/components/sidebar/AddRepoDialogStepContent.tsx
  • src/renderer/src/components/sidebar/AddRepoNestedImportStep.test.tsx
  • src/renderer/src/components/sidebar/AddRepoNestedImportStep.tsx
  • src/renderer/src/components/sidebar/useAddRepoNestedImportFlow.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json

Comment on lines +138 to +145
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>/)
})

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.

🎯 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.

Suggested change
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]>
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026

This branch has not been deployed

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants