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:
@@ -31,8 +31,15 @@ class ChatAccountUsage {
|
||||
required this.unsupported,
|
||||
this.switchedAt = 0,
|
||||
this.extraUsage,
|
||||
this.email = '',
|
||||
this.organization = '',
|
||||
});
|
||||
|
||||
/// The account the harness is signed in to now ("sam@example.com"); empty
|
||||
/// when it did not say (an API key, or a harness without accounts).
|
||||
final String email;
|
||||
final String organization;
|
||||
|
||||
/// Display name of the harness ("Claude Code", "Codex", "OpenCode").
|
||||
final String harness;
|
||||
final String plan;
|
||||
@@ -131,9 +138,10 @@ ChatAccountUsage? chatAccountUsage(Object? value) {
|
||||
}
|
||||
}
|
||||
final switchedAt = _millis(value['switched_at']);
|
||||
// A switched account replaces the previous report even with no windows
|
||||
// yet; otherwise an empty report keeps the last one.
|
||||
if (windows.isEmpty && switchedAt == 0) return null;
|
||||
final email = '${value['email'] ?? ''}'.trim();
|
||||
// A switched or newly named account replaces the previous report even with
|
||||
// no windows yet; otherwise an empty report keeps the last one.
|
||||
if (windows.isEmpty && switchedAt == 0 && email.isEmpty) return null;
|
||||
return ChatAccountUsage(
|
||||
harness: harness,
|
||||
plan: '${value['plan'] ?? ''}'.trim(),
|
||||
@@ -142,6 +150,8 @@ ChatAccountUsage? chatAccountUsage(Object? value) {
|
||||
unsupported: false,
|
||||
switchedAt: switchedAt,
|
||||
extraUsage: _extraUsage(value['extra_usage']),
|
||||
email: email,
|
||||
organization: '${value['organization'] ?? ''}'.trim(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,22 @@ String chatUsageRingResetTime(DateTime at, DateTime now) {
|
||||
return '${local.day} ${months[local.month - 1]} $time';
|
||||
}
|
||||
|
||||
/// The send button's tooltip: [label] ("Send"), then the account the chat
|
||||
/// runs on and its usage: "sam@example.com · 5-hour 42% · resets 17:20 · …".
|
||||
/// Either part may be missing; with neither the tooltip is the label alone.
|
||||
String chatSendTooltip(
|
||||
String label,
|
||||
ChatAccountUsage? usage,
|
||||
ChatUsageRing? ring,
|
||||
DateTime now,
|
||||
) {
|
||||
final line = [
|
||||
if (usage?.email case final email? when email.isNotEmpty) email,
|
||||
if (ring != null) chatUsageRingSummary(ring, now),
|
||||
].join(' · ');
|
||||
return line.isEmpty ? label : '$label\n$line';
|
||||
}
|
||||
|
||||
/// "5-hour 42% · resets 17:20 · Weekly 61% · resets Thu 09:00", then any
|
||||
/// extra usage note.
|
||||
String chatUsageRingSummary(ChatUsageRing ring, DateTime now) => [
|
||||
|
||||
Reference in New Issue
Block a user