Before #1220 a bare Copilot login named one account (a same-named one
wrote over it), so the per-account settings in providers.json kept under
it are that account's. When an account is renamed login -> login@host
(an old enterprise record read by nameAlike, or the editors' own
enterprise account renamed in sideLogins), renameTo remembers the old
name (savedLogin.was, never written) and pins the account's stable id
from it. writeLogins then moves accountProxies, accountModels,
accountCaps and accountConcurrency of the copilot provider from the old
key to the new (moveAccountSettings), and writes the new name only once
that has worked (renameSettled):
- a setting the new name has already stays, and the old with it;
- an old name another account still bears is left to that account;
- providers.json that can't be read or written stops the move, and the
account is written under its old name, its settings with it, retried
a minute later (renameDue) rather than at every listing.
sideLogins writes a pending rename the first time copilot is listed,
on a copy so the listing keeps its order.
Not moved: usage history, quota history, usage-alert marks and the
GUI's expanded/brief card state (localStorage) - records and view
state, not settings. Gateway keys' account lists go by the stable
login id, which is kept.
Tests (each FAILs with moveAccountSettings stubbed to do nothing):
- TestCopilotRenameKeepsSettings: proxy, cap, models, concurrency under
"mona" are mona@a.ghe.com's after the upgrade; a github.com mona added
after has neither proxy nor cap.
- TestCopilotOwnGHERenameKeepsSettings: the editors' own GHE account
keeps cap and proxy.
- TestCopilotRenameWaitsForSettings: an unreadable providers.json is
left as it is and logins.json keeps "mona"; once readable, the
settings move and the new name is written.
- TestCopilotRenameKeepsNewNamesSetting.
Ran: rebased onto origin/main (b6f33753); gofmt -l clean; go vet -tags
nogui . ./internal/provider ./internal/gui ./internal/gateway for
GOOS=darwin, linux, windows; go build ./...; GOOS=linux/windows go
build -tags nogui .; go test -tags nogui -count=1 ./internal/provider
./internal/gui ./internal/gateway . under a temp HOME with pinned
caches and pipefail, all ok; -race -count=5 -run TestCopilot
./internal/provider ok.