Skip to content

feat(claude-accounts): choose the Claude account when starting Claude from the "+" menu - #1

Draft
thega1 wants to merge 1 commit into
mainfrom
claude/project-thread-yrimm4
Draft

thega1 wants to merge 1 commit into
mainfrom
claude/project-thread-yrimm4

Conversation

@thega1

@thega1 thega1 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Requested by aden · project thread

ELI5

The "+" (new tab) menu now has a Claude on account ▸ submenu listing your saved Claude accounts. Pick one and a Claude terminal opens on that account. The selected account doesn't change, so other tabs and later launches keep using it.

What Changed

Before: every Claude launch from the "+" menu used the one selected account. Running two accounts side by side meant switching back and forth, and a switch offered to restart running sessions.

After:

  • ClaudeAccountLaunchSubmenu sits under the agent rows in the "+" menu. It shows when Claude can start in a terminal here and at least one host (non-WSL) Claude account is saved. The selected account has a check mark.
  • Choosing an account calls launchAgentInNewTab({ agent: 'claude', requestedSurface: 'terminal', claudeAccountId }). That puts ORCA_CLAUDE_PINNED_ACCOUNT_ID in the tab's startup env.
  • Main (claude-profile-pinned-launch.ts): when the spawn env carries that id, withClaudeProfileTerminalEnv sends the pane to the account's own folder instead of the selected one. It sets CLAUDE_CONFIG_DIR and ORCA_CLAUDE_INJECTED_CONFIG_DIR, and adds a per-account pointer file (claude-profiles/<id>/pinned-pointer). Because of the pointer, a claude typed again in that pane stays on the same account. A direct claude spawn (isClaudeLaunch) sets up that account's folder before launch, just like launches on the selected account (preparePinnedClaudeLaunchAuth in both spawn preflights).
  • An account switch no longer offers to restart tabs pinned this way (localClaudePanes skips them).
  • SSH, web-runtime and WSL workspaces refuse the choice with a toast. Before, they would quietly start on a different account. Unknown or WSL account ids fall back to normal routing.
  • Strings added to every locale catalog.

Why

People with a work account and a personal account want to choose per launch without switching globally. Several upstream PRs are close: stablyai#23228 (per-project, ask on launch), stablyai#38581 (pin a project's account), stablyai#22691 (CLI --account). None is merged. stablyai#23228 is built on 16 commits from stablyai#22691. This change is small and only covers one launch. It reuses main's existing per-account Claude folders, so nothing about logins is copied or swapped.

Linked Issue

Related upstream: stablyai#23227, stablyai#9496

Visual Proof

Not captured. The UI is a new submenu in the "+" menu, and I couldn't run the Electron app in this environment.

Testing

  • I manually tested these changes locally
  • Automated tests added: claude-profile-pinned-launch.test.ts (env routing, the real claude shell function re-reading the pinned pointer, the fallback for unknown or WSL accounts, auth prep) and launch-agent-in-new-tab-claude-account.test.ts (startup env and pin on a local terminal, refusal on SSH).
  • Every added test fails without this change and avoids the test anti-patterns

Passing locally: web typecheck, a typecheck of the changed main files, oxlint, changed-code quality gate, import boundaries, localization extraction and catalogs, the max-lines and e2e ratchets, and 1791 tests across the account, pty-spawn, tab-bar and launch suites. Two claude-profile-history.test.ts cases fail on main too in this sandbox, so they're unrelated.

Risk

Level: Medium. The change touches pty spawn env assembly for Claude panes. Without the pin env var, behaviour is unchanged.

  • If you restore a pinned tab after an app restart, it follows the selected account again, because the pin lives in memory for the window.
  • If a pinned account is removed, its pointer file goes with it and the pane falls back to System default.

To back it out, a plain revert works. The only things left on disk are the pinned-pointer files.

Review

Look closest at claude-profile-pinned-launch.ts, the two spawn-preflight.ts hooks, and the refusal paths in launch-agent-in-new-tab.ts.

Agent skill upstream boundary

  • Not applicable

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I stated the risk
  • Before/after screenshots
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path impact considered (SSH, web runtime and WSL refused explicitly)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (partial runs locally, as listed above)

Generated by Claude Code

… from the "+" menu

The new-tab "+" menu gets a "Claude on account" submenu listing the saved host
Claude accounts. Picking one opens a Claude terminal on that account without
changing the selected account; other tabs and later launches keep using it.

- The launch carries ORCA_CLAUDE_PINNED_ACCOUNT_ID in the tab's startup env.
- Main routes that pane to the account's own folder: CLAUDE_CONFIG_DIR plus a
  per-account pointer file, so a `claude` typed again in the pane stays on it.
  A direct `claude` spawn prepares that account's folder the same way the
  selected account's launches do.
- Account switches no longer offer to restart tabs pinned this way.
- SSH, web-runtime and WSL workspaces refuse the choice with a toast instead
  of silently starting on another account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YBT3FxGf5UPAtT84wR2n6D
@thega1 thega1 self-assigned this Nov 6, 2026
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