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:
@@ -56,12 +56,12 @@ JsonMap? chatClaudeAccountsReply(JsonMap request) {
|
||||
}
|
||||
_active = index;
|
||||
final now = DateTime.now().millisecondsSinceEpoch;
|
||||
usage = {
|
||||
usage = _named({
|
||||
'harness': 'Claude Code',
|
||||
'plan': 'max',
|
||||
'as_of': now,
|
||||
'switched_at': now,
|
||||
};
|
||||
});
|
||||
}
|
||||
return {
|
||||
'id': request['id'],
|
||||
@@ -70,14 +70,30 @@ JsonMap? chatClaudeAccountsReply(JsonMap request) {
|
||||
};
|
||||
}
|
||||
|
||||
/// The active account's quota frame for `?claudeUsage=`, or null.
|
||||
/// The account usage.account names: the active one, as the server sends it.
|
||||
JsonMap _named(JsonMap account) => {
|
||||
...account,
|
||||
'email': _emails[_active],
|
||||
'organization': 'Caplens',
|
||||
};
|
||||
|
||||
/// The usage.account of other fixtures (`?quota=`) with the active account's
|
||||
/// name when the chat has Claude accounts.
|
||||
JsonMap chatClaudeNamedAccount(JsonMap account) =>
|
||||
_count == 0 ? account : _named(account);
|
||||
|
||||
/// The active account's frame on subscribe: its quota for `?claudeUsage=`,
|
||||
/// else the account alone (as a process start reports it); null without
|
||||
/// Claude accounts.
|
||||
JsonMap? chatClaudeUsageFrame(String sessionId) {
|
||||
if (_count == 0) return null;
|
||||
final percent = switch (_params['claudeUsage']) {
|
||||
'limit' => 100.0,
|
||||
'warn' => 88.0,
|
||||
_ => null,
|
||||
};
|
||||
if (percent == null) return null;
|
||||
// `?quota=` already reports the (named) account's quota.
|
||||
if (percent == null && _params['quota'] != null) return null;
|
||||
final now = DateTime.now();
|
||||
return {
|
||||
'type': 'chat_event',
|
||||
@@ -85,21 +101,22 @@ JsonMap? chatClaudeUsageFrame(String sessionId) {
|
||||
'session_id': sessionId,
|
||||
'kind': 'usage',
|
||||
'usage': {
|
||||
'account': {
|
||||
'account': _named({
|
||||
'harness': 'Claude Code',
|
||||
'plan': 'max',
|
||||
'as_of': now.millisecondsSinceEpoch,
|
||||
'windows': [
|
||||
{
|
||||
'id': 'five_hour',
|
||||
'label': '5-hour',
|
||||
'used_percent': percent,
|
||||
'resets_at': now
|
||||
.add(const Duration(hours: 2, minutes: 10))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
if (percent != null)
|
||||
{
|
||||
'id': 'five_hour',
|
||||
'label': '5-hour',
|
||||
'used_percent': percent,
|
||||
'resets_at': now
|
||||
.add(const Duration(hours: 2, minutes: 10))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -218,7 +218,7 @@ List<JsonMap> perfChatFollowUps(JsonMap request) {
|
||||
'total_tokens': 132408,
|
||||
'context_tokens': 42000,
|
||||
'context_window': 200000,
|
||||
'account': account,
|
||||
'account': chatClaudeNamedAccount(account),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user