Schedule a message for when the usage limit resets
When the open chat's account has an exhausted quota window, a banner above the composer reads "Usage limit reached · resets at HH:MM" and offers to send the last message (or the current draft) a minute after the reset, via chat_prompt send_at. Queued prompts with a future send_at read "Scheduled · sends at HH:MM" and keep Remove. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -154,8 +154,12 @@ class ChatComposerController extends ChangeNotifier {
|
||||
/// device until the server accepts it. A refusal restores the exact draft
|
||||
/// (unless newer text is present) and shows the message as "Not sent"; an
|
||||
/// unchanged re-send (same text and parts) reuses its operation id, and a
|
||||
/// changed one replaces it. Returns whether the server accepted this prompt.
|
||||
Future<bool> send({List<JsonMap> attachments = const []}) async {
|
||||
/// changed one replaces it. A [sendAt] (epoch ms) asks the server to hold
|
||||
/// the prompt until then. Returns whether the server accepted this prompt.
|
||||
Future<bool> send({
|
||||
List<JsonMap> attachments = const [],
|
||||
int sendAt = 0,
|
||||
}) async {
|
||||
if (_disposed || _sending) return false;
|
||||
final exact = _draft;
|
||||
final text = exact.trim();
|
||||
@@ -164,6 +168,7 @@ class ChatComposerController extends ChangeNotifier {
|
||||
late final ChatComposerSend intent;
|
||||
if (previous != null &&
|
||||
previous.text == text &&
|
||||
previous.sendAt == sendAt &&
|
||||
_sameAttachments(previous.attachments, attachments)) {
|
||||
intent = previous;
|
||||
} else {
|
||||
@@ -176,6 +181,7 @@ class ChatComposerController extends ChangeNotifier {
|
||||
operationId: operationId,
|
||||
nativeMessageId: nativeChatMessageId(operationId),
|
||||
attachments: attachments,
|
||||
sendAt: sendAt,
|
||||
);
|
||||
}
|
||||
_pending = intent;
|
||||
@@ -185,6 +191,23 @@ class ChatComposerController extends ChangeNotifier {
|
||||
return _deliver(intent, clearDraft: true);
|
||||
}
|
||||
|
||||
/// Asks the server to send [text] (text only) at [sendAt] epoch ms, as a
|
||||
/// new message, leaving the draft alone: the usage-limit banner's re-send
|
||||
/// of the operator's last message. Returns whether the server accepted it.
|
||||
Future<bool> schedule(String text, int sendAt) async {
|
||||
final trimmed = text.trim();
|
||||
if (_disposed || _sending || trimmed.isEmpty) return false;
|
||||
final operationId = _nextOperationId();
|
||||
final intent = ChatComposerSend(
|
||||
sessionId: sessionId,
|
||||
text: trimmed,
|
||||
operationId: operationId,
|
||||
nativeMessageId: nativeChatMessageId(operationId),
|
||||
sendAt: sendAt,
|
||||
);
|
||||
return _deliver(intent, clearDraft: false);
|
||||
}
|
||||
|
||||
/// Sends an unsent intent again with its own operation id, so the server and
|
||||
/// the transcript see the same message rather than a second one. When its
|
||||
/// text is back in the composer, the composer is cleared as for a send.
|
||||
@@ -285,6 +308,7 @@ class ChatComposerController extends ChangeNotifier {
|
||||
intent.text,
|
||||
operationId: intent.operationId,
|
||||
attachments: intent.attachments,
|
||||
sendAt: intent.sendAt,
|
||||
);
|
||||
if (_disposed) return false;
|
||||
final queued = reply['chat_queued'] == true;
|
||||
@@ -297,7 +321,9 @@ class ChatComposerController extends ChangeNotifier {
|
||||
_composerSendsAccepted++;
|
||||
}
|
||||
deliveries.accepted(intent, queued: queued, steered: steered);
|
||||
_queued = deliveries.isQueued(intent.operationId) || deliveries.ownQueued;
|
||||
_queued =
|
||||
(intent.sendAt == 0 && deliveries.isQueued(intent.operationId)) ||
|
||||
deliveries.ownQueued;
|
||||
onAccepted?.call(intent, queued);
|
||||
_settle(null);
|
||||
// The accepted intent's stored copy is gone before the send completes.
|
||||
|
||||
Reference in New Issue
Block a user