Merge current main and preserve Material chat cleanup
This commit is contained in:
@@ -16,7 +16,9 @@ import 'package:pipelines_app/shell/windows/window_host.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_kind.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_manager.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_store.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_entry.dart';
|
||||
import 'package:pipelines_app/ui/motion/fade_through_stack.dart';
|
||||
import 'package:pipelines_app/ui/input/keyboard_owner.dart';
|
||||
|
||||
import 'conversation/chat_thread_fixtures.dart';
|
||||
|
||||
@@ -46,6 +48,19 @@ class _Store implements WindowStore {
|
||||
}
|
||||
}
|
||||
|
||||
class _TerminalKind extends WindowKind {
|
||||
@override
|
||||
String get key => 'terminal';
|
||||
@override
|
||||
bool get serverScoped => false;
|
||||
@override
|
||||
IconData get icon => Icons.terminal;
|
||||
@override
|
||||
String title(BuildContext context, WindowEntry entry) => entry.contentId;
|
||||
@override
|
||||
Widget build(BuildContext context, WindowEntry entry) => const SizedBox();
|
||||
}
|
||||
|
||||
Finder _thread(String id) => find.byWidgetPredicate(
|
||||
(widget) => widget is ChatThreadView && widget.sessionId == id,
|
||||
skipOffstage: false,
|
||||
@@ -83,21 +98,21 @@ class _App {
|
||||
late final ChatRuntime runtime;
|
||||
late final WindowManager manager;
|
||||
late final ChatWindows windows;
|
||||
final terminalFocus = FocusNode(debugLabel: 'test terminal');
|
||||
final terminalTyped = <LogicalKeyboardKey>[];
|
||||
|
||||
Future<void> start(
|
||||
WidgetTester tester, {
|
||||
Size size = const Size(1800, 1000),
|
||||
bool terminalSurface = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
bindServerIdentity(gateway, 'server-a');
|
||||
runtime = ChatRuntime(gateway: gateway, serverKey: 'server-a');
|
||||
manager = WindowManager(
|
||||
kinds: WindowKinds(),
|
||||
store: store,
|
||||
server: 'server-a',
|
||||
);
|
||||
final kinds = WindowKinds()..register(_TerminalKind());
|
||||
manager = WindowManager(kinds: kinds, store: store, server: 'server-a');
|
||||
windows = ChatWindows(
|
||||
manager: manager,
|
||||
runtime: runtime,
|
||||
@@ -131,6 +146,21 @@ class _App {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (terminalSurface)
|
||||
Positioned.fill(
|
||||
child: TypingSurface(
|
||||
child: Focus(
|
||||
focusNode: terminalFocus,
|
||||
onKeyEvent: (node, event) {
|
||||
if (event is KeyDownEvent) {
|
||||
terminalTyped.add(event.logicalKey);
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
},
|
||||
child: const SizedBox(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned.fill(child: WindowHost(manager: manager)),
|
||||
],
|
||||
),
|
||||
@@ -147,6 +177,7 @@ class _App {
|
||||
manager.dispose();
|
||||
destination.dispose();
|
||||
chatBuilt.dispose();
|
||||
terminalFocus.dispose();
|
||||
gateway.close();
|
||||
}
|
||||
|
||||
@@ -187,6 +218,13 @@ Future<void> _chord(WidgetTester tester) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> _controlChord(WidgetTester tester) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyY);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Float and Dock move the live chat with its draft', (
|
||||
tester,
|
||||
@@ -391,6 +429,36 @@ void main() {
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Ctrl+Y from a terminal raises chat and focuses its composer',
|
||||
(tester) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester, terminalSurface: true);
|
||||
await _menu(tester, 'b', 'Float (Option+Y)');
|
||||
app.manager.open('terminal', 'terminal');
|
||||
app.terminalFocus.requestFocus();
|
||||
await tester.pump();
|
||||
|
||||
await _controlChord(tester);
|
||||
final input = _input('b');
|
||||
expect(_shown('Chat b'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<EditableText>(input).focusNode.hasPrimaryFocus,
|
||||
isTrue,
|
||||
);
|
||||
tester.testTextInput.enterText('from terminal');
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester.widget<EditableText>(input).controller.text,
|
||||
'from terminal',
|
||||
);
|
||||
expect(app.terminalTyped, isEmpty);
|
||||
await app.stop(tester);
|
||||
},
|
||||
variant: const TargetPlatformVariant({TargetPlatform.macOS}),
|
||||
);
|
||||
|
||||
testWidgets('floating chats saved by an older build come back as windows', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -5,6 +5,8 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/search/search_screen.dart';
|
||||
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -51,6 +53,11 @@ Future<void> _setup(WidgetTester tester) async {
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||
AppDestination.search: (_) => SearchScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (_) {},
|
||||
embedded: true,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -104,8 +111,8 @@ void main() {
|
||||
expect(await _slash(tester), isFalse);
|
||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isTrue);
|
||||
|
||||
// Shift+/ (a question mark) and Alt+/ are not the shortcut; Ctrl+/ is
|
||||
// the shell's own Search chord.
|
||||
// Shift+/ (a question mark) is not the shortcut. Alt+/ opens the Search
|
||||
// destination, while Ctrl+/ remains the shell's own Search chord.
|
||||
await _focusSidebar(tester);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.slash, character: '?');
|
||||
@@ -114,7 +121,11 @@ void main() {
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.slash);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.pumpAndSettle();
|
||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
|
||||
expect(find.byKey(searchFieldKey), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<TextField>(find.byKey(searchFieldKey)).focusNode!.hasFocus,
|
||||
isTrue,
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
|
||||
@@ -135,6 +135,20 @@ void main() {
|
||||
expect(find.text('model-b'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('choosing the current model only dismisses the chooser', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = _ModelGateway()..modelsReply = _catalog;
|
||||
await _openThread(tester, gateway);
|
||||
await _openChooser(tester);
|
||||
|
||||
await tester.tap(find.text('Model Alpha'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('chat-model-chooser')), findsNothing);
|
||||
expect(gateway.lastFields('chat_model'), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a refusal keeps the previous model and shows the reason', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
}) async {
|
||||
final bubble = ChatBubbleColor(
|
||||
name: color,
|
||||
child: const ChatUserBubble(cupertino: false, child: Text('Hello')),
|
||||
child: const ChatUserBubble(child: Text('Hello')),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -68,9 +68,7 @@ void main() {
|
||||
testWidgets('a bubble with no colour scope stays neutral', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChatUserBubble(cupertino: false, child: Text('Hello')),
|
||||
),
|
||||
home: Scaffold(body: ChatUserBubble(child: Text('Hello'))),
|
||||
),
|
||||
);
|
||||
final context = tester.element(find.byType(ChatUserBubble));
|
||||
|
||||
@@ -232,7 +232,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'on macOS Ctrl+Y in a terminal stays with it; Cmd+Y and Option+Y toggle',
|
||||
'on macOS Ctrl+Y from a terminal raises chat; Cmd+Y and Option+Y toggle',
|
||||
(tester) async {
|
||||
await wide(tester);
|
||||
final typing = FocusNode();
|
||||
@@ -256,12 +256,12 @@ void main() {
|
||||
typing.requestFocus();
|
||||
await tester.pump();
|
||||
await _chord(tester, LogicalKeyboardKey.controlLeft);
|
||||
expect(h.manager.groupShown(chatWindowKind), isTrue);
|
||||
expect(typed, contains(LogicalKeyboardKey.keyY));
|
||||
await _chord(tester, LogicalKeyboardKey.metaLeft);
|
||||
expect(h.manager.groupShown(chatWindowKind), isFalse);
|
||||
await _chord(tester);
|
||||
expect(typed, isNot(contains(LogicalKeyboardKey.keyY)));
|
||||
await _chord(tester, LogicalKeyboardKey.metaLeft);
|
||||
expect(h.manager.groupShown(chatWindowKind), isTrue);
|
||||
await _chord(tester);
|
||||
expect(h.manager.groupShown(chatWindowKind), isFalse);
|
||||
},
|
||||
variant: const TargetPlatformVariant({TargetPlatform.macOS}),
|
||||
);
|
||||
|
||||
@@ -29,6 +29,10 @@ void main() {
|
||||
chord({LogicalKeyboardKey.controlLeft}, TargetPlatform.linux),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
chord({LogicalKeyboardKey.controlLeft}, TargetPlatform.macOS),
|
||||
isTrue,
|
||||
);
|
||||
expect(chord({LogicalKeyboardKey.metaLeft}, TargetPlatform.linux), isFalse);
|
||||
expect(chord({LogicalKeyboardKey.metaLeft}, TargetPlatform.macOS), isTrue);
|
||||
expect(
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/keyboard_shortcuts_help.dart';
|
||||
import 'package:pipelines_app/features/settings/keyboard_shortcuts_registry.dart';
|
||||
|
||||
void main() {
|
||||
const registry = KeyboardShortcutRegistry(
|
||||
platform: TargetPlatform.macOS,
|
||||
web: true,
|
||||
);
|
||||
|
||||
test('registry uses platform labels and browser caveats', () {
|
||||
final entries = registry.entries;
|
||||
final terminal = entries.firstWhere(
|
||||
(entry) => entry.action == 'Show or hide terminal',
|
||||
);
|
||||
final search = entries.firstWhere((entry) => entry.action == 'Open Search');
|
||||
|
||||
expect(terminal.keys, contains('Option+T'));
|
||||
expect(terminal.keys, isNot(contains('Cmd+T')));
|
||||
expect(search.keys, 'Option+/, Cmd+/, Ctrl+/');
|
||||
expect(search.caveat, contains('browser'));
|
||||
});
|
||||
|
||||
test('uses the shell primary modifier rule on iOS', () {
|
||||
final entries = const KeyboardShortcutRegistry(
|
||||
platform: TargetPlatform.iOS,
|
||||
web: false,
|
||||
).entries;
|
||||
expect(
|
||||
entries
|
||||
.firstWhere((entry) => entry.action == 'Open a chat list item')
|
||||
.keys,
|
||||
'Ctrl+1…9',
|
||||
);
|
||||
expect(
|
||||
entries.firstWhere((entry) => entry.action == 'Open Search').keys,
|
||||
'Option+/, Ctrl+/',
|
||||
);
|
||||
expect(
|
||||
entries
|
||||
.firstWhere((entry) => entry.action == 'Show or hide floating chats')
|
||||
.caveat,
|
||||
contains('focuses its message input'),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('help is readable and keyboard traversable', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: KeyboardShortcutsHelp(registry: registry),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Keyboard shortcuts'), findsOneWidget);
|
||||
expect(find.text('Show or hide floating chats'), findsOneWidget);
|
||||
expect(find.text('Option+Y, Ctrl+Y, Cmd+Y'), findsOneWidget);
|
||||
expect(
|
||||
tester.getSemantics(find.bySemanticsLabel('Keyboard shortcuts help')),
|
||||
matchesSemantics(
|
||||
scopesRoute: true,
|
||||
namesRoute: true,
|
||||
label: 'Keyboard shortcuts help',
|
||||
),
|
||||
);
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
expect(find.byTooltip('Close keyboard shortcuts'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('narrow help content scrolls', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(
|
||||
size: Size(400, 640),
|
||||
textScaler: TextScaler.linear(2),
|
||||
),
|
||||
child: MaterialApp(
|
||||
home: Scaffold(body: KeyboardShortcutsHelp(registry: registry)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(SingleChildScrollView), findsOneWidget);
|
||||
expect(find.text('Keyboard shortcuts'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -84,7 +84,6 @@ class TerminalTestAppState extends State<TerminalTestApp> {
|
||||
Widget build(BuildContext context) => TerminalSurface(
|
||||
hub: widget.hub,
|
||||
layout: widget.layout,
|
||||
cupertino: false,
|
||||
shortcutHere: widget.shortcutHere,
|
||||
floating: floating,
|
||||
windows: WindowHost(manager: manager),
|
||||
@@ -92,7 +91,7 @@ class TerminalTestAppState extends State<TerminalTestApp> {
|
||||
appBar: AppBar(
|
||||
title: const Text('App'),
|
||||
actions: [
|
||||
TerminalToggleButton(layout: widget.layout, cupertino: false),
|
||||
TerminalToggleButton(layout: widget.layout),
|
||||
],
|
||||
),
|
||||
body: const TextField(key: appField),
|
||||
|
||||
@@ -62,7 +62,6 @@ void main() {
|
||||
home: TerminalSurface(
|
||||
hub: hub,
|
||||
layout: layout,
|
||||
cupertino: false,
|
||||
child: AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
|
||||
Reference in New Issue
Block a user