Merge branch 'main' into pipelines/run-20261112-2323-read-chat-replies-aloud-with-word-highli-e079

This commit is contained in:
2026-11-13 01:29:09 +00:00
18 changed files with 668 additions and 126 deletions
@@ -11,7 +11,6 @@ import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/chat/windows/chat_windows.dart';
import 'package:pipelines_app/features/chat/workspace/chat_float_store.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
import 'package:pipelines_app/features/chat/shell/chat_shell_command.dart';
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
import 'package:pipelines_app/shell/windows/window_frame.dart';
@@ -236,12 +235,16 @@ Future<List<String>> _listMenu(WidgetTester tester, String id) async {
// Windows sit over the list, so the list's menu is reached with them hidden.
await tester.tap(find.byTooltip('Chat actions for Chat $id').first);
await tester.pumpAndSettle();
// A wide app shows an anchored menu; a phone shows a bottom sheet of rows.
final rows = find.byType(PopupMenuItem<Object>).evaluate().isNotEmpty
? find.byType(PopupMenuItem<Object>)
: find.descendant(
of: find.byType(BottomSheet),
matching: find.byType(ListTile),
);
return [
for (final text in tester.widgetList<Text>(
find.descendant(
of: find.byType(PopupMenuItem<Object>),
matching: find.byType(Text),
),
find.descendant(of: rows, matching: find.byType(Text)),
))
text.data!,
];
@@ -788,7 +791,9 @@ void main() {
await tester.tap(finder.first);
await tester.pumpAndSettle();
expect(find.textContaining('Float'), findsNothing);
expect(find.text('Open chats (2)'), findsOneWidget);
// A phone's menu is a bottom sheet.
expect(find.byType(BottomSheet), findsOneWidget);
expect(find.text('Open chats (2)'), findsNothing);
await app.stop(tester);
});
@@ -808,13 +813,15 @@ void main() {
'Open below',
'Float (Alt+Y)',
'Add chat pane',
'Open chats (2)',
'Close pane',
'Files',
'Run command…',
'Star',
// Closing comes last.
'Close pane',
]),
);
expect(labels, isNot(contains('Open chats (2)')));
expect(labels, isNot(contains('Run command…')));
expect(labels.last, 'Close chat…');
expect(labels.any((label) => label.startsWith('Center stage')), isTrue);
// Only a window's own pane offers Chat details, and no terminal is wired.
expect(labels, isNot(contains('Chat details')));
@@ -900,24 +907,6 @@ void main() {
await app.stop(tester);
});
testWidgets('a list choice runs the command dialog for its chat', (
tester,
) async {
await _saved('a', 'b');
final app = _App(_Store());
await app.start(tester);
app.manager.setGroupShown(chatWindowKind, false);
await tester.pumpAndSettle();
await _listChoice(tester, 'b', 'Run command…');
expect(find.text(chatShellRunDialogTitle), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a', 'b']);
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('narrow layouts offer the list the panes it can reach', (
tester,
) async {
@@ -929,7 +918,7 @@ void main() {
await tester.pumpAndSettle();
final labels = await _listMenu(tester, 'b');
expect(labels, contains('Add chat pane'));
expect(labels, contains('Open chats (2)'));
expect(labels, isNot(contains('Open chats (2)')));
expect(labels.any((label) => label.startsWith('Center stage')), isFalse);
expect(labels, isNot(contains('Float (Alt+Y)')));
expect(labels, isNot(contains('Open to the right')));
@@ -106,7 +106,11 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.keyA);
await tester.pump();
expect(count, 0, reason: 'a key with no focus in the pane is not its input');
expect(
count,
0,
reason: 'a key with no focus in the pane is not its input',
);
focus.requestFocus();
await tester.pump();
@@ -116,7 +120,9 @@ void main() {
expect(count, 1);
});
testWidgets('code-driven focus into the pane reports nothing', (tester) async {
testWidgets('code-driven focus into the pane reports nothing', (
tester,
) async {
var count = 0;
final focus = FocusNode();
addTearDown(focus.dispose);
@@ -127,7 +133,11 @@ void main() {
await tester.pump(const Duration(seconds: 1));
expect(focus.hasFocus, isTrue);
expect(count, 0, reason: 'focus moved in code, with no key press, is passive');
expect(
count,
0,
reason: 'focus moved in code, with no key press, is passive',
);
});
testWidgets('Tab from outside the pane into it reports once', (tester) async {
@@ -38,8 +38,12 @@ void main() {
tester,
) async {
final gateway = await pumpThread(tester);
await tester.tap(find.byTooltip('More actions').hitTestable().first);
await tester.pumpAndSettle();
// With nothing else to offer, the bar shows no More menu at all.
final more = find.byTooltip('More actions').hitTestable();
if (more.evaluate().isNotEmpty) {
await tester.tap(more.first);
await tester.pumpAndSettle();
}
expect(find.text('Stop'), findsNothing);
expect(gateway.interruptBodies, isEmpty);
});
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar_overflow.dart';
import 'chat_shell_fixtures.dart';
@@ -66,25 +65,4 @@ void main() {
expect(find.text('Type a command after !.'), findsOneWidget);
expect(gateway.bodies('chat_shell_run'), isEmpty);
});
testWidgets('Run command… in the actions menu runs the typed command', (
tester,
) async {
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.tap(find.byKey(segmentedMoreKey).hitTestable().first);
await tester.pumpAndSettle();
await tester.tap(find.text('Run command…'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('chat-shell-run-field')),
' ls -la ',
);
await tester.tap(find.byKey(const Key('chat-shell-run-confirm')));
// The running card's indicator never settles; let the dialog close.
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(gateway.bodies('chat_shell_run').single['command'], 'ls -la');
expect(find.text('\$ ls -la'), findsOneWidget);
});
}
@@ -71,9 +71,12 @@ void main() {
gateway.runs = [shellRecord('run_live')];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.tap(find.byKey(segmentedMoreKey).hitTestable().first);
await tester.pump(const Duration(milliseconds: 500));
expect(find.text('Run command…'), findsOneWidget);
// With nothing else to offer, the bar shows no More menu at all.
final more = find.byKey(segmentedMoreKey).hitTestable();
if (more.evaluate().isNotEmpty) {
await tester.tap(more.first);
await tester.pump(const Duration(milliseconds: 500));
}
expect(find.text('Dismiss all finished commands'), findsNothing);
});
@@ -174,9 +174,6 @@ void main() {
await tester.pumpAndSettle();
final scrim = find.byKey(const ValueKey('chat-pane-dim-scrim')).first;
expect(
tester.widget<AnimatedContainer>(scrim).duration,
Motion.standard,
);
expect(tester.widget<AnimatedContainer>(scrim).duration, Motion.standard);
});
}
@@ -0,0 +1,177 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar_overflow.dart';
import 'package:pipelines_app/ui/layout/app_overflow_menu.dart';
void _size(WidgetTester tester, double width) {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
Widget _menu(void Function(String) picked) => MaterialApp(
home: Scaffold(
body: Center(
child: AppOverflowMenu<String>(
key: const Key('menu'),
sheetTitle: 'notes.md',
sheetSubtitle: 'Markdown · 2 KB',
onSelected: (_, value) => picked(value),
actions: const [
AppMenuAction(
value: 'delete',
label: 'Delete…',
icon: Icons.delete_outline,
destructive: true,
),
AppMenuAction(value: 'open', label: 'Open', icon: Icons.open_in_new),
AppMenuAction(
value: 'rename',
label: 'Rename…',
icon: Icons.edit_outlined,
),
],
),
),
),
);
void main() {
testWidgets('a phone opens a headed sheet with icon rows and destructive '
'actions last', (tester) async {
_size(tester, 430);
String? picked;
await tester.pumpWidget(_menu((value) => picked = value));
await tester.tap(find.byKey(const Key('menu')));
await tester.pumpAndSettle();
expect(find.byType(BottomSheet), findsOneWidget);
expect(find.text('notes.md'), findsOneWidget);
expect(find.text('Markdown · 2 KB'), findsOneWidget);
final rows = find.descendant(
of: find.byType(BottomSheet),
matching: find.byType(ListTile),
);
expect(rows, findsNWidgets(3));
final labels = [
for (final tile in tester.widgetList<ListTile>(rows))
(tile.title! as Text).data,
];
expect(labels, ['Open', 'Rename…', 'Delete…']);
for (final icon in [
Icons.open_in_new,
Icons.edit_outlined,
Icons.delete_outline,
]) {
expect(
find.descendant(of: rows, matching: find.byIcon(icon)),
findsOneWidget,
);
}
// Rows are full width and at least 56 px tall.
final open = tester.getRect(find.widgetWithText(ListTile, 'Open'));
expect(open.height, greaterThanOrEqualTo(56));
expect(open.width, closeTo(430, 1));
// The destructive row reads in the error colour.
final scheme = Theme.of(tester.element(rows.first)).colorScheme;
final deleteText = tester.widget<Text>(find.text('Delete…'));
expect(deleteText.style?.color, scheme.error);
await tester.tap(find.text('Rename…'));
await tester.pumpAndSettle();
expect(find.byType(BottomSheet), findsNothing);
expect(picked, 'rename');
});
testWidgets(
'a wide app keeps an anchored menu with icons, destructive last',
(tester) async {
_size(tester, 1200);
String? picked;
await tester.pumpWidget(_menu((value) => picked = value));
await tester.tap(find.byKey(const Key('menu')));
await tester.pumpAndSettle();
expect(find.byType(BottomSheet), findsNothing);
final items = find.byType(PopupMenuItem<String>);
expect(items, findsNWidgets(3));
expect(
[
for (final item in tester.widgetList<PopupMenuItem<String>>(items))
item.value,
],
['open', 'rename', 'delete'],
);
expect(find.byType(PopupMenuDivider), findsOneWidget);
expect(find.byIcon(Icons.edit_outlined), findsOneWidget);
expect(tester.getSize(items.first).width, greaterThanOrEqualTo(220));
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
expect(picked, 'open');
},
);
testWidgets('a bar More button opens the same sheet on a phone, with '
'submenu choices on a second sheet', (tester) async {
_size(tester, 430);
var closed = 0;
String? sort;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: SegmentedMoreButton(
sheetTitle: 'Chat a',
sheetSubtitle: 'demo',
entries: [
SegmentedOverflowEntry(
label: 'Close pane',
icon: Icons.close,
destructive: true,
onPressed: () => closed++,
),
SegmentedOverflowEntry(
label: 'Sort',
icon: Icons.sort,
choices: [
SegmentedMenuChoice(
label: 'Name',
selected: true,
onSelected: () => sort = 'name',
),
SegmentedMenuChoice(
label: 'Size',
onSelected: () => sort = 'size',
),
],
),
],
),
),
),
),
);
await tester.tap(find.byKey(segmentedMoreKey));
await tester.pumpAndSettle();
expect(find.text('Chat a'), findsOneWidget);
final labels = [
for (final tile in tester.widgetList<ListTile>(find.byType(ListTile)))
(tile.title! as Text).data,
];
expect(labels, ['Sort', 'Close pane']);
await tester.tap(find.text('Sort'));
await tester.pumpAndSettle();
expect(find.text('Name'), findsOneWidget);
expect(find.byIcon(Icons.check), findsOneWidget);
await tester.tap(find.text('Size'));
await tester.pumpAndSettle();
expect(sort, 'size');
await tester.tap(find.byKey(segmentedMoreKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Close pane'));
await tester.pumpAndSettle();
expect(closed, 1);
});
}
+8 -2
View File
@@ -106,7 +106,7 @@ void main() {
await tester.pumpAndSettle();
expect(taps, 1);
// The overflow control is a Material menu.
// The overflow control opens a phone's bottom sheet at this width.
expect(
find.descendant(
of: find.byKey(const Key('menu')),
@@ -117,7 +117,13 @@ void main() {
await tester.tap(find.byKey(const Key('menu')));
await tester.pumpAndSettle();
expect(taps, 1, reason: 'the menu is its own control');
expect(find.byType(PopupMenuItem<String>), findsNWidgets(2));
expect(
find.descendant(
of: find.byType(BottomSheet),
matching: find.byType(ListTile),
),
findsNWidgets(2),
);
await tester.tap(find.byKey(const Key('menu-delete')));
await tester.pumpAndSettle();
expect(picked, 'delete');