Repository navigation
Conversation
…olution) Adds the optional `ProjectGroup.claudeConfigDir` binding, normalizes it on load and on update (trim, absolute-only, null when unbound), and lands three pure resolvers in `src/shared/claude-home-binding.ts` that answer "given this workspace, is there a bound Claude home, and which group bound it?". `claudeConfigDir` is an additive optional field on `projectGroup.update` (remote-wire Rule 1), so no capability negotiation is needed. Absolute-path checks go through `win32.isAbsolute`, which accepts POSIX roots too, so a Windows host's binding survives a macOS client. `docs/adr/0001-per-group-claude-config-dir.md` records why bound groups fork Claude's config dir; `docs/adr/` is allow-listed in .gitignore alongside the other tracked docs.
…and host-scoped
Review round 1 on the U1 branch. Five defects, all in the model and resolution
layer this unit added:
- Drop `node:path` from `claude-home-binding.ts`. It is value-reachable from
every renderer entry, and a Vite browser build externalizes it to `{}`, so
`win32.isAbsolute` is `undefined` and any renderer call throws. The existing
`renderer-node-builtin-boundary` ratchet was already red on this; use
`isWindowsAbsolutePathLike` from `cross-platform-path.ts` instead.
- That also fixes the validation itself: `win32.isAbsolute` accepted the
drive-relative `\Users\alice`, which resolves against the process's current
drive on Windows and is a plain relative filename on POSIX, so one binding
could mean a different home per session.
- Scope group and repo lookup to one execution host. Both arrays are
host-qualified catalogs, so a duplicated id resolved last-wins and could hand
a local session a remote host's path. The host comes from an explicit input
field or off a host-qualified workspace identity; an unmatched host still
falls back to the first row by id, so unstamped catalogs are unchanged.
- Accept a host-qualified workspace identity (`ssh:target|repo::path`) through
the canonical `normalizeWorkspaceSessionKeyToWorkspaceId` unwrapper. It
previously resolved to null, reporting a bound group as unbound — silently
running the session on the shared `~/.claude`.
- Converge the two update hops on `ClearableString`, so an emptied field clears
on both. `OptionalString` folded `''` into `undefined`, making a clear a
silent no-op over RPC while Electron IPC cleared. `null` vs `undefined` still
survives both hops distinctly.
`getProjectGroupExecutionHostId` moves into shared `execution-host.ts` next to
`getRepoExecutionHostId`; the renderer's `getProjectGroupHostId` now delegates
to it instead of repeating the body.
… dir binding Review round 2 on the U1 branch. Four defects: - `findRowForHost` fell back to the first same-id row from ANY other host when no row carried the requested one, so a group stamped `ssh:build-box` could hand `/home/ci/.claude-ci` to a local session. The fallback now accepts only a row that states no ownership at all — a legacy row predating host stamping, which resolves to `local` on the fast path anyway, so the only state the old fallback served was the one it had to refuse. - An unparseable non-blank path at update time parsed to the same `null` that means "clear", so typing `~/.claude-work` DESTROYED the existing binding and reported success. `ClaudeConfigDirBinding` now refuses it at the schema hop, shared by the RPC and Electron IPC schemas, and the test that codified the destructive behaviour is replaced by one asserting the binding survives. - `ClearableString` absorbed a wrong-typed value as "no update", so a client type bug read back a success response carrying the old binding. It is now a `string | null` union, so a present wrong-typed value fails validation. An absent field still means "no update", keeping older peers tolerated. - Renamed this branch's `normalizeClaudeConfigDir` to `parseClaudeConfigDirBinding`. `src/main/rate-limits/service/service-types.ts` exports the old name for a different contract (rewrites separators, accepts a relative path) and both are importable from main, so a wrong auto-import was silent in either direction. The two names no longer share a prefix. R4 (three spellings of `getProjectGroupExecutionHostId`) is deferred by the review and deliberately left alone.
Adds a per-group usage row beside the inactive-account rows: `boundClaudeHomes` on `RateLimitState`, fetched on the same Claude-switcher expand trigger, 60s debounce and sequential loop, evicted when a binding changes or its group goes away. The switcher renders a "Bound groups" section below the account list, with usage bars for a readable directory and a muted status line otherwise. Orca stays read-only toward a bound directory (D9): the fetch reads only that directory's `.credentials.json` and, for a live token, makes exactly one OAuth usage call (D10). An expired or absent token is a status, never a refresh. `claude-bound-home-usage.test.ts` is a mechanical ratchet for that — every write verb on `node:fs`, `node:fs/promises`, the Keychain, the OAuth refresh, the managed-credential staging and the PTY modules throws, so a future edit that writes anything on this path fails the suite. `boundClaudeHomes` is optional on the wire: an older host omits it and an older client drops it, so both degrade to rendering no section rather than erroring. No new RPC method, stream opcode or capability negotiation.
…name Thread the workspace's project group into the structured create-intent's account-home decision, so a group-bound Claude config dir outranks the launch env, the managed selection and ~/.claude. An unbound workspace keeps today's chain byte for byte. A bound home must prove itself before the session record commits: assertClaudeBoundHomeUsable refuses a remote or WSL execution host, a missing or non-absolute directory, a directory holding no credentials (the config-dir scoped Keychain item on macOS, .credentials.json elsewhere), and a launch env naming a different directory. The env comparison goes through the same realpath-alias expansion the Keychain lookup uses, so one directory spelled two ways does not read as two homes. Never a silent fallback to the shared home. The record then carries an optional host-set accountHome.binding marker. The managed-account gate and the auth-switch settle assertion skip a bound record (it is a custom home that does not read the shared runtime auth); reservation admission still compares variable and path exactly, so a re-attach whose binding changed is refused. Splits AgentSessionAccountHome and the record field limits into their own modules to keep agent-session-record.ts under its max-lines cap.
…s dialog Adds a third "Group settings…" item to the project-group header menu, opening a dialog hosted beside the existing rename and delete dialogs. One row: the group's own Claude config directory, a platform directory picker, a clear action that writes null, and an inherited-value hint naming the ancestor group that supplies the binding when the group has none of its own. Validation is advisory and inline — absolute-path shape, directory existence, and whether the directory looks signed in. It never blocks saving, because the directory's state can change between editing and launching and the authoritative refusal lives at launch. The existence probe uses shell.pathExists, not fs.pathExists: the latter is sandboxed to the workspace roots and rejects any Claude home outside them. It is also local-only, so a group owned by an SSH host is left unprobed rather than answered from the client's filesystem, where the same path means something else.
…n host The Claude config dir is a filesystem path on exactly one host, so the dialog must never read or browse the client's filesystem for a group owned elsewhere. - Gate the advisory probe on the resolved execution host instead of the legacy connectionId field, which owner stamping leaves null for every runtime-environment-owned group. - Hide the client folder picker for a non-local group and name the host the path is read on. - Resolve the inherited hint from the group's parent, so clearing a self-bound group's field reveals the ancestor it falls back to. - Match the sidebar dialogs' type ramp through new `compact` primitive variants rather than inline restyles. - Keep the dialog open with the draft intact when a save is refused. - Reuse the shared findRowForHost instead of a second host-scoping rule. - Drop aria-describedby so the live-region advisory announces once.
…and make the D9 ratchet bite Round-1 review fixes for the bound-home usage rows. Credentials (F1): a macOS Claude login stores the token in the config-dir-scoped Keychain item and writes no `.credentials.json`, so the file-only read rendered a signed-in bound home as "Signed out" on Orca's primary platform. Resolve scoped Keychain first, then the directory's `.credentials.json`, on every platform. The unscoped legacy Keychain item is never consulted for a bound directory: it belongs to the shared home, so answering with it would render the user's personal quota under the bound group's name. D9 ratchet (F2, F3, F4, F8): `guardModule` only replaced function exports, so `node:fs`'s `promises` object passed through with every write verb live; it now recurses one level. `node:child_process` and `shared/child-process` are guarded by argv, so `security add-generic-password` and any PTY spawn throw while a `find-generic-password` read passes. The keychain module's `read*` exports and the `*Sync` read verbs are allowed — a read is required, a write of any kind is not. Read paths are recorded and asserted under the bound directory, so the test's title is now something it checks. Execution-host boundary (F5): the resolver built a row for every group, including `ssh:` and `runtime:` ones, then read that remote path on the client. It now skips non-local groups, in a module of its own. Staleness (F6, F7): a transient usage error deleted the cached row, so one 500 made the group vanish from the menu; the delete is now guarded by the same staleness check the inactive-account previews use. `evictBoundClaudeHomeUsage` had no production caller — it is wired to a group's binding change and to a group delete. Also drops an optional call on a store method that is always defined (F9).
…red Claude home Every failure mode in the bound-home path is now a named, visible refusal. - Adopting a conversation under a bound group offers only the bound home, so a transcript living in ~/.claude refuses instead of committing the session there. - A client-supplied accountHome.binding is stripped at the RPC boundary; it is host-set and is what turns two host-side account gates off. - createSupport skips the managed-account gate for a bound workspace, matching the acquisition gate, so a bound group is usable for the users it exists for. - The bound home is re-proved on every acquisition, not only at create. - "Signed in" now reads the config-dir-scoped Keychain item then that directory's .credentials.json, parsed rather than merely present, on every platform. The unscoped legacy item is never consulted: it answers for the shared home. - Reservation admission compares the binding marker, not just variable and path. - Env-conflict comparison is case-folded on macOS as well as Windows. - The binding decision moved out of the @ts-nocheck runtime file into claude-structured-account-home.ts; an unreadable store refuses by name rather than degrading to "unbound". The create-support probe stays fail-closed. - The auth-switch settle assertion is back ahead of the record validations, so unbound error precedence is unchanged.
…ettings dialog live Round-2 findings N1-N7 on the per-group Claude config dir settings dialog. N1: opening group settings for a row whose owner host cannot be resolved no longer falls back to `local`. It refuses with a toast, and the dialog is only mounted once a target resolves, so the probe, the folder picker and the save can never address the client's filesystem for a remote group. N7: the dialog's group name, own binding and inherited-ancestor hint are now a useMemo over the live catalog instead of a snapshot taken at open time, so the hint cannot name the wrong ancestor after the parent's binding changes. N2/N3/N4: the sidebar density is spelled `size="sm"` on DialogTitle, DialogDescription, Label and Input, styled by static `data-[size=sm]:` utilities the way SelectTrigger already does in the same folder, and the rename and delete dialogs are migrated onto it. The field now renders at the same size in all three dialogs, and their inline restyles are gone. N5: the advisory's live region is mounted empty and filled on a later commit through useDeferredValue, so an advisory that is already true when the dialog opens is announced exactly once instead of not at all. N6: a test covers the successful-save close that F5's boolean return introduced.
… the path the local renderer takes
R1 + the sixth path: the ratchet guarded write *verbs* but not the specifiers that reach a sink
around vitest's module registry. It named a PTY spawn as forbidden while `await import('node-pty')`
— spelled twice in this repo — touched nothing it guarded. Guard node-pty, Electron's unpatched
`original-fs` (via `asar-transparent-fs`), `createRequire` (the general form of that escape) and
`node:worker_threads` (a second module graph no mock here reaches). Every probe is now an executed
test rather than a hand-run trace, and the spawn guard read `command` where `ProcessSpec` says
`program`, so the one allowed read was denied by accident rather than by rule.
R2: `evictBoundClaudeHomeUsage` was wired only onto `RuntimeProjectGroupController`, the RPC
surface. A plain local Orca — the only configuration that renders these rows — sends group edits
through `projectGroups:update` / `projectGroups:delete`, so a rebind left the previous directory's
bars on screen under the group's new name. One notification seam, called from both paths.
R3: a binding whose very first fetch failed rendered no row at all, reading as "the binding did not
save". It now surfaces an `unavailable` status; a binding with a prior row still keeps its
last-known bars.
R4: the read-path assertion could not observe the macOS alias walk, which the stub replaces. The
claim is narrowed to the reads this module makes through a mocked module, and the guarantee that
matters — one Keychain entry point, always config-dir-scoped — is asserted directly.
R5: a directory holding only a refresh token reported "Signed out", sending the user to a full
re-login — the operation most likely to rotate the token Orca is deliberately not touching. It
reports "Session expired".
…arker A binding naming the home the Claude CLI would find on its own pins nothing, so it must not switch off the managed-account gate or the auth-switch settle assertions on the shared home. One predicate now answers "is this a custom home" for all three readers. A group bound after a chat exists refuses by name instead of silently keeping the old account; an unreadable Keychain gets its own refusal and remedy; the project catalog refuses on an unhydrated store; and every env-conflict check reads the environment the child actually receives.
…ngs dialog The group settings dialog reads its Claude config dir as a live prop, so an edit to that group's binding from another window replaced text the user was still typing. It now re-seeds only a pristine field; a dirty draft is kept and the new stored value is named inline instead. The dialog also unmounted silently when its row left the merged catalog — an SSH host dropping — and re-opened by itself when the host came back, because the open state was never cleared. The hook now closes it during render and reuses the existing unresolved-host refusal toast as the notice.
The pin's `samePath` compared resolved path strings and case-folded on win32 only, while its sibling `comparablePath` folded on darwin too and expanded realpath aliases. On macOS a group bound to `~/.Claude`, or to a symlink alias of `~/.claude`, therefore read as a custom home: the binding marker survived, `assertClaudeBoundHomeUsable` passed through the variant spelling, and the managed-account gate plus both auth-switch assertions were skipped for a session running on the shared home those gates protect. Delete `samePath` and converge the unit on one function: `comparablePath` and `sameClaudeConfigDir` move into `claude-config-dir-identity.ts`, which the pin, the env-conflict refusal and the predates-binding check all import. Agreement between the two notions of "same config dir" is now structural, not a coincidence two authors have to maintain. Linux stays case-sensitive — `.Claude` and `.claude` really are two directories there — and a test asserts it so this is not "fixed" later by folding case everywhere.
…er held
The ratchet's header says its job is to fail the suite on five writes — a file
write, a credential stage, a Keychain item write, a PTY spawn and a token
refresh. Four had a sink guard. The fifth was guarded only by
`vi.mock('../claude-accounts/oauth-refresh')`, which is the wrapper module; the
sink is a network call, and `vi.mock` is specifier-exact. An inline refresh
spelled `fetch`, `node:https`, `node:http` or `net.fetch` passed green, and the
`electron` spelling was denied by a TypeError from a stub with no `net` — an
accident the next author fixes by completing the stub.
Guard the sinks by specifier instead: `fetch` (a global, so `vi.stubGlobal`),
`node:https`, `node:http`, `node:net`, `node:tls`, and an `electron` mock whose
`net` and `utilityProcess` throw by rule. `utilityProcess.fork` is guarded with
them because it is the `node:worker_threads` escape under a second specifier —
a module graph none of these mocks reach. Each new specifier gets an executed
probe, and each was mutation-checked from `fetchBoundClaudeHomeUsage` itself.
Also:
- Catalog the "Usage unavailable" string the previous commit introduced. It was
in no locale file, so `verify:localization-catalog` and
`verify:localization-extraction` — both PR CI gates — were red.
- Clear the fetch debounce when a bound home is evicted. Eviction deleted the
row but left `lastBoundClaudeHomeFetchAt`, so a group rebound within 60s of
the last poll rendered as *absent*, not stale — the same "the binding did not
save" misread the unavailable row exists to remove.
- Pin the startup seam. `main-process-account-services.ts` holds the only line
connecting binding changes to the service, and no test reached it; deleting it
left the suite green while restoring the stale-row defect.
…s kept The branch that keeps a user's in-progress binding draft never advanced the "last seeded" value, so a draft typed back to the original read as pristine and a second external edit silently replaced it.
…aunch Unit 2 of 4 for per-group Claude config dir binding (stablyai#19754). Verified clean at e217919 by an independent review (findings/u2-round4.md).
…work-sink ratchet Unit 4 of 4 for per-group Claude config dir binding (stablyai#19754). Verified clean at 4fd336b by an independent review (findings/u4-round4.md). Conflict resolution, claude-oauth-credentials.ts: U2 and U4 gave the same function different names. Took U4's readClaudeOAuthCredentialsFile, which says what it reads, and pointed U2's one remaining caller at it. No behaviour change on either side.
… a group settings dialog Unit 3 of 4 for per-group Claude config dir binding (stablyai#19754). Re-verified at bc5a19a: no defects found in the diff (findings/u3-round5.md).
Keeps the branch current with upstream before opening the PR for stablyai#19754.
The ADR would have introduced a docs/adr/ convention this repo does not have, and it needed two .gitignore allow-list entries to be tracked at all under the blanket docs/** ignore. The decision it recorded — that a bound group forks Claude's chat, settings and plugins, against the intent noted in GlobalSettings — now lives in the pull request description instead. .gitignore is byte-identical to main again; this PR no longer touches it. Note: commit 538bf09's message still points at docs/adr/0001-per-group-claude-config-dir.md, which no longer exists.
Conflict in en.json: both sides added a sibling key to the same object. Kept both — this unit's BoundClaudeHomesSection and upstream's NativeChatResumeStatusSegment. Both localization verifiers pass.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 691cc6471852d1d852a6168e61ce9b7322da5593 and 54814677a240644574784ca08c53a91da31759da. 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds project-group Claude config-directory bindings across shared contracts, persistence, runtime launch, rate-limit usage, and the sidebar. It validates scoped credentials and launch environments, preserves binding identity in sessions, and rejects stale or unusable homes. The rate-limit service fetches read-only usage for local bound homes and evicts stale rows after group changes. The sidebar adds settings, validation advice, inherited-binding display, and bound-home usage statuses. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains in the reviewed terminal-binding changes. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR implements the Claude-specific project-group subset of [ Resolution Extend the implementation to satisfy the remaining coding requirements in [ 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.
Important
One scope gap to settle before merge: the binding reaches structured/native-chat sessions only, while the PR body (and Fixes #19754) reads as covering every Claude launch in the group. A terminal claude started in a bound worktree still reads ~/.claude.
Reviewed changes
- Group binding model + resolution —
ProjectGroup.claudeConfigDir(absolute-path-only) resolved down the group tree, host-scoped, withparseClaudeConfigDirBindingvalidating by syntax so a macOS client keeps a Windows/UNC binding. - Persistence + both wire hops — a shared
ClearableString-basedClaudeConfigDirBindingwhere blank clears, absent means no update, and an unparseable path is a rejected write rather than a silent clear. - Launch pinning and refusals —
resolveClaudeStructuredAccountHomepins the bound home or refuses by name; the managed-account gate and the auth-switch settle assertion are skipped only for an effective custom home; a chat that predates a later binding refuses withclaude_bound_home_predates_binding. - Credential scoping — a bound directory reads only its config-dir-scoped Keychain item, then its own
.credentials.json, never the unscoped legacy item;unreadableis kept distinct fromsigned-out. - Bound-home usage — read-only per-group usage rows, 60s-debounced and generation-guarded, added to
RateLimitStateas an optional field, with eviction wired on both group-mutation paths. - UI + hardening — the group settings dialog and status-bar section, new
smdensity variants on the shared primitives, and stripping of a client-suppliedaccountHome.bindingat the RPC boundary.
⚠️ The binding does not reach a fresh terminal Claude session
The binding is consulted only on the structured/native-chat paths. A plain terminal claude launched in a worktree of a bound group assembles its env from settings.agentDefaultEnv alone, so it still reads ~/.claude — the silent-wrong-account outcome the feature exists to prevent. The PR body's "Every project in that group, and every group nested inside it, launches Claude against that directory", the settings-dialog copy, and Fixes #19754 all imply coverage this branch does not have.
Technical details
# The binding is only read on structured/native-chat paths
## Affected sites
- `src/main/runtime/orca-runtime-resolve-recovered-structured-tui-transcript.ts:153` — `resolveClaudeStructuredAccountHome` is the only production consumer of the binding.
- `src/shared/agent-startup-plan-inputs.ts:60` — a fresh terminal agent's env is `resolveTuiAgentLaunchEnv(agent, settings.agentDefaultEnv)` alone; no group/repo lookup.
- `src/main/runtime/orca-runtime-create-agent-session.ts` — the fresh terminal launch path, which never reads `ProjectGroup.claudeConfigDir`.
- `src/main/runtime/orca-runtime-get-agent-session-execution-namespace.ts:151-158` — terminal resume sets `CLAUDE_CONFIG_DIR` only from `handoffAuthority.providerRoot` (a structured session's handoff), not from the group.
## Required outcome
- Either wire the resolved binding into the terminal agent startup env (the same `resolveClaudeHomeBindingForSession` read the structured path uses), or make the scope explicit in the settings-dialog copy, the PR description, and the linked issue, so a user does not bind a group and then have a terminal `claude` run on `~/.claude`.
## Open questions for the human
- Is a terminal (PTY) Claude session intentionally out of scope, with native chat as the only target?ℹ️ Nitpicks
src/main/rate-limits/claude-bound-home-usage.test.tsmocks./claude-oauth-usage-request, so the D9 ratchet never runs the production network path; a token refresh added inside the realfetchClaudeOAuthUsagewould escape every guarded sink the header names. The header's claim about guarding the refresh sinks is only exercised by the self-test's direct probes.src/main/rate-limits/service/service-bound-claude-homes.ts:55deletes the cached row on any staleness, including a generation bump caused by a different group's eviction, while the siblingdiscardBoundClaudeHomeRowguards the same delete withisCurrentBoundClaudeHome. A still-current group can lose its row until the next trigger (bounded, because the eviction resets the debounce).src/main/claude/claude-config-dir-identity.ts:9folds case on every darwin host, but APFS can be case-sensitive: a binding to a case-variant of the default home is then treated as the default and not pinned. The PR's cross-platform note claims case-sensitive volumes are covered, which is true only for Linux here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| } | ||
| const [directoryExists, signedIn] = await Promise.all([ | ||
| pathExists(configDir), | ||
| pathExists(getClaudeConfigDirCredentialsPath(configDir)) |
There was a problem hiding this comment.
The signed-in half of this probe tests only for .credentials.json, but on macOS Claude writes the token to the config-dir-scoped Keychain item and no file — the behaviour the new bound-home usage reader documents in claude-bound-home-usage.ts. A correctly signed-in bound home on Orca's primary platform will therefore always show "That directory has no Claude credentials yet, so sessions will start signed out", contradicting the launch-time assertClaudeBoundHomeUsable that reads the scoped Keychain.
Technical details
# The dialog's signed-in probe disagrees with the launch-time credential read on macOS
## Affected sites
- `src/renderer/src/components/sidebar/use-claude-config-dir-probe.ts:49-52` — checks only `pathExists(<home>/.credentials.json)`.
- `src/renderer/src/components/sidebar/claude-config-dir-advice.ts:55-62` — turns that into the `signed-out` advisory.
- `src/main/claude/claude-bound-home-refusal.ts:119-124` — the authoritative check reads the scoped Keychain on darwin, so it accepts the same home.
## Required outcome
- The advisory should not claim "signed out" for a home the launch would accept. Either suppress the signed-out advice on darwin, or route the probe through a host-side check that uses `readClaudeConfigDirScopedOAuthCredentials`.…nd home The binding reached only structured sessions and TUI *resume*: the two callers of `claudeConfigDirEnvPatch`. A fresh terminal launch — which is every launch when structured native chat is off — resolved the group, exported ORCA_PROJECT_GROUP_ID into the PTY, and then dropped the binding on the floor, so the session ran on whatever account the shared home held. The group setting looked saved and correct while doing nothing, which is the silent-wrong-account failure the binding exists to prevent. `resolveAgentTerminalCreateOptions` is where this belongs: its own comment says every create lane funnels through it, and it already knows the resolved agent and holds the env the PTY gets. Deliberately the *same* resolver a structured session uses, not a second precedence ladder — a terminal and a chat disagreeing about which account a group runs under is the bug, and two ladders is how they would come to disagree. So a group binding still outranks every other source and an unusable one still refuses rather than falling back. Three boundaries worth naming: - Only a binding pins. An unbound launch emits nothing even with an account selected, because the managed-account selector swaps per-account auth rather than the config dir; pinning it here would fork Claude's shared chat and session context. - `claude-agent-teams` is included. It launches the same binary behind a shim and reads the same credentials, so excluding it would make the teams launcher the one way to run a bound group on another account. - Remote and WSL workspaces return no patch instead of refusing. A binding is a path on one machine; refusing there would take away Claude terminals that work today against the remote's own account. The resolver lives in its own type-checked module rather than inline, for the reason claude-structured-account-home.ts already states: runtime class files are @ts-nocheck, so a wrong call site there would compile, and the wrong answer here is another organisation's account.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 1111914b-fac2-4cf5-bec5-b6f8da8effb8
📥 Commits
Reviewing files that changed from the base of the PR and between c1a0d6005e0ed19c556770a8f2bc8abf3d9bc879 and 691cc6471852d1d852a6168e61ce9b7322da5593.
📒 Files selected for processing (3)
src/main/claude/claude-terminal-account-home.test.tssrc/main/claude/claude-terminal-account-home.tssrc/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| executionHostId: isRemote ? null : LOCAL_EXECUTION_HOST_ID, | ||
| wslDistro: resolveClaudeTerminalWslDistro({ | ||
| store, | ||
| repo: workspace.repo, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '220,290p' src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
sed -n '40,115p' src/main/claude/claude-terminal-account-home.ts
rg -n "resolveAgentTerminalCreateOptions|projectRuntime|wslDistro|executionHostId" src/main/runtime src/main/persistence src/shared | head -240Repository: stablyai/orca
Length of output: 34470
🏁 Script executed:
set -e
printf '%s\n' '--- resolver and imports ---'
sed -n '1,225p' src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
printf '%s\n' '--- WSL helper and config resolver locations ---'
rg -n "function getLocalProjectWorktreeGitOptions|const getLocalProjectWorktreeGitOptions|export function getLocalProjectWorktreeGitOptions|resolveClaudeTerminalWslDistro|resolveClaudeTerminalConfigDirEnv" src
printf '%s\n' '--- workspace and terminal create definitions ---'
rg -n "type .*Workspace|interface .*Workspace|workspace:.*repo|resolveAgentTerminalCreateOptions|connectionId.*path.*repo|repo:.*Repo" src/main/runtime src/shared src/main/persistence | head -240
printf '%s\n' '--- binding host matching ---'
sed -n '1,220p' src/shared/claude-home-binding.tsRepository: stablyai/orca
Length of output: 42105
🏁 Script executed:
set -e
printf '%s\n' '--- project runtime git options ---'
sed -n '1,145p' src/main/project-runtime-git-options.ts
printf '%s\n' '--- execution host helpers ---'
rg -n "function getRepoExecutionHostId|const getRepoExecutionHostId|export .*getRepoExecutionHostId|function parseExecutionHostId|LOCAL_EXECUTION_HOST_ID" src/shared/execution-host.ts
sed -n '1,290p' src/shared/execution-host.ts
printf '%s\n' '--- Claude terminal account-home implementation ---'
sed -n '1,180p' src/main/claude/claude-terminal-account-home.ts
printf '%s\n' '--- workspace launch scope and construction references ---'
sed -n '1,90p' src/main/runtime/runtime-legacy-worker-terminal-recovery-types.ts
rg -n -C 5 "TerminalWorkspaceLaunchScope|connectionId:.*workspace|repo:.*repo|repo:.*getRepo|path:.*workspace" src/main/runtime/orca-runtime-create-terminal.ts src/main/runtime/orca-runtime-create-terminal-desktop.ts src/main/runtime src/shared | head -260Repository: stablyai/orca
Length of output: 41624
Filter repository WSL settings by terminal host.
A local terminal can receive repository metadata owned by another host. resolveClaudeTerminalWslDistro uses that repository's configured wslDistro before checking workspace.path. The non-null distro then makes resolveClaudeTerminalConfigDirEnv return {}, so the local project-group binding does not set CLAUDE_CONFIG_DIR. Claude can use the shared/default configuration instead of the group-bound configuration.
Filter workspace.repo by the terminal route before passing it to the WSL resolver.
Suggested fix
-import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../shared/execution-host'
+import {
+ getRepoExecutionHostId,
+ LOCAL_EXECUTION_HOST_ID,
+ type ExecutionHostId
+} from '../../shared/execution-host'
...
- repo: workspace.repo,
+ repo:
+ !isRemote &&
+ workspace.repo &&
+ getRepoExecutionHostId(workspace.repo) === LOCAL_EXECUTION_HOST_ID
+ ? workspace.repo
+ : null,There was a problem hiding this comment.
Important
The prior terminal-launch gap is fixed cleanly, but the new call site introduces a Windows-only regression: resolveClaudeTerminalWslDistro runs eagerly for every agent launch and can throw on a repair-required project runtime.
Reviewed changes
- Wired the group binding into the terminal funnel —
resolveAgentTerminalCreateOptionsnow calls the newresolveClaudeTerminalConfigDirEnv, which reusesresolveClaudeStructuredAccountHomeso a terminal and a chat cannot disagree about which account a group runs under. - Scoped the terminal resolver deliberately —
CLAUDE_CONFIG_DIRis emitted only forclaude/claude-agent-teams, only on a local non-WSL workspace, and only when the resolved home is an effective custom binding; an unusable binding throws instead of falling back to the shared home. - Left remote/WSL and selected-account-only launches untouched — remote and WSL workspaces return no patch rather than refusing, and an unbound launch emits nothing even when a managed account is selected.
- Added resolver-level tests for pinning, non-Claude pass-through, no-op bindings to
~/.claude, the selected-account-without-binding case, remote/WSL, and refusal.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| store, | ||
| location: { | ||
| executionHostId: isRemote ? null : LOCAL_EXECUTION_HOST_ID, | ||
| wslDistro: resolveClaudeTerminalWslDistro({ |
There was a problem hiding this comment.
location.wslDistro is evaluated right here while the argument is built, so resolveClaudeTerminalWslDistro runs for every agent launch — including codex — before resolveClaudeTerminalConfigDirEnv can apply its agent and remote/WSL guards. For a local Windows repo whose project runtime is repair-required, getLocalProjectWorktreeGitOptions throws Project runtime requires repair before git execution, turning a terminal agent launch that used to succeed into a hard failure. The rest of the codebase deliberately treats a repair-required runtime as launchable (getAgentLaunchPlatformForRepo handles it; the spawn lane catches the same throw), so this path needs the same treatment.
Technical details
# Eager WSL-distro resolution throws before the resolver's guards
## Affected sites
- `src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts:256-274` — argument object at `:256`; eager `resolveClaudeTerminalWslDistro` call at `:261`.
- `src/main/claude/claude-terminal-account-home.ts:53-73` — `resolveClaudeTerminalWslDistro` only checks `isLocalHost`, then calls `getLocalProjectWorktreeGitOptions`.
- `src/main/project-runtime-git-options.ts:28-38,47-51,58-64` — `getLocalProjectWorktreeGitOptions` -> `getLocalProjectGitExecOptions` -> throws when `status === 'repair-required'`.
- `src/shared/project-execution-runtime.ts:148-211` — `repair-required` is produced only on `win32`, when a WSL runtime is preferred but unavailable / distro missing.
- `src/main/runtime/orca-runtime-resolve-recovered-structured-tui-transcript.ts:125-128` — the structured lane already reads this throwing function, so the delta widens the failure to the terminal lane for every agent.
## Required outcome
- A local terminal agent launch must not fail because the project's WSL runtime needs repair; the existing behavior (host fallback, launch still proceeds) must be preserved.
- The agent guard should run before this resolution, or the WSL-distro lookup should use a non-throwing variant (cf. `getWorktreeCreatePrefetchGitOptions` / `getWorktreeMirrorDistro`).
## Suggested approach (optional)
- Gate the `resolveClaudeTerminalConfigDirEnv` call on `terminalAgentReadsClaudeConfigDir(agent)` so non-Claude agents never build the `location`, then make the helper tolerate `repair-required`.
- Add a test that drives `resolveAgentTerminalCreateOptions` (not just the pure resolver) with a repair-required runtime and a non-Claude agent.
## Open questions for the human
- Is a repair-required project runtime expected to block agent terminals, or should it fall back to the host runtime as elsewhere?| return configured | ||
| } | ||
| } | ||
| return parseWslUncPath(input.workspacePath)?.distro ?? null |
There was a problem hiding this comment.
The JSDoc above says the UNC fallback is "for a folder workspace, which has no repo Git options", but the code applies it whenever the repo has no configured distro — including git worktrees. The structured resolver (resolveStructuredAgentSessionLocation) guards the same fallback with folderWorkspace && isLocalHost; without that guard a git worktree on a WSL UNC path can resolve a distro here and none there, so one route pins the binding and the other silently skips it — the terminal/structured disagreement this module exists to prevent. Is the folder-workspace guard intended?
(cherry picked from commit 50381c7c881c5f346202780911c95da6c88ffbe6)
There was a problem hiding this comment.
Important
The PTY-boundary pin is wired correctly for both lanes, but it asks the custom-home question with process.env instead of the child launch env, so it can classify a binding oppositely to the structured route it exists to agree with.
Reviewed changes
- Moved group-account pinning to the PTY spawn boundary — a new
prepareClaudeTerminalBoundAuthreplaces the bareprepareClaudeAuthcall in both the desktop IPC and runtime spawn preflights, resolving the group binding with the host-scoped lookup and pinning a custom home (or refusing) for local, non-WSLclaudelaunches. - Added a two-lane spawn test —
claude-group-account-spawn.test.tsdrives the real preflight and option assembly for both lanes, covering the pin, an inherited pin, a missing-directory refusal, a repo worktree, an env conflict, explicit credentials, and the unbound fallback.
ℹ️ Nitpicks
src/main/ipc/pty/claude-group-account-spawn.test.ts:126-161builds only local folder/repo workspaces, so nothing pins thetarget.runtime === 'wsl'fallback or theconnectionId-gated non-invocation — the cross-host invariant rests on the callers'ctx.isClaudeLaunchexpression with no regression test.- A bound launch now validates twice on the runtime lane (
resolveClaudeTerminalConfigDirEnvat create,prepareClaudeTerminalBoundAuthat spawn), i.e. two scoped-Keychain credential reads per launch. Path #1 is not removable — it is the create-time refusal surface and keeps the desktop lane from timing out atwaitForTerminalHandle— so this duplication is inherent unless the second check is scoped to lanes that skip the first.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| executionHostId: LOCAL_EXECUTION_HOST_ID | ||
| }) | ||
| // An earlier launch stage may already have pinned the binding in the overlay. | ||
| if (!binding || !isCustomClaudeConfigDir(binding.configDir)) { |
There was a problem hiding this comment.
The custom-home question is asked with process.env here, but every sibling asks it with the child launch env: claude-terminal-account-home.ts:110,113 and claude-structured-account-home.ts:155-156 both pass claudeChildLaunchEnv(...), and claude-config-dir-pin.ts documents isCustomClaudeConfigDir as the one place that question is decided. When the launch env already carries CLAUDE_CONFIG_DIR — the case the new test's "earlier launch stage already pinned it" scenario builds — this route calls the binding custom (pins, stripAuthEnv: true) while the structured route treats it as a no-op and keeps the managed-account gates, so the two routes disagree about which account a group runs under.
Technical details
# Custom-home predicate resolved against the wrong environment
## Affected sites
- `src/main/claude/claude-terminal-bound-auth.ts:33` — `isCustomClaudeConfigDir(binding.configDir)` defaults `env` to `process.env`.
- `src/main/claude/claude-terminal-bound-auth.ts:44` — `claudeConfigDirEnvPatch(binding.configDir)` likewise.
- `src/main/claude/claude-terminal-bound-auth.ts:39` — `assertClaudeBoundHomeUsable` already uses `claudeChildLaunchEnv(args.env)`, so inside this one function the env-conflict check and the custom-home check read different environments.
- Contrast: `src/main/claude/claude-terminal-account-home.ts:110,113`, `src/main/claude/claude-structured-account-home.ts:155-156`.
## Required outcome
- The "is this home custom" decision and the emitted patch must use `claudeChildLaunchEnv(args.env)` — the same environment the pin and refusal checks use — so this route and the structured route classify a binding identically.
## Suggested approach
- Hoist `const childEnv = claudeChildLaunchEnv(args.env)` and pass `{ env: childEnv }` to both `isCustomClaudeConfigDir` and `claudeConfigDirEnvPatch`; the existing test's second case then exercises the no-op branch rather than silently pinning.
## Open questions for the human
- Which classification is intended when the launch env names the same directory the group binds — custom (pin + strip) or no-op (keep the managed gates)?5481467 to
267c0f0
Compare
Local integration for testing alongside the unmerged sidebar work. Draft PR upstream: stablyai#22068

ELI5
If you work for two different companies, you have two different Claude logins. Today Orca uses one
Claude login for everything, so switching between a client's work and your own means logging out and
back in, or hand-editing environment variables with direnv.
This lets you point a group of projects at its own Claude config directory. The client's projects
use the client's Claude account. Your own projects use yours. Both can run at the same time, in the
same window, without either one noticing the other.
What Changed
Before. Every agent Orca launched read
~/.claude. One account, globally. Running a secondaccount meant a direnv shim per directory, and nothing in Orca's UI knew about it.
After. A project group can name a Claude config directory. Right-click a group → Group
settings → type or browse to a directory. Every project in that group, and every group nested
inside it, launches Claude against that directory. Groups with nothing set keep using
~/.claude,so existing setups are untouched.
The mechanism, in four parts:
The binding itself — a
claudeConfigDiron the project group, resolved down the group treeso a nested group inherits its parent's answer unless it sets its own. A config directory is a
filesystem path on exactly one machine, so the binding is scoped to that group's execution host
and is refused if it would cross hosts.
Launch — when Orca starts an agent it pins the resolved directory onto the launch, rather
than letting the process inherit whatever
CLAUDE_CONFIG_DIRhappened to be in the environment.A launch that would land on a different directory than the one bound is refused with a message
naming both, instead of silently starting on the wrong account. This covers both routes an
agent can start on — a structured chat session and a terminal/TUI launch — from one resolver;
see Both launch routes below for why that is load-bearing rather than tidy.
Credentials — a bound directory is read from its own config-dir-scoped Keychain item, then
its own
.credentials.json. Deliberately not the shared unscoped Keychain item: that oneanswers for the global login, so consulting it would let a signed-out bound directory read as
signed in and land the launch on another organisation's account. A Keychain that cannot be read
is reported as unreadable rather than as "no credentials" — the two have different remedies.
Usage — the status bar reports rate-limit and usage state per bound directory, so two
accounts running at once are distinguishable rather than being merged into one number.
Why
The alternative was a per-project environment variable, which is what the direnv workaround already
does. It was rejected for three reasons: it is invisible to Orca, so nothing in the UI can show
which account a workspace is on; it does not survive Orca launching the process itself; and it has
no answer for remote hosts, where the directory has to belong to the machine that actually runs the
agent.
Binding at the group level rather than per project was chosen because accounts follow clients
and employers, not individual repositories. Grouping is the level at which that boundary already
exists in Orca.
The trade-off this accepts, deliberately
A bound group's Claude chat history, settings and plugins live in the bound directory rather than
the shared one. That forking is not a side effect — it is the price of the feature, and it is worth
being explicit that it overturns an intent already written into the codebase.
GlobalSettingscarries a comment saying to persist per-account auth and specifically not to swapCLAUDE_CONFIG_DIR, precisely so that switching accounts does not fork Claude's shared chat andsession context. The WSL runtime is the existing exception, and #11824 records what it costs there:
switching loses settings, plugins and statusline.
That intent is overturned here because per-group binding needs two identities live at once on one
host, and that is impossible while every session reads one shared home. Managed Claude accounts are
globally exclusive on the host runtime — selecting one copies its credentials into the single shared
location and the auth service tracks exactly one
lastSyncedAccountId.Two alternatives were considered and rejected:
no concurrency: a session already running in another group is left on an identity that silently
changed under it. The feature exists to make the account unmissable; this would make it a race.
same, so it does not avoid the decision — it only changes who owns the directory, at the cost of
abandoning the history and plugins the user already has.
Two consequences follow, and both are load-bearing:
~/.claudeforks nothingand runs on the shared home — so it keeps every gate that protects the shared home. The
managed-account gate and the auth-switch settle assertions are skipped for a custom home, never
for a declared binding that resolves to the default one.
isCustomClaudeConfigDiris the singlepredicate all three readers ask, so they cannot drift apart.
record when a chat is created, and a resume rebuilds it verbatim — a resume that drifted would
look for a transcript under a home that does not hold it. So binding a group does not move the
chats already in it, and a launch whose record predates the binding refuses by name
(
claude_bound_home_predates_binding) rather than quietly continuing to bill the old account.The refusals are deliberate. Every failure mode this change can have ends with an agent running as
the wrong account, and a silent fallback to the global login is the worst possible outcome — it
looks like success. So the binding fails loudly and names what it expected.
Both launch routes, from one resolver
An earlier revision of this PR pinned the directory on a structured chat session and on a TUI
resume, and nowhere else. A fresh terminal launch resolved the group, exported
ORCA_PROJECT_GROUP_IDinto the PTY, and then dropped the binding — so the session ran on whateveraccount the shared home held. That is the worst shape this feature can take: the setting is saved,
the dialog shows it, and it does nothing. It was also the common path, not an edge case — with
experimentalStructuredNativeChatoff, every new Claude session is a terminal launch.The fix resolves the binding in
resolveAgentTerminalCreateOptions, which its own comment alreadydescribes as the funnel every terminal create passes through, and does so by calling the same
resolveClaudeStructuredAccountHomea chat session calls. Deliberately not a second precedenceladder: a terminal and a chat disagreeing about which account a group runs under is precisely the
bug, and two ladders is how they would come to disagree.
Three boundaries in that path are decisions, not defaults:
because the selector swaps per-account auth rather than the config dir. Pinning it there would
fork the shared chat and session context for people who never asked for a binding — the very cost
this PR argues is only worth paying when someone declares one.
claude-agent-teamsis included. It launches the same binary behind a shim and reads the samecredentials, so leaving it out would make the teams launcher the one supported way to run a bound
group on another account.
machine.
assertClaudeBoundHomeUsablewould refuse there, which is right for a chat session(remote was never supported) but would take away remote Claude terminals that work today against
the remote's own account. That is a regression the local binding does not justify. This is the
one place the feature declines to refuse, and it is the part of this section most worth arguing
with.
The resolver is its own type-checked module rather than inline at the call site, for the reason
claude-structured-account-home.tsalready gives: the runtime class files are@ts-nocheck, so awrong call written there would compile, and the wrong answer here is another organisation's
account.
Linked Issue
Fixes #19754
Visual Proof
Before — a project group's menu offered only Rename and Delete; there was nowhere to express an
account.
After — the menu gains Group settings, and the dialog takes a Claude config directory, with
inline advice that understands the group's execution host (shown here telling the user the directory
does not exist on that host yet).
Testing
Built in four reviewed units, each one independently reviewed by a reviewer who did not write it,
with every finding fixed and re-verified before merge.
On the merged branch:
pnpm tc— exit 0pnpm exec oxlint— exit 0 (2 pre-existingprefer-array-flat-mapwarnings inmobile/)pnpm run check:code-quality:changed— exit 0pnpm run check:dead-classes— exit 0pnpm run verify:localization-catalog— exit 0pnpm run verify:localization-extraction— exit 0ORCA_BACKGROUND_LAUNCH=1 pnpm test— 86,512 tests passed, 6 failing files, all of which failidentically on
mainon this host (skill-recipe-shellneeds a newer bash,relay-region-correctionneeds
pg, plus three other pre-existing failures and one that is load-sensitive).Platforms: developed and tested on macOS. Path comparison is platform-branched at runtime and
covered by tests for case-insensitive (macOS/Windows) and case-sensitive (Linux) volumes, but Linux
and Windows were not exercised on real hardware. The execution-host scoping is what covers the
SSH case; remote hosts were tested through the host-boundary unit tests, not against a live remote.
On the terminal-launch commit, on this host:
tsc --noEmit -p config/tsconfig.node.json— exit 0vitest src/main/claude/claude-terminal-account-home.test.ts— 7 passed (binding pins; non-Claudeagent untouched; selected-account-without-binding emits nothing; no-op binding to
~/.claudeemits nothing; remote and WSL return no patch and never call the refusal; an unusable binding
throws rather than falling back)
vitest src/main/claude src/shared/claude-home-binding.test.ts src/shared/project-groups.test.ts—1,223 passed, 1 failed. The failure is
claude-structured-real-cli.test.ts, which spawns the realClaude CLI and asserts on the host's skill catalog; verified pre-existing by stashing the change
and re-running, where it fails identically.
oxlinton the changed files, andoxlint --type-awareon the new module — exit 0check:ts-nocheck-ratchet— OK, no new suppressionsI manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Written with Claude (Opus 5) under human direction, in a supervised multi-agent delivery run: four
implementation units, each reviewed by an independent reviewer agent, with the findings and fixes
recorded per round.
Review
Two known residuals, both judged non-blocking and recorded rather than hidden:
node:http2is not covered by the D9 network-sink ratchet. The ratchet guards eight outboundsinks by exact module specifier;
http2is not one of them. It was equally unguarded before thischange, nothing in the repo uses it, and the app disables HTTP/2 — but a future author reaching for
http2would not be caught. Worth a follow-up.symlinkSync(..., 'dir')unconditionally where its sibling uses'junction'on win32. This would fail for a developer running that file on Windows. No Windowsworkflow runs it, so no CI job is affected.
Also worth a reviewer's attention: the credential-resolution order in part 3 above is a security
boundary, not a preference. If you disagree with excluding the unscoped Keychain item, that is the
thing to argue about.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
shared login; see part 3 and the Review section.
folding and symlink/firmlink aliases. Not exercised on real Linux/Windows hardware.
cross hosts is refused rather than silently resolved locally.
optional and absent by default.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)