Skip to content

Multi-folder projects: primary repo plus read/search folders (#514) - #1653

Merged
currentbits merged 2 commits into
mainfrom
coder/multi-folder-projects-primary-repo-plus--397088
Oct 16, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/multi-folder-projects-primary-repo-plus--397088

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #514.

A project can now list secondary folders next to its primary path. The primary keeps git, worktrees, AGENTS.md / skills / memory (#179 keying unchanged). Agents can read and search the secondary folders. Writes there are denied until the user grants that folder on the thread's permission card.

What changed

  • Data: project.folders holds the ordered secondary folders (absolute, must exist, local projects only, max 8, de-duplicated, primary skipped). Turning a project remote clears them. Grants live per thread in thread.folderWriteGrants. Shared helpers are in electron/projectFolders.js.
  • Claude: each folder is passed with --add-dir=<dir>. Ungranted folders also get a permissions.ask rule, Edit(//dir/**), merged into the single --settings JSON with fastMode. I checked this against the real CLI (2.1.283): the ask rule still prompts under acceptEdits and bypassPermissions, reads in the added dir need no prompt, and primary-folder writes are unchanged. The folder lists are part of the warm-CLI reuse key, so a grant respawns the CLI on the next turn.
  • Permission card: an edit inside an ungranted secondary folder shows which folder it is and adds Allow writes to <folder> (decision allowFolder). That allows the edit and saves the grant. If a folder is granted mid-run, the warm CLI still has the ask rule, so those edits are auto-allowed only in modes that would auto-allow a primary edit.
  • All providers: the prompt gets a [Project folders] note listing each folder as read-only or granted.
  • UI: the project editor has an "Other folders" field (one path per line, hidden for remote projects). The scope menu and project group headers show a "+N folders" badge; its tooltip lists the paths.

Known limits (v1)

  • Other providers can't write to secondary folders. Codex, Grok, Kimi, OpenCode and Cursor get read/search plus the note. Their writes there are blocked by the existing write.outside guardrail hooks, and for Codex also by the sandbox. They have no grant path. With guardrails off, only Codex's sandbox still blocks.
  • Only file-edit tools are gated. Shell commands can still write to secondary folders.
  • Not tested: Windows paths in the ask rule, and whether Claude loads skills from --add-dir folders.
  • No folder picker. The field is a plain text box.
  • Out of scope, per the issue: worktrees per secondary folder, cross-repo commits, multi-repo diff review.

Tests

  • New electron/test/project-folders.test.js covers validation, the argv/settings shape, the prompt note, and a full ask → allowFolder → allow run through a fake Claude CLI.
  • New renderer cases in test/permissionPrompt.test.tsx and test/editProject.test.tsx.
  • Rebased on main 58a0b90. On top of it: test:electron 4792/4792 (CODER_* env stripped, CI-style), related renderer suites 297/297, tsc and vite build clean.

🤖 Generated with Claude Code

A project can list secondary folders next to its primary path. The
primary keeps git, worktrees, AGENTS.md/skills/memory. Agents can read
and search the secondary folders; writes are denied until the user grants
a folder on a thread's permission card.

- projects.update accepts folders (absolute, existing, local only, max 8)
- claude: --add-dir per folder, plus a permissions.ask Edit(//dir/**) rule
  for ungranted folders (prompts even under acceptEdits/bypass, 2.1.283)
- permission card: "Allow writes to <folder>" persists a per-thread grant
- every provider gets a [Project folders] prompt note; non-claude writes
  stay blocked by the existing write.outside guardrail hooks
- project editor "Other folders" field and a "+N folders" sidebar badge

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T08:02:16.124183Z 638d015 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 638d015a35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +59 to +61
function secondaryFolders(project) {
if (!project || project.remoteHost || !Array.isArray(project.folders)) return [];
return project.folders.filter((f) => typeof f === "string" && path.isAbsolute(f));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject or translate secondary folders for WSL projects

On Windows, a project rooted at \\wsl$\<distro>\... has no remoteHost, so this returns its Windows UNC folder paths even though runs cross the WSL boundary. Claude explicitly drops these folders when crossesBoundary(project) is true, while foldersNoteFor still tells every provider they are available using host-side paths; consequently WSL users can configure folders that agents cannot read or search. Detect wslTarget(project) here or reject/translate these paths during normalization.

Useful? React with 👍 / 👎.

Comment on lines +36 to +37
const p = path.resolve(s);
if (p === primary) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compare Windows folder identities case-insensitively

On Windows, paths are case-insensitive but these string comparisons are not. Entering the primary checkout with different casing, such as c:\repo for a project stored as C:\Repo, therefore stores the primary as a secondary folder and installs an ask rule over ordinary project edits; casing variants are likewise not de-duplicated. Canonicalize folder identities before comparing them so the primary cannot become its own read-only secondary folder.

Useful? React with 👍 / 👎.

Comment on lines +83 to +85
for (const f of folders) {
const rel = path.relative(f, abs);
if (rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel))) return f;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match the most specific configured folder

When configured folders overlap, this first-match loop assigns every nested edit to whichever ancestor appears first. For example, with [/shared, /shared/private], granting only /shared/private still leaves edits there classified as the ungranted /shared; conversely, granting the ancestor can auto-allow a request raised by the still-ungranted nested folder. Select the longest containing path or reject overlapping folder entries so each displayed grant controls the folder it names.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit 96fd116 into main Oct 16, 2026
6 checks passed
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.

Multi-folder projects: primary repo plus secondary read/search folders

1 participant