motui9535 on Discord: after making another Claude account first in
Providers, a refresh at the top of Usage turned the previous account back
into the first.
Here is how. Make first switches Claude Code to the account (say Max). A
Claude Code started on the previous account (Pro) before the switch keeps
writing Pro's profile into ~/.claude.json afterwards. While the
credentials are still the ones a saved record holds, claudeSignInOwner
names the sign-in by them (#1938, netfishx). The Usage refresh then runs
/usage in Claude Code's own config, and that renews the sign-in. The new
tokens are held by no record, so the sign-in was named after the stale
profile: Pro. rememberLogins then saved Max's renewed tokens under Pro's
record and marked Pro active. Max's record kept a dead refresh token, and
Pro's record now held Max.
The fix: the held record now keeps the profile magpie read at its last
look (HeldAs). A sign-in held by no record is the held account's own
renewal when all three of these hold:
- its profile is that same profile;
- the profile names another account;
- its plan is not another's.
A /login writes its own account's profile, so it is still the new
account's.
Tests: TestClaudeMadeFirstStaysFirstWhenRenewedUnderAnothersProfile (the
reporter's sequence, then a SwitchWhenSpent look) and
TestClaudeLoginAnewIsTheNewAccounts (a /login with a new profile, or with
another plan, is the new account's).
Run on mote:
- go test -count=1 -timeout 45m ./internal/provider ./internal/gui
./internal/cli: ok.
- go vet for darwin, linux and windows on ./internal/provider: ok.
- gofmt -l: clean.
Broken by hand:
- claudeRenewedHeld never applied: the first test goes red ("first is
pro@x.com", pro holds tok-max@x.com-renewed).
- No plan guard: the "its plan" subtest goes red.
Not tried:
- The reporter's real accounts and a real Claude Code renewing its token.
The sequence is reproduced with files in a sandbox HOME, and that Claude
Code renews during /usage is inferred, not observed.
- A /login back to the very account the stale profile names, on the same
plan, still reads as the held account's renewal.