Merge commit 'a88a7bddaf656394bbea74bb42a5e1656b52847d' into pipelines/run-20261112-0053-chat-list-more-menu-matches-the-pane-mor-f0d0

This commit is contained in:
2026-11-12 01:23:49 +00:00
43 changed files with 1248 additions and 346 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,
@@ -156,11 +156,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';
@@ -87,7 +87,7 @@ class ChatSessionsBody extends StatelessWidget {
emptyMessageOverride ??
(sessions.isEmpty
? error == null
? 'No chat sessions on this server yet.'
? 'No chats yet. Use New chat to start one.'
: null
: 'No chats match "${query.trim()}".');
@@ -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,
@@ -77,11 +77,13 @@ class PipelineFilters {
);
}
/// The empty-state sentence for the list plus its optional reset action.
/// The empty-state sentence for the list, an optional line naming the next
/// step, and an optional reset action.
class PipelineEmptyState {
const PipelineEmptyState(this.message, {this.clearAction});
const PipelineEmptyState(this.message, {this.detail, this.clearAction});
final String message;
final String? detail;
final String? clearAction;
}
@@ -153,7 +155,10 @@ PipelineEmptyState? pipelineListEmptyState(
) {
if (items.isNotEmpty) return null;
if (all.isEmpty) {
return const PipelineEmptyState('No pipelines are defined on this server.');
return const PipelineEmptyState(
'No pipelines yet.',
detail: 'Create one from a template in Templates.',
);
}
final name = filters.name;
final onlyName =
@@ -192,6 +192,15 @@ class PipelineListPanel extends StatelessWidget {
textAlign: TextAlign.center,
style: _mutedStyle(context),
),
if (empty.detail != null)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
empty.detail!,
textAlign: TextAlign.center,
style: _mutedStyle(context),
),
),
if (empty.clearAction != null)
PipelineTextButton(
label: empty.clearAction!,
+20 -6
View File
@@ -163,18 +163,32 @@ class RunsList extends StatelessWidget {
// Filtered and sorted once per build: the getter recomputes every read.
final visible = controller.visibleRuns;
if (visible.isNotEmpty) return _groupedRuns(context, header, visible);
// A server with no runs at all is not a filter problem: say what the list
// is for and where its first run comes from. A free-text query counts as
// a filter too, so a search on an empty server reads as "nothing found".
final noRunsAtAll = controller.runs.isEmpty &&
controller.activeFilterCount == 0 &&
controller.query.trim().isEmpty;
return BelowTopBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
...header,
Expanded(
child: _state(
context,
icon: const Icon(Icons.inbox_outlined),
title: 'No runs found.',
subtitle: 'Try changing or clearing the filters.',
),
child: noRunsAtAll
? _state(
context,
icon: const Icon(Icons.inbox_outlined),
title: 'No runs yet.',
subtitle:
'Start one from Pipelines and its runs appear here.',
)
: _state(
context,
icon: const Icon(Icons.inbox_outlined),
title: 'No runs found.',
subtitle: 'Try changing or clearing the filters.',
),
),
],
),
@@ -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.
+61
View File
@@ -0,0 +1,61 @@
# Empty-server states (Pipelines, Runs, Chat)
On a brand-new server (no pipelines, runs or chats) the healthy empty reply
should read as "nothing here yet" with the next step, not as a filter problem
or a missing list. Real failures keep their error treatment and never show the
empty copy.
## Changed states
| Destination | Before (empty, healthy server) | After |
| --- | --- | --- |
| Pipelines list | "No pipelines are defined on this server." | "No pipelines yet." + "Create one from a template in Templates." |
| Runs list | "No runs found." + "Try changing or clearing the filters." | "No runs yet." + "Start one from Pipelines and its runs appear here." |
| Runs list, filter hides every run | (same as above) | unchanged: "No runs found." + filter hint |
| Chat list | "No chat sessions on this server yet." | "No chats yet. Use New chat to start one." |
Source: `lib/features/pipelines/pipeline_filter.dart`,
`lib/features/pipelines/widgets/pipeline_list_panel.dart` (renders the new
`PipelineEmptyState.detail` line), `lib/features/runs/ui/runs_list.dart`,
`lib/features/chat/ui/sessions/chat_sessions_body.dart`.
Unchanged error paths: a failed Pipelines list shows its error banner with
Retry; a failed Runs list shows the error with Retry; a failed chat load hides
the empty message and shows the reason.
## Focused results
Command (from `app/`): `tool/memwatch/full.sh 'test/features/pipelines/pipelines_empty_server_test.dart test/features/pipelines/pipeline_filter_test.dart test/features/pipelines/pipelines_screen_filter_test.dart test/features/runs/ui/runs_list_widget_test.dart test/features/chat/ui/sessions/chat_sessions_screen_test.dart test/features/chat/ui/sessions/chat_ios_material_test.dart'`
- Before the source change (new and updated expectations): 18 passed, 6 failed,
as expected on the old copy. The new test file also failed to compile
(missing `Key` import), fixed before the rerun.
- After the change: PASS, 25 passed, 0 failed, peak 1484 MB, 5s.
- Review fix (runs must-fix): the no-runs state now also requires an empty
free-text query, so an empty server with a search query shows "No runs
found." with the filter hint. Covered by a new widget test in
`runs_list_widget_test.dart`. Focused rerun of that file: PASS, 6 passed,
0 failed, peak 768 MB, 4s.
- `tool/analyze.sh`: clean (rerun after the review fix).
New or extended coverage:
- `test/features/pipelines/pipelines_empty_server_test.dart`: empty server shows
the no-pipelines state and next step, with no spinner, list or Retry; a failed
list still shows the error and not the empty copy.
- `test/features/runs/ui/runs_list_widget_test.dart`: loading, error, and
server-empty states stay distinct; a status filter that hides every run keeps
the "No runs found." filter state.
- Chat and pipeline-filter expectations updated to the new copy.
## Not verified here
- No UI build or capture; `ui-review` owns rendered evidence.
- Schedules, Search, Settings, Usage/stats, Needs-you and Templates were read,
not changed or tested. Their empty copy is already calm, except that
"No schedules yet." has no next step because the list has no add action.
Stats says "No runs loaded." (secondary text, not an error).
- Runs and other error text still shows the raw error string (`'$e'`); this is
not an empty-server path and was not changed.
- Server gap: this stage did not check Go's empty-database replies. The client
treats an empty list as healthy. No Go change was made.
@@ -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));
@@ -13,6 +13,7 @@ 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';
import 'package:pipelines_app/shell/windows/window_host.dart';
import 'package:pipelines_app/shell/windows/window_kind.dart';
@@ -50,6 +51,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';
@@ -107,6 +118,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;
@@ -126,6 +138,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,
@@ -243,6 +262,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);
@@ -477,6 +509,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');
@@ -17,7 +17,7 @@ void main() {
expect(find.byType(Scaffold), findsWidgets);
const message = 'No chat sessions on this server yet.';
const message = 'No chats yet. Use New chat to start one.';
expect(find.text(message), findsOneWidget);
expectNormalTextStyle(tester, message);
});
@@ -39,7 +39,7 @@ void main() {
'for this operator';
expect(find.text(message), findsOneWidget);
expectNormalTextStyle(tester, message);
expect(find.text('No chat sessions on this server yet.'), findsNothing);
expect(find.text('No chats yet. Use New chat to start one.'), findsNothing);
expect(
find.ancestor(
of: find.text('Retry'),
@@ -91,7 +91,10 @@ void main() {
) async {
final gateway = FakeChatGateway();
await pumpMaterialChat(tester, gateway);
expect(find.text('No chat sessions on this server yet.'), findsOneWidget);
expect(
find.text('No chats yet. Use New chat to start one.'),
findsOneWidget,
);
expect(find.textContaining('No chats match'), findsNothing);
});
@@ -111,7 +114,7 @@ void main() {
'Bad state: server unavailable while listing chat sessions '
'for this operator';
expect(find.text(message), findsOneWidget);
expect(find.text('No chat sessions on this server yet.'), findsNothing);
expect(find.text('No chats yet. Use New chat to start one.'), findsNothing);
final messageBox = tester.renderObject<RenderBox>(find.text(message));
expect(
messageBox.size.height,
@@ -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();
@@ -132,7 +132,7 @@ void main() {
const [],
const PipelineFilters(),
)?.message,
'No pipelines are defined on this server.',
'No pipelines yet.',
);
expect(pipelineListEmptyState(all, all, const PipelineFilters()), isNull);
});
@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'fixtures.dart';
import 'test_helpers.dart';
/// A brand-new server: every list is empty and healthy.
FakeGateway emptyServerGateway() => FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(const []),
'list_runs' => runListReply(const []),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
},
);
void main() {
testWidgets(
'an empty server shows a calm no-pipelines state with the next step',
(tester) async {
await pumpWide(tester, emptyServerGateway());
expect(find.text('No pipelines yet.'), findsOneWidget);
expect(
find.text('Create one from a template in Templates.'),
findsOneWidget,
);
expect(find.text('Loading pipelines…'), findsNothing);
expect(find.byKey(const Key('pipeline-list')), findsNothing);
expect(find.textContaining('not defined'), findsNothing);
expect(find.text('Retry'), findsNothing);
expect(tester.takeException(), isNull);
},
);
testWidgets(
'a failed list stays an error and never reads as an empty server',
(tester) async {
await pumpWide(
tester,
gatewayFor(PipelineFixture(), listFails: true, summaries: const []),
);
expect(find.textContaining('server offline'), findsOneWidget);
expect(find.text('No pipelines yet.'), findsNothing);
expect(find.text('Loading pipelines…'), findsNothing);
expect(tester.takeException(), isNull);
},
);
}
@@ -98,8 +98,9 @@ void main() {
MaterialApp(home: PipelinesScreen(gateway: emptyGateway)),
);
await tester.pumpAndSettle();
expect(find.text('No pipelines yet.'), findsOneWidget);
expect(
find.text('No pipelines are defined on this server.'),
find.text('Create one from a template in Templates.'),
findsOneWidget,
);
});
@@ -162,9 +162,50 @@ void main() {
gateway.reply = {'runs': []};
await controller.load();
await tester.pumpAndSettle();
expect(find.text('No runs found.'), findsOneWidget);
expect(find.text('No runs yet.'), findsOneWidget);
expect(find.textContaining('Start one from Pipelines'), findsOneWidget);
expect(find.text('No runs found.'), findsNothing);
expect(find.textContaining('offline'), findsNothing);
expect(tester.takeException(), isNull);
// A filter that hides every run is a different state: say so and offer
// the filter as the way back, not a server with no runs.
controller.setStatus('failed');
await tester.pumpAndSettle();
expect(find.text('No runs found.'), findsOneWidget);
expect(find.text('No runs yet.'), findsNothing);
expect(
find.text('Try changing or clearing the filters.'),
findsOneWidget,
);
expect(tester.takeException(), isNull);
},
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
testWidgets(
'an empty server with a search query reads as no match, not no runs',
(tester) async {
gateway.failure = null;
gateway.gate = null;
gateway.reply = {'runs': []};
await controller.load();
controller.setQuery('deploy');
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunsList(controller: controller, onSelected: (_) {}),
),
),
);
await tester.pumpAndSettle();
expect(find.text('No runs found.'), findsOneWidget);
expect(find.text('No runs yet.'), findsNothing);
expect(
find.text('Try changing or clearing the filters.'),
findsOneWidget,
);
expect(tester.takeException(), isNull);
},
variant: TargetPlatformVariant.only(TargetPlatform.android),
);
@@ -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);
}