LeeHom on Discord: two Claude Pro accounts vanished from Providers, and
signing one in again showed the other as "needs sign in again". While
Claude Code is signed out, the claude provider is built on
claudeStandIn's account. claudeStandIn skips an account whose sign-in
Claude Code let go of (claudeLoggedOut's claudeLogoutLapse) or that is
still Held. With every saved account like that, it returned "", no claude
provider was made, and the subscription and both accounts left the GUI,
the TUI and `magpie providers` at once.
claudeStandInAccount and Logins now ask claudeListed: the stand-in, else
the signed-out account seen last. A Held account is never listed this way,
because the sign-in Claude Code left on disk would then be served
(TestClaudeSignedOut still holds). The listed account's token still fails
with the lapse reason (claudeSavedDir), so nothing is served on it.
claudeStandIn itself is unchanged, since addLogin and logins_on rely on
it.
The app's row already said "{user} is signed out" when every login in use
had lapsed. Provider.SignedOut is that rule in Go. With it, `magpie
providers` says "○ <user> is signed out · sign in again" and the TUI says
"○ <user> is signed out", instead of a green "signed in". The CLI's key
column moved into keyColumn so it can be tested. The providers-accounts
doc row says this.
Tests:
- TestClaudeAllSignedOutStaysListed: signed in, a second account
logout-lapsed, then Claude Code signed out. It fails on the old code
("Claude Code left the Providers list with every account signed out:
false") and with SignedOut returning false (both broken by hand).
- TestProvidersSaySignedOut, in cli and tui: a signed-out account reads
as signed out and a signed-in one still reads as signed in.
Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./...; go build for all three.
Then go test -timeout 45m ./... under a sandbox HOME at base ba319a758
(load ~25). Every package was ok except two:
- internal/agent timed out with a 2s-old test running (rerun alone: ok
1866s).
- internal/gateway failed TestRateLimitIsWaitedOut, "an hour away: passed
on after 1.32s" against its 1s bound. That is #1971, open, a wall-clock
bound under load and not this change; rerun alone: ok 1433s.
Rebased on d771138c4 (13 commits, including c79400556 in
agent/provider.go). At the pushed head: gofmt clean, go build for darwin,
linux nogui and windows, go vet of provider/cli/tui, and go test
./internal/provider ./internal/cli ./internal/tui all ok. No GUI file
changed, so the GUI suite was not run.
Not tried: a real Claude account signed out in Claude Code. The sandbox
test drives the same files (.credentials.json, .claude.json, logins.json).
26 lines
1.0 KiB
Go
26 lines
1.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// An account whose every sign-in in use was refused is listed signed out,
|
|
// to be signed in again, never "signed in as" (LeeHom on Discord: two
|
|
// Claude Pro accounts gone from the list, then "needs sign in again").
|
|
func TestProvidersSaySignedOut(t *testing.T) {
|
|
out := map[string]bool{"claude": true}
|
|
signedOut = func(p provider.Provider) bool { return out[p.ID] }
|
|
t.Cleanup(func() { signedOut = provider.Provider.SignedOut })
|
|
gone := keyColumn(provider.Provider{ID: "claude", Account: &provider.Account{User: "two@example.com"}})
|
|
if !strings.Contains(gone, "two@example.com is signed out") || !strings.Contains(gone, "sign in again") || strings.Contains(gone, "signed in as") {
|
|
t.Fatalf("signed-out row: %q", gone)
|
|
}
|
|
in := keyColumn(provider.Provider{ID: "codex", Account: &provider.Account{User: "one@example.com"}})
|
|
if !strings.Contains(in, "signed in as one@example.com") {
|
|
t.Fatalf("signed-in row: %q", in)
|
|
}
|
|
}
|