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:
@@ -68,13 +68,15 @@ class _ChatAccountUsageSectionState extends State<ChatAccountUsageSection> {
|
||||
),
|
||||
)
|
||||
else ...[
|
||||
if (plan.isNotEmpty)
|
||||
if (plan.isNotEmpty || usage.email.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
usage.harness.isEmpty
|
||||
? '$plan plan'
|
||||
: '${usage.harness} · $plan plan',
|
||||
[
|
||||
if (usage.email.isNotEmpty) usage.email,
|
||||
if (usage.harness.isNotEmpty) usage.harness,
|
||||
if (plan.isNotEmpty) '$plan plan',
|
||||
].join(' · '),
|
||||
key: const Key('chat-account-usage-plan'),
|
||||
style: muted,
|
||||
),
|
||||
|
||||
@@ -9,8 +9,9 @@ import '../domain/chat_usage_ring.dart';
|
||||
/// A thin ring around the composer's send button showing how much of the
|
||||
/// harness account's quota is used ([chatUsageRing]): barely visible
|
||||
/// normally, the tertiary colour from 80% and the error colour from 95%. The
|
||||
/// button's tooltip (hover, or long-press on touch) adds every window:
|
||||
/// "Send" then "5-hour 42% · resets 17:20 · Weekly 61% · resets Thu 09:00".
|
||||
/// button's tooltip (hover, or long-press on touch) adds the account and
|
||||
/// every window: "Send" then "sam@example.com · 5-hour 42% · resets 17:20 ·
|
||||
/// Weekly 61% · resets Thu 09:00" ([chatSendTooltip]).
|
||||
///
|
||||
/// The ring is painted beside the button, never in its layout or hit test,
|
||||
/// so the button keeps its size, target, states and animations. Without a
|
||||
@@ -72,17 +73,14 @@ class _ChatSendUsageRingState extends State<ChatSendUsageRing> {
|
||||
|
||||
Widget _ring(BuildContext context) {
|
||||
final now = widget.now();
|
||||
final ring = chatUsageRing(widget.usage(), now);
|
||||
final usage = widget.usage();
|
||||
final ring = chatUsageRing(usage, now);
|
||||
_ticking(ring != null);
|
||||
// The button stays the same child with or without a ring, so a report
|
||||
// arriving never remounts it (its hover, focus and ink stay).
|
||||
return CustomPaint(
|
||||
painter: ring == null ? null : _painter(context, ring),
|
||||
child: widget.button(
|
||||
ring == null
|
||||
? widget.label
|
||||
: '${widget.label}\n${chatUsageRingSummary(ring, now)}',
|
||||
),
|
||||
child: widget.button(chatSendTooltip(widget.label, usage, ring, now)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -513,6 +513,15 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
controller.transcriptChanges.addListener(
|
||||
() => _reconcileUnsent(controller),
|
||||
);
|
||||
// The menu's Claude account item names the signed-in account, which a
|
||||
// usage frame (not a transcript change) reports.
|
||||
var email = controller.accountUsage?.email;
|
||||
controller.addListener(() {
|
||||
final now = controller.accountUsage?.email;
|
||||
if (now == email) return;
|
||||
email = now;
|
||||
if (mounted) setState(() {});
|
||||
});
|
||||
// Delivery states follow the server's queue reports. Read the composer
|
||||
// when the report arrives: it is not built yet while this one is.
|
||||
controller.onQueue = (queue) {
|
||||
@@ -1559,6 +1568,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_controller.running,
|
||||
// The More menu offers Dismiss all finished commands only with one.
|
||||
_shellRuns.finishedIds.isNotEmpty,
|
||||
// The Claude account item names the signed-in account.
|
||||
_controller.accountUsage?.email,
|
||||
],
|
||||
() => _buildHeader(session, inShellBar, canGoBack, answeredBy, inWindow),
|
||||
);
|
||||
@@ -1651,6 +1662,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
ChatBarAction(
|
||||
key: const Key('chat-claude-account-menu'),
|
||||
label: 'Claude account',
|
||||
// The account the chat's Claude Code is signed in to now.
|
||||
subtitle: _controller.accountUsage?.email,
|
||||
identifier: 'chat-claude-account',
|
||||
onPressed: () =>
|
||||
unawaited(showChatClaudeAccountsDialog(context, accounts)),
|
||||
|
||||
@@ -14,7 +14,8 @@ import 'chat_thread_controller.dart';
|
||||
|
||||
/// Above the composer while the chat's account is out of quota, as Claude
|
||||
/// Code's own app shows it: "Out of usage credits" (or the refusal's own
|
||||
/// "You've hit your 5-hour limit"), "Auto-resuming at 15:41", an
|
||||
/// "You've hit your 5-hour limit"), the account that hit it and
|
||||
/// "Auto-resuming at 15:41", an
|
||||
/// "Auto-continue when limits reset" checkbox and Try again.
|
||||
///
|
||||
/// With auto-continue on (a preference shared by every chat, on by default,
|
||||
@@ -179,7 +180,10 @@ class _ChatUsageLimitBannerState extends State<ChatUsageLimitBanner> {
|
||||
final resumesAt = pending.isEmpty
|
||||
? limit.sendAt
|
||||
: chatScheduledSendAt(pending.first['send_at'], now)!;
|
||||
final email = widget.thread.accountUsage?.email ?? '';
|
||||
final status = [
|
||||
// The account that hit the limit.
|
||||
if (email.isNotEmpty) email,
|
||||
if (enabled && refused != null)
|
||||
'Auto-resuming at ${time(resumesAt)}'
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user