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
@@ -48,12 +48,6 @@ mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
label: 'Add chat pane',
enabled: true,
),
if (tiled)
(
action: SessionPaneAction.openChats,
label: 'Open chats ($panes)',
enabled: true,
),
if (tiled && showsListBesideDetail(context))
(
action: SessionPaneAction.centerStage,
@@ -69,12 +63,6 @@ mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
'(${chatPaneMoveShortcutLabel(move.direction)})',
enabled: moves[move.direction] != null,
),
if (pane != null && tiled)
(
action: SessionPaneAction.closePane,
label: 'Close pane',
enabled: true,
),
if (WindowScope.maybeOf(context) != null)
(
action: SessionPaneAction.chatDetails,
@@ -82,11 +70,6 @@ mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
enabled: true,
),
(action: SessionPaneAction.files, label: 'Files', enabled: true),
(
action: SessionPaneAction.runCommand,
label: chatShellRunActionLabel,
enabled: true,
),
if (_paneCommands.hasFinished(id))
(
action: SessionPaneAction.dismissFinished,
@@ -99,6 +82,13 @@ mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
label: terminalOpenActionLabel,
enabled: true,
),
// Closing comes last.
if (pane != null && tiled)
(
action: SessionPaneAction.closePane,
label: 'Close pane',
enabled: true,
),
];
}
@@ -106,6 +106,8 @@ class ChatThreadHeader extends StatelessWidget {
if (action is! SegmentedOverflowable) action,
if (settingsEntry != null || menuActions.isNotEmpty)
SegmentedMoreButton(
sheetTitle: title.isEmpty ? 'Chat' : title,
sheetSubtitle: folder.isEmpty ? null : folder,
entries: [
?settingsEntry,
for (final action in menuActions) action.overflowEntry,
@@ -1467,6 +1467,10 @@ class _ChatThreadViewState extends State<ChatThreadView> {
);
}
/// A pane control that closes the pane: listed last in the menu.
static bool _closes(Widget control) =>
control is ChatBarAction && control.destructive;
Widget _buildHeader(
JsonMap? session,
bool inShellBar,
@@ -1484,6 +1488,12 @@ class _ChatThreadViewState extends State<ChatThreadView> {
final folder = directory
.split(RegExp(r'[/\\]'))
.lastWhere((part) => part.isNotEmpty, orElse: () => '');
final openTerminal = terminalOpenMenuAction(
context,
gateway: widget.gateway,
directory: directory,
onRefused: _terminalRefused,
);
return ChatThreadHeader(
key: const Key('chat-thread-header'),
chatColor: chatSessionColor(session),
@@ -1514,8 +1524,9 @@ class _ChatThreadViewState extends State<ChatThreadView> {
materialIcon: _filesVisible ? Icons.folder : Icons.folder_outlined,
),
// A narrow layout's terminal button, beside Files; wide keeps the
// shell bar's.
?terminalChatBarAction(context),
// shell bar's. Where the menu already offers the chat's terminal
// (Open in terminal) there is no second terminal entry.
if (openTerminal == null) ?terminalChatBarAction(context),
],
moreActions: [
?widget.sidebarControl,
@@ -1536,16 +1547,12 @@ class _ChatThreadViewState extends State<ChatThreadView> {
onPressed: _openInfo,
materialIcon: Icons.info_outline,
),
...widget.paneControls,
chatShellRunMenuAction(onPressed: _runShellFromMenu),
...widget.paneControls.where((c) => !_closes(c)),
if (_shellRuns.finishedIds.isNotEmpty)
chatShellDismissAllMenuAction(onPressed: _dismissFinishedShellRuns),
?terminalOpenMenuAction(
context,
gateway: widget.gateway,
directory: directory,
onRefused: _terminalRefused,
),
?openTerminal,
// Closing comes last.
...widget.paneControls.where(_closes),
],
controls: [
// Labelled, so a narrow bar's settings sheet shows their names.
+29 -4
View File
@@ -11,6 +11,9 @@ import 'files_entry_actions.dart';
import 'files_upload_notice.dart';
import 'files_viewer.dart';
import 'files_header.dart';
import 'files_models.dart';
import 'files_preview.dart';
import '../../artifacts/domain/artifact_kind.dart';
import '../../../ui/layout/app_overflow_menu.dart';
import '../../terminal/terminal_open_action.dart';
import '../../terminal/terminal_scope.dart';
@@ -160,6 +163,10 @@ class _FilesPanelState extends State<FilesPanel> {
/// Open and Download for a file, then Rename, Move and Delete for any entry.
Widget _menu(DirectoryEntry entry) => AppOverflowMenu<FileAction>(
label: entry.isDir ? 'Folder actions' : 'File actions',
sheetTitle: entry.name,
sheetSubtitle: entry.isDir
? 'Folder'
: '${artifactKindLabel(artifactKind(fileContentType(entry.name), entry.name))} · ${fileSizeLabel(entry.size)}',
onSelected: (_, action) => switch (action) {
FileAction.open => _open(entry),
FileAction.download => widget.viewer.download(
@@ -179,19 +186,37 @@ class _FilesPanelState extends State<FilesPanel> {
},
actions: [
if (!entry.isDir) ...const [
AppMenuAction(value: FileAction.open, label: 'Open'),
AppMenuAction(value: FileAction.download, label: 'Download'),
AppMenuAction(
value: FileAction.open,
label: 'Open',
icon: Icons.open_in_new,
),
AppMenuAction(
value: FileAction.download,
label: 'Download',
icon: Icons.download_outlined,
),
],
if (entry.isDir && TerminalScope.maybeOf(context) != null)
const AppMenuAction(
value: FileAction.terminal,
label: terminalOpenActionLabel,
icon: Icons.terminal,
),
const AppMenuAction(value: FileAction.rename, label: 'Rename…'),
const AppMenuAction(value: FileAction.move, label: 'Move…'),
const AppMenuAction(
value: FileAction.rename,
label: 'Rename…',
icon: Icons.edit_outlined,
),
const AppMenuAction(
value: FileAction.move,
label: 'Move…',
icon: Icons.drive_file_move_outlined,
),
const AppMenuAction(
value: FileAction.delete,
label: 'Delete…',
icon: Icons.delete_outline,
destructive: true,
),
],
+1 -7
View File
@@ -22,7 +22,6 @@ import 'package:flutter/services.dart';
import '../../core/api_gateway.dart';
import '../../core/servers/server_scope.dart';
import '../../shell/windows/window_scope.dart';
import 'shell/chat_shell_command.dart';
import 'shell/chat_shell_dismiss.dart';
import '../terminal/terminal_open_action.dart';
import 'ui/sessions/session_pane_menu.dart';
@@ -440,12 +439,6 @@ class _ChatScreenState extends State<ChatScreen>
onPressed: () => _addPane(paneContext),
materialIcon: Icons.add_box_outlined,
),
if (_workspace.paneCount > 1)
ChatBarAction(
label: 'Open chats (${_workspace.paneCount})',
onPressed: () => _pickPane(paneContext),
materialIcon: Icons.view_quilt_outlined,
),
if (_workspace.paneCount > 1 && showsListBesideDetail(context))
chatCenterStageAction(ChatCenterStageController.instance),
...chatPaneMoveActions(
@@ -458,6 +451,7 @@ class _ChatScreenState extends State<ChatScreen>
label: 'Close pane',
onPressed: () => _closePane(pane.id),
materialIcon: Icons.close,
destructive: true,
),
],
),
@@ -8,6 +8,7 @@ class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
required this.onPressed,
required this.materialIcon,
this.identifier,
this.destructive = false,
});
final String label;
@@ -16,12 +17,16 @@ class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
final String? identifier;
/// Closes or removes something; menus list it last, in the error colour.
final bool destructive;
/// A narrow bar moves it into its More menu, under the bar's host's icon.
@override
SegmentedOverflowEntry get overflowEntry => SegmentedOverflowEntry(
label: label,
icon: materialIcon,
onPressed: onPressed,
destructive: destructive,
);
@override
@@ -53,21 +53,27 @@ class SessionActionsButton extends StatelessWidget {
return AppOverflowMenu<Object>(
label: sessionActionsLabel(session, duplicateTitles),
sheetTitle: chatSessionTitle(session),
sheetSubtitle: '${session['directory'] ?? ''}'.trim().isEmpty
? null
: '${session['directory']}',
actionsBuilder: () => [
if (allowOpenBeside)
const AppMenuAction<Object>(
value: SessionAction.openBeside,
label: 'Open to the right',
icon: Icons.vertical_split_outlined,
),
if (allowOpenBelow)
const AppMenuAction<Object>(
value: SessionAction.openBelow,
label: 'Open below',
icon: Icons.horizontal_split_outlined,
),
if (allowFloat)
AppMenuAction<Object>(
value: SessionAction.float,
label: 'Float (${chatFloatShortcutLabel()})',
icon: Icons.picture_in_picture_alt_outlined,
),
for (final choice
in paneMenu?.choicesFor(context, session) ??
@@ -76,9 +82,16 @@ class SessionActionsButton extends StatelessWidget {
value: choice.action,
label: choice.label,
enabled: choice.enabled,
icon: _paneIcon(choice.action),
destructive: choice.action == SessionPaneAction.closePane,
),
for (final item in _items(session))
AppMenuAction<Object>(value: item.action, label: item.label),
AppMenuAction<Object>(
value: item.action,
label: item.label,
icon: item.icon,
destructive: item.action == SessionAction.close,
),
],
onSelected: (context, value) {
if (value is SessionAction) {
@@ -91,19 +104,51 @@ class SessionActionsButton extends StatelessWidget {
}
}
List<({SessionAction action, String label})> _items(JsonMap session) {
IconData _paneIcon(SessionPaneAction action) => switch (action) {
SessionPaneAction.addPane => Icons.add_box_outlined,
SessionPaneAction.openChats => Icons.view_quilt_outlined,
SessionPaneAction.centerStage => Icons.center_focus_strong_outlined,
SessionPaneAction.moveUp => Icons.arrow_upward,
SessionPaneAction.moveDown => Icons.arrow_downward,
SessionPaneAction.moveLeft => Icons.arrow_back,
SessionPaneAction.moveRight => Icons.arrow_forward,
SessionPaneAction.closePane => Icons.close,
SessionPaneAction.chatDetails => Icons.info_outline,
SessionPaneAction.files => Icons.folder_outlined,
SessionPaneAction.runCommand => Icons.terminal,
SessionPaneAction.openTerminal => Icons.terminal,
SessionPaneAction.dismissFinished => Icons.clear_all,
};
List<({SessionAction action, String label, IconData icon})> _items(
JsonMap session,
) {
final isClosed = session['closed_at'] != null;
final starred = session['starred'] == true;
return [
(
action: SessionAction.star,
label: session['starred'] == true ? 'Unstar' : 'Star',
label: starred ? 'Unstar' : 'Star',
icon: starred ? Icons.star : Icons.star_outline,
),
(
action: SessionAction.color,
label: 'Colour…',
icon: Icons.palette_outlined,
),
(action: SessionAction.rename, label: 'Rename…', icon: Icons.edit_outlined),
(
action: SessionAction.hide,
label: 'Hide on this device',
icon: Icons.visibility_off_outlined,
),
(action: SessionAction.color, label: 'Colour…'),
(action: SessionAction.rename, label: 'Rename…'),
isClosed
? (action: SessionAction.reopen, label: 'Reopen')
: (action: SessionAction.close, label: 'Close chat…'),
(action: SessionAction.hide, label: 'Hide on this device'),
? (action: SessionAction.reopen, label: 'Reopen', icon: Icons.restore)
: (
action: SessionAction.close,
label: 'Close chat…',
icon: Icons.close,
),
];
}
+174
View File
@@ -0,0 +1,174 @@
import 'package:flutter/material.dart';
/// One action in an [showAppActionSheet] sheet.
class AppSheetAction {
const AppSheetAction({
required this.label,
this.icon,
this.onSelected,
this.destructive = false,
this.enabled = true,
this.selected = false,
this.choices = const [],
this.key,
});
final String label;
final IconData? icon;
/// Runs once the sheet has closed. Null (with no [choices]) disables it.
final VoidCallback? onSelected;
/// Shown last, after a divider, in the theme's error colour.
final bool destructive;
final bool enabled;
/// Marks the current choice in a [choices] list.
final bool selected;
/// Choices offered on a second sheet (a sort order) instead of [onSelected].
final List<AppSheetAction> choices;
/// Placed on the row so tests can find it.
final Key? key;
}
/// A phone's menu: a modal bottom sheet with a header naming what the actions
/// apply to ([title], [subtitle]) and one full-width row per action, each with
/// its icon. Destructive actions come last, after a divider, in the error
/// colour. The chosen action runs after the sheet has closed.
Future<void> showAppActionSheet(
BuildContext context, {
String? title,
String? subtitle,
required List<AppSheetAction> actions,
}) async {
final chosen = await showModalBottomSheet<AppSheetAction>(
context: context,
useRootNavigator: true,
showDragHandle: true,
isScrollControlled: true,
useSafeArea: true,
builder: (sheet) =>
_ActionSheet(title: title, subtitle: subtitle, actions: actions),
);
if (chosen == null) return;
if (chosen.choices.isNotEmpty) {
if (!context.mounted) return;
return showAppActionSheet(
context,
title: chosen.label,
actions: chosen.choices,
);
}
chosen.onSelected?.call();
}
class _ActionSheet extends StatelessWidget {
const _ActionSheet({
required this.title,
required this.subtitle,
required this.actions,
});
final String? title;
final String? subtitle;
final List<AppSheetAction> actions;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final regular = [
for (final action in actions)
if (!action.destructive) action,
];
final destructive = [
for (final action in actions)
if (action.destructive) action,
];
final hasTitle = title != null && title!.trim().isNotEmpty;
return SafeArea(
top: false,
child: SingleChildScrollView(
padding: const EdgeInsets.only(bottom: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (hasTitle) ...[
Padding(
padding: const EdgeInsets.fromLTRB(24, 0, 24, 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title!,
style: theme.textTheme.titleMedium,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
if (subtitle != null && subtitle!.trim().isNotEmpty) ...[
const SizedBox(height: 2),
Text(
subtitle!,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
const Divider(height: 1),
],
const SizedBox(height: 8),
for (final action in regular) _ActionRow(action: action),
if (destructive.isNotEmpty) ...[
if (regular.isNotEmpty)
const Divider(height: 17, indent: 24, endIndent: 24),
for (final action in destructive) _ActionRow(action: action),
],
],
),
),
);
}
}
class _ActionRow extends StatelessWidget {
const _ActionRow({required this.action});
final AppSheetAction action;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final enabled =
action.enabled &&
(action.onSelected != null || action.choices.isNotEmpty);
final color = action.destructive ? scheme.error : null;
return ListTile(
key: action.key,
enabled: enabled,
minTileHeight: 56,
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
leading: action.icon == null
? null
: Icon(action.icon, color: enabled ? color : null),
iconColor: scheme.onSurfaceVariant,
title: Text(
action.label,
style: color == null || !enabled ? null : TextStyle(color: color),
),
trailing: action.choices.isNotEmpty
? const Icon(Icons.chevron_right)
: action.selected
? Icon(Icons.check, color: scheme.primary)
: null,
selected: action.selected,
onTap: enabled ? () => Navigator.of(context).pop(action) : null,
);
}
}
@@ -1,4 +1,6 @@
import 'app_action_sheet.dart';
import 'app_menu_anchor.dart';
import 'app_popups.dart';
import 'package:flutter/material.dart';
/// The key of a [SegmentedBar]'s More button, shown when its actions do not
@@ -27,11 +29,16 @@ class SegmentedOverflowEntry {
this.onPressed,
this.choices = const [],
this.shortcut,
this.destructive = false,
});
final String label;
final IconData icon;
/// Closes or removes something (Close pane): listed last on a phone sheet,
/// after a divider, in the error colour.
final bool destructive;
/// What choosing the entry does; null (with no [choices]) disables it.
final VoidCallback? onPressed;
@@ -68,16 +75,55 @@ class SegmentedOverflowAction extends StatelessWidget
}
/// The bar's More button: the host's overflow icon at the platform's touch
/// target, opening a Material menu of [entries].
/// target, opening a Material menu of [entries] on a wide app and a bottom
/// sheet headed by [sheetTitle] on a phone.
class SegmentedMoreButton extends StatelessWidget {
const SegmentedMoreButton({super.key, required this.entries});
const SegmentedMoreButton({
super.key,
required this.entries,
this.sheetTitle,
this.sheetSubtitle,
});
final List<SegmentedOverflowEntry> entries;
/// The phone sheet's header: what the actions apply to (a chat).
final String? sheetTitle;
final String? sheetSubtitle;
static const String label = 'More actions';
@override
Widget build(BuildContext context) {
if (!usesDesktopPopups(context)) {
return IconButton(
key: segmentedMoreKey,
tooltip: label,
icon: const Icon(Icons.more_vert),
onPressed: () => showAppActionSheet(
context,
title: sheetTitle,
subtitle: sheetSubtitle,
actions: [
for (final entry in entries)
AppSheetAction(
label: entry.label,
icon: entry.icon,
onSelected: entry.onPressed,
destructive: entry.destructive,
choices: [
for (final choice in entry.choices)
AppSheetAction(
label: choice.label,
selected: choice.selected,
onSelected: choice.onSelected,
),
],
),
],
),
);
}
return AppMenuAnchor(
menuChildren: [
for (final entry in entries)
+104 -14
View File
@@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import '../adaptive/app_action_sheet.dart';
import '../adaptive/app_popups.dart';
/// One choice in an [AppOverflowMenu].
class AppMenuAction<T> {
const AppMenuAction({
required this.value,
required this.label,
this.icon,
this.key,
this.destructive = false,
this.enabled = true,
@@ -13,22 +17,25 @@ class AppMenuAction<T> {
final T value;
final String label;
/// The action's glyph, beside its label in the menu and the phone sheet.
final IconData? icon;
/// Placed on the menu item so tests can find the same item.
final Key? key;
/// A disabled item stays listed but cannot be chosen.
final bool enabled;
// Kept for callers that distinguish destructive actions in their data model;
// Material PopupMenuItem does not apply a separate action-sheet treatment.
/// Listed last, after a divider, in the theme's error colour.
final bool destructive;
}
/// The app's one row/header overflow control: the host's "more" icon that
/// opens the row's secondary actions.
///
/// Shows a [PopupMenuButton] with [Icons.more_vert]. Every list row and the run
/// header use this, so overflow actions are anchored to their button.
/// On a wide app it is a menu anchored to its button, with each action's icon;
/// on a phone it opens a bottom sheet headed by [sheetTitle], with full-width
/// rows (see [showAppActionSheet]). Destructive actions come last either way.
class AppOverflowMenu<T> extends StatelessWidget {
const AppOverflowMenu({
super.key,
@@ -37,6 +44,7 @@ class AppOverflowMenu<T> extends StatelessWidget {
required this.onSelected,
this.label = 'More actions',
this.sheetTitle,
this.sheetSubtitle,
this.enabled = true,
this.icon = const Icon(Icons.more_vert),
});
@@ -53,20 +61,60 @@ class AppOverflowMenu<T> extends StatelessWidget {
/// Tooltip and accessible label.
final String label;
/// Retained for source compatibility; Material menus do not show a title.
/// The phone sheet's header: what the actions apply to (a chat, a file).
final String? sheetTitle;
/// A second header line under [sheetTitle] (a file's size, a folder).
final String? sheetSubtitle;
final bool enabled;
/// The button glyph. Most callers use the default overflow icon; controls
/// whose action has a distinct meaning can provide a matching Material icon.
final Widget icon;
List<AppMenuAction<T>> _ordered() {
final all = actionsBuilder?.call() ?? actions;
return [
for (final action in all)
if (!action.destructive) action,
for (final action in all)
if (action.destructive) action,
];
}
@override
Widget build(BuildContext context) {
if (actionsBuilder == null && actions.isEmpty) {
return const SizedBox.shrink();
}
if (!usesDesktopPopups(context)) {
return IconButton(
icon: icon,
tooltip: label,
onPressed: !enabled
? null
: () => showAppActionSheet(
context,
title: sheetTitle,
subtitle: sheetSubtitle,
actions: [
for (final action in _ordered())
AppSheetAction(
key: action.key,
label: action.label,
icon: action.icon,
destructive: action.destructive,
enabled: action.enabled,
onSelected: () {
if (context.mounted) onSelected(context, action.value);
},
),
],
),
);
}
final scheme = Theme.of(context).colorScheme;
return Localizations.override(
context: context,
delegates: const [DefaultMaterialLocalizations.delegate],
@@ -76,18 +124,60 @@ class AppOverflowMenu<T> extends StatelessWidget {
icon: icon,
tooltip: label,
enabled: enabled,
constraints: const BoxConstraints(minWidth: 220),
onSelected: (value) => onSelected(context, value),
itemBuilder: (_) => [
for (final action in actionsBuilder?.call() ?? actions)
PopupMenuItem<T>(
key: action.key,
value: action.value,
enabled: action.enabled,
child: Text(action.label),
),
],
itemBuilder: (_) {
final ordered = _ordered();
final firstDestructive = ordered.indexWhere((a) => a.destructive);
return [
for (final (index, action) in ordered.indexed) ...[
if (index == firstDestructive && index > 0)
const PopupMenuDivider(),
PopupMenuItem<T>(
key: action.key,
value: action.value,
enabled: action.enabled,
child: _MenuRow(
label: action.label,
icon: action.icon,
color: action.destructive && action.enabled
? scheme.error
: null,
),
),
],
];
},
),
),
);
}
}
class _MenuRow extends StatelessWidget {
const _MenuRow({required this.label, this.icon, this.color});
final String label;
final IconData? icon;
final Color? color;
@override
Widget build(BuildContext context) {
final text = Text(
label,
style: color == null ? null : TextStyle(color: color),
);
if (icon == null) return text;
return Row(
children: [
Icon(
icon,
size: 20,
color: color ?? Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 12),
Flexible(child: text),
],
);
}
}
@@ -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');