Repository navigation
Conversation
There was a problem hiding this comment.
Important
The PR's own request-param change breaks an existing CLI test. src/cli/index-worktree-selector-resolution.test.ts:154 asserts the exact agentTeams.prepareLaunch call arguments and now fails because the handler also sends prepareAuth: true. CI will be red until that expectation is updated.
Reviewed changes
- Managed auth prep reaches Teams:
AgentTeamsPrepareLaunchgains an optionalprepareAuth; the CLI sendstrue, deletes the host'senvToDeletekeys from its inherited env, then mergeslaunch.env(which carriesauth.envPatch). - Host-side resolution:
prepareClaudeAgentTeamsLeaderForHandleawaitsprepareForClaudeLaunch, appliesapplyClaudeEnvPatch(baseEnv, auth.envPatch, { stripAuthEnv }), and returnsenvToDeleteonly whenstripAuthEnvis set. Native Teams pane setup is untouched. - Wiring:
prepareClaudeAuthis threaded throughmain-process-runtime-service.ts; the RPC result passesenvToDeletethrough intact. - Tests:
src/cli/handlers/core.test.tscovers the CLI delete/merge path.
⚠️ An existing CLI test fails on the new request param
src/cli/index-worktree-selector-resolution.test.ts:154 uses toHaveBeenCalledWith('agentTeams.prepareLaunch', { paneKey, env }), which is a strict deep-equality match, so the extra prepareAuth: true fails it (verified locally — 1 failed / 12 passed across the two files). Add prepareAuth: true to the expected object; the other two claude-teams cases in that file only assert the spawn call and still pass.
Technical details
# Update the prepareLaunch call assertion
## Affected sites
- `src/cli/index-worktree-selector-resolution.test.ts:154` — `toHaveBeenCalledWith` expects `{ paneKey, env }`; the handler now sends `{ paneKey, env, prepareAuth: true }` (`src/cli/handlers/core.ts:79`).
## Required outcome
- The assertion matches the actual `agentTeams.prepareLaunch` params, including `prepareAuth: true`.
## Suggested approach (optional)
- Add `prepareAuth: true` to the expected object. This file is in `config/scripts/ci-shard-timings.json`, so it runs in CI.ℹ️ Host-side prepareAuth branch has no direct test
The added tests in src/cli/handlers/core.test.ts mock the RPC response, so they cover the CLI's delete/merge but not the host logic that decides envToDelete, applies the patch, and assembles the returned env — the actual fix. A runtime-level test with a fake prepareClaudeAuth returning stripAuthEnv: true / false (mirroring src/main/ipc/pty-spawn-runtime-handle-binding.test.ts) would pin that branch.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| baseEnv?: Record<string, string> | ||
| }): Promise<{ env: Record<string, string> }> { | ||
| prepareAuth?: boolean | ||
| }): Promise<{ env: Record<string, string>; envToDelete?: string[] }> { |
There was a problem hiding this comment.
envToDelete is now part of the runtime contract, but the pane-key wrapper prepareClaudeAgentTeamsLeader (:114) is still typed Promise<{ env: Record<string, string> }>, so the field is erased before the RPC handler and CLI can see it. Widening the wrapper's return type to { env: Record<string, string>; envToDelete?: string[] } keeps the type honest so a future refactor cannot silently drop the strip list.
Technical details
# Widen the wrapper return type to include envToDelete
## Affected sites
- `src/main/runtime/orca-runtime-resolve-terminal-split-source-authority.ts:114` — `prepareClaudeAgentTeamsLeader` return type is `{ env: Record<string, string> }`; the value it returns from `...ForHandle` also carries `envToDelete`.
- `src/main/runtime/rpc/methods/terminal/terminal-lifecycle-methods.ts:189` — inferred `launch` type therefore omits `envToDelete` even though it is present at runtime.
- `src/cli/handlers/core.ts:78` — the CLI declares its own `envToDelete?` type and relies on the runtime value.
## Required outcome
- The wrapper's declared result type includes the optional `envToDelete` field that `...ForHandle` produces.There was a problem hiding this comment.
ℹ️ The blocking test failure from the prior review is fixed; no new issues in the delta.
Reviewed changes (since f306b0a)
- Test expectation updated:
src/cli/index-worktree-selector-resolution.test.tsnow includesprepareAuth: truein theagentTeams.prepareLaunchcall assertion, matching the handler. Verified locally:index-worktree-selector-resolution.test.tsandcore.test.tsboth pass (13 tests).
The previously noted non-blocking type nit (the prepareClaudeAgentTeamsLeader wrapper still declares its result without envToDelete) is unchanged and remains in the prior review thread; it does not block merge.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe Claude Teams launch contract now accepts Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The managed Claude authentication environment is passed through to the Teams CLI, while conflicting inherited credentials are removed before launch. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
* fix: apply managed Claude auth to agent teams * test: update agent teams auth launch expectation * refactor: derive agent teams auth deletions
|
@Jinwoo-H — a quick heads-up from a neighboring change, since you clearly know this launch path: Mentioning it here because the two changes touch the same function and the survival mechanisms from #14590 deliberately exclude renderer leaf panes — which is what team panes are. If you have a moment to look at #11742, the logic is one 40-line wrapper and the rest is wiring; it's been review-pending since early August and I've been keeping it mergeable weekly. |

ELI5
Claude Agent Teams could ignore Orca's selected Claude subscription when the shell had an
ANTHROPIC_API_KEY, because its CLI launcher skipped Orca's managed-auth preparation. Teams now uses the same account selection and auth cleanup as a normal Claude terminal.What Changed
The
agentTeams.prepareLaunchRPC can request Claude auth preparation. Theorca claude-teamsCLI uses that result to apply the managedCLAUDE_CONFIG_DIRand remove inherited Anthropic auth variables when a managed account is active. System-auth launches continue to preserve user-provided API keys. Native Teams pane setup remains unchanged.Why
The existing managed-auth policy already defines the correct precedence and protects users from accidentally billing a different API account. Reusing it at the Teams CLI boundary fixes the inconsistency without changing the policy or the Teams/TMUX shim.
Linked Issue
Fixes #21256
Visual Proof
N/A — this changes CLI environment preparation and has no UI layout or visual behavior change.
Testing
Focused Teams and CLI tests: 21 passed, 1 skipped
pnpm tc:nodepnpm tc:clipnpm run check:code-quality:changedpnpm run generate:rpc-params-catalog -- --writegit diff --checkI manually tested these changes locally
Automated tests added/updated
AI Disclosure
Review
Agent skill upstream boundary
Notes
The change is host-local and preserves the existing auth policy for managed, system, and remote runtime cases.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (CI will cover the full suite)