fix(desktop): stop Usage "Add account" from replacing a signed-in profile
Closed
HA
2d ago+192+192+012345678901234567890123456789-4-4-0123456789
What & why
Part of PARA-3523 ("adding accounts in Usage is broken").
In Settings → Usage → Add account, the profile name always defaulted to work, and nothing checked it against the profiles already on the host. Adding a second Claude or Codex account with the prefilled name ran claude auth login (or codex login) again in ~/.claude-work / ~/.codex-work. That replaced the first account, and because findCompletedLogin accepts a CLI that exits 0, the dialog still reported " is signed in". The user ends up with one account where they expected two.
Changes
utils/profileNames(new):freeProfileNamepicks the first ofwork,work-2, … that is not a signed-in profile.isProfileSignedIncompares against the host'sloginslist, normalizing separators and a trailing slash.AddAccountDialog:- The default name follows each poll until the user edits it, so a stale cache can't leave a taken default, and typing is never overwritten.
- A typed name that maps to a signed-in profile disables Sign in and hides the copy-paste command (remote host), with an inline message.
- Switch sign-in (
switchTarget) is unchanged.
- 1 new string, translated into all 17 locales.
How I tested it
bun test src/renderer/routes/_authenticated/settings/usage: 50 pass (4 new inprofileNames.test.ts).tsc --noEmitfor desktop is clean, biome is clean, andbun run check:i18npasses.- I rendered the real dialog in Storybook against a host that already has
~/.claude-worksigned in (a throwaway story, not committed):- Before: the default is
workand Sign in is enabled. - After: the default is
work-2, and typingworkblocks Sign in.
- Before: the default is
- Not tested: a real second browser login in the desktop app. This sandbox has no signed-in desktop session.
- A subagent reviewed the change. I fixed its findings: the copy-paste path wasn't blocked, the default came from stale cache, and the path comparison was exact-string.
Screenshots, video, and the cloud chat sign-in verification for PARA-3523: https://app.superset.sh/page/para-3523-chat-sign-in-cloud-and-usage-add-account-ou4a3c
Summary by CodeRabbit
- New Features
- New account profiles automatically receive an available name when you haven’t entered one.
- If the chosen name is already in use by a signed-in profile, you’ll see an error and can choose a different name.
- Profile-name conflict messages are available in multiple languages.