App: Claude account auto-switch setting; the limit banner leaves a refusal the server is continuing alone
The Claude account dialog shows 'Auto-switch account when usage runs out' (claude_account_auto_switch) when the server reports it. The usage-limit banner schedules no auto-continue while the server's auto-switch continue prompt is queued. A chat refused after another chat already switched the Claude home gets a fresh switch stamp, so its banner clears too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,9 +84,11 @@ func (c *Chat) AutoSwitchAccount(ctx context.Context, refusal UsageRefusal) (Aut
|
||||
c.markRefused(from, organizationOf(list, from), now)
|
||||
active := *list.Active
|
||||
if !strings.EqualFold(active.Email, from) && c.usable(active, now) {
|
||||
// Another chat's refusal already moved the home on.
|
||||
// Another chat's refusal already moved the home on. The switch is
|
||||
// stamped again so this chat's later refusal reads as the old
|
||||
// account's too.
|
||||
identity := accountIdentity{key: accountKeyFor(active.Email, active.Organization), plan: active.Plan, email: active.Email, organization: active.Organization}
|
||||
return AutoSwitch{From: from, To: active.Email, Usage: c.accountUsage(identity)}, nil
|
||||
return AutoSwitch{From: from, To: active.Email, Usage: c.switchAccount(ctx, configDir, identity)}, nil
|
||||
}
|
||||
candidate, ok := c.pickAccount(list, from, now)
|
||||
if !ok {
|
||||
|
||||
@@ -130,7 +130,8 @@ func TestAutoSwitchMovesToTheSavedAccountWithTheMostUsageLeft(t *testing.T) {
|
||||
if result.From != "a@example.invalid" {
|
||||
t.Fatalf("from = %+v", result)
|
||||
}
|
||||
if result.Switched && (result.Usage == nil || result.Usage.SwitchedAt == 0) {
|
||||
// Both chats' refusals predate a switch stamp, so their banners clear.
|
||||
if result.Usage == nil || result.Usage.SwitchedAt == 0 {
|
||||
t.Fatalf("the switch was not marked: %+v", result.Usage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ func refusalKey(refusal claude.UsageRefusal) string {
|
||||
|
||||
// claim reports whether refusal is new, remembering it.
|
||||
func (s *chatAutoSwitchState) claim(refusal claude.UsageRefusal) bool {
|
||||
key := refusal.SessionID + "\x00" + refusal.TurnID
|
||||
key := refusal.SessionID + "\x00" + refusal.TurnID + "\x00" + refusal.MessageID
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.handled[key] {
|
||||
|
||||
Reference in New Issue
Block a user