Files
pipelines/app/test/features/chat/domain/chat_commands_test.dart
T
alan ad4233f7b8 Chat: /new continues the same chat on a fresh session
The composer's /new used to create a separate chat. It now sends
chat_new_session. The server starts a fresh native session on the chat's
own harness (OpenCode, Codex or Claude Code) and re-keys the
operator_sessions row in one transaction. The chat keeps its title,
directory, backend, colour, star, model and mode. The old row is kept
unlisted with replaced_by, and its native session stays resumable.

The reply and the chat_session_changed push carry previous_id, so every
client swaps the row in place and an open conversation follows it to the
fresh, empty transcript with a notice.
2026-11-03 14:06:44 +00:00

94 lines
3.1 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/domain/chat_commands.dart';
void main() {
test('records the web command list verbatim and in order', () {
expect(chatCommands.map((command) => command.name), [
'new',
'close',
'rename',
'stop',
'help',
]);
expect(chatCommands.map((command) => command.usage), [
'/new',
'/close',
'/rename <title>',
'/stop',
'/help',
]);
expect(chatCommands.map((command) => command.summary), [
'Clear the context: continue this chat in a fresh session',
'Finish this session for every client, keeping its history',
'Rename this session',
'Stop the turn that is running',
'List every command',
]);
expect(
chatCommands.where((command) => command.takesArgument).map((c) => c.name),
['rename'],
);
});
test('a bare slash offers every recorded command', () {
expect(chatCommandSuggestions('/'), chatCommands);
expect(chatCommandSuggestions(' /'), chatCommands);
});
test('the name prefix filters case-insensitively', () {
expect(chatCommandSuggestions('/n').map((command) => command.name), [
'new',
]);
expect(chatCommandSuggestions('/re').map((command) => command.name), [
'rename',
]);
expect(chatCommandSuggestions('/CL').map((command) => command.name), [
'close',
]);
expect(chatCommandSuggestions('/s').map((command) => command.name), [
'stop',
]);
});
test('an argument, plain text or an unknown word offers nothing', () {
expect(chatCommandSuggestions('/close '), isEmpty);
expect(chatCommandSuggestions('/rename My chat'), isEmpty);
expect(chatCommandSuggestions('/zzz'), isEmpty);
expect(chatCommandSuggestions('hello'), isEmpty);
expect(chatCommandSuggestions(''), isEmpty);
});
test('the query is only the single slash word', () {
expect(chatCommandQuery('/Help'), 'help');
expect(chatCommandQuery(' /He'), 'he');
expect(chatCommandQuery('/help '), isNull);
expect(chatCommandQuery('help'), isNull);
});
test('the slash word carries any argument and is null without a slash', () {
expect(chatCommandWord('/close'), '/close');
expect(chatCommandWord(' /close now'), '/close');
expect(chatCommandWord('/rename My chat'), '/rename');
expect(chatCommandWord('plain'), isNull);
expect(chatCommandWord('/'), '/');
expect(chatCommandNamed('/CLOSE'), chatCommands[1]);
expect(chatCommandNamed('/close'), chatCommands[1]);
expect(chatCommandNamed('/rename My chat'), chatCommands[2]);
expect(chatCommandNamed('/zzz'), isNull);
expect(chatCommandNamed('/close now'), chatCommands[1]);
expect(chatCommandNamed('plain'), isNull);
});
test('the parsed reports keep the web client words', () {
expect(
chatUnknownCommandReport('/nope'),
'“/nope” is not a command, so nothing was sent to the agent. '
'Send it as a message, or cancel.',
);
expect(
chatCommandUnavailableReport('/close'),
'“/close” is not available yet, so nothing was sent to the agent.',
);
});
}