feat(multi-account): Accounts tab in Settings (Batch 2b part 1)
Summary
Batch 2b (part 1) of multi-account support (follows #123): an Accounts tab in Settings — manage Claude Code accounts from the UI instead of the terminal.
- List configured accounts: label, identity (email / "not logged in" hint),
defaultmarker - Add an account (creates the registry entry + regenerates
accounts.sh; shows theclaude <label>log-in hint) - Remove an account (unregisters; keeps its folder on disk; anchor
~/.claudeaccount is protected) - Set default — what bare
clauderesolves to (2e, now clickable) - Shell integration install/uninstall (the marker-guarded
~/.zshrcsource block)
Architecture
The tab is a set of thin IPC handlers (accounts-get/add/remove/set-default/shell-hook in main.ts) over the same shared manager (src/cli/account-manager.ts) that the codev account CLI uses — one generator for accounts.json + accounts.sh, no drift between CLI and UI. Mutations invalidate the accounts cache so the Sessions tab picks up changes.
src/popup.tsx— newaccountstab (state + handlers + UI, matching the existing tab style)src/preload.ts/src/electron-api.d.ts— API wiring +CodevAccountInfotypesrc/main.ts— IPC handlers
Scope notes
- Rename is deferred: labels name their dirs (
~/.claude-<label>), so rename implies a dir migration; remove+add covers the rare need. codevbinary on PATH is the remaining 2b item (next PR) — until then the CLI runs viayarn account <cmd>.
Supported shells & terminals
- Shell integration (Install button /
codev account install): writes~/.zshrc— zsh only for now (the macOS default). The generatedaccounts.shis bash-compatible (bash users cansourceit from.bashrcmanually); fish is unsupported (different function syntax). Shell detection is future work (design doc §6.C). - Account-aware resume/launch: every terminal CodeV supports — iTerm2, Terminal.app, Ghostty, cmux, and the embedded Term tab. VS Code sessions can't be account-switched (#121).
Checking which account a session runs under (gotcha)
Inside any Claude Code session, !claude auth status reports the global default, not the session's account — Claude Code snapshots your interactive shell's functions, so in-session claude is the accounts.sh dispatcher. Valid probes:
!command claude auth status✅ —commandbypasses shell functions, so the real binary inherits the session process's ownCLAUDE_CONFIG_DIR→ the session's actual account!echo ${CLAUDE_CONFIG_DIR:-unset}✅ — the session's own config dir (unset= anchor account)
Full write-up: #123's "Gotcha" section + design doc §6.A.
How to test
Needs yarn make (main-process + renderer changes):
- Settings → Accounts tab: your accounts appear with email +
defaultmarker; shell integration shows Uninstall (already installed). - Add a
testaccount → appears as "not logged in — run: claude test"; registry +accounts.shregenerate. Set defaultontest→ notice appears;yarn account listshows*moved (restore after).- Remove
test→ gone from list;~/.claude-testfolder stays. - Sessions tab still shows personal+work sessions with badges (cache invalidation works).
Automated: yarn test 13/13; tsc --noEmit 0 errors.
🤖 Generated with Claude Code
Summary by cubic
Adds a new Accounts tab in Settings so you can manage Claude Code accounts from the UI instead of the terminal. This lets you add/remove accounts, set the default for bare claude, and toggle shell integration.
-
New Features
- List accounts with identity (email or “not logged in”), a “default” marker, and the exact launch command (
claudeorclaude <name>). - Add an account (shows login hint:
claude <name>), remove an account (keeps its folder), and set the global default. - Install/uninstall shell integration for
~/.zshrc. - IPC handlers (
accounts-get/add/remove/set-default/shell-hook) wrap the sharedaccount-managerused by thecodev accountCLI; mutations invalidate the Sessions cache. - Notes: the anchor
~/.claudeaccount is protected; rename is deferred; remaining 2b item is a realcodevbinary on PATH.
- List accounts with identity (email or “not logged in”), a “default” marker, and the exact launch command (
-
Bug Fixes
- Seed the anchor
~/.claudeaccount on first extra add so the existing machine default stays registered and remains the global default. accounts-addreturns the enriched shape and derivesisCurrentDefaultin the fallback path to matchCodevAccountInfo; shell-hook action is validated (malformed payloads fail).- UI hardening: async refresh with error handling, stale notices cleared on tab open, clear guidance when shell integration isn’t installed, and a busy guard to serialize account operations.
- Seed the anchor
Summary by CodeRabbit
- New Features
- Added an Accounts tab in Settings for multi-account management.
- Users can view accounts, add/remove accounts, and set the default (with current-default indicators).
- Added UI to install/uninstall shell integration from the Accounts tab.
- Settings can now open directly to the Accounts tab.
- Chores
- Updated the app version to v1.0.78 and refreshed the release entry.