Skip to content

feat(accounts): launch Claude in user-owned profile folders - #38149

Open
spamsch wants to merge 2 commits into
stablyai:mainfrom
spamsch:feat/claude-profiles
Open

spamsch wants to merge 2 commits into
stablyai:mainfrom
spamsch:feat/claude-profiles

Conversation

@spamsch

@spamsch spamsch commented Nov 4, 2026

Copy link
Copy Markdown

ELI5

Some people keep more than one Claude Code setup on the same machine, each in its own folder with its own settings, CLAUDE.md, memory, skills and login. Today they start them from shell aliases like CLAUDE_CONFIG_DIR=~/.claude-work claude. This PR lets you register such a folder once in Settings, and then it shows up as its own entry in the agent menu, for example "Claude · work".

What Changed

Before: Orca knew one kind of extra Claude setup, the managed account. Managed accounts live in Orca's data folder, are selected globally ("the next Claude you start uses it"), and Orca copies settings.json, CLAUDE.md and parts of .claude.json from ~/.claude into them on every setup. There was no way to start Claude in a folder the user owns from the agent menu.

After:

  • Settings > AI Provider Accounts > Claude has a new "Claude Profiles" block. You add a profile with a label and an absolute folder path (typed or picked with Browse). Remove only forgets the profile; the folder is never touched.
  • Each profile appears as a terminal launch row "Claude · " next to Claude in the tab bar agent menu (AgentLaunchPickerMenu) and in the plain agent menu (ProjectedAgentMenuItems). Rows appear only when the Claude CLI is detected and the workspace runs on this computer.
  • Launching a profile row starts the normal claude terminal agent with two extra launch env entries: CLAUDE_CONFIG_DIR=<folder> and ORCA_CLAUDE_CONFIG_PROFILE_DIR=<folder>. They go through the existing agentEnv of the startup plan, so they are recorded in the launch config and a cold restore resumes the session in the same folder.
  • In main, both PTY spawn preflights (IPC and runtime) recognise a launch whose ORCA_CLAUDE_CONFIG_PROFILE_DIR equals its CLAUDE_CONFIG_DIR. For such a launch Orca skips managed-account routing: withClaudeProfileTerminalEnv does not inject the pointer or the selected account's CLAUDE_CONFIG_DIR, and prepareClaudeAuth is not called. Instead, prepareClaudeConfigProfileLaunch creates the folder if it is missing and merges Orca's status hooks into its settings.json (only when agent status hooks are enabled for Claude), using the existing claudeHookService.install({ configDir }). Nothing else in the folder is written.
  • The plain "Claude" entry and the global account switcher behave exactly as before.

Mechanism, in short: the profile is a launch-scoped env overlay on the existing claude agent, not a new TuiAgent id and not a new kind of managed account.

Why

The motivating setup: two folders, ~/.claude-operayo and ~/.claude-placeholder, started today through aliases that run CLAUDE_CONFIG_DIR=... claude --dangerously-skip-permissions. Both need to be startable side by side from Orca, each with its own configuration.

Managed accounts do not cover this:

Alternatives considered:

  • A kind: 'profile' variant inside claudeManagedAccounts. Rejected: that list feeds the switcher, usage and rate limits, WSL account push, the session move dialog and more. Each consumer would need a branch to keep profiles out of the sync and the global selection. A sibling claudeConfigProfiles list keeps those paths unchanged.
  • One dynamic TuiAgent id per profile. Rejected: TuiAgent is a closed union used by detection, hooks, permissions, telemetry and the agent catalog.
  • agentDefaultEnv.claude.CLAUDE_CONFIG_DIR already works, but only for one folder and it changes every Claude launch.

Linked Issue

#25065 (the Claude half: "connect an existing CLI configuration folder" and show it as its own launch entry). Codex homes from that issue are not part of this PR.

Related: #27660 and #24873 (status hooks missing for a custom config folder). This PR installs the hooks for registered profile folders only.

Visual Proof

Screenshots omitted: I did not run the Electron app for this change, so the UI is untested. Reviewers should check the new "Claude Profiles" block in Settings > AI Provider Accounts and the "Claude · " rows in the tab bar agent menu.

Testing

Automated:

  • pnpm tc: passes.
  • New tests, each failing without the change:
    • src/main/ipc/pty/pty-launch-race-parity.test.ts: on both spawn lanes, a profile launch reaches the provider with its own CLAUDE_CONFIG_DIR while prepareClaudeAuth would route it to a selected account. Verified to fail on both lanes with the preflight change reverted.
    • src/main/claude-accounts/claude-profile-router.test.ts: with an account selected, withClaudeProfileTerminalEnv leaves a profile launch env unchanged and still routes an ordinary pane.
    • src/shared/claude-config-profiles.test.ts: normalization drops ~, relative and .. paths, blank labels, and repeated ids or folders; the env marker only counts when it equals CLAUDE_CONFIG_DIR.
    • src/renderer/src/components/tab-bar/claude-config-profile-rows.test.ts: placement of profile rows, and no rows on an SSH host.
  • pnpm check:changed: typecheck, format, oxlint, every ratchet, localization, import boundaries and changed-code quality pass. Its unit test step fails only on tests that also fail on unmodified main in my checkout:
    • 47 tests/e2e/cross-version-wire/* tests, because my clone is shallow and lacks the release tags they check out (the harness says so).
    • src/main/runtime/rpc/agent-sender-refresh.test.ts (2 work-count tests), which fails the same way on main.
  • pnpm test --changed=origin/main: 41771 passed; the 38 failures are the ones listed above.
  • src/shared/remote-runtime/host-store/wsl-host-deployment-store.test.ts (3 tests) also fails on unmodified main locally.

Manual steps for a reviewer (macOS or Linux):

  1. Create two folders, for example ~/.claude-a and ~/.claude-b, and sign in to Claude once in each (CLAUDE_CONFIG_DIR=~/.claude-a claude).
  2. In Settings > AI Provider Accounts > Claude > Claude Profiles, add both with absolute paths.
  3. Open the tab bar agent menu in a local workspace. "Claude · a" and "Claude · b" appear below Claude.
  4. Start both. In each, /status shows that folder's login, and echo $CLAUDE_CONFIG_DIR in a shell started from that tab is not affected. The sidebar shows working/idle status for both.
  5. Select a managed account in the status bar switcher and start "Claude · a" again: it still runs in ~/.claude-a. Plain "Claude" uses the selected account.
  6. Remove a profile: its row disappears and the folder still exists.

Platforms: only the automated checks above were run, on macOS. Not tested on Windows, Linux, over SSH or WSL.

Risk

Level: Low

  • Saved settings gain an optional claudeConfigProfiles array. Older builds ignore it. Normalization runs on load, in the main settings update and in the renderer settings slice.
  • The main-side change only applies to launches that carry ORCA_CLAUDE_CONFIG_PROFILE_DIR equal to CLAUDE_CONFIG_DIR. Every other launch takes the existing path.
  • Orca writes its status hooks into the profile folder's settings.json, as it already does for ~/.claude/settings.json. Removing a profile does not remove those hooks. The hook script exits immediately outside an Orca pane, so stale entries are inert.
  • Profiles are host folders. Rows are hidden for SSH and Orca server workspaces, and a profile launch is refused for SSH, server and WSL (\\wsl$) workspaces instead of falling back to another account. A Windows host whose agent runtime is set to WSL for a non-UNC folder is not detected and is untested.
  • Profile launches are terminal only. They never take the structured chat route, and they skip the host-side prompt paste path because that path rebuilds the launch env from settings.
  • Back out with a plain revert. Saved profiles stay in settings as an unused key.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: the folder path must be absolute and contain no .. segment; ~ is rejected because env values are not shell-expanded. Main re-checks the marker before skipping account routing.
  • Cross-platform: path validation accepts POSIX and C:\ style paths. The env overlay and hook install use existing cross-platform code.
  • Remote SSH and mobile: profiles are not offered there.
  • Not done in this PR: profile rows in the tab bar omnibox search results, per-profile usage display, Codex homes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Register a Claude config folder (CLAUDE_CONFIG_DIR) with a label in
Settings > AI Provider Accounts. Each profile becomes its own terminal
entry "Claude · <label>" in the agent menus. The launch carries the
folder as CLAUDE_CONFIG_DIR plus ORCA_CLAUDE_CONFIG_PROFILE_DIR in its
agent env, so a cold restore resumes in the same folder.

Main skips managed-account routing for such launches: no pointer or
account CLAUDE_CONFIG_DIR is injected and prepareClaudeAuth is not
called. It creates the folder when missing and merges Orca's status
hooks into its settings.json; nothing else in the folder is written,
unlike managed accounts, which sync settings.json, CLAUDE.md and
.claude.json from ~/.claude.

Profiles are host folders, so they are not offered for SSH, Orca
server or WSL workspaces, and a launch there is refused rather than
falling back to another account.
@spamsch
spamsch requested a review from brennanb2025 as a code owner November 4, 2026 14:42
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The change adds saved Claude configuration profiles to global settings, with validation and normalization. The accounts settings view lets users add, browse, and remove profiles. Launch menus display eligible profiles and pass the selected profile ID into local Claude launches. The launch flow applies the profile environment. PTY preflight prepares the profile directory and conditionally installs status hooks.

Merge Risk: Moderate · up to 2ef2e

An incompatible folder path can launch Claude with the wrong configuration. Reaching the profile limit can also erase an unsaved entry. Refuse incompatible paths before launch and preserve drafts at the limit before merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: launching Claude in user-owned profile folders.
Description check Passed The description is mostly complete. It explains the user impact, implementation, rationale, linked issue reference, testing, risks, platform limitations, rollback plan, and scope. It does not provide …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Description check

Explanation

The description is mostly complete. It explains the user impact, implementation, rationale, linked issue reference, testing, risks, platform limitations, rollback plan, and scope. It does not provide the required explicit N/A statement for visual proof and does not include a direct issue link, but these omissions do not make the description largely incomplete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 31 functions across 30 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

@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: 3

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 630503a8-3092-4a25-afba-93c70520cb5a
Commits

Reviewing files that changed from the base of the PR and between 2724b03 and 6d4ee4c.

Files selected for processing: 29
  • src/main/claude-accounts/claude-config-profile-launch.ts
  • src/main/claude-accounts/claude-credential-persistence-ratchet.test.ts
  • src/main/claude-accounts/claude-profile-installed-router.ts
  • src/main/claude-accounts/claude-profile-router.test.ts
  • src/main/ipc/pty/ipc/spawn-preflight.ts
  • src/main/ipc/pty/pty-claude-config-profile-spawn.test.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx
  • src/renderer/src/components/agent/ClaudeConfigProfileMenuItems.tsx
  • src/renderer/src/components/settings/accounts/accounts-claude-search.ts
  • src/renderer/src/components/settings/accounts/claude/accounts-pane-claude-section.tsx
  • src/renderer/src/components/settings/accounts/claude/claude-config-profiles-setting.tsx
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/components/tab-bar/claude-config-profile-rows.test.ts
  • src/renderer/src/components/tab-bar/claude-config-profile-rows.ts
  • src/renderer/src/components/tab-bar/tab-agent-row-presentation.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/lib/claude-config-profile-launch.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-args.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-test-fixture.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/store/slices/settings.ts
  • src/shared/agent-launch/picker/agent-launch-picker-rows.ts
  • src/shared/claude-config-profiles.test.ts
  • src/shared/claude-config-profiles.ts
  • src/shared/claude-profile-routing.ts
  • src/shared/global-settings-base.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/shared/claude-config-profiles.ts Resolved
- A profile folder that cannot be created now fails the PTY spawn with
  claudeAccountSetupFailed instead of starting Claude with only a
  console warning. Status hook installation stays non-fatal.
- Profiles are refused and hidden when the workspace's resolved
  project runtime is WSL, including Windows-drive projects set to run
  in WSL, not only for \\wsl$ paths.
- Profile folders may be UNC shares such as \\server\share\claude; any
  control character is rejected along with `..` segments.
- Doc comments on the new and touched functions.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Guard add() when the profile limit is reached. · claude-config-profiles-setting.tsx:60-75

src/renderer/src/components/settings/accounts/claude/claude-config-profiles-setting.tsx:60-75
Minor · Functional Correctness · Quick win

Guard add() when the profile limit is reached.

The Add button is disabled at 32 profiles, but pressing Enter in the directory field still calls add(). A valid 33rd profile is appended, discarded by normalizeClaudeConfigProfiles, and followed by clearing both draft fields. Check full inside add() before validating or clearing the draft.

Suggested fix
   /** Save the draft as a new profile, or show why it cannot be saved. */
   const add = (): void => {
+    if (full) {
+      return
+    }
     const problem = draftError(label, configDir, profiles)
Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 630439b5-7a5a-43a2-a013-8ce6cc6df4aa
Commits

Reviewing files that changed from the base of the PR and between 6d4ee4c and 2ef2eb1.

Files selected for processing: 20
  • src/main/claude-accounts/claude-config-profile-launch.ts
  • src/main/claude-accounts/claude-profile-installed-router.ts
  • src/main/claude-accounts/claude-profile-launch-errors.ts
  • src/main/ipc/pty/ipc/spawn-preflight.ts
  • src/main/ipc/pty/pty-claude-config-profile-spawn.test.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx
  • src/renderer/src/components/agent/ClaudeConfigProfileMenuItems.tsx
  • src/renderer/src/components/settings/accounts/claude/accounts-pane-claude-section.tsx
  • src/renderer/src/components/settings/accounts/claude/claude-config-profiles-setting.tsx
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/components/tab-bar/tab-agent-row-presentation.ts
  • src/renderer/src/lib/claude-config-profile-launch.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-windows-quoting.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/store/slices/settings.ts
  • src/shared/claude-config-profiles.test.ts
  • src/shared/claude-config-profiles.ts
Files skipped from review as they are similar to previous changes: 10
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/renderer/src/components/settings/accounts/claude/accounts-pane-claude-section.tsx
  • src/renderer/src/components/tab-bar/tab-agent-row-presentation.ts
  • src/main/ipc/pty/ipc/spawn-preflight.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/renderer/src/store/slices/settings.ts
  • src/main/claude-accounts/claude-profile-installed-router.ts
  • src/renderer/src/components/agent/AgentLaunchPickerMenu.tsx
  • src/renderer/src/components/settings/accounts/claude/claude-config-profiles-setting.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

const MAX_DIR_LENGTH = 4096

// POSIX root, a drive root such as C:\, or a UNC share such as \\server\share.
const ABSOLUTE_DIR = /^(?:\/|[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/][^\\/]+)/

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.

Major · Functional Correctness · Heavy lift

Check that the profile path is absolute on the launch host.

On macOS or Linux, this expression accepts C:\Users\me\.claude and \\server\share\claude. Those are not absolute paths on that host. The settings form can save either value, and profile preflight then passes it to mkdir. Orca can create a directory relative to its working directory while Claude resolves CLAUDE_CONFIG_DIR from the terminal’s working directory. The selected profile can therefore start with the wrong configuration. Keep normalization cross-platform if saved settings must survive a host change, but reject a profile at launch and before mkdir unless its path is absolute for that host. (raw.githubusercontent.com)

Based on learnings, Windows path prefixes do not make a path absolute on Unix, and platform-specific behavior requires runtime checks.

Source: Learnings

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant