b1fcdcf2c3
- New chat: a cleared Name creates the chat without an operator title; the list shows the harness's own title, or the default name until it has one. The server no longer records "New chat" for a blank title and OpenCode is created without a title so it names the session itself. - New chat harness defaults to the one last used in the chosen folder, else anywhere, else OpenCode; remembered on the device per server. - Markdown tables wrap at word boundaries and never go below a column's longest word (tokens over ~40 characters may break); a table whose words cannot fit scrolls sideways with the code block affordance. - Composer: right-click, long-press, Shift+F10 or the context menu key on Send opens Send later... (30 min, 1 h, tomorrow 9:00, usage reset, pick a time), sent through the same path with send_at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
2.1 KiB
Dart
59 lines
2.1 KiB
Dart
/// "Send later…": the quick times the composer offers for scheduling the
|
|
/// operator's own message (the server holds it until `send_at`).
|
|
library;
|
|
|
|
import 'chat_account_usage.dart';
|
|
import 'chat_usage_limit.dart';
|
|
|
|
enum ChatSendLaterKind { halfHour, hour, tomorrowMorning, usageReset }
|
|
|
|
typedef ChatSendLaterChoice = ({ChatSendLaterKind kind, DateTime at});
|
|
|
|
/// When the account's quota is back: the exhausted limit's reset if one is
|
|
/// reported, else the next reported window reset; a minute later, as
|
|
/// auto-continue does. Null when no reset time is known.
|
|
DateTime? chatSendLaterUsageReset(ChatAccountUsage? usage, DateTime now) {
|
|
final limit = chatUsageLimit(usage, now);
|
|
if (limit != null) return limit.sendAt;
|
|
if (usage == null || usage.unsupported) return null;
|
|
int? next;
|
|
for (final window in usage.windows) {
|
|
final at = window.resetsAt;
|
|
if (at <= now.millisecondsSinceEpoch) continue;
|
|
if (next == null || at < next) next = at;
|
|
}
|
|
if (next == null) return null;
|
|
return DateTime.fromMillisecondsSinceEpoch(next).add(chatScheduleMargin);
|
|
}
|
|
|
|
/// In 30 minutes, in 1 hour, tomorrow at 9:00 and, when known, at the usage
|
|
/// reset.
|
|
List<ChatSendLaterChoice> chatSendLaterChoices(
|
|
DateTime now, {
|
|
DateTime? usageReset,
|
|
}) {
|
|
final local = now.toLocal();
|
|
return [
|
|
(
|
|
kind: ChatSendLaterKind.halfHour,
|
|
at: local.add(const Duration(minutes: 30)),
|
|
),
|
|
(kind: ChatSendLaterKind.hour, at: local.add(const Duration(hours: 1))),
|
|
(
|
|
kind: ChatSendLaterKind.tomorrowMorning,
|
|
at: DateTime(local.year, local.month, local.day + 1, 9),
|
|
),
|
|
if (usageReset != null && usageReset.isAfter(now))
|
|
(kind: ChatSendLaterKind.usageReset, at: usageReset.toLocal()),
|
|
];
|
|
}
|
|
|
|
/// A picked time of day: today when it is still ahead, else tomorrow.
|
|
DateTime chatSendLaterAt(DateTime now, int hour, int minute) {
|
|
final local = now.toLocal();
|
|
final today = DateTime(local.year, local.month, local.day, hour, minute);
|
|
return today.isAfter(local)
|
|
? today
|
|
: DateTime(local.year, local.month, local.day + 1, hour, minute);
|
|
}
|