Chat usage limit: Claude Code-style banner with auto-continue; drop the approaching-limit banner

- The usage-limit banner now reads 'Out of usage credits' (or the refusal's
  own 'You've hit your 5-hour limit'), 'Auto-resuming at <time>', an
  'Auto-continue when limits reset' checkbox and Try again, keeping the
  account switcher's 'Switch to <account>'.
- Auto-continue (a shared, persisted preference, on by default) hands the
  server a durable scheduled prompt (send_at = reset + 1 min) with an
  idempotent auto-continue-<refusal id> operation id: the refused operator
  message again, or 'continue' when the refused turn had already worked.
  Unchecking unqueues it; Try again unqueues it and sends now.
- Remove the approaching-limit banner, its SnackBar announcements and their
  marks; the send-button usage ring replaces them.
- Claude Code's rate_limit_event overage fields (overageStatus,
  isUsingOverage/overageInUse, overageDisabledReason, overageResetsAt) reach
  clients as usage.account.extra_usage; the ring tooltip and the banner say
  'Extra usage available' or 'Using extra usage'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 16:13:33 +00:00
parent 7a259d8f60
commit 293474ac3c
22 changed files with 905 additions and 1254 deletions
@@ -52,8 +52,8 @@ import 'chat_composer_bar.dart';
import 'chat_composer_controller.dart';
import 'chat_escape_stop.dart';
import 'chat_delivery_indicator.dart';
import 'chat_auto_continue.dart';
import 'chat_usage_limit_banner.dart';
import 'chat_usage_warning_banner.dart';
import '../domain/chat_usage_limit.dart';
import 'chat_draft_store.dart';
import 'chat_effort_control.dart';
@@ -120,6 +120,7 @@ class ChatThreadView extends StatefulWidget {
this.onEffortChanged,
this.syncToken = 0,
this.drafts,
this.autoContinue,
this.newOperationId,
this.attachmentPicker,
this.scrollPositions,
@@ -214,6 +215,10 @@ class ChatThreadView extends StatefulWidget {
/// Draft persistence for tests and previews; production uses the app store.
final ChatDraftStore? drafts;
/// The usage-limit banner's auto-continue preference for tests; null
/// uses the shared one.
final ChatAutoContinue? autoContinue;
/// Test/fixture seam for deterministic operation ids.
final String Function()? newOperationId;
@@ -1279,21 +1284,11 @@ class _ChatThreadViewState extends State<ChatThreadView> {
pasteTarget: widget.pasteTarget,
ownsPasteWhenFocused: widget.ownsPasteWhenFocused,
runShell: _shellRuns.start,
limitBanner: (sendDraft) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ChatUsageLimitBanner(
thread: _controller,
composer: _composer,
sendDraft: sendDraft,
accounts: _accounts,
),
ChatUsageWarningBanner(
thread: _controller,
accounts: _accounts,
),
],
limitBanner: ChatUsageLimitBanner(
thread: _controller,
composer: _composer,
accounts: _accounts,
autoContinue: widget.autoContinue,
),
backgroundTasks: ChatBackgroundTasks(
key: ValueKey('chat-background-tasks-${widget.sessionId}'),