Chat: unnamed chats take the harness title, harness default per folder, word-safe tables, Send later

- 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>
This commit is contained in:
2026-12-02 19:55:40 +00:00
parent c441400f36
commit b1fcdcf2c3
22 changed files with 1059 additions and 90 deletions
@@ -0,0 +1,86 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'chat_composer_bar_fixtures.dart';
final _send = find.byKey(const Key('chat-composer-primary'));
Future<ComposerBarGateway> _pumpDraft(WidgetTester tester, String text) async {
final gateway = ComposerBarGateway()..page = fixtureTurn();
addTearDown(gateway.close);
await tester.pumpWidget(
composerThread(gateway, newOperationId: () => 'op/1'),
);
await tester.pumpAndSettle();
await tester.enterText(find.byKey(const Key('chat-composer-field')), text);
await tester.pump();
return gateway;
}
void main() {
testWidgets('right-click on Send schedules the message with send_at', (
tester,
) async {
final gateway = await _pumpDraft(tester, 'Check the deploy');
final before = DateTime.now();
await tester.tap(_send, buttons: kSecondaryButton);
await tester.pumpAndSettle();
expect(find.text('Send later…'), findsOneWidget);
expect(find.text('Tomorrow at 9:00'), findsOneWidget);
// No usage report: no reset time to offer.
expect(find.byKey(const Key('chat-send-later-usageReset')), findsNothing);
await tester.tap(find.byKey(const Key('chat-send-later-hour')));
await tester.pumpAndSettle();
final body = gateway.promptBodies.single;
expect(body['text'], 'Check the deploy');
final sendAt = DateTime.fromMillisecondsSinceEpoch(body['send_at'] as int);
expect(sendAt.difference(before).inMinutes, inInclusiveRange(59, 61));
expect(fieldText(tester), isEmpty);
});
testWidgets('long-press opens it on touch, and Send still sends now', (
tester,
) async {
final gateway = await _pumpDraft(tester, 'Now please');
await tester.longPress(_send);
await tester.pumpAndSettle();
expect(find.byKey(const Key('chat-send-later-halfHour')), findsOneWidget);
await tester.tapAt(const Offset(5, 5));
await tester.pumpAndSettle();
await tester.tap(_send);
await tester.pumpAndSettle();
expect(gateway.promptBodies.single.containsKey('send_at'), isFalse);
});
testWidgets('the keyboard opens it from Send with Shift+F10', (tester) async {
final gateway = await _pumpDraft(tester, 'Later');
// Focus the Send button itself, as Tab would.
Focus.of(tester.element(find.byIcon(Icons.arrow_upward))).requestFocus();
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.f10);
await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
await tester.pumpAndSettle();
expect(find.byKey(const Key('chat-send-later-tomorrowMorning')), findsOne);
await tester.tap(find.byKey(const Key('chat-send-later-tomorrowMorning')));
await tester.pumpAndSettle();
final at = DateTime.fromMillisecondsSinceEpoch(
gateway.promptBodies.single['send_at'] as int,
);
expect((at.hour, at.minute), (9, 0));
});
testWidgets('a slash command cannot be scheduled', (tester) async {
final gateway = await _pumpDraft(tester, '/compact');
await tester.tap(_send, buttons: kSecondaryButton);
await tester.pumpAndSettle();
final item = tester.widget<MenuItemButton>(
find.byKey(const Key('chat-send-later-hour')),
);
expect(item.onPressed, isNull);
expect(gateway.promptBodies, isEmpty);
});
}