Chat: hide the chat list entirely (Ctrl+B / Cmd+B), per device

ListDetailPanes takes listHidden and slides the list to zero width (at once
with reduced motion), keeping its expanded or compact mode for when it comes
back. A wide chat offers Hide chat list in the list's bar and the pane menu,
Ctrl+B (Cmd+B on Apple; a focused terminal keeps Ctrl+B) and, while hidden,
a Show chat list button at the start of the top-left pane's bar. The choice
is device-local (pipelines.chat.listHidden.v1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 21:33:05 +00:00
parent 22ab20077b
commit 109ea72252
15 changed files with 631 additions and 11 deletions
@@ -0,0 +1,82 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_list_hidden_controller.dart';
import 'package:shared_preferences/shared_preferences.dart';
KeyDownEvent _b() => const KeyDownEvent(
physicalKey: PhysicalKeyboardKey.keyB,
logicalKey: LogicalKeyboardKey.keyB,
timeStamp: Duration.zero,
);
void main() {
test('the choice is kept per device and restored', () async {
SharedPreferences.setMockInitialValues({});
final first = ChatListHiddenController();
expect(first.value, isFalse);
first.toggle();
expect(first.value, isTrue);
await Future<void>.delayed(Duration.zero);
expect(
(await SharedPreferences.getInstance()).getBool(
chatListHiddenPreferenceKey,
),
isTrue,
);
final next = ChatListHiddenController();
await next.restore();
expect(next.value, isTrue);
});
test('a choice made while restoring wins', () async {
final store = MemoryChatListHiddenStore(true);
final controller = ChatListHiddenController(store: store);
final restoring = controller.restore();
controller.value = false;
await restoring;
expect(controller.value, isFalse);
});
testWidgets('Ctrl+B elsewhere, Cmd+B on Apple; no other chord', (
tester,
) async {
final keyboard = HardwareKeyboard.instance;
Future<bool> matches(
List<LogicalKeyboardKey> modifiers,
TargetPlatform platform,
) async {
for (final key in modifiers) {
await tester.sendKeyDownEvent(key);
}
final result = chatListToggleShortcut(_b(), keyboard, platform: platform);
for (final key in modifiers.reversed) {
await tester.sendKeyUpEvent(key);
}
return result;
}
const linux = TargetPlatform.linux;
const mac = TargetPlatform.macOS;
expect(await matches([LogicalKeyboardKey.controlLeft], linux), isTrue);
expect(await matches([LogicalKeyboardKey.metaLeft], mac), isTrue);
expect(await matches([LogicalKeyboardKey.controlLeft], mac), isFalse);
expect(await matches([LogicalKeyboardKey.metaLeft], linux), isFalse);
expect(
await matches([
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.shiftLeft,
], linux),
isFalse,
);
expect(
await matches([
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.altLeft,
], linux),
isFalse,
);
expect(await matches(const [], linux), isFalse);
expect(chatListToggleLabel(true, linux), 'Show chat list (Ctrl+B)');
expect(chatListToggleLabel(false, mac), 'Hide chat list (Cmd+B)');
});
}