wip(app): chat /stop and /help commands (retained from the cancelled lane)

This commit is contained in:
2026-10-22 21:16:13 +01:00
parent 1bcc26a4fd
commit 65b175b8e5
3 changed files with 186 additions and 35 deletions
@@ -200,7 +200,7 @@ void main() {
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close');
expect(fieldText(tester), '');
expect(
find.text(
'“/close” is not available yet, so nothing was sent to the agent.',
@@ -208,28 +208,100 @@ void main() {
findsOneWidget,
);
// The primary control and the explicit send shortcut take the same path.
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close');
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close');
// An argument does not make the slash draft sendable either.
// An argument is validated locally, then consumed too.
await tester.enterText(field, '/close now');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/close now');
expect(fieldText(tester), '');
expect(find.text('/close does not take an argument.'), findsOneWidget);
});
testWidgets('/help consumes the draft and lists commands in recorded order', (
tester,
) async {
await pumpComposer(tester);
await tester.enterText(
find.byKey(const Key('chat-composer-field')),
'/help',
);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(gateway.promptBodies, isEmpty);
expect(
find.text(
'/new — Start a fresh session in this directory\n'
'/close — Finish this session for every client, keeping its history\n'
'/rename <title> — Rename this session on this device\n'
'/stop — Stop the turn that is running\n'
'/help — List every command',
),
findsOneWidget,
);
expect(find.text('Command'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-command-dismiss')));
await tester.pump();
expect(find.byKey(const Key('chat-composer-command-notice')), findsNothing);
});
testWidgets('/stop without a running turn and extra arguments fail locally', (
tester,
) async {
await pumpComposer(tester);
final field = find.byKey(const Key('chat-composer-field'));
await tester.enterText(field, '/stop');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(gateway.interruptBodies, isEmpty);
expect(find.text('Command failed'), findsOneWidget);
expect(find.text('No turn is running in this chat.'), findsOneWidget);
await tester.enterText(field, '/help x');
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(fieldText(tester), '');
expect(find.text('/help does not take an argument.'), findsOneWidget);
expect(gateway.promptBodies, isEmpty);
});
testWidgets('/stop interrupts the current session through the composer', (
tester,
) async {
await pumpComposer(tester);
gateway.emitEvent({
'session_id': 's',
'kind': 'step',
'step': {'status': 'started', 'turn_id': 'turn', 'intermediate': false},
});
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('chat-composer-field')),
'/stop',
);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(gateway.interruptBodies, [
<String, dynamic>{'session_id': 's'},
]);
expect(fieldText(tester), '');
expect(gateway.promptBodies, isEmpty);
});
testWidgets('a command picked from the palette is never sent either', (
@@ -244,17 +316,15 @@ void main() {
await tester.pumpAndSettle();
expect(fieldText(tester), '/help');
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pumpAndSettle();
expect(gateway.promptBodies, isEmpty);
expect(fieldText(tester), '/help');
expect(
find.text(
'“/help” is not available yet, so nothing was sent to the agent.',
),
findsOneWidget,
);
expect(fieldText(tester), '');
expect(find.text('Command'), findsOneWidget);
expect(find.textContaining('/help — List every command'), findsOneWidget);
});
testWidgets('a row completes the command and never prompts', (tester) async {