Skip to content

feat(bots): pick the Claude account a bot's chats use - #49370

Open
lurunzi wants to merge 3 commits into
stablyai:mainfrom
lurunzi:feat/bot-account-picker
Open

lurunzi wants to merge 3 commits into
stablyai:mainfrom
lurunzi:feat/bot-account-picker

Conversation

@lurunzi

@lurunzi lurunzi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

ELI5

#48466 lets a bot remember which Claude account its chats should use, but there is no way to set it in the app yet. This adds a "Claude account" select to the bot's Agent and model settings, so someone with a work and a personal account can point each bot at the right one without switching the whole computer.

What Changed

Stacked on #48466. This branch is #48466's commit (f870db423c5) plus one commit on top. Until #48466 merges, the diff here includes it; the change in this PR is only the last commit.

  • The bot's Agent and model page shows a Claude account select under the agent picker, for Claude bots only (only the Claude launch reads a bot's account in feat(accounts): account field on bots and automations, resolve hook #48466).
  • Options:
    • "Use this computer's selected account" (or "Use {host}'s selected account" for a bot on a paired server). It saves an empty string, which clears account.
    • "System default", saved as system.
    • Every Claude account saved on the bot's host, saved by id and labelled the way the status-bar Claude switcher labels it.
  • The list comes from the bot's own host: this computer's account list, or a paired server's own snapshot through the existing useProviderAccountList subscription. No new RPC and no main-process change.
  • A saved account the host no longer has stays selected as "{account} (unavailable)", with a note that chats use the selected account (feat(accounts): account field on bots and automations, resolve hook #48466 falls back to the host selection). It is not rewritten.
  • If two records share a login (the switcher folds them into one row), the record the bot saved stays the one shown.
  • resolveClaudeAccountRef (from feat(accounts): account field on bots and automations, resolve hook #48466) now accepts any accounts with id and email, a type-only widening, so the renderer's account summaries can use the same matching a launch uses.

Why

Asked for in #46994 and #47020. #48466 says UI is out of its scope on purpose; this is that piece.

Linked Issue

Refs #46994, #47020. Depends on #48466.

Visual Proof

Before: the Agent and model page has only the agent picker. After: fixture screenshots (default, open on a paired server, unavailable saved account; light and dark) will be attached here shortly.

Testing

  • bot-claude-account-choices.test.ts: a duplicated login keeps the saved record, matching by id / email / name / system / empty, and the unknown case.

  • Component fixtures for the three states, rendered headlessly in both themes with pnpm fixtures:shot.

  • pnpm check:changed against feat(accounts): account field on bots and automations, resolve hook #48466's commit: 39 of 39 checks pass (typecheck, lint, design-system and React Doctor code-quality, localization, focused unit tests).

  • Windows only. Not yet exercised in the running Electron app, on macOS or Linux, or against a real paired server.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

Performance

None, because the select only renders on a Claude bot's Agent and model settings page and reuses the account list subscription the status-bar switcher already keeps; nothing new runs elsewhere.

Risk

Level: Low. It only writes the account field #48466 already accepts through bots.update. The riskiest part is a paired server whose account list fails to load: the select then shows the raw saved value without calling it unavailable, and choosing "Use the host's selected account" still clears it. Mobile is unchanged: its bot agent page would need its own account subscription and drill-in page, left for a follow-up. Back out with a plain revert.

AI Disclosure

Written with Claude Code (Claude Opus 5.5). Opened as a draft until #48466 settles and the screenshots are attached.

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

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)

darkpandawarrior and others added 2 commits November 25, 2026 02:29
Bots and automations can name the account their launches run under (a saved account's id, email or
name, or system). Claude native chats honour it before the host selection, for that launch only.

A new plugin hook, agent.account.resolve, lets a plugin change the account for a launch. It has the
usual 2 s deadline and falls back to the saved account.

Refs stablyai#46994, stablyai#47020, stablyai#47954
Builds on stablyai#48466, which added the bot `account` field and makes Claude
launches honour it but left the choice without UI.

The bot's Agent and model page gains a Claude account select under the
agent picker, shown for Claude bots. It lists the accounts saved on the
bot's own host (this computer, or a paired server through its existing
account subscription) with the status-bar switcher's labels, plus
"System default" and "Use the host's selected account", which clears the
field. A saved account the host no longer has stays visible as
unavailable instead of being rewritten.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
lurunzi added a commit to lurunzi/orca that referenced this pull request Nov 26, 2026
Cherry-picks upstream draft stablyai#48466 (bot and automation
`account` field, Claude launches honour it) and adds the bot account
picker on a Claude bot's Agent and model page (upstream follow-up
stablyai#49370). The fork's dashboard launch composition moves into
withDashboardClaudeLaunch to keep the launch file under its line limit.

Co-authored-by: Siddharth Pandalai <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cker

# Conflicts:
#	src/main/bots/bot-structured-session-wiring.ts
#	src/shared/plugins/events/plugin-hook-payloads.ts
@lurunzi
lurunzi marked this pull request as ready for review November 28, 2026 03:14
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The change adds account references for bots and automations, and adds the agent.account.resolve plugin hook. Session launch wiring resolves the requested account and passes it into Claude launch preparation. Bot settings now provide Claude account choices, including a follow-host option. The plugin reference documents the new hook and its manifest contribution.

Merge Risk: Moderate · up to fbb7c

Choosing a specific Claude account for a bot can launch with the wrong home or an unauthenticated profile in some setups, such as a custom config directory or a legacy account that shares the System default login. Resuming a session in a custom config directory can fail. Fix these launch-routing issues before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(bots): pick the Claude account a bot's chats use" matches the main change: a Claude account selector in the bot's Agent and model settings that saves the bot's account field. It is con…
Description check Passed The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Refs #46994, #47020, depends on #48466), Visual Proof, Testing, Performance, Risk with level, AI Disclosu…
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: Title check

Explanation

The title "feat(bots): pick the Claude account a bot's chats use" matches the main change: a Claude account selector in the bot's Agent and model settings that saves the bot's account field. It is concise, single-sentence, and specific. The summary and objectives also describe this selector as the main change of the PR.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (Refs #46994, #47020, depends on #48466), Visual Proof, Testing, Performance, Risk with level, AI Disclosure, the upstream boundary checkbox, and Notes/Checklist. It explains the stacked dependency and the before/after behavior. Gaps: the Visual Proof section has no attached before/after screenshots yet (it says they will be attached), the Linked Issue uses 'Refs' rather than 'Fixes' with a real linked issue, and the Risk level is given without a backout detail beyond a plain revert. The checklist also leaves screenshots and the pnpm build/lint items unchecked. These are non-critical or acknowledged as pending, so the description is mostly complete.

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

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: 86834e95-c567-4fa4-bac5-30315bc8bd7e
Commits

Reviewing files that changed from the base of the PR and between a7a02c1 and fbb7cc1.

Files selected for processing: 31

  • skill-guides/orca-plugin-authoring/references/host-api.md
  • skill-guides/orca-plugin-authoring/references/manifest.md
  • src/cli/skills/bundled-skill-guides.ts
  • src/main/bots/bot-structured-session-account.test.ts
  • src/main/bots/bot-structured-session-wiring.ts
  • src/main/claude-accounts/profiles/routing/claude-profile-router-requested.test.ts
  • src/main/claude-accounts/profiles/routing/claude-profile-router.ts
  • src/main/claude-accounts/profiles/routing/claude-system-default-comparison.ts
  • src/main/claude-accounts/selection/launch-account-resolution.test.ts
  • src/main/claude-accounts/selection/launch-account-resolution.ts
  • src/main/claude/structured/launch/claude-launch-account.ts
  • src/main/claude/structured/launch/claude-structured-launch-resolution.ts
  • src/main/runtime/agent-session/installation/structured-agent-runtime-registrations.ts
  • src/main/runtime/agent-session/installation/structured-agent-session-runtime-contract.ts
  • src/renderer/src/components/settings/bots/BotClaudeAccountPicker.fixture.tsx
  • src/renderer/src/components/settings/bots/BotClaudeAccountPicker.tsx
  • src/renderer/src/components/settings/bots/BotGeneralSettings.tsx
  • src/renderer/src/components/settings/bots/bot-claude-account-choices.test.ts
  • src/renderer/src/components/settings/bots/bot-claude-account-choices.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/agent-accounts/launch-account-ref.test.ts
  • src/shared/agent-accounts/launch-account-ref.ts
  • src/shared/automations/automation-definition.ts
  • src/shared/bot-types.ts
  • src/shared/bots/bot-launch.ts
  • src/shared/plugins/contributions/plugin-hook-contribution.ts
  • src/shared/plugins/events/plugin-hook-payloads.ts
  • src/shared/plugins/installation/plugin-host-version.ts
  • src/shared/plugins/workers/plugin-hook-chain-account-resolve.test.ts
  • src/shared/rpc-contract/automations/automation-params.ts
  • src/shared/rpc-contract/bots-params.ts

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

Comment on lines +195 to +199
const profile = requested
? requested.kind === 'managed'
? this.describe(requested.accountId)
: null
: this.routedProfile()

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 · Quick win

Route covered managed requests through the System default.

An explicit managed request for an account that coveredBySystemDefault reports as covered still describes that account's private profile. The covered account has no login of its own. Setup for that profile copies settings and state, but not .credentials.json or a Keychain credential, and it still reports prepared. The launch can therefore run with CLAUDE_CONFIG_DIR set to a folder that cannot authenticate. Host selection avoids this profile for the same account and uses the System default login. Apply the same rule to explicit requests.

Suggested fix

--- "a/src/main/claude-accounts/profiles/routing/claude-profile-router.ts"
+++ "b/src/main/claude-accounts/profiles/routing/claude-profile-router.ts"
@@ -192,11 +192,11 @@
       // Login changes since publication can change the route.
       this.writePointer()
     }
     const profile = requested
-      ? requested.kind === 'managed'
+      ? requested.kind === 'managed' && !this.coveredBySystemDefault(requested.accountId)
         ? this.describe(requested.accountId)
         : null
       : this.routedProfile()
     if (!profile) {
       return this.preparation(profile)
     }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
const profile = requested
? requested.kind === 'managed'
? this.describe(requested.accountId)
: null
: this.routedProfile()
const profile = requested
? requested.kind === 'managed' && !this.coveredBySystemDefault(requested.accountId)
? this.describe(requested.accountId)
: null
: this.routedProfile()

// A requested System default must not be routed through the host's selected account.
const home =
preparation.provenance === 'system'
preparation.provenance === 'system' && !requested

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 · Quick win

Requested System must honor the launch-environment CLAUDE_CONFIG_DIR.

When the environment sets a per-agent CLAUDE_CONFIG_DIR, an explicit { kind: 'system' } request resolves to the router's system default. prepareClaudeLaunchAccount takes preparation.configDir, which is systemDefaultHome(), because the !requested guard skips the override-aware resolver. launchEnv(null) also omits the override. The returned recipe therefore has home set to the system default while configDir keeps the override.

With CLAUDE_CONFIG_DIR=/custom and a system default of /home/u/.claude, launchHome becomes /home/u/.claude. The resumed session's transcript is under /custom, so the resume check throws historyInOtherAccount before launch. The unrequested System path returns /custom and resumes correctly. The launch env at claude-structured-launch-resolution.ts:296 is also rewritten to /home/u/.claude, so the process does not use the override either.

Resolve a requested System home the same way the unrequested System path does. Keep the launch-environment override, and do not apply host account selection. Use that one home for the recipe, the withClaudeLaunchAccountPin requested-System branch, the env patch, and the transcript lookup. Do not call resolveStructuredClaudeAccountHomePath unchanged for this case, because it routes through the selected account.

{ runtime: 'host', wslDistro: null }
)
const choices: BotClaudeAccountChoice[] = host.targets.map((target) => ({
value: target.id ?? LAUNCH_ACCOUNT_SYSTEM,

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.

Minor · Functional Correctness · Heavy lift

The Claude account picker cannot choose a usable duplicate login when the selected record needs sign-in.

For a Claude login that appears more than once, the host group keeps one row per identity. When the selected record needs sign-in, that row's value is the signed-out record's id, and the usable record's id is dropped. A bot saved to that record can keep a signed-out account, and this picker offers no row that selects the usable duplicate. A saved reference that still resolves must stay selected and must not be rewritten to another account.

Fix the selection so a bot can choose the usable duplicate login from this picker. Keep a saved reference that still resolves selected as written. Choose the representation for that case explicitly.

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.

2 participants