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,143 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/data/chat_create_harness_store.dart';
import 'package:pipelines_app/features/chat/data/chat_create_prompt_store.dart';
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
import 'package:pipelines_app/features/chat/ui/sessions/create_chat_dialog.dart';
import 'fake_chat_gateway.dart';
class _NoPrompts implements ChatCreatePromptStore {
@override
Future<ChatCreatePrompt?> read(String backend, String directory) async =>
null;
@override
Future<void> write(String b, String d, ChatCreatePrompt v) async {}
}
Future<List<ChatDraft>> _open(
WidgetTester tester,
ChatCreateHarnessStore harnesses,
) async {
final sent = <ChatDraft>[];
final gateway = FakeChatGateway()
..directoriesHandler = (() async => {
'chat_directories': ['/home/me', '/work/app', '/work/site'],
})
..backendsHandler = (() async => {
'chat_backends': ['claude', 'codex', 'opencode'],
});
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: CreateChatDialog(
repository: ChatRepository(gateway),
operationId: 'op',
prompts: _NoPrompts(),
harnesses: harnesses,
onSubmit: (draft, _) async {
sent.add(draft);
return {'id': 'new'};
},
),
),
),
);
await tester.pumpAndSettle();
return sent;
}
String _field(WidgetTester tester, String key) => tester
.widget<DropdownButtonFormField<String>>(find.byKey(Key(key)))
.initialValue!;
String _name(WidgetTester tester) => tester
.widget<TextField>(find.byKey(const Key('chat-create-name')))
.controller!
.text;
Future<void> _pickDirectory(WidgetTester tester, String directory) async {
await tester.tap(find.byKey(const Key('chat-create-server-directory')));
await tester.pumpAndSettle();
await tester.tap(find.text(directory).last);
await tester.pumpAndSettle();
}
Future<void> _confirm(WidgetTester tester) async {
await tester.ensureVisible(find.byKey(const Key('chat-create-confirm')));
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pumpAndSettle();
}
void main() {
test('the default harness: folder, then anywhere, then OpenCode', () {
const offered = ['claude', 'codex', 'opencode'];
expect(
chatDefaultHarness(offered, directoryLast: 'codex', anywhereLast: 'x'),
'codex',
);
expect(
chatDefaultHarness(offered, directoryLast: 'pi', anywhereLast: 'claude'),
'claude',
);
expect(chatDefaultHarness(offered), 'opencode');
expect(chatDefaultHarness(const ['codex', 'claude']), 'codex');
});
testWidgets('the name is prefilled; cleared, the harness names the chat', (
tester,
) async {
final sent = await _open(tester, MemoryChatCreateHarnessStore());
expect(_name(tester), 'Home OpenCode');
expect(find.text("Leave empty to use the harness's title"), findsOneWidget);
await tester.enterText(find.byKey(const Key('chat-create-name')), '');
await _pickDirectory(tester, '/work/app');
// A cleared name stays cleared when the folder changes.
expect(_name(tester), '');
await _confirm(tester);
expect(sent.single.title, '');
expect(sent.single.directory, '/work/app');
});
testWidgets('the harness follows the folder it was last used in', (
tester,
) async {
final store = MemoryChatCreateHarnessStore(
byDirectory: {'/work/app': 'codex'},
last: 'claude',
);
final sent = await _open(tester, store);
// Home remembers none: the harness last used anywhere.
expect(_field(tester, 'chat-create-backend'), 'claude');
expect(_name(tester), 'Home Claude');
await _pickDirectory(tester, '/work/app');
expect(_field(tester, 'chat-create-backend'), 'codex');
expect(_name(tester), 'App Codex');
await _confirm(tester);
expect(sent.single.backend, 'codex');
expect(sent.single.title, 'App Codex');
expect(store.byDirectory['/work/app'], 'codex');
expect(store.last, 'codex');
});
testWidgets('an explicit pick stays for a folder that remembers none', (
tester,
) async {
final store = MemoryChatCreateHarnessStore(
byDirectory: {'/work/app': 'codex'},
);
await _open(tester, store);
expect(_field(tester, 'chat-create-backend'), 'opencode');
await tester.tap(find.byKey(const Key('chat-create-backend')));
await tester.pumpAndSettle();
await tester.tap(find.text('Claude').last);
await tester.pumpAndSettle();
await _pickDirectory(tester, '/work/site');
expect(_field(tester, 'chat-create-backend'), 'claude');
await _pickDirectory(tester, '/work/app');
expect(_field(tester, 'chat-create-backend'), 'codex');
});
}
@@ -156,7 +156,7 @@ void main() {
_host(
child: const ChatMarkdownView(
text:
'```\nvery_long_identifier_very_long_identifier_very_long_identifier\n```\n\n| Heading one | Heading two | Heading three |\n| --- | --- | --- |\n| alpha alpha alpha | beta beta beta | gamma gamma gamma |',
'```\nvery_long_identifier_very_long_identifier_very_long_identifier\n```\n\n| H1 | H2 | H3 |\n| --- | --- | --- |\n| a a a a a a a a | b b b b b b | c c c c c c |',
),
),
);
@@ -23,16 +23,11 @@ void main() {
) async {
await pumpTable(
tester,
'| Item | Description | Status |\n| --- | --- | --- |\n'
// Short words, so every column's longest word fits side by side.
'| No | Text | Ok |\n| --- | --- | --- |\n'
'| one | ${List.filled(30, 'word').join(' ')} | done |',
);
expect(
find.descendant(
of: find.byType(ChatMarkdownView),
matching: find.byType(Scrollable),
),
findsNothing,
);
expect(find.text('Scroll horizontally'), findsNothing);
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
final description = tester.getSize(find.textContaining('word word'));
final status = tester.getSize(find.text('done'));
@@ -49,6 +44,44 @@ void main() {
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
});
testWidgets('a word is never broken to fit; the table scrolls instead', (
tester,
) async {
// Seven columns whose words cannot all fit 390 pixels side by side.
const words = ['Column', 'Another', 'Heading', 'Numbers', 'Remarks'];
await pumpTable(
tester,
'| ${words.join(' | ')} | Owner | Status |\n'
'| --- | --- | --- | --- | --- | --- | --- |\n'
'| a b | c d | e f | g h | i j | k l | m n |',
);
expect(find.text('Scroll horizontally'), findsOneWidget);
expect(
find.bySemanticsLabel('Horizontally scrollable table'),
findsOneWidget,
);
expect(tableRect(tester).width, greaterThan(screenRight));
// Each heading stays on one line: no word broke inside itself.
final line = tester.getSize(find.text('Owner')).height;
for (final word in words) {
expect(tester.getSize(find.text(word)).height, line);
}
});
testWidgets('a column keeps its longest word when the table fits', (
tester,
) async {
await pumpTable(
tester,
'| Column | Notes |\n| --- | --- |\n'
'| x | ${List.filled(40, 'note').join(' ')} |',
);
expect(find.text('Scroll horizontally'), findsNothing);
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
final header = tester.getSize(find.text('Column')).height;
expect(header, tester.getSize(find.text('x')).height);
});
testWidgets('a narrow table keeps its content width', (tester) async {
await pumpTable(tester, '| a | b |\n| --- | --- |\n| 1 | 2 |');
expect(tableRect(tester).width, lessThan(screenRight / 2));