Chat: Ctrl+K / Alt+K on Chat opens a quick switcher for the open chats
On Chat the chord now toggles a centred dialog (bottom sheet on a phone) with an autofocused filter over the open chats in list order; Ctrl+N/Down and Ctrl+P/Up move the wrapping selection, Enter opens the chat as Ctrl+Tab does (pane reused, composer focused), Esc or the chord closes it. From other destinations the chord still jumps to Chat. Ctrl+N/Ctrl+P are handled so the web page prevents their defaults (Ctrl+P no longer prints); a browser tab keeps Ctrl+N reserved, documented in the help and notes/chat-quick-switch.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_quick_switch.dart';
|
||||
|
||||
final rows = <JsonMap>[
|
||||
{'id': 'r1', 'title': 'Recent work', 'directory': '/home/a/alpha'},
|
||||
{'id': 'z', 'title': 'Zeta notes', 'starred': true},
|
||||
{
|
||||
'id': 'r2',
|
||||
'title': 'Older',
|
||||
'directory': '/home/a/beta',
|
||||
'backend': 'codex',
|
||||
},
|
||||
{'id': 'r3', 'title': 'Same folder', 'directory': '/home/a/alpha'},
|
||||
{'id': 'a', 'title': 'Alpha starred', 'starred': true},
|
||||
{'id': 'c', 'title': 'Closed one', 'closed_at': 5},
|
||||
{'id': 'x', 'title': 'Closed flag', 'closed': true},
|
||||
{
|
||||
'id': 'f',
|
||||
'title': 'Far away',
|
||||
'_server_id': 'm2',
|
||||
'_server_name': 'Studio',
|
||||
},
|
||||
];
|
||||
|
||||
List<String> ids(List<JsonMap> rows) => [
|
||||
for (final row in rows) '${row['id']}',
|
||||
];
|
||||
|
||||
void main() {
|
||||
test('no query lists open chats in list order, starred first', () {
|
||||
// Starred by name, then Chats by directory group in server recency.
|
||||
expect(ids(chatQuickSwitchCandidates(rows)), [
|
||||
'a',
|
||||
'z',
|
||||
'r1',
|
||||
'r3',
|
||||
'r2',
|
||||
'f',
|
||||
]);
|
||||
});
|
||||
|
||||
test('a query narrows by title, directory, harness and machine', () {
|
||||
final open = chatQuickSwitchCandidates(rows);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'beta')), ['r2']);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'CODEX')), ['r2']);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'studio')), ['f']);
|
||||
expect(
|
||||
ids(chatQuickSwitchMatches(open, 'lab', serverName: (_) => 'Lab box')),
|
||||
['a', 'z', 'r1', 'r3', 'r2', 'f'],
|
||||
);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'closed')), isEmpty);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'nothing here')), isEmpty);
|
||||
expect(ids(chatQuickSwitchMatches(open, ' ')), ids(open));
|
||||
});
|
||||
|
||||
test('title starts rank before word starts, then substrings', () {
|
||||
final open = chatQuickSwitchCandidates(<JsonMap>[
|
||||
{'id': 'mid', 'title': 'kalpha'},
|
||||
{'id': 'dir', 'title': 'Other', 'directory': '/src/alpha'},
|
||||
{'id': 'word', 'title': 'The alpha plan'},
|
||||
{'id': 'start', 'title': 'Alpha first'},
|
||||
{'id': 'inner', 'title': 'Other', 'directory': '/src/xalphax'},
|
||||
]);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'alp')), [
|
||||
'start',
|
||||
'word',
|
||||
'dir',
|
||||
'mid',
|
||||
'inner',
|
||||
]);
|
||||
});
|
||||
|
||||
test('every word must match; ranks add up', () {
|
||||
final open = chatQuickSwitchCandidates(rows);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'same alpha')), ['r3']);
|
||||
expect(ids(chatQuickSwitchMatches(open, 'alpha')), ['a', 'r1', 'r3']);
|
||||
});
|
||||
|
||||
test('an unnamed harness is OpenCode', () {
|
||||
expect(chatQuickSwitchHarness({'id': 'q'}), 'opencode');
|
||||
expect(chatQuickSwitchHarness({'backend': 'claude'}), 'claude');
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user