Skip to content

Add settings toggle to isolate new threads in a git worktree by default - #2

Merged
currentbits merged 1 commit into
mainfrom
feat/default-worktree-threads
Aug 13, 2026
Merged

currentbits merged 1 commit into
mainfrom
feat/default-worktree-threads

Conversation

@currentbits

@currentbits currentbits commented Aug 13, 2026 •

Copy link
Copy Markdown
Owner

What

Adds a defaultWorktree app setting (Settings → Threads → "Isolate new threads in a git worktree"). When enabled, the plain New thread button creates a worktree thread — its own branch and working directory under <userData>/worktrees/<threadId> — instead of running the agent directly in the project checkout.

Why

Worktree isolation already existed but only behind the caret menu's "New worktree thread", so most threads ran in the main checkout and concurrent threads on the same project could step on each other's files. This closes that gap by letting users make it the default while keeping plain threads available.

How

  • electron/store.js: new defaultWorktree setting — absent/junk on disk heals to false, setSettings rejects non-booleans, persists alongside budget/auto-settle.
  • src/shared/ipc.ts: AppSettings.defaultWorktree: boolean.
  • src/useCoder.ts: createThread is the single choke point — when the setting is on and the project is local it sends worktree: true, so every plain-creation path (sidebar button, kanban empty state) gets isolation. Explicit opts.worktree still wins; remote projects always get plain threads (worktrees are local-only, matching the existing IPC guard).
  • src/components/SettingsModal.tsx: new Threads section with a save-on-toggle checkbox.
  • src/devCoder.ts / test/support/fakeCoder.ts: dev and test doubles mirror the setting with the same validation.
  • Tests: new coverage for normalize/validate/persist of the flag in electron/test/auto-settle-settings.test.js; full-shape settings assertions updated there and in budget-spend.test.js.

No behavior change with the toggle off (the default). All downstream machinery (branch naming, merge, PR, checkpoints) is unchanged — this only changes who opts in.

Testing

  • npm run typecheck — clean

  • npm run test:electron — 650/650 pass

  • npm run test:renderer — 699/699 pass

  • PR created by the Claude Code agent

New defaultWorktree app setting. When enabled, plain 'New thread'
creates a worktree thread (local projects only; explicit opts and
remote projects are unaffected). Wired through store validation,
AppSettings, useCoder.createThread, SettingsModal checkbox, and the
dev/test doubles.

Co-Authored-By: Claude Fable 5 <[email protected]>
@currentbits
currentbits merged commit fb99bb0 into main Aug 13, 2026

@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

solenta/src/useCoder.ts

Lines 544 to 546 in 4a15094

const worktree =
opts?.worktree ??
(settings?.defaultWorktree === true && !project?.remoteHost);

P2 Badge Enforce the worktree default for automation-created threads

When defaultWorktree is enabled, this only injects worktree: true for threads created through the React hook. Scheduled automations bypass this path and create/run threads directly in electron/automations.js via services.createThread, so those agent runs still execute in the project checkout and can collide with other work even though the user enabled global isolation. Apply the default in the backend creation path, or pass it from automation, so all new agent threads honor the setting.

ℹ️ 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".

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