Merge commit '66a96ad136930286c817a282bc253dd7f7c9980a' into pipelines/run-20261112-0053-clear-empty-states-on-a-new-server-e7cd

This commit is contained in:
2026-11-12 01:19:33 +00:00
32 changed files with 1047 additions and 329 deletions
+8 -1
View File
@@ -689,6 +689,13 @@ class _PipelinesAppState extends State<PipelinesApp>
AppRoute? _chatWorkspaceRoute;
Set<String>? _availableChatSessionIds;
/// After Ctrl+K or Alt+K shows Chat: the keyboard goes to the open chat's
/// composer, if a chat is open.
void _focusOpenChatComposer() {
final id = _chatWorkspaceRoute?.chatSessionId;
if (id != null) _chatRuntime.composerFocus.request(id);
}
void _selectDestination(AppDestination destination) {
final current = tabForRoute(_delegate.route);
final last = _tabRoutes[destination];
@@ -825,6 +832,7 @@ class _PipelinesAppState extends State<PipelinesApp>
runningRunCount: counts.running,
destination: _destinationOf(route.kind),
onDestinationSelected: _selectDestination,
onOpenChat: _focusOpenChatComposer,
onClosePage: () => _delegate.goTo(
_bodyRoutes[AppDestination.pipelines] ?? AppRoute.pipelines,
),
@@ -923,7 +931,6 @@ class _PipelinesAppState extends State<PipelinesApp>
store: SharedPreferencesSettingsStore(
serverId: widget.serverId ?? '',
),
onOpenTemplates: _delegate.openTemplates,
notifications: _notifications,
deliveryService: _deliveryService,
deliveryServiceController: _deliveryController,
@@ -147,11 +147,14 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
/// focus. Over a single pane it swaps in the chat shown before this one
/// instead, and back again (see [_toggleRecentChat]). Command+Tab stays
/// with the operating system's application switcher. While the app's
/// terminal is shown, Ctrl+Tab moves between its tabs instead.
/// terminal is shown, Ctrl+Tab moves between its tabs instead. While a
/// floating chat window holds the keyboard, Ctrl+Tab cycles those windows
/// (see [ChatWindows]).
bool _cycleChatKey(KeyEvent event) {
final keyboard = HardwareKeyboard.instance;
if (event is! KeyDownEvent ||
TerminalScope.peek(context)?.claimsTabKeys == true ||
keyboardWindow()?.entry.kind == chatWindowKind ||
event.logicalKey != LogicalKeyboardKey.tab ||
!keyboard.isControlPressed ||
keyboard.isMetaPressed ||
+1
View File
@@ -1,5 +1,6 @@
import 'chat_pane_content.dart';
import 'chat_runtime.dart';
import 'windows/chat_window_tabs.dart';
import 'windows/chat_windows.dart';
import 'workspace/federated_workspace_store.dart';
import '../../core/servers/chat/federated_chat_gateway.dart';
@@ -0,0 +1,39 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import '../../../shell/windows/window_entry.dart';
import '../../../shell/windows/window_scope.dart';
/// The step Ctrl+Tab (1) or Ctrl+Shift+Tab (-1) moves between floating chat
/// windows, or null for any other key. Command+Tab stays with the system.
int? chatWindowTabStep(KeyEvent event, HardwareKeyboard keyboard) {
if (event is! KeyDownEvent ||
event.logicalKey != LogicalKeyboardKey.tab ||
!keyboard.isControlPressed ||
keyboard.isMetaPressed ||
keyboard.isAltPressed) {
return null;
}
return keyboard.isShiftPressed ? -1 : 1;
}
/// The window [step] away from the window [currentId] in [visible] (bottom
/// to top), wrapping around. Null when [currentId] is not listed or there is
/// no other window to move to.
WindowEntry? chatWindowAfter(
List<WindowEntry> visible,
String currentId,
int step,
) {
final at = visible.indexWhere((w) => w.id == currentId);
if (at < 0 || visible.length < 2) return null;
return visible[(at + step) % visible.length];
}
/// The floating window whose content holds the keyboard, if one does. Read
/// from the focused node's ancestors, so it needs no reference to the host.
WindowScope? keyboardWindow() {
final context = FocusManager.instance.primaryFocus?.context;
if (context == null) return null;
return context.findAncestorWidgetOfExactType<WindowScope>();
}
@@ -8,11 +8,13 @@ import '../../../shell/list_detail_policy.dart';
import '../../../shell/windows/window_entry.dart';
import '../../../shell/windows/window_kind.dart';
import '../../../shell/windows/window_manager.dart';
import '../../terminal/terminal_scope.dart';
import '../chat_runtime.dart';
import '../domain/chat_commands.dart';
import '../workspace/chat_float_shortcut.dart';
import '../workspace/chat_float_store.dart';
import 'chat_window_content.dart';
import 'chat_window_tabs.dart';
const chatWindowKind = 'chat';
@@ -79,7 +81,9 @@ class ChatWindows {
if (_started) return;
_started = true;
manager.kinds.register(kind);
FocusManager.instance.addEarlyKeyEventHandler(_key);
FocusManager.instance
..addEarlyKeyEventHandler(_key)
..addEarlyKeyEventHandler(_tabKey);
runtime.addSessionReplacedListener(_replacedElsewhere);
runtime.sessions.addListener(_rowsChanged);
manager.addListener(_rowsChanged);
@@ -89,7 +93,9 @@ class ChatWindows {
void dispose() {
if (!_started) return;
_started = false;
FocusManager.instance.removeEarlyKeyEventHandler(_key);
FocusManager.instance
..removeEarlyKeyEventHandler(_key)
..removeEarlyKeyEventHandler(_tabKey);
runtime.removeSessionReplacedListener(_replacedElsewhere);
runtime.sessions.removeListener(_rowsChanged);
manager.removeListener(_rowsChanged);
@@ -224,6 +230,36 @@ class ChatWindows {
if (event is KeyDownEvent) manager.toggleOrRaiseGroup(chatWindowKind);
return KeyEventResult.handled;
}
/// Ctrl+Tab and Ctrl+Shift+Tab while a floating chat window holds the
/// keyboard: the next (previous) visible chat window, in stacking order and
/// wrapping, comes to the top. The window host then gives it the keyboard,
/// its composer. Left alone when another window or the tiling has the
/// keyboard, when the terminal claims tab keys, or with one window.
KeyEventResult _tabKey(KeyEvent event) {
final step = chatWindowTabStep(event, HardwareKeyboard.instance);
if (step == null || !_wide) return KeyEventResult.ignored;
final scope = keyboardWindow();
if (scope == null ||
scope.entry.kind != chatWindowKind ||
_terminalClaimsTabs()) {
return KeyEventResult.ignored;
}
final target = chatWindowAfter(
windows.where(manager.isVisible).toList(),
scope.entry.id,
step,
);
if (target == null) return KeyEventResult.ignored;
manager.raise(target.id);
return KeyEventResult.handled;
}
bool _terminalClaimsTabs() {
final context = FocusManager.instance.primaryFocus?.context;
return context != null &&
TerminalScope.peek(context)?.claimsTabKeys == true;
}
}
class _Never implements Listenable {
@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'chat_center_stage_layout.dart';
/// Hairline thickness of a center-stage edge.
const double chatCenterStageEdgeThickness = 1;
/// Where the stage's two hairlines sit: each in the gap beside the stage, or on
/// the workspace edge when the stage reaches it. Returns (left, right).
(Rect, Rect) chatCenterStageEdgeRects(Rect stage, Size size) {
final half = chatCenterStageGap / 2;
const t = chatCenterStageEdgeThickness;
final maxX = size.width - t;
final leftX = stage.left <= 0
? 0.0
: (stage.left - half - t / 2).clamp(0.0, maxX).toDouble();
final rightX = stage.right >= size.width
? maxX
: (stage.right + half - t / 2).clamp(0.0, maxX).toDouble();
return (
Rect.fromLTWH(leftX, 0, t, size.height),
Rect.fromLTWH(rightX, 0, t, size.height),
);
}
/// The stage's left and right hairlines in the workspace's stack, drawn in the
/// theme's outlineVariant so the centred chat column has a visible boundary.
/// Only center stage calls this; the split layout keeps its own dividers.
List<Widget> chatCenterStageEdges({
required BuildContext context,
required Rect rect,
required Size size,
}) {
final color = Theme.of(context).colorScheme.outlineVariant;
final (left, right) = chatCenterStageEdgeRects(rect, size);
return [
Positioned.fromRect(
key: const ValueKey('chat-center-stage-edge-left'),
rect: left,
child: ColoredBox(color: color),
),
Positioned.fromRect(
key: const ValueKey('chat-center-stage-edge-right'),
rect: right,
child: ColoredBox(color: color),
),
];
}
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'chat_center_stage_edges.dart';
import 'chat_center_stage_motion.dart';
import 'chat_center_stage_strip.dart';
import 'chat_mobile_panes.dart';
@@ -138,6 +139,12 @@ Widget chatWorkspaceSurface({
for (final pane in livePanes)
if (pane.key == ValueKey('chat-workspace-${motion.topPaneId}'))
pane,
if (stage.stage case final layout?)
...chatCenterStageEdges(
context: context,
rect: stage.rectFor(layout.stageId)!,
size: size,
),
if (mobile?.peekId != null && !motion.isAnimating)
Positioned(
top: mobile!.contentHeight - 12,
@@ -4,6 +4,7 @@ import '../chat/workspace/chat_center_stage_controller.dart';
import '../chat/workspace/chat_float_shortcut.dart';
import '../terminal/terminal_shortcuts.dart';
import '../../shell/windows/window_shortcuts.dart';
import '../../shell/shell_chat_shortcut.dart';
import '../../shell/shell_search_shortcut_labels.dart';
/// A shortcut entry shown in the in-app help. Keeping these entries together
@@ -53,6 +54,13 @@ class KeyboardShortcutRegistry {
caveat:
'Brings a chat forward from Terminal and focuses its message input.',
),
KeyboardShortcutEntry(
action: 'Open Chat',
keys: shellChatShortcutLabels(platform).join(', '),
caveat: web
? 'Shows the open chat and focuses its message input. The browser may reserve Ctrl+K.'
: 'Shows the open chat and focuses its message input. In the terminal Ctrl+K stays kill-line; Alt+K still opens Chat.',
),
KeyboardShortcutEntry(
action: 'Toggle Center Stage',
keys:
@@ -9,7 +9,6 @@ abstract final class SettingsKeys {
static const reconnect = ValueKey<String>('settings.reconnect');
static const workspace = ValueKey<String>('settings.workspace');
static const saveWorkspace = ValueKey<String>('settings.saveWorkspace');
static const templates = ValueKey<String>('settings.templates');
static const schedules = ValueKey<String>('settings.schedules');
static const keyboardShortcuts = ValueKey<String>(
'settings.keyboardShortcuts',
@@ -6,7 +6,7 @@ import 'settings_row.dart';
/// The Settings entry to the saved-schedule list.
///
/// The row only opens the route; the list's own controller performs the single
/// `list_schedules` read, exactly like the Templates entry.
/// `list_schedules` read.
const String settingsSchedulesLabel = 'Browse schedules';
const String settingsSchedulesSecondary =
'Saved run configurations for every pipeline.';
@@ -33,7 +33,6 @@ import 'security/settings_security_section.dart';
import 'settings_updates_section.dart';
import '../updates/app_updates.dart';
import 'settings_store.dart';
import 'settings_templates_section.dart';
import 'server_connections.dart';
import 'saved_servers_section.dart';
import 'managed_connection_section.dart';
@@ -58,7 +57,6 @@ class SettingsScreen extends StatefulWidget {
this.ping,
this.embedded = false,
this.navigationScope,
this.onOpenTemplates,
this.onOpenSchedules,
this.notifications,
this.showSignIn = false,
@@ -108,10 +106,6 @@ class SettingsScreen extends StatefulWidget {
/// The logical server scope used to restore the last Settings category.
final String? navigationScope;
/// Opens the Templates gallery. Null keeps Settings standalone/incomplete
/// without a dead row that would go nowhere.
final VoidCallback? onOpenTemplates;
/// Opens the saved-schedule list above Settings.
final VoidCallback? onOpenSchedules;
@@ -1,30 +0,0 @@
import 'package:flutter/material.dart';
import 'settings_keys.dart';
import 'settings_row.dart';
/// The Settings entry to the Templates gallery.
///
/// The row wording matches the web Settings page: `Browse templates` with the
/// server-catalogue secondary line. It only opens the route; loading the
/// catalogue is the gallery's own read.
const String settingsTemplatesLabel = 'Browse templates';
const String settingsTemplatesSecondary =
'Reusable pipeline definitions offered by the server.';
/// A navigation row (chevron) for a Settings group.
class SettingsTemplatesSection extends StatelessWidget {
const SettingsTemplatesSection({super.key, required this.onOpen});
final VoidCallback onOpen;
@override
Widget build(BuildContext context) => SettingsRow(
key: SettingsKeys.templates,
leading: const Icon(Icons.widgets_outlined),
title: const Text(settingsTemplatesLabel),
subtitle: const Text(settingsTemplatesSecondary),
chevron: true,
onTap: onOpen,
);
}
@@ -87,16 +87,11 @@ extension _SettingsTopicPages on _SettingsScreenState {
leadingRows: true,
children: const [SettingsKeyboardShortcutsSection()],
),
if (widget.onOpenSchedules != null || widget.onOpenTemplates != null)
if (widget.onOpenSchedules case final open?)
SettingsGroup(
title: 'Library',
leadingRows: true,
children: [
if (widget.onOpenSchedules case final open?)
SettingsSchedulesSection(onOpen: open),
if (widget.onOpenTemplates case final open?)
SettingsTemplatesSection(onOpen: open),
],
children: [SettingsSchedulesSection(onOpen: open)],
),
],
),
+21 -1
View File
@@ -9,6 +9,7 @@ import 'destination.dart';
import 'list_detail.dart';
import 'list_pane_widths.dart';
import 'shell_bar.dart';
import 'shell_chat_shortcut.dart';
import 'shell_list_shortcuts.dart';
import 'shell_search_shortcut_labels.dart';
import 'tab_history.dart';
@@ -22,6 +23,7 @@ class AdaptiveShell extends StatefulWidget {
this.onDestinationSelected,
this.onClosePage,
this.onSearch,
this.onOpenChat,
this.attentionCount = 0,
this.runningRunCount,
this.listPaneWidthStore = const SharedPreferencesListPaneWidthStore(),
@@ -47,6 +49,10 @@ class AdaptiveShell extends StatefulWidget {
/// shell tests and compositions without routing keep their tab set only.
final VoidCallback? onSearch;
/// Runs after Ctrl+K or Alt+K has shown the Chat destination (also when it
/// was already shown), so the open chat's composer can take the keyboard.
final VoidCallback? onOpenChat;
/// Runs needing the operator today, retained in the tab's accessible label.
final int attentionCount;
@@ -271,9 +277,16 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
/// fields. Split-pane navigation belongs to the chat workspace; tab changes
/// have no global keyboard chord.
bool _handleDestinationKeyEvent(KeyEvent event) {
final keyboard = HardwareKeyboard.instance;
// Ctrl+K is the terminal's kill-line while the terminal has the keyboard;
// Alt+K still opens Chat there.
if (shellChatShortcut(event, keyboard) &&
(keyboard.isAltPressed || !primaryFocusIsTypingSurface())) {
if (event is KeyDownEvent) _openChat();
return true;
}
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits).
if (primaryFocusIsTypingSurface()) return false;
final keyboard = HardwareKeyboard.instance;
if (_selected == AppDestination.search &&
event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.escape &&
@@ -299,6 +312,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
return _bar.lists.open(AppDestination.chat, listIndex);
}
/// Shows Chat (the tab's own selection, so its open chat returns) and then
/// lets the app focus that chat's composer.
void _openChat() {
if (_selected != AppDestination.chat) _select(AppDestination.chat);
widget.onOpenChat?.call();
}
/// A popup or nested viewer owns Escape before the underlying Search tab.
bool _searchEscape() {
final route = ModalRoute.of(context);
+29
View File
@@ -0,0 +1,29 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
/// Whether [event] opens the Chat destination from any destination: Ctrl+K,
/// or Alt+K (Option+K on Apple platforms). Alt+K is recognised by key position
/// too, because Option+K yields a dead-key symbol on a Mac. Shift, Cmd and
/// chords with both Ctrl and Alt are not the shortcut. Repeats of a held chord
/// match as well, so the caller can swallow them; only its first press acts.
bool shellChatShortcut(KeyEvent event, HardwareKeyboard keyboard) {
if (event is KeyUpEvent ||
keyboard.isShiftPressed ||
keyboard.isMetaPressed) {
return false;
}
final control = keyboard.isControlPressed;
final alt = keyboard.isAltPressed;
if (control == alt) return false;
if (event.logicalKey == LogicalKeyboardKey.keyK) return true;
return alt && event.physicalKey == PhysicalKeyboardKey.keyK;
}
/// The chords that open Chat as they read on this platform, for the help
/// page. Alt (Option on Apple platforms) leads, as it does for the floating
/// chats; Ctrl+K is the other chord everywhere.
List<String> shellChatShortcutLabels([TargetPlatform? platform]) {
final target = platform ?? defaultTargetPlatform;
final apple = target == TargetPlatform.macOS || target == TargetPlatform.iOS;
return [apple ? 'Option+K' : 'Alt+K', 'Ctrl+K'];
}
+40
View File
@@ -0,0 +1,40 @@
# Center stage column edges
## Change
- In center stage (Alt+E / Option+E), the centred chat column had no visible
boundary: its neighbours are strips or the workspace background, so the
column's end read as unfinished.
- Added two 1px `outlineVariant` hairlines (`ChatCenterStageEdges` in
`app/lib/features/chat/workspace/chat_center_stage_edges.dart`). Each sits
centred in the 12px gap beside the stage, or on the workspace edge when the
stage reaches it.
- Painted from `chat_workspace_surface.dart`, only while a stage layout exists.
The split layout, phone/collapsed layouts and single-chat workspaces draw
nothing new.
- Reading width is unchanged (stage stays `chatCenterStageWidth`, 950 at the
test size). The lines travel with the stage's animated rectangle.
## Focused results
- `tool/memwatch/full.sh 'test/features/chat/workspace/chat_center_stage_test.dart'`
→ PASS: 21 passed, 0 failed, 0 skipped; peak 893 MB; 8s; exit 0.
New tests among them:
- `the stage edges sit in the gaps beside the stage, or on the workspace edge`
- `center stage draws the column edges in the light theme, only on stage`
- `center stage draws the column edges in the dark theme, only on stage`
- `tool/analyze.sh` → clean, exit 0.
- Not run: other `test/features/chat/workspace/*` files use `ChatWorkspace`
without `centerStage` on stage, so the new branch is not reached there. The
land gate runs the suites.
## Affected states (code-level only)
- Center stage on, 3 panes, light and dark: both hairlines present, colour is
the theme's `outlineVariant`.
- Center stage off: no hairlines (asserted in both themes).
- Stage with a neighbour on each side (gaps) and stage at a workspace edge
(line on the edge) are both covered by the geometry test.
## Limitations
- No browser or device capture was made; `ui-review` owns visual evidence.
Visual weight of a 1px `outlineVariant` line in light and dark is unverified.
- Hairlines hide at once when leaving center stage (same as the split
dividers); they do not fade.
+25
View File
@@ -29,6 +29,14 @@ every destination and come back at app start without Chat being opened.
terminal). On macOS Ctrl+Y in a terminal always goes to the shell.
- **Focus**: a window that shows or comes to the top puts the keyboard in its
composer; hiding the last window gives it back to what had it.
- **Cycle**: while a floating chat window's content holds the keyboard (a
composer, a Files page inside it), Ctrl+Tab brings the next visible chat
window to the top and Ctrl+Shift+Tab the previous one, wrapping round. The
order is the stacking order, bottom to top, and the window's composer takes
the keyboard. Command+Tab stays with the system. With the tiling focused,
Ctrl+Tab still cycles its panes; while the terminal claims tab keys (shown)
it switches terminal tabs. Alt+` (`windowCycleShortcut`) still cycles every
kind of window, not only chats.
- **Popups**: sheets, dialogs, menus and tooltips opened from a floating chat
are above every window. Files opens as a page inside the window, and a file
opened from it stays in the window. Because the window's own title bar names
@@ -60,6 +68,23 @@ every destination and come back at app start without Chat being opened.
## Checks
- Focused, 2026-11-12, `tool/memwatch/full.sh` with
`test/features/chat/chat_floating_pane_test.dart` and
`test/features/terminal/terminal_chat_tab_test.dart`: 16 passed, 0 failed.
New in the first: Ctrl+Tab and Ctrl+Shift+Tab over three floating chats
(order, wrap, composer focus, Command+Tab ignored); with the tiling focused
Ctrl+Tab moves the active pane and leaves the windows alone, and with one
window focused it does nothing; a terminal that claims tab keys keeps
Ctrl+Tab over a focused chat window.
- `tool/analyze.sh` on the changed paths: clean.
- Affected states: two or more floating chats; one floating chat; tiling
focused; a window focused with the terminal shown (claimed); Command+Tab.
- Not covered: the terminal's own tab switching (the test app has no terminal
surface), real browser or device keys, and captures (ui-review's).
- Observed, not changed: in the widget harness, floating from a pane's More
menu does not leave the keyboard in the new window's composer (the window
takes it); the chord and Ctrl+Tab do.
- `test/features/chat/chat_floating_pane_test.dart` (the Chat screen with the
window host), `test/features/chat/windows/chat_windows_test.dart`,
`test/features/chat/workspace/chat_workspace_float_test.dart`,
+32
View File
@@ -0,0 +1,32 @@
# Ctrl+K / Alt+K open Chat
Run 391 (ctrl-k-and-alt-k-open-chat), stage 01-implement. Not committed.
## Behaviour
- Ctrl+K, or Alt+K (Option+K on Apple platforms, matched by physical key so the dead-key symbol still counts), switches the shell to the Chat destination from any destination, then calls `AdaptiveShell.onOpenChat`.
- The app passes `_focusOpenChatComposer`, which requests the composer of the last workspace chat (`_chatWorkspaceRoute`) through `ChatRuntime.composerFocus`.
- Ctrl+K is left to the terminal while the terminal has the keyboard (`primaryFocusIsTypingSurface`). Alt+K still switches there.
- Shift, Meta, or Ctrl+Alt together do not match. Repeats are swallowed; only the first key-down acts.
- The help page has an "Open Chat" entry: `Option+K, Ctrl+K` on macOS, `Alt+K, Ctrl+K` elsewhere.
## Changed paths
- `app/lib/shell/shell_chat_shortcut.dart` (new): `shellChatShortcut`, `shellChatShortcutLabels`.
- `app/lib/shell/adaptive_shell.dart`: key handling, `_openChat`, `onOpenChat` parameter.
- `app/lib/application/pipelines_app.dart`: `_focusOpenChatComposer`, wired as `onOpenChat`.
- `app/lib/features/settings/keyboard_shortcuts_registry.dart`: "Open Chat" entry.
- `app/test/shell/shell_chat_shortcut_test.dart` (new): matcher, switch from another destination, controlled shell callback, terminal exception.
- `app/test/application/chat_open_shortcut_test.dart` (new): the full `PipelinesApp` opens `/chat/s1`, moves to Runs, then Alt+K and Ctrl+K each return to `/chat/s1` and put the keyboard in the `s1` composer (primary focus).
- `app/test/features/settings/keyboard_shortcuts_help_test.dart`: "Open Chat" help entry test.
## Focused results
- Review follow-up (composer focus), `tool/memwatch/full.sh 'test/application/chat_open_shortcut_test.dart test/shell/shell_chat_shortcut_test.dart test/features/settings/keyboard_shortcuts_help_test.dart'`: PASS, 12 passed, 0 failed, peak 1306 MB, 5s, exit 0. Run after `dart format` on the new test.
- Mutation check: with the `_focusOpenChatComposer` request removed from `pipelines_app.dart`, `chat_open_shortcut_test.dart` fails on the composer focus expectation. The source was restored afterwards; `git diff` shows the original wiring.
- Earlier stage run (not repeated here): `test/shell/destination_shortcuts_test.dart`, `test/shell/search_shortcuts_test.dart`, `test/features/chat/workspace/chat_float_shortcut_test.dart` passed with the shell test and help test (21 passed, 0 failed, peak 1062 MB).
- `tool/analyze.sh`: clean.
- Tests that press K chords: none outside the new files. The new shell check returns false for every other key, so the earlier typing-surface and search paths keep their order.
## Not covered
- The composer-focus test drives the real app with a fake channel; it does not cover a chat opened only through a route with no history yet.
- No UI capture or device run (ui-review owns that).
- Ctrl+Y: the float chord is not left to the terminal. `chatFloatShortcut` matches Ctrl+Y on every platform, and `chat_floating_pane_test.dart` covers Ctrl+Y from the terminal on macOS. Ctrl+K was made the only terminal exception, as the task asked.
- On web, the browser may keep Ctrl+K (address/search focus); the help caveat says so.
@@ -0,0 +1,58 @@
# Remove the Templates entry from Settings
## What changed
- Deleted `lib/features/settings/settings_templates_section.dart` (the
`Browse templates` chevron row and its label constants).
- Removed `SettingsKeys.templates`, the `onOpenTemplates` parameter and its
doc comment from `SettingsScreen`, and the Templates row from the Tools
topic's Library group (`settings_topic_pages.dart`). The Library group now
renders only when a Schedules route is supplied.
- `pipelines_app.dart` no longer passes `onOpenTemplates`.
- `settings_schedules_section.dart`: doc comment no longer refers to the
Templates entry.
## Kept on purpose
- The Templates destination (`lib/application/templates_destination.dart`),
the `AppRoute.templates` kind, its codec (`/templates`, `/settings/templates`
aliases), `AppRouter.openTemplates`/`closeTemplates`, and the templates
feature under `lib/features/templates/`. They remain reachable by URL
(`/templates`, `/settings/templates`) and by `AppRouter.openTemplates`, so
they are not solely reachable from the removed row. Removing them is a
separate follow-up if the route itself should go.
## Tests
- `test/application/templates_wiring_test.dart` and
`test/application/templates_behind_bar_test.dart` used to reach Templates by
tapping the Settings row. They now boot at `/pipelines` and push `/templates`
by route, then assert the same embedded page, bar, refresh, detail and
create expectations. The Settings-only assertions (edited server URL
surviving the detour, the Settings row being present, the `ping` answer)
were removed with the row.
- `readTemplates` in `templates_wiring_test.dart` settles the frame after the
list reply before answering `validate`, because the shell's own `ping`
shares the request queue.
- New `test/features/settings/settings_library_test.dart`: Tools shows
`Library` with Schedules and no `Browse templates`; Schedules still calls its
route; without a Schedules route the Library group is absent.
## Focused results (app/, `tool/memwatch/full.sh`)
- Baseline on the untouched worktree, 4 files: 31 passed, 0 failed.
- After the change, 10 files (the 4 above plus `settings_library_test.dart`,
`settings_topic_restore_test.dart`, `settings_screen_test.dart`,
`settings_layout_test.dart`, `settings_tabs_test.dart`,
`settings_shell_background_test.dart`): 61 passed, 0 failed.
- `tool/analyze.sh`: clean.
- Not run: the whole `test` directory (left to the land gate), and no UI
capture was made.
## Affected states (not yet captured)
- Settings > Tools: Library group shows Schedules only.
- `/templates` and `/settings/templates` deep links: still open the embedded
Templates page; Back returns to Settings.
## Known leftovers
- `app/tool/templates_wiring_probe*`, `templates_gallery_probe*` and
`template_create_probe.dart` drive Settings > Templates and will fail
against this build. They were not edited or run here.
- `app/PARITY.md`, `app/WORK.md` and `app/pipelines/flutter-design.md` may
still describe the Settings entry; they were not reviewed.
@@ -0,0 +1,93 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import 'chat_registration_test.dart'
show replyHistory, replySessions, replySubscribe, webServer;
bool _composerFocused(WidgetTester tester, String id) => tester
.widget<EditableText>(
find.descendant(
of: find.byKey(ValueKey('chat-composer-$id')),
matching: find.byType(EditableText),
),
)
.focusNode
.hasPrimaryFocus;
Future<void> _chord(WidgetTester tester, LogicalKeyboardKey modifier) async {
await tester.sendKeyDownEvent(modifier);
await tester.sendKeyEvent(LogicalKeyboardKey.keyK);
await tester.sendKeyUpEvent(modifier);
await tester.pump();
await tester.pump();
}
void main() {
testWidgets(
'Ctrl+K and Alt+K from another destination focus the open chat composer',
(tester) async {
tester.view.physicalSize = const Size(900, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/chat/s1')),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
androidSupported: false,
server: webServer(),
client: client,
routeInformationProvider: provider,
),
);
await tester.pump();
await replySessions(tester, channel);
await replySubscribe(tester, channel);
await replyHistory(tester, channel);
await tester.pumpAndSettle();
expect(find.byType(ChatThreadView), findsOneWidget);
expect(_composerFocused(tester, 's1'), isFalse);
// Leave Chat for another destination, then clear any focus left over.
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pump(const Duration(milliseconds: 600));
FocusManager.instance.primaryFocus?.unfocus();
await tester.pump();
expect(provider.value.uri.path, '/runs');
await _chord(tester, LogicalKeyboardKey.altLeft);
expect(provider.value.uri.path, '/chat/s1');
expect(find.byType(ChatThreadView), findsOneWidget);
expect(_composerFocused(tester, 's1'), isTrue);
expect(tester.takeException(), isNull);
// Ctrl+K does the same from another destination.
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pump(const Duration(milliseconds: 600));
FocusManager.instance.primaryFocus?.unfocus();
await tester.pump();
expect(_composerFocused(tester, 's1'), isFalse);
await _chord(tester, LogicalKeyboardKey.controlLeft);
expect(provider.value.uri.path, '/chat/s1');
expect(find.byType(ChatThreadView), findsOneWidget);
expect(_composerFocused(tester, 's1'), isTrue);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
},
);
}
@@ -8,7 +8,7 @@ import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
import 'pipelines_replies.dart';
import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp;
import 'templates_wiring_test.dart' show pumpApp, readTemplates;
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
/// open template reach the top edge, start below the bar at rest and scroll
@@ -23,8 +23,10 @@ void main() {
addTearDown(provider.dispose);
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyPipelines(tester, channel, PipelineFixture());
await openSettings(tester, channel, provider);
await openTemplates(tester, channel, provider);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/templates')),
);
await readTemplates(tester, channel);
await tester.pumpAndSettle();
final bar = find.ancestor(
+23 -51
View File
@@ -5,7 +5,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/application/templates_destination.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/settings/settings_keys.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_create_wording.dart';
import 'package:pipelines_app/features/templates/ui/template_detail.dart'
@@ -18,7 +17,6 @@ import '../features/templates/ui/template_gallery_test_support.dart'
show GalleryGateway, galleryTemplates, pumpGallery, templatesReply;
import 'pipelines_app_test.dart' show webServer;
import 'pipelines_replies.dart';
import '../features/settings/settings_topic_test_helper.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
List<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
@@ -85,38 +83,13 @@ Future<void> pumpApp(
await tester.pump();
}
Future<void> openSettings(
/// Answers the reads a Templates page makes when it opens by route.
Future<void> readTemplates(
WidgetTester tester,
FakeChannel channel,
PlatformRouteInformationProvider provider,
) async {
await tester.tap(find.byKey(const Key('pipelines-open-settings')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
// Settings pings the shared socket; answer it so later reads are not queued.
await reply(tester, channel, 'ping', 1, {
'type': 'pong',
'build': {'version': 'probe'},
'time': 'fixture',
});
// Hidden notification settings do not load during this navigation flow.
expect(requestsOf(channel, 'notification_settings'), isEmpty);
await selectSettingsTopic(tester, 'Connection');
}
Future<void> openTemplates(
WidgetTester tester,
FakeChannel channel,
PlatformRouteInformationProvider provider, {
FakeChannel channel, {
int listRead = 1,
}) async {
await selectSettingsTopic(tester, 'Tools');
await tester.ensureVisible(find.byKey(SettingsKeys.templates));
await tester.tap(find.byKey(SettingsKeys.templates));
await tester.pump();
await tester.pump(const Duration(milliseconds: 600));
expect(provider.value.uri.path, '/templates');
await reply(tester, channel, 'list_templates', listRead, {
'type': 'templates',
'templates': [
@@ -129,6 +102,9 @@ Future<void> openTemplates(
},
],
});
// The shell's own ping shares the request queue; let it go out before the
// gallery's validate reads, as the list read is followed by the shell's ping.
await tester.pumpAndSettle();
await reply(tester, channel, 'validate', listRead, {
'type': 'graph',
'graph': {'stages': <dynamic>[]},
@@ -153,7 +129,7 @@ void main() {
});
testWidgets(
'Settings opens the embedded Templates page and Back restores it',
'a /templates link opens the embedded page and Back restores Settings',
(tester) async {
final fixture = PipelineFixture();
final channel = FakeChannel()..readyCompleter.complete();
@@ -176,14 +152,12 @@ void main() {
provider: provider,
);
await replyPipelines(tester, channel, fixture);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/templates')),
);
await readTemplates(tester, channel);
await tester.pumpAndSettle();
await openSettings(tester, channel, provider);
// An edit that only Settings owns must survive the Templates detour.
await tester.enterText(find.byType(EditableText).first, 'edited url');
await tester.pump();
expect(find.text('edited url'), findsOneWidget);
await openTemplates(tester, channel, provider);
final screen = tester.widget<TemplatesScreen>(
find.byType(TemplatesScreen),
);
@@ -214,8 +188,8 @@ void main() {
expect(find.byKey(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templatesPageBackKey), findsNothing);
// Detail Back returns to the gallery, then the page Back restores the
// same Settings state.
// Detail Back returns to the gallery, then the page Back closes the
// page to Settings.
await tester.tap(find.byKey(templateDetailBackKey));
await tester.pump();
// The gallery hands the bar back to the page's Back on the next frame.
@@ -225,15 +199,14 @@ void main() {
expect(provider.value.uri.path, '/settings');
expect(find.byType(TemplatesScreen), findsNothing);
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('edited url'), findsOneWidget);
expect(find.text('Server URL'), findsOneWidget);
expect(sockets, 1);
expect(requestsOf(channel, 'ping'), hasLength(1));
// Browser Back from /templates follows the same close path.
await openTemplates(tester, channel, provider, listRead: 2);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/templates')),
);
await readTemplates(tester, channel, listRead: 2);
await tester.pumpAndSettle();
expect(find.byType(TemplatesScreen), findsOneWidget);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/settings')),
@@ -241,9 +214,6 @@ void main() {
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
expect(find.byType(TemplatesScreen), findsNothing);
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('edited url'), findsOneWidget);
expect(requestsOf(channel, 'list_templates'), hasLength(2));
expect(sockets, 1);
@@ -271,13 +241,15 @@ void main() {
await pumpApp(tester, channel: channel, client: client, provider: provider);
await replyPipelines(tester, channel, fixture);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/templates')),
);
expect(
find.byKey(const Key('pipeline-row-41'), skipOffstage: false),
findsNothing,
);
await openSettings(tester, channel, provider);
await openTemplates(tester, channel, provider);
await readTemplates(tester, channel);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pump();
await tester.tap(find.byKey(templateCreateActionKey));
@@ -11,6 +11,7 @@ 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/workspace/chat_workspace_store.dart';
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
import 'package:pipelines_app/shell/windows/window_frame.dart';
import 'package:pipelines_app/shell/windows/window_host.dart';
import 'package:pipelines_app/shell/windows/window_kind.dart';
@@ -48,6 +49,16 @@ class _Store implements WindowStore {
}
}
class _ClaimingTerminal implements TerminalActions {
const _ClaimingTerminal();
@override
void toggle() {}
@override
bool get claimsTabKeys => true;
@override
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
}
class _TerminalKind extends WindowKind {
@override
String get key => 'terminal';
@@ -105,6 +116,7 @@ class _App {
WidgetTester tester, {
Size size = const Size(1800, 1000),
bool terminalSurface = false,
bool terminalClaimsTabs = false,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
@@ -124,6 +136,13 @@ class _App {
);
await tester.pumpWidget(
MaterialApp(
// A terminal that shows its tabs: it claims Ctrl+Tab.
builder: terminalClaimsTabs
? (context, child) => TerminalScope(
actions: const _ClaimingTerminal(),
child: child!,
)
: null,
home: Scaffold(
body: Stack(
fit: StackFit.expand,
@@ -218,6 +237,19 @@ Future<void> _chord(WidgetTester tester) async {
await tester.pumpAndSettle();
}
/// Ctrl+Tab, or Ctrl+Shift+Tab with [shift].
Future<void> _tab(WidgetTester tester, {bool shift = false}) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
if (shift) await tester.sendKeyDownEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
if (shift) await tester.sendKeyUpEvent(LogicalKeyboardKey.shiftLeft);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
}
bool _composerFocused(WidgetTester tester, String id) =>
tester.widget<EditableText>(_input(id)).focusNode.hasPrimaryFocus;
Future<void> _controlChord(WidgetTester tester) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyY);
@@ -452,6 +484,91 @@ void main() {
await app.stop(tester);
});
testWidgets('Ctrl+Tab and Ctrl+Shift+Tab cycle the floating chat windows, '
'each composer taking the keyboard', (tester) async {
await _saved('a', 'b', 'c');
final app = _App(_Store());
await app.start(tester);
await _menu(tester, 'b', 'Float (Alt+Y)');
await _menu(tester, 'c', 'Float (Alt+Y)');
await _menu(tester, 'a', 'Float (Alt+Y)');
expect(app.floating, ['b', 'c', 'a']);
// Command+Tab belongs to the system.
await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
await tester.pumpAndSettle();
expect(app.floating, ['b', 'c', 'a']);
await _tab(tester);
expect(app.floating, ['c', 'a', 'b']);
expect(_composerFocused(tester, 'b'), isTrue);
// Past the top, the bottom window comes up again.
await _tab(tester);
expect(app.floating, ['a', 'b', 'c']);
expect(_composerFocused(tester, 'c'), isTrue);
await _tab(tester, shift: true);
expect(app.floating, ['a', 'c', 'b']);
expect(_composerFocused(tester, 'b'), isTrue);
await _tab(tester, shift: true);
expect(app.floating, ['a', 'b', 'c']);
expect(_composerFocused(tester, 'c'), isTrue);
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('with the tiling focused Ctrl+Tab cycles its panes and leaves '
'the windows alone', (tester) async {
await _saved('a', 'b', 'c');
final app = _App(_Store());
await app.start(tester);
await _menu(tester, 'c', 'Float (Alt+Y)');
expect(app.floating, ['c']);
final controller = _workspace(tester);
await tester.tapAt(tester.getCenter(_input('a')));
await tester.pump();
expect(controller.activePane?.sessionId, 'a');
await _tab(tester);
expect(controller.activePane?.sessionId, 'b');
expect(_composerFocused(tester, 'b'), isTrue);
expect(app.floating, ['c']);
// With a window focused, the panes stay where they are; a single window
// has nothing to cycle to.
await tester.tapAt(tester.getCenter(_input('c')));
await tester.pump();
expect(_composerFocused(tester, 'c'), isTrue);
await _tab(tester);
expect(controller.activePane?.sessionId, 'b');
expect(app.floating, ['c']);
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('a terminal that claims tab keys keeps Ctrl+Tab over a focused '
'floating chat', (tester) async {
await _saved('a', 'b', 'c');
final app = _App(_Store());
await app.start(tester, terminalClaimsTabs: true);
await _menu(tester, 'b', 'Float (Alt+Y)');
await _menu(tester, 'c', 'Float (Alt+Y)');
expect(app.floating, ['b', 'c']);
await tester.tapAt(tester.getCenter(_input('c')));
await tester.pump();
expect(_composerFocused(tester, 'c'), isTrue);
// The terminal's tabs get the key (its own handler is not in this app);
// neither the windows nor the panes move.
await _tab(tester);
expect(app.floating, ['b', 'c']);
expect(_composerFocused(tester, 'c'), isTrue);
expect(_workspace(tester).activePane?.sessionId, 'a');
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('a floating chat types, runs its tickers, hides and shows over '
'another destination', (tester) async {
await _saved('a', 'b');
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_controller.dart';
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_edges.dart';
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_keys.dart';
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_layout.dart';
import 'package:pipelines_app/features/chat/workspace/chat_center_stage_strip.dart';
@@ -82,7 +83,10 @@ Widget host(
List<KeyEvent>? fieldKeys,
bool actionBars = false,
bool filesProbe = false,
ThemeMode themeMode = ThemeMode.light,
}) => MaterialApp(
themeMode: themeMode,
darkTheme: ThemeData.dark(),
home: MediaQuery(
data: MediaQueryData(disableAnimations: reduceMotion),
child: Scaffold(
@@ -410,6 +414,71 @@ void main() {
},
);
test(
'the stage edges sit in the gaps beside the stage, or on the workspace edge',
() {
final (left, right) = chatCenterStageEdgeRects(
const Rect.fromLTWH(418, 0, 950, 800),
const Size(1368, 800),
);
expect(left, const Rect.fromLTWH(411.5, 0, 1, 800));
expect(right, const Rect.fromLTWH(1367, 0, 1, 800));
// A stage that reaches the workspace's right edge keeps its hairline inside.
final (edgeLeft, edgeRight) = chatCenterStageEdgeRects(
const Rect.fromLTWH(650, 0, 950, 800),
const Size(1600, 800),
);
expect(edgeLeft, const Rect.fromLTWH(643.5, 0, 1, 800));
expect(edgeRight, const Rect.fromLTWH(1599, 0, 1, 800));
},
);
for (final mode in [ThemeMode.light, ThemeMode.dark]) {
testWidgets(
'center stage draws the column edges in the ${mode.name} theme, only on stage',
(tester) async {
wide(tester);
final workspace = threePanes();
final stage = ChatCenterStageController(store: _MemoryStore());
addTearDown(workspace.dispose);
addTearDown(stage.dispose);
await tester.pumpWidget(host(workspace, stage, themeMode: mode));
await tester.pumpAndSettle();
const leftKey = ValueKey('chat-center-stage-edge-left');
const rightKey = ValueKey('chat-center-stage-edge-right');
expect(find.byKey(leftKey), findsNothing);
expect(find.byKey(rightKey), findsNothing);
stage.value = true;
await tester.pumpAndSettle();
final outline = Theme.of(
tester.element(find.byType(ChatWorkspace)),
).colorScheme.outlineVariant;
for (final key in [leftKey, rightKey]) {
expect(
tester
.widget<ColoredBox>(
find.descendant(
of: find.byKey(key),
matching: find.byType(ColoredBox),
),
)
.color,
outline,
);
}
// The hairlines frame the stage; the reading width is unchanged.
expect(widthOf(tester, 'three'), 950);
stage.value = false;
await tester.pumpAndSettle();
expect(find.byKey(leftKey), findsNothing);
expect(find.byKey(rightKey), findsNothing);
},
);
}
testWidgets('reduced motion stages at once', (tester) async {
wide(tester);
final workspace = threePanes();
@@ -23,6 +23,23 @@ void main() {
expect(search.caveat, contains('browser'));
});
test(
'Open Chat lists Option+K or Alt+K with Ctrl+K and the terminal rule',
() {
KeyboardShortcutEntry openChat(TargetPlatform platform) =>
KeyboardShortcutRegistry(
platform: platform,
web: false,
).entries.firstWhere((entry) => entry.action == 'Open Chat');
expect(openChat(TargetPlatform.macOS).keys, 'Option+K, Ctrl+K');
final linux = openChat(TargetPlatform.linux);
expect(linux.keys, 'Alt+K, Ctrl+K');
expect(linux.caveat, contains('kill-line'));
expect(openChat(TargetPlatform.windows).keys, 'Alt+K, Ctrl+K');
},
);
test('uses the shell primary modifier rule on iOS', () {
final entries = const KeyboardShortcutRegistry(
platform: TargetPlatform.iOS,
@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart'
as transport;
import 'package:pipelines_app/features/settings/settings_keys.dart';
import 'package:pipelines_app/features/settings/settings_screen.dart';
import 'package:pipelines_app/features/settings/settings_store.dart';
import 'fake_channel.dart';
import 'settings_topic_test_helper.dart';
/// The Tools topic's Library group lists Schedules only: Templates left
/// Settings, and Schedules keeps its own route.
void main() {
Future<void> pump(
WidgetTester tester, {
VoidCallback? onOpenSchedules,
}) async {
await tester.binding.setSurfaceSize(const Size(560, 1000));
addTearDown(() => tester.binding.setSurfaceSize(null));
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SettingsScreen(
client: client,
store: MemorySettingsStore(),
embedded: true,
onOpenSchedules: onOpenSchedules,
),
),
),
);
await tester.pump();
await selectSettingsTopic(tester, 'Tools');
}
testWidgets('Tools offers Schedules and no Templates entry', (tester) async {
var opened = 0;
await pump(tester, onOpenSchedules: () => opened++);
expect(find.text('Library'), findsOneWidget);
expect(find.text('Browse templates'), findsNothing);
expect(
find.byKey(const ValueKey<String>('settings.templates')),
findsNothing,
);
await tester.ensureVisible(find.byKey(SettingsKeys.schedules));
await tester.tap(find.byKey(SettingsKeys.schedules));
await tester.pump();
expect(opened, 1);
});
testWidgets('without a Schedules route the Library group is absent', (
tester,
) async {
await pump(tester);
expect(find.text('Library'), findsNothing);
expect(find.text('Browse templates'), findsNothing);
expect(find.byKey(SettingsKeys.schedules), findsNothing);
});
}
@@ -0,0 +1,181 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/shell_chat_shortcut.dart';
import 'package:pipelines_app/ui/input/keyboard_owner.dart';
const _k = KeyDownEvent(
physicalKey: PhysicalKeyboardKey.keyK,
logicalKey: LogicalKeyboardKey.keyK,
timeStamp: Duration.zero,
);
void main() {
test('Ctrl+K and Alt+K open Chat; other modifiers and plain K do not', () {
bool chord(Set<LogicalKeyboardKey> held, [KeyEvent event = _k]) =>
shellChatShortcut(event, _FakeKeyboard(held));
expect(chord({}), isFalse);
expect(chord({LogicalKeyboardKey.controlLeft}), isTrue);
expect(chord({LogicalKeyboardKey.altLeft}), isTrue);
expect(
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.altLeft}),
isFalse,
);
expect(
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.shiftLeft}),
isFalse,
);
expect(chord({LogicalKeyboardKey.metaLeft}), isFalse);
expect(
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.metaLeft}),
isFalse,
);
expect(
shellChatShortcut(
const KeyUpEvent(
physicalKey: PhysicalKeyboardKey.keyK,
logicalKey: LogicalKeyboardKey.keyK,
timeStamp: Duration.zero,
),
_FakeKeyboard({LogicalKeyboardKey.controlLeft}),
),
isFalse,
);
});
test('Option+K matches by key position though it types a symbol', () {
// On a Mac, Option+K produces ˚: the logical key is not K.
const ring = KeyDownEvent(
physicalKey: PhysicalKeyboardKey.keyK,
logicalKey: LogicalKeyboardKey(0x02da),
character: '˚',
timeStamp: Duration.zero,
);
expect(
shellChatShortcut(ring, _FakeKeyboard({LogicalKeyboardKey.altLeft})),
isTrue,
);
// Without Alt the same symbol is ordinary typing.
expect(shellChatShortcut(ring, _FakeKeyboard({})), isFalse);
});
test('labels name the Option chord on Apple platforms', () {
expect(shellChatShortcutLabels(TargetPlatform.linux), ['Alt+K', 'Ctrl+K']);
expect(shellChatShortcutLabels(TargetPlatform.macOS), [
'Option+K',
'Ctrl+K',
]);
});
testWidgets('Ctrl+K and Alt+K show Chat from another destination', (
tester,
) async {
var opened = 0;
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: {
for (final destination in shellTabDestinations)
destination: (_) => Text('${destination.name} body'),
},
onOpenChat: () => opened++,
),
),
);
expect(find.text('pipelines body'), isOnstage);
// Chat is built on its first visit only.
expect(find.text('chat body'), findsNothing);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyK);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
// The outgoing tab fades out while still mounted, so Chat being built
// and onstage is the switch.
expect(find.text('chat body'), isOnstage);
expect(opened, 1);
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyK);
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
await tester.pump();
expect(find.text('chat body'), isOnstage);
// Already in Chat, the chord still hands the keyboard to the composer.
expect(opened, 2);
expect(tester.takeException(), isNull);
});
testWidgets('a controlled shell reports the switch to Chat', (tester) async {
final selected = <AppDestination>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destination: AppDestination.runs,
onDestinationSelected: selected.add,
destinationBodies: {
for (final destination in shellTabDestinations)
destination: (_) => Text('${destination.name} body'),
},
),
),
);
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyK);
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
await tester.pump();
expect(selected, [AppDestination.chat]);
});
testWidgets(
'terminal keeps Ctrl+K for kill-line but Alt+K still opens Chat',
(tester) async {
final terminal = FocusNode();
addTearDown(terminal.dispose);
var opened = 0;
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
onOpenChat: () => opened++,
destinationBodies: {
AppDestination.pipelines: (_) => TypingSurface(
child: Focus(
focusNode: terminal,
child: const Text('terminal'),
),
),
AppDestination.chat: (_) => const Text('chat body'),
},
),
),
);
terminal.requestFocus();
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyK);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pump();
expect(find.text('chat body'), findsNothing);
expect(find.text('terminal'), isOnstage);
expect(opened, 0);
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyK);
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
await tester.pump();
expect(find.text('chat body'), isOnstage);
expect(opened, 1);
expect(tester.takeException(), isNull);
},
);
}
class _FakeKeyboard extends HardwareKeyboard {
_FakeKeyboard(this.pressed);
final Set<LogicalKeyboardKey> pressed;
@override
bool isLogicalKeyPressed(LogicalKeyboardKey key) => pressed.contains(key);
}