Chat: show the active Claude account in the send tooltip, menu and limit banner
usage.account now carries the email and organization of the account Claude Code is signed in to (from its initialize account, or the saved account just switched to), sent at process start and after a switch. The app shows it as the send tooltip's usage prefix, the Claude account menu subtitle, the usage-limit banner's status line and the info sheet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-14
@@ -25,10 +25,13 @@ const quotaHarness = "Claude Code"
|
||||
const quotaSource = "rate_limit_event"
|
||||
|
||||
// accountIdentity is the signed-in account a process reported at initialize.
|
||||
// key is never sent to clients; it only shares quota between sessions.
|
||||
// key is never sent to clients; it only shares quota between sessions. email
|
||||
// and organization name the account to the operator (usage.account).
|
||||
type accountIdentity struct {
|
||||
key string
|
||||
plan string
|
||||
key string
|
||||
plan string
|
||||
email string
|
||||
organization string
|
||||
}
|
||||
|
||||
func decodeAccountIdentity(raw json.RawMessage) accountIdentity {
|
||||
@@ -45,7 +48,12 @@ func decodeAccountIdentity(raw json.RawMessage) accountIdentity {
|
||||
if strings.Trim(key, "\x00") == "" {
|
||||
key = ""
|
||||
}
|
||||
return accountIdentity{key: key, plan: strings.TrimSpace(account.SubscriptionType)}
|
||||
return accountIdentity{
|
||||
key: key,
|
||||
plan: strings.TrimSpace(account.SubscriptionType),
|
||||
email: strings.TrimSpace(account.Email),
|
||||
organization: strings.TrimSpace(account.Organization),
|
||||
}
|
||||
}
|
||||
|
||||
type rateLimitWindowInfo struct {
|
||||
@@ -175,16 +183,6 @@ func mergeRateLimit(previous *protocol.ChatAccountUsage, raw json.RawMessage, pl
|
||||
return next
|
||||
}
|
||||
|
||||
// accountUsage returns a copy of the latest quota for an account key.
|
||||
func (c *Chat) accountUsage(key string) *protocol.ChatAccountUsage {
|
||||
if key == "" {
|
||||
return nil
|
||||
}
|
||||
c.quotaMu.Lock()
|
||||
defer c.quotaMu.Unlock()
|
||||
return c.quotas[key].Clone()
|
||||
}
|
||||
|
||||
// handleRateLimit records a rate_limit_event for the session's account and
|
||||
// republishes the latest usage snapshot, with the new quota, to every session
|
||||
// of that account.
|
||||
|
||||
Reference in New Issue
Block a user