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:
@@ -6,8 +6,9 @@
|
||||
// `?chats=N` N chat sessions in the chat list, each opening a short
|
||||
// markdown transcript;
|
||||
// `?graph=1` run 7 carries its pinned graph (plan -> build);
|
||||
// `?quota=claude|opencode` (with `?chats=N`) pushes a usage frame with
|
||||
// that harness's account quota after a chat subscribes.
|
||||
// `?quota=claude|opencode|limit` (with `?chats=N`) pushes a usage frame
|
||||
// with that harness's account quota after a chat subscribes;
|
||||
// `limit` is Claude Code with its 5-hour window exhausted.
|
||||
// `?colors=1` (with `?chats=N`) names the chats, stars and colours some of
|
||||
// them, and keeps colours picked with chat_color;
|
||||
// `?activity=1` (with `?chats=N`) lists a running chat, one with
|
||||
@@ -143,6 +144,24 @@ List<JsonMap> perfChatFollowUps(JsonMap request) {
|
||||
if (answered.isNotEmpty) return answered;
|
||||
final shell = chatShellFollowUps(request);
|
||||
if (shell.isNotEmpty) return shell;
|
||||
if (_scheduledPrompt(request) case final prompt?) {
|
||||
return [
|
||||
{
|
||||
'type': 'chat_queue',
|
||||
'chat_queue': {
|
||||
'session_id': prompt['session_id'],
|
||||
'prompts': [
|
||||
{
|
||||
'operation_id': prompt['operation_id'],
|
||||
'native_message_id': prompt['native_message_id'],
|
||||
'text': prompt['text'],
|
||||
'send_at': prompt['send_at'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
final quota = _params['quota'];
|
||||
if (_chats == 0 || quota == null || request['type'] != 'chat_subscribe') {
|
||||
return const [];
|
||||
@@ -160,7 +179,7 @@ List<JsonMap> perfChatFollowUps(JsonMap request) {
|
||||
{
|
||||
'id': 'five_hour',
|
||||
'label': '5-hour',
|
||||
'used_percent': 42,
|
||||
'used_percent': quota == 'limit' ? 100 : 42,
|
||||
'resets_at': at(
|
||||
const Duration(hours: 2, minutes: 14, seconds: 30),
|
||||
),
|
||||
@@ -191,6 +210,13 @@ List<JsonMap> perfChatFollowUps(JsonMap request) {
|
||||
];
|
||||
}
|
||||
|
||||
/// A `chat_prompt` body carrying `send_at`, or null.
|
||||
Map? _scheduledPrompt(JsonMap request) {
|
||||
if (request['type'] != 'chat_prompt') return null;
|
||||
final body = request['chat_prompt'];
|
||||
return body is Map && body['send_at'] is num ? body : null;
|
||||
}
|
||||
|
||||
/// Run 7's pinned graph for `?graph=1`.
|
||||
JsonMap perfRunGraphFixture() => {
|
||||
'name': 'Release train',
|
||||
@@ -305,7 +331,8 @@ JsonMap? perfChatReply(JsonMap request) {
|
||||
return {
|
||||
'id': id,
|
||||
'type': 'chat_prompt',
|
||||
'chat_queued': false,
|
||||
// A scheduled prompt (`send_at`) is always held, as the server does.
|
||||
'chat_queued': _scheduledPrompt(request) != null,
|
||||
if (_params['steered'] == '1') 'chat_steered': true,
|
||||
};
|
||||
case 'chat_shells':
|
||||
|
||||
Reference in New Issue
Block a user