12c7642e35
Ctrl+K lists open chats most recently used first (tracked on open and pane focus, persisted per server) and preselects the previous chat, so Ctrl+K, Enter returns to it. Rows mark needs you / working / unread; a query also lists matching closed chats under Closed, and choosing one reopens it. Alt+N (Option+N) starts a new chat and Alt+J (Option+J) opens the next chat waiting for you, unread or failed, cycling; the terminal keeps both. In run detail, bare 1-4 switch tabs when not typing. Cheatsheet entries added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.5 KiB
Dart
45 lines
1.5 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/chat/data/chat_recency.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
void main() {
|
|
test('touch moves a chat to the front and persists the order', () async {
|
|
final store = MemoryChatRecencyStore(['b', 'a']);
|
|
final recency = ChatRecency(store: store);
|
|
await recency.load();
|
|
expect(recency.ids, ['b', 'a']);
|
|
recency.touch('a');
|
|
recency.touch('c');
|
|
expect(recency.ids, ['c', 'a', 'b']);
|
|
await Future<void>.delayed(Duration.zero);
|
|
expect(store.ids, ['c', 'a', 'b']);
|
|
});
|
|
|
|
test('a chat touched before the read stays in front', () async {
|
|
final recency = ChatRecency(store: MemoryChatRecencyStore(['b', 'a']));
|
|
recency.touch('a');
|
|
await recency.load();
|
|
expect(recency.ids, ['a', 'b']);
|
|
});
|
|
|
|
test('keeps at most the limit', () async {
|
|
final recency = ChatRecency(limit: 2);
|
|
for (final id in ['a', 'b', 'c']) {
|
|
recency.touch(id);
|
|
}
|
|
expect(recency.ids, ['c', 'b']);
|
|
});
|
|
|
|
test('shared preferences keep the order per server', () async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
const one = SharedPreferencesChatRecencyStore(serverScope: 'one');
|
|
const two = SharedPreferencesChatRecencyStore(serverScope: 'two');
|
|
await one.write(['x', 'y']);
|
|
expect(await one.read(), ['x', 'y']);
|
|
expect(await two.read(), isEmpty);
|
|
final reloaded = ChatRecency(store: one);
|
|
await reloaded.load();
|
|
expect(reloaded.ids, ['x', 'y']);
|
|
});
|
|
}
|