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:
@@ -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);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_default_name.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_sessions.dart';
|
||||
|
||||
void main() {
|
||||
test('an operator or harness title is shown as is', () {
|
||||
expect(
|
||||
chatSessionTitle({'id': 's', 'title': 'Fix login', 'directory': '/a'}),
|
||||
'Fix login',
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'an untitled chat shows the default name until the harness names it',
|
||||
() {
|
||||
expect(
|
||||
chatSessionTitle({
|
||||
'id': 'ses_1',
|
||||
'title': '',
|
||||
'directory': '/work/pipelines',
|
||||
'backend': 'codex',
|
||||
}),
|
||||
'Pipelines Codex',
|
||||
);
|
||||
expect(
|
||||
chatSessionTitle({
|
||||
'id': 'ses_2',
|
||||
'title': 'New session - 2026-12-02T09:00:00.000Z',
|
||||
'directory': '/work/site',
|
||||
'backend': 'opencode',
|
||||
}),
|
||||
'Site OpenCode',
|
||||
);
|
||||
// No backend field: an older server's chats are OpenCode.
|
||||
expect(
|
||||
chatSessionTitle({'id': 'ses_3', 'directory': '/work/site'}),
|
||||
'Site OpenCode',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('a row without a directory still falls back to its id', () {
|
||||
expect(chatSessionTitle({'id': 'ses_abc'}), 'ses_abc');
|
||||
expect(chatSessionTitle(const {}), 'Untitled chat');
|
||||
});
|
||||
|
||||
test('only blank titles and the placeholder count as unnamed', () {
|
||||
expect(chatHarnessTitle(' '), isNull);
|
||||
expect(chatHarnessTitle('Child session - 2026-01-01T00:00:00Z'), isNull);
|
||||
expect(chatHarnessTitle('New session notes'), 'New session notes');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_account_usage.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_send_later.dart';
|
||||
|
||||
ChatAccountUsage _usage(List<ChatQuotaWindow> windows) => ChatAccountUsage(
|
||||
harness: 'Claude Code',
|
||||
plan: 'max',
|
||||
asOf: 0,
|
||||
windows: windows,
|
||||
unsupported: false,
|
||||
);
|
||||
|
||||
void main() {
|
||||
final now = DateTime(2026, 12, 2, 14, 10);
|
||||
|
||||
test('quick times: 30 minutes, an hour, tomorrow at 9:00', () {
|
||||
final choices = chatSendLaterChoices(now);
|
||||
expect(choices.map((c) => c.kind), [
|
||||
ChatSendLaterKind.halfHour,
|
||||
ChatSendLaterKind.hour,
|
||||
ChatSendLaterKind.tomorrowMorning,
|
||||
]);
|
||||
expect(choices[0].at, DateTime(2026, 12, 2, 14, 40));
|
||||
expect(choices[1].at, DateTime(2026, 12, 2, 15, 10));
|
||||
expect(choices[2].at, DateTime(2026, 12, 3, 9));
|
||||
});
|
||||
|
||||
test('the usage reset is offered only when it is known and ahead', () {
|
||||
final reset = DateTime(2026, 12, 2, 17, 21);
|
||||
expect(chatSendLaterChoices(now, usageReset: reset).last, (
|
||||
kind: ChatSendLaterKind.usageReset,
|
||||
at: reset,
|
||||
));
|
||||
expect(
|
||||
chatSendLaterChoices(now, usageReset: now).map((c) => c.kind),
|
||||
isNot(contains(ChatSendLaterKind.usageReset)),
|
||||
);
|
||||
});
|
||||
|
||||
test('the reset: an exhausted window first, else the next reset', () {
|
||||
final soon = DateTime(2026, 12, 2, 17, 20).millisecondsSinceEpoch;
|
||||
final later = DateTime(2026, 12, 5, 9).millisecondsSinceEpoch;
|
||||
final reset = chatSendLaterUsageReset(
|
||||
_usage([
|
||||
ChatQuotaWindow(
|
||||
id: 'five_hour',
|
||||
label: '5-hour',
|
||||
usedPercent: 40,
|
||||
resetsAt: soon,
|
||||
),
|
||||
ChatQuotaWindow(
|
||||
id: 'week',
|
||||
label: 'Weekly',
|
||||
usedPercent: 100,
|
||||
resetsAt: later,
|
||||
),
|
||||
]),
|
||||
now,
|
||||
);
|
||||
expect(reset, DateTime(2026, 12, 5, 9, 1));
|
||||
expect(
|
||||
chatSendLaterUsageReset(
|
||||
_usage([
|
||||
ChatQuotaWindow(
|
||||
id: 'five_hour',
|
||||
label: '5-hour',
|
||||
usedPercent: 40,
|
||||
resetsAt: soon,
|
||||
),
|
||||
]),
|
||||
now,
|
||||
),
|
||||
DateTime(2026, 12, 2, 17, 21),
|
||||
);
|
||||
expect(chatSendLaterUsageReset(_usage(const []), now), isNull);
|
||||
expect(chatSendLaterUsageReset(null, now), isNull);
|
||||
});
|
||||
|
||||
test('a picked time is today when ahead, else tomorrow', () {
|
||||
expect(chatSendLaterAt(now, 18, 30), DateTime(2026, 12, 2, 18, 30));
|
||||
expect(chatSendLaterAt(now, 8, 0), DateTime(2026, 12, 3, 8));
|
||||
});
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user