Merge commit '06d3e23b796c81aeeef21b27d9cfeb0697845247' into pipelines/run-20261112-0129-desktop-navigation-rail-with-settings-9292

This commit is contained in:
2026-11-12 02:29:16 +00:00
32 changed files with 968 additions and 144 deletions
@@ -107,7 +107,12 @@ Widget runDetailSummaryTab({
title: 'Output',
controller: outputController,
copyText: runFieldCopyText(run['output']),
body: RunFieldBody(value: run['output'], empty: visitEmptyOutput),
// Output starts open, so it is a sliver: a long one builds only the
// fields on screen.
sliverBody: RunFieldSliver(
value: run['output'],
empty: visitEmptyOutput,
),
),
const SliverToBoxAdapter(child: SizedBox(height: 16)),
const SliverFloatingBarClearance(),
@@ -115,19 +120,25 @@ Widget runDetailSummaryTab({
);
}
/// A summary section that starts closed, follows its [controller] (so a
/// search hit can open it), and offers a copy of its recorded text.
/// A summary section that follows its [controller] (its open state starts from
/// the controller's; a search hit can open it), and offers a copy of its
/// recorded text.
class _StickyField extends StatefulWidget {
const _StickyField({
super.key,
required this.title,
required this.body,
this.body,
this.sliverBody,
this.controller,
this.copyText,
});
}) : assert((body == null) != (sliverBody == null));
final String title;
final Widget body;
/// The content as a box, or as [sliverBody] for a long one (see
/// [StickySection.sliverBody]); exactly one is given.
final Widget? body;
final Widget? sliverBody;
final ExpansibleController? controller;
final String? copyText;
@@ -158,25 +169,31 @@ class _StickyFieldState extends State<_StickyField> {
final copyText = widget.copyText;
return ListenableBuilder(
listenable: _controller,
builder: (context, _) => StickySection(
title: widget.title,
open: _controller.isExpanded,
onToggle: () => _controller.isExpanded
? _controller.collapse()
: _controller.expand(),
trailing: [
if (copyText != null && copyText.isNotEmpty)
IconButton(
tooltip: 'Copy ${widget.title}',
onPressed: _copy,
icon: Icon(_copied ? Icons.check : Icons.copy),
),
],
body: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: widget.body,
),
),
builder: (context, _) {
// The body's own padding, the same for the box and the sliver form.
const padding = EdgeInsets.fromLTRB(16, 0, 16, 16);
final box = widget.body;
final sliver = widget.sliverBody;
return StickySection(
title: widget.title,
open: _controller.isExpanded,
onToggle: () => _controller.isExpanded
? _controller.collapse()
: _controller.expand(),
trailing: [
if (copyText != null && copyText.isNotEmpty)
IconButton(
tooltip: 'Copy ${widget.title}',
onPressed: _copy,
icon: Icon(_copied ? Icons.check : Icons.copy),
),
],
body: box == null ? null : Padding(padding: padding, child: box),
sliverBody: sliver == null
? null
: SliverPadding(padding: padding, sliver: sliver),
);
},
);
}
}
+17 -11
View File
@@ -98,12 +98,13 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
Route<void>? _visitRoute;
late final ValueNotifier<JsonMap> _liveRun = ValueNotifier(widget.run);
/// The Summary's collapsible Input and Output sections. A search text hit
/// expands the one its recorded field names, exactly as the browser opens the
/// matching Summary section. The detail owns them so the tab body stays a
/// presentation widget.
/// The Summary's collapsible Input and Output sections. Output starts open
/// and Input starts closed; the operator may close either for this view. A
/// search text hit expands the one its recorded field names, exactly as the
/// browser opens the matching Summary section. The detail owns them so the
/// tab body stays a presentation widget.
final _inputSection = ExpansibleController();
final _outputSection = ExpansibleController();
final _outputSection = ExpansibleController()..expand();
/// The search request last applied by this detail, so a rebuild of the same
/// request never reopens a pane the operator closed in the meantime.
@@ -124,6 +125,12 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
_applySearchSelection();
}
/// The Summary's default sections: Input closed, Output open.
void _resetSummarySections() {
_inputSection.collapse();
_outputSection.expand();
}
@override
void dispose() {
_inputSection.dispose();
@@ -146,8 +153,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
_tab = RunDetailTab.summary;
_selectedStage = null;
_selectedVisit = null;
_inputSection.collapse();
_outputSection.collapse();
_resetSummarySections();
_applyInitialVisit();
} else if (!sameTarget) {
// A route that names another stage or visit is applied to the same run.
@@ -231,10 +237,10 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
case RunSummarySection.output:
_outputSection.expand();
case null:
// A hit that names no section must not leave a previously expanded
// one open; the Summary panel starts collapsed.
_inputSection.collapse();
_outputSection.collapse();
// A hit that names no section must not leave a previously toggled
// one in a state the operator did not open; the Summary returns to
// its default sections.
_resetSummarySections();
}
case RunVisitTarget(:final stageKey, :final timelineIndex):
if (detailVisitStepAt(widget.run, timelineIndex) == null) return;
@@ -111,7 +111,8 @@ Widget runVisitSectionBody({
);
switch (section) {
case RunVisitSection.summary:
// Input then Output, each a sticky collapsible with a copy button.
// Input then Output, each a sticky collapsible with a copy button; Output
// starts open.
return _VisitSummary(
key: ValueKey('run-visit-summary-$visitIndex'),
input: step['input'],
@@ -181,7 +182,9 @@ class _VisitSummary extends StatefulWidget {
}
class _VisitSummaryState extends State<_VisitSummary> {
final Set<String> _closed = {'Input', 'Output'};
/// The sections the operator has closed. Input starts closed; Output starts
/// open, and this set is per visit view.
final Set<String> _closed = {'Input'};
String? _copied;
Future<void> _copy(String name, dynamic value) async {
@@ -189,7 +192,14 @@ class _VisitSummaryState extends State<_VisitSummary> {
if (mounted) setState(() => _copied = name);
}
Widget _section(String name, dynamic value, String empty) {
/// [lazy] builds the field as a sliver, for a section open by default (the
/// Output): a long one then lays out only the fields on screen.
Widget _section(
String name,
dynamic value,
String empty, {
bool lazy = false,
}) {
final copy = IconButton(
key: ValueKey('run-visit-copy-$name'),
tooltip: 'Copy $name',
@@ -197,6 +207,7 @@ class _VisitSummaryState extends State<_VisitSummary> {
icon: Icon(_copied == name ? Icons.check : Icons.copy),
);
final open = !_closed.contains(name);
const padding = EdgeInsets.fromLTRB(16, 0, 16, 16);
return StickySection(
key: ValueKey('run-visit-section-$name'),
title: name,
@@ -205,10 +216,18 @@ class _VisitSummaryState extends State<_VisitSummary> {
if (!_closed.remove(name)) _closed.add(name);
}),
trailing: [copy],
body: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: RunFieldBody(value: value, empty: empty),
),
body: lazy
? null
: Padding(
padding: padding,
child: RunFieldBody(value: value, empty: empty),
),
sliverBody: lazy
? SliverPadding(
padding: padding,
sliver: RunFieldSliver(value: value, empty: empty),
)
: null,
);
}
@@ -221,7 +240,7 @@ class _VisitSummaryState extends State<_VisitSummary> {
const SliverTopBarClearance(),
if (widget.facts case final facts?) SliverToBoxAdapter(child: facts),
_section('Input', widget.input, visitEmptyInput),
_section('Output', widget.output, visitEmptyOutput),
_section('Output', widget.output, visitEmptyOutput, lazy: true),
const SliverFloatingBarClearance(),
],
);
+87 -28
View File
@@ -55,40 +55,99 @@ class RunFieldBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
final map = value is Map ? Map<String, dynamic>.from(value as Map) : null;
if (map == null || map.isEmpty) return _plain(empty);
if (map.length == 1 && map.keys.single.toLowerCase() == 'markdown') {
return _value(runFieldText(map.values.single));
final map = _runFieldMap(value);
if (map == null || map.isEmpty) {
return _runFieldPlain(empty, textBuilder);
}
if (_isMarkdownDocument(map)) {
return _runFieldValue(runFieldText(map.values.single), textBuilder);
}
final caption = Theme.of(context).textTheme.labelMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
for (final (index, entry) in map.entries.indexed)
Padding(
padding: EdgeInsets.only(top: index == 0 ? 0 : 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
entry.key.trim().isEmpty ? 'value' : entry.key,
style: caption,
),
const SizedBox(height: 2),
_value(runFieldText(entry.value)),
],
),
),
_runFieldRow(context, index, entry, textBuilder),
],
);
}
Widget _value(String text) => runFieldLooksLikeMarkdown(text)
? ChatMarkdownView(text: text)
: _plain(text);
Widget _plain(String text) => textBuilder?.call(text) ?? SelectableText(text);
}
/// [RunFieldBody] as a sliver, for a section of a [CustomScrollView] that is
/// open by default. A field map builds and lays out only the fields on screen,
/// however many there are, so a long Output does not cost a full layout when
/// its section opens. Its rows take the full width the sliver gives them; the
/// host pads it.
class RunFieldSliver extends StatelessWidget {
const RunFieldSliver({
super.key,
required this.value,
required this.empty,
this.textBuilder,
});
final dynamic value;
final String empty;
/// Draws a plain value; the host's selectable text by default.
final Widget Function(String text)? textBuilder;
@override
Widget build(BuildContext context) {
final map = _runFieldMap(value);
if (map == null || map.isEmpty || _isMarkdownDocument(map)) {
return SliverToBoxAdapter(
child: RunFieldBody(
value: value,
empty: empty,
textBuilder: textBuilder,
),
);
}
final entries = map.entries.toList(growable: false);
return SliverList.builder(
itemCount: entries.length,
itemBuilder: (context, index) =>
_runFieldRow(context, index, entries[index], textBuilder),
);
}
}
Map<String, dynamic>? _runFieldMap(dynamic value) =>
value is Map ? Map<String, dynamic>.from(value) : null;
/// A lone `markdown` field, shown as the document itself.
bool _isMarkdownDocument(Map<String, dynamic> map) =>
map.length == 1 && map.keys.single.toLowerCase() == 'markdown';
/// One recorded field: its name, then its value.
Widget _runFieldRow(
BuildContext context,
int index,
MapEntry<String, dynamic> entry,
Widget Function(String text)? textBuilder,
) {
final theme = Theme.of(context);
final caption = theme.textTheme.labelMedium?.copyWith(
fontWeight: FontWeight.w600,
color: theme.colorScheme.onSurfaceVariant,
);
return Padding(
padding: EdgeInsets.only(top: index == 0 ? 0 : 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(entry.key.trim().isEmpty ? 'value' : entry.key, style: caption),
const SizedBox(height: 2),
_runFieldValue(runFieldText(entry.value), textBuilder),
],
),
);
}
Widget _runFieldValue(String text, Widget Function(String text)? textBuilder) =>
runFieldLooksLikeMarkdown(text)
? ChatMarkdownView(text: text)
: _runFieldPlain(text, textBuilder);
Widget _runFieldPlain(String text, Widget Function(String text)? textBuilder) =>
textBuilder?.call(text) ?? SelectableText(text);
@@ -5,6 +5,7 @@ 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_runs_pipelines_shortcut.dart';
import '../../shell/shell_search_shortcut_labels.dart';
/// A shortcut entry shown in the in-app help. Keeping these entries together
@@ -61,6 +62,12 @@ class KeyboardShortcutRegistry {
? '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.',
),
const KeyboardShortcutEntry(
action: 'Switch between Runs and Pipelines',
keys: shellRunsPipelinesShortcutLabel,
caveat:
'Goes to Runs from other destinations and to Pipelines from Runs. In a text field or the terminal Ctrl+A keeps its own meaning.',
),
KeyboardShortcutEntry(
action: 'Toggle Center Stage',
keys:
@@ -17,7 +17,7 @@ const _terminalContent = 'terminal';
///
/// [TerminalLayout] stays the terminal's own state (shown, panel or float):
/// showing it in float mode opens or shows the window, hiding minimises it,
/// and the window's Minimise and Close hide the terminal.
/// and the window's X (minimise) hides the terminal.
class TerminalWindows {
TerminalWindows({
required this.manager,
@@ -110,7 +110,7 @@ class TerminalWindows {
if (legacy && layout.maximized) manager.setMaximized(entry.id, true);
}
/// The window's Minimise or Close (or the windows' own show and hide)
/// The window's X or Minimise (or the windows' own show and hide)
/// hides the terminal.
void _windowsChanged() {
if (!_started || !_ready || _syncing || !_wanted) return;
+11 -2
View File
@@ -13,6 +13,7 @@ import 'list_pane_widths.dart';
import 'shell_bar.dart';
import 'shell_chat_shortcut.dart';
import 'shell_list_shortcuts.dart';
import 'shell_runs_pipelines_shortcut.dart';
import 'shell_search_shortcut_labels.dart';
import 'tab_history.dart';
import '../ui/input/keyboard_owner.dart';
@@ -322,8 +323,9 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
}
/// App-wide search and conversation-list selection are handled before text
/// fields. Split-pane navigation belongs to the chat workspace; tab changes
/// have no global keyboard chord.
/// fields. Split-pane navigation belongs to the chat workspace. Ctrl+A
/// bounces between Runs and Pipelines, but leaves text fields and the
/// terminal their own Ctrl+A (select all, line start).
bool _handleDestinationKeyEvent(KeyEvent event) {
final keyboard = HardwareKeyboard.instance;
// Ctrl+K is the terminal's kill-line while the terminal has the keyboard;
@@ -333,6 +335,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
if (event is KeyDownEvent) _openChat();
return true;
}
if (shellRunsPipelinesShortcut(event, keyboard)) {
if (primaryFocusTakesTyping()) return false;
if (event is KeyDownEvent) {
_select(shellRunsPipelinesTarget(_selected));
}
return true;
}
// A terminal keeps its keys (Escape, Ctrl+/, Ctrl+digits).
if (primaryFocusIsTypingSurface()) return false;
if (_selected == AppDestination.search &&
@@ -0,0 +1,28 @@
import 'package:flutter/services.dart';
import 'destination.dart';
/// The chord that bounces between Runs and Pipelines, as the help page reads
/// it. It is the same on every platform.
const shellRunsPipelinesShortcutLabel = 'Ctrl+A';
/// Whether [event] is Ctrl+A. Only Ctrl counts: Alt, 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 shellRunsPipelinesShortcut(KeyEvent event, HardwareKeyboard keyboard) {
if (event is KeyUpEvent ||
keyboard.isAltPressed ||
keyboard.isShiftPressed ||
keyboard.isMetaPressed ||
!keyboard.isControlPressed) {
return false;
}
return event.logicalKey == LogicalKeyboardKey.keyA;
}
/// The destination Ctrl+A goes to from [current]: Pipelines from Runs, and
/// Runs from every other destination (Pipelines included).
AppDestination shellRunsPipelinesTarget(AppDestination current) =>
current == AppDestination.runs
? AppDestination.pipelines
: AppDestination.runs;
+1 -1
View File
@@ -37,7 +37,7 @@ class WindowEntry {
/// The saved frame; it is drawn fitted inside the window area.
final Rect frame;
/// Hidden by its minimise button; still listed and shown again with its
/// Hidden by the title bar's X; still listed and shown again with its
/// group.
final bool minimized;
final bool maximized;
+7 -11
View File
@@ -11,8 +11,9 @@ double windowTitleBarHeight(BuildContext context) =>
MediaQuery.textScalerOf(context).scale(40).clamp(40.0, 64.0);
/// A floating window's card and title bar: the title (drag to move, double
/// click to maximise), the kind's actions, then Minimise, Maximise and
/// Close. The content is drawn over the card's body by the window's
/// click to maximise), the kind's actions, then Maximise and the X. The X
/// minimises: it hides the window and keeps its state, like the chord does
/// in reverse. The content is drawn over the card's body by the window's
/// navigator.
class WindowFrame extends StatelessWidget {
const WindowFrame({
@@ -25,7 +26,6 @@ class WindowFrame extends StatelessWidget {
required this.onMoveEnd,
required this.onMinimize,
required this.onToggleMaximized,
required this.onClose,
});
final String title;
@@ -36,9 +36,10 @@ class WindowFrame extends StatelessWidget {
/// The drag's delta and the pointer's global position.
final void Function(Offset delta, Offset globalPosition) onMove;
final VoidCallback onMoveEnd;
/// The X: hides the window, keeping it listed and its state.
final VoidCallback onMinimize;
final VoidCallback onToggleMaximized;
final VoidCallback onClose;
@override
Widget build(BuildContext context) {
@@ -69,11 +70,6 @@ class WindowFrame extends StatelessWidget {
onPressed: action.onPressed,
icon: Icon(action.icon),
),
IconButton(
tooltip: 'Minimise',
onPressed: onMinimize,
icon: const Icon(Icons.minimize),
),
IconButton(
tooltip: maximized ? 'Restore size' : 'Maximise',
onPressed: onToggleMaximized,
@@ -82,8 +78,8 @@ class WindowFrame extends StatelessWidget {
),
),
IconButton(
tooltip: 'Close',
onPressed: onClose,
tooltip: 'Minimise',
onPressed: onMinimize,
icon: const Icon(Icons.close),
),
const SizedBox(width: 4),
+3 -3
View File
@@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'window_entry.dart';
/// One action in a window's title bar, before Minimise and Close (Dock on a
/// One action in a window's title bar, before Maximise and the X (Dock on a
/// chat, a kind's own menu).
class WindowAction {
const WindowAction({
@@ -42,7 +42,7 @@ abstract class WindowKind {
/// The window's content, below the title bar.
Widget build(BuildContext context, WindowEntry entry);
/// Title-bar actions before Minimise and Close.
/// Title-bar actions before Maximise and the X.
List<WindowAction> actions(BuildContext context, WindowEntry entry) =>
const [];
@@ -57,7 +57,7 @@ abstract class WindowKind {
/// as its window takes focus. The default leaves it on the window.
void focusContent(WindowEntry entry) {}
/// Called after the user closes the window (the X).
/// Called after the window is closed (Dock, Close all, a chat's /close).
void closed(WindowEntry entry) {}
/// Validates a saved window's [WindowEntry.data]; null drops the window.
-1
View File
@@ -259,7 +259,6 @@ class _WindowLayerState extends State<WindowLayer>
onMinimize: () => manager.setMinimized(_id, true),
onToggleMaximized: () =>
manager.setMaximized(_id, !entry.maximized),
onClose: () => manager.close(_id),
),
),
),
@@ -229,11 +229,14 @@ class _Frame {
required bool tracking,
}) {
const curve = Curves.fastOutSlowIn;
// Played backwards in time, the same easing reads as the item settling.
// Closing reads `t` from 1 to 0, so easeIn of `t` is a shrink that
// decelerates in time and starts on the first frame. The time-reversed
// fastOutSlowIn barely moved for its first ~60 ms, which read as Back
// doing nothing.
final grown = tracking
? t
: closing
? curve.flipped.transform(t)
? Curves.easeInCubic.transform(t)
: curve.transform(t);
// Opening covers the item first and shows the page late; closing hides
// the page first and uncovers the item late.
+54
View File
@@ -0,0 +1,54 @@
# Chat Back starts immediately (phone)
## Finding
Static reading of the phone chat path (`DetailPageHost`, `ContainerTransformPageRoute`,
`ContainerTransformFlight`, the chat screen's `_back`, the shell's back handling) found no
awaited work before the pop. Draft, scroll and transcript saves run fire-and-forget or in
`dispose`, after the reverse animation. `DetailPageHost`'s `onClosed` runs when the route is
disposed, so it cannot delay the pop.
The delay the user sees is the close curve. Closing used `Curves.fastOutSlowIn.flipped`
against the animation value, which barely moves for its first ~60 ms. The page sat still
after Back, then began to shrink.
## Change
`lib/ui/motion/container_transform_flight.dart`: the closing shrink uses
`Curves.easeInCubic.transform(t)` on the reverse animation value. That is a shrink that starts
on the first frame and decelerates into the row. Opening is unchanged. The reverse duration
stays at `Motion.containerTransformReverse` = 250 ms (≤300 ms).
## Measured (widget test, fake frame clock, 390x844, 16 ms per frame)
Share of the page's shrink travel completed after each frame following the system Back
(`handlePopRoute` then `pump`). The first frame after the pop only starts the ticker, so it
reads 0 in both builds.
| Elapsed after pop | Before | After |
| --- | ---: | ---: |
| 16 ms | 0.0% | 0.0% |
| 32 ms | 1.0% | 15.7% |
| 48 ms | 4.6% | 30.7% |
| 64 ms | 12.1% | 44.1% |
| 80 ms | 25.2% | 56.4% |
The Back route is no longer current, and its animation is `reverse`, after the first pump
in both builds. Route change was already synchronous.
## Focused tests
Command: `tool/memwatch/full.sh 'test/ui/motion/container_transform_back_start_test.dart test/ui/motion/container_transform_route_test.dart test/shell/detail_page_test.dart test/features/chat/chat_open_transition_test.dart'`
Result: 15 passed, 0 failed (peak 1284 MB, 11 s).
- New regression `container_transform_back_start_test.dart`: system Back changes the route
in one pump, and the page is more than 10% shrunk 16 ms later. The owner's close work
awaits a future that never completes, and Back still starts. Against the old curve this
test fails (shrink 0.99%).
- `tool/analyze.sh`: clean.
## Not verified
- `tool/chat_back_latency_probe.mjs` (browser) was not run; UI capture belongs to ui-review.
- Phone device timing was not measured (no device test ran).
- Leaving the chat list (tab-root Back) was read, not measured: it calls `_select` synchronously.
+6 -5
View File
@@ -15,13 +15,14 @@ every destination and come back at app start without Chat being opened.
chat's window last was, else at the default frame stepped 32 px per chat
window already open.
- **Window**: drag the title bar to move, the lower right corner to resize,
double click the title to maximise. The title bar has Dock, Minimise,
Maximise and Close.
double click the title to maximise. The title bar has Dock, Maximise and
the X.
- **Dock** puts the chat back into the tiling, right of the active pane. When
the Chat destination is not built it opens the chat there instead.
- **Minimise** hides that window; the chord brings it back.
- **Close (X)** closes the window and returns nothing to the tiling. The chat
itself is not closed on the server.
- **X** (tooltip and semantics: Minimise) hides that window, keeping its state;
it stays listed in the Windows menu and the chord brings it back. It never
closes the window, the chat or the tiling: nothing returns to the tiling.
The chat itself is not closed on the server.
- **Chord**: Alt+Y, Ctrl+Y, and Cmd+Y on Apple platforms (`chatFloatShortcut`).
With chat windows open it hides or shows all of them. With none it floats the
active tiled pane, when that pane can float and Chat has the keyboard;
+37
View File
@@ -0,0 +1,37 @@
# Ctrl+A toggles Runs and Pipelines
Stage 01-implement (artifact 401). Not committed.
## Behaviour
- Ctrl+A (the same chord on every platform) moves the shell between destinations:
- from Runs, to Pipelines;
- from Pipelines, to Runs;
- from any other destination (Chat, Search, Settings), to Runs.
- It is matched like Ctrl+K in `shell/adaptive_shell.dart`: logical key A with Ctrl alone. Alt, Shift, Cmd, Ctrl+Alt, and key-up events do not match. Repeats of a held chord are swallowed; only the first key-down acts.
- It does not act while a text field (`primaryFocusTakesTyping`) or a `TypingSurface` such as the terminal has focus. The handler returns false, so the field or terminal keeps Ctrl+A (select all, line start).
- The switch goes through the shell's normal `_select`, so a controlled shell (`onDestinationSelected`) receives the destination.
## Changed paths
- `app/lib/shell/shell_runs_pipelines_shortcut.dart` (new): `shellRunsPipelinesShortcut` (matcher), `shellRunsPipelinesTarget` (destination rule), `shellRunsPipelinesShortcutLabel` (`'Ctrl+A'`).
- `app/lib/shell/adaptive_shell.dart`: one branch in `_handleDestinationKeyEvent`, after the Ctrl+K branch and before the typing-surface check; updated doc comment.
- `app/lib/features/settings/keyboard_shortcuts_registry.dart`: "Switch between Runs and Pipelines" help entry, `Ctrl+A` on every platform, with a caveat about text fields and the terminal.
- `app/test/shell/runs_pipelines_shortcut_test.dart` (new): matcher, destination rule, Chat→Runs→Pipelines→Runs sequence, text-field exception, terminal exception.
- `app/test/features/settings/keyboard_shortcuts_help_test.dart`: help entry test over every `TargetPlatform` value.
## Focused results
- `tool/memwatch/full.sh 'test/shell/runs_pipelines_shortcut_test.dart test/features/settings/keyboard_shortcuts_help_test.dart test/shell/shell_chat_shortcut_test.dart test/shell/destination_shortcuts_test.dart'`: PASS, 19 passed, 0 failed, peak 1151 MB, 13s, exit 0.
- Mutation check: with the `primaryFocusTakesTyping()` guard removed, `runs_pipelines_shortcut_test.dart` fails (2 failed, including the text-field case). The guard was restored; the file matches the pre-mutation backup.
- `tool/analyze.sh` on the changed files: clean, exit 0. Run after the focused tests, sequentially.
- No existing test sends Ctrl+A. The `keyA` uses in `chat_shell_terminal_test.dart` and `chat_transcript_selection_test.dart` are plain or Cmd+A, so they are unaffected.
## Affected states
- Shell tabs: Pipelines, Runs, Chat, Search, and Settings (a page of Pipelines).
- Text field focused: Ctrl+A goes to the field.
- Terminal focused: Ctrl+A goes to the terminal.
- Help page: new "Switch between Runs and Pipelines" row.
## Not covered
- No UI capture or device run (ui-review owns that).
- The text-field test pins the platform to Android so that Ctrl+A means select all. On Apple platforms Ctrl+A is line start in the field; the field still keeps it, but that case is not tested.
- The chat composer is not tested directly; it is a text field, so the same guard applies.
- On web, the browser may keep Ctrl+A; the registry caveat does not mention this.
+4 -3
View File
@@ -15,7 +15,8 @@ mode (below). `FloatingLayer`, the overlay the old windows used, is gone.
- `WindowHost`: the windows as plain children of the terminal stage's stack, in
the shell page (not an overlay above it), outside every destination.
- `WindowLayer` / `WindowFrame`: one window's card, title bar (drag, double
click to maximise, kind actions, Minimise, Maximise, Close) and resize corner.
click to maximise, kind actions, Maximise, the X = minimise) and resize corner.
There is no separate Minimise button; the X hides the window and keeps it.
- `WindowNavigator`: each window's own page stack.
- `WindowFocus`: a focus scope per window; the keyboard follows the top window
and returns to what had it when the last one hides.
@@ -73,8 +74,8 @@ the device, not a server) and `TerminalWindows`, which keeps it in step with
float, panel height); the bottom panel is still a shell panel.
- Showing the terminal in float mode opens or shows the window; hiding it
(Alt+T, Ctrl+`, the options menu) minimises it. The window's Minimise and
Close both hide the terminal. Its shells and tabs live in `TerminalHub`, so
(Alt+T, Ctrl+`, the options menu) minimises it. The window's X (minimise)
hides the terminal. Its shells and tabs live in `TerminalHub`, so
nothing is lost either way, and the window comes back where it was.
- The frame and maximised state are the window system's. The first window
takes the ones `pipelines.terminal-layout.v1` saved before; that record is
+39
View File
@@ -0,0 +1,39 @@
# Run detail: Output section starts expanded
## Change
- The run Summary's Output section (`run-detail-summary-output`) now starts open.
Input still starts closed. The Summary's default is restored on a different run
and when a search hit names no section (`RunDetailTabs._resetSummarySections`).
- A visit's Summary Output (`run-visit-section-Output`) starts open; Input starts
closed (`_VisitSummaryState._closed = {'Input'}`).
- Both stay collapsible by tapping the title. The open/closed state lives in the
controller or State for that view only; it is not persisted.
- Long outputs: Output is a sliver. `RunFieldSliver` (in `run_field_body.dart`)
builds one `SliverList` row per recorded
field, so a map with hundreds of fields lays out only the rows on screen. It
is used for the run Summary Output (`_StickyField.sliverBody`) and the visit
Summary Output (`_section(..., lazy: true)`), both through `StickySection`'s
sliver path. A closed `SliverReveal` builds nothing.
- Input stays on the box path (`RunFieldBody`); it starts closed, so its cost is
paid only when the operator opens it. The box and sliver forms share the row
builder, so they render the same fields.
## Tests (run through `tool/memwatch/full.sh`, one quoted path list)
- Command: `tool/memwatch/full.sh 'test/features/runs/ui/run_detail_visit_sections_test.dart test/features/runs/ui/run_detail_summary_fields_test.dart test/features/runs/ui/run_detail_widget_test.dart test/features/runs/ui/run_search_selection_test.dart test/features/runs/ui/run_detail_tabs_test.dart test/features/runs/ui/run_detail_visit_test.dart'`
- Verdict (final code): `PASS: 49 passed, 0 failed, 0 skipped; peak 1884 MB; 32s; exit 0`
- New: visit Output starts expanded and collapses/reopens; run Output starts
expanded and collapses for the view; a 500-field visit Output opens with only
its first field built and the page scrolls to the last one (lazy regression).
- Updated (the old expectation was that Output started closed): visit tab/empty-state
tests, run Summary empty-wording and recorded-input tests, search-selection tests
for input, retired field and replacing a visit with the Summary.
- Not changed: Input's closed default and every Input expectation.
## Analyze
- `tool/analyze.sh`: `analyze: clean; 10s; exit 0`
- `dart format --set-exit-if-changed` on the changed files: formatted one widget
test file (whitespace only).
## Limitations
- No widget capture or browser/device check was run here; ui-review owns that.
- Very long Output is laid out when the section opens. Not measured for jank.
+55
View File
@@ -0,0 +1,55 @@
# Window X minimises (no separate Minimise button)
## Change
- The title bar of a floating window is now: kind actions (Dock on a chat),
Maximise / Restore size, then the X.
- The X hides the window and keeps its state, exactly as Minimise did. Its
tooltip and semantics are `Minimise`. It keeps the X glyph (`Icons.close`).
- The X never calls the kind's `closed` hook, so a chat window keeps its chat
open on the server and returns nothing to the tiling.
- `WindowFrame` no longer takes `onClose`; `WindowLayer` wires the X to
`manager.setMinimized(id, true)`.
- Unchanged: the chord (Alt+Y) shows hidden chat windows; the Windows menu
still lists minimised windows with a minimise mark and shows them on choice;
Show all, Minimise all and Close all stay in that menu. Terminal windows
still hide the terminal when their window is hidden by the X.
Changed paths (under `app/`):
- `lib/shell/windows/window_frame.dart`, `window_layer.dart`, `window_kind.dart`,
`window_entry.dart` (comments and the frame's parameters)
- `lib/features/terminal/terminal_window.dart` (comment only)
- `test/shell/windows/window_host_test.dart`, `window_layering_test.dart`
- `test/features/chat/chat_floating_pane_test.dart`
- `test/features/terminal/terminal_surface_test.dart`
- `notes/floating-windows.md`, `notes/chat-floating-pane.md`
## Focused results
- `tool/memwatch/full.sh 'test/shell/windows/window_host_test.dart
test/shell/windows/window_layering_test.dart
test/shell/windows/window_conveniences_test.dart
test/features/chat/chat_floating_pane_test.dart
test/features/terminal/terminal_surface_test.dart'`:
PASS, 72 passed, 0 failed, 0 skipped, exit 0.
- `tool/analyze.sh`: clean, exit 0.
- Not run: the full suite (the land gate runs it). No Cupertino code or tests
touched.
## Affected states (widget-test coverage only)
- Window title bar: no `Close` tooltip; `Minimise` on the X; `Maximise` /
`Restore size` unchanged.
- Chat window: X hides it; the chat stays open, is not docked and sends no
`chat_close`; the chord shows it again with the same frame and composer.
- Probe window: X keeps the entry (minimised), the content state survives, and
the group toggle brings it back.
- Terminal float window: X hides the terminal and keeps its tabs; the chord
shows it again at the same frame.
## Limitations
- No browser or device capture here; `ui-review` owns the title-bar captures.
- The X glyph with a Minimise tooltip is a deliberate choice; a minimise glyph
would be a one-line change in `window_frame.dart` if preferred.
@@ -390,19 +390,24 @@ void main() {
await app.stop(tester);
});
testWidgets('X closes the window and returns nothing to the tiling', (
tester,
) async {
testWidgets('X minimises the window: the chat stays open, returns nothing '
'to the tiling, and the chord brings the window back', (tester) async {
await _saved('a', 'b');
final app = _App(_Store());
await app.start(tester);
await _menu(tester, 'b', 'Float (Alt+Y)');
await tester.tap(find.byTooltip('Close'));
await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle();
expect(app.floating, isEmpty);
// Still a window, hidden; not closed and not docked.
expect(app.floating, ['b']);
expect(app.windows.windows.single.minimized, isTrue);
expect(_shown('Chat b'), findsNothing);
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a']);
expect(_thread('b'), findsNothing);
expect(app.gateway.calls.where((c) => c.type == 'chat_close'), isEmpty);
await _chord(tester);
expect(_shown('Chat b'), findsOneWidget);
expect(_thread('b').hitTestable(), findsOneWidget);
expect(app.floating, ['b']);
await app.stop(tester);
});
@@ -244,10 +244,9 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('No input recorded.'), findsOneWidget);
// Output starts open, so its empty sentence shows without a tap.
await tester.ensureVisible(find.text('Output'));
await tester.pumpAndSettle();
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text('No output recorded.'), findsOneWidget);
});
@@ -266,5 +265,35 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('ship it'), findsOneWidget);
});
testWidgets('${platform.name} summary output starts expanded and '
'collapses for this view', (tester) async {
await pumpRunDetail(
tester,
platform,
run: recordedRunFixture(),
size: const Size(900, 1600),
);
final output = find.byKey(const ValueKey('run-detail-summary-output'));
final outputTitle = find.descendant(
of: output,
matching: find.text('Output'),
);
final outputBody = find.descendant(of: output, matching: find.text('ok'));
// Output opens with its recorded value; Input stays closed.
expect(outputBody, findsOneWidget);
expect(find.text('ship it'), findsNothing);
await tester.ensureVisible(outputTitle.first);
await tester.pumpAndSettle();
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsNothing);
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsOneWidget);
});
}
}
@@ -49,21 +49,77 @@ void main() {
}
});
testWidgets('${platform.name} visit Output starts expanded and collapses', (
tester,
) async {
await openVisit(tester, platform);
final output = find.byKey(const ValueKey('run-visit-section-Output'));
final outputTitle = find.descendant(
of: output,
matching: find.text('Output'),
);
final outputBody = find.descendant(of: output, matching: find.text('ok'));
final input = find.byKey(const ValueKey('run-visit-section-Input'));
// Output opens expanded; Input stays closed.
expect(find.text('result'), findsOneWidget);
expect(outputBody, findsOneWidget);
expect(find.text('Ship it.'), findsNothing);
// The operator can collapse Output, and open it again.
await tester.ensureVisible(outputTitle.first);
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsNothing);
expect(find.text('result'), findsNothing);
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsOneWidget);
expect(input, findsOneWidget);
});
testWidgets('${platform.name} long visit Output opens lazily and still '
'scrolls to its last field', (tester) async {
final run = visitRunFixture();
firstVisitStep(run)['output'] = <String, dynamic>{
for (var i = 0; i < 500; i++) 'field$i': 'value $i',
};
await openVisit(tester, platform, run: run);
// Open by default, yet only the fields on screen are built.
expect(find.text('value 0'), findsOneWidget);
expect(find.text('value 499'), findsNothing);
// Scrolling the page reaches the rest of the Output.
await tester.scrollUntilVisible(
find.text('value 499'),
500,
// The page's own scroll view is the outermost of its scrollables.
scrollable: find
.descendant(
of: find.byKey(const Key('run-visit-body-summary')),
matching: find.byType(Scrollable),
)
.first,
);
expect(find.text('value 499'), findsOneWidget);
});
testWidgets('${platform.name} tabs show recorded values and exact empty '
'wording', (tester) async {
await openVisit(tester, platform);
// Each field by name with its value, never raw JSON.
// Each field by name with its value, never raw JSON. Output is open at
// once; Input's value shows only after its tap.
expect(find.text('Ship it.'), findsNothing);
expect(find.text('ok'), findsNothing);
expect(find.text('ok'), findsOneWidget);
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text('prompt'), findsOneWidget);
expect(find.text('Ship it.'), findsOneWidget);
expect(find.textContaining('"prompt"'), findsNothing);
// Output is open as the visit opens; no tap is needed to read it.
await openVisitTab(tester, RunVisitSection.output);
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text('result'), findsOneWidget);
expect(find.text('ok'), findsOneWidget);
@@ -127,13 +183,12 @@ void main() {
await openVisit(tester, platform, run: run);
expect(find.text(visitEmptyInput), findsNothing);
expect(find.text(visitEmptyOutput), findsNothing);
// Output is open, so its empty sentence is already there.
expect(find.text(visitEmptyOutput), findsOneWidget);
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text(visitEmptyInput), findsOneWidget);
await openVisitTab(tester, RunVisitSection.output);
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text(visitEmptyOutput), findsOneWidget);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(
@@ -172,7 +172,17 @@ void main() {
expect(find.text('alpha=1, items=1, 2'), findsOneWidget);
expect(find.textContaining('"alpha"'), findsNothing);
await openSummarySection('Output');
// Output starts open: its value is there to scroll to, without a tap.
await tester.scrollUntilVisible(
find.text('ok=true'),
200,
scrollable: find
.descendant(
of: find.byKey(const Key('run-detail-tab-body-summary')),
matching: find.byType(Scrollable),
)
.first,
);
expect(find.text('ok=true'), findsOneWidget);
await tapTab('Timeline');
@@ -263,7 +263,7 @@ void main() {
});
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} input field expands only the input section', (
testWidgets('${platform.name} input field expands the input section', (
tester,
) async {
await pumpSelection(
@@ -277,7 +277,8 @@ void main() {
findsOneWidget,
);
expect(find.text('ship it'), findsOneWidget);
expect(find.text('ok'), findsNothing);
// Output keeps its default: open, as every Summary opens.
expect(find.text('ok'), findsOneWidget);
});
testWidgets(
@@ -310,8 +311,9 @@ void main() {
find.byKey(const Key('run-detail-tab-body-summary')),
findsOneWidget,
);
// The plain Summary shows its default sections: Output open, Input closed.
expect(find.text('ship it'), findsNothing);
expect(find.text('ok'), findsNothing);
expect(find.text('ok'), findsOneWidget);
});
for (final platform in RunDetailTestPlatform.values) {
@@ -337,8 +339,9 @@ void main() {
find.byKey(const Key('run-detail-tab-body-summary')),
findsOneWidget,
);
// The Summary's default sections: Output open, Input closed.
expect(find.text('ship it'), findsNothing);
expect(find.text('ok'), findsNothing);
expect(find.text('ok'), findsOneWidget);
},
);
}
@@ -40,6 +40,19 @@ void main() {
},
);
test('Runs and Pipelines switch is Ctrl+A on every platform', () {
for (final platform in TargetPlatform.values) {
final entry = KeyboardShortcutRegistry(platform: platform, web: false)
.entries
.firstWhere(
(entry) => entry.action == 'Switch between Runs and Pipelines',
);
expect(entry.keys, 'Ctrl+A', reason: platform.name);
expect(entry.caveat, contains('Pipelines'));
expect(entry.caveat, contains('text field'));
}
});
test('uses the shell primary modifier rule on iOS', () {
final entries = const KeyboardShortcutRegistry(
platform: TargetPlatform.iOS,
@@ -167,10 +167,12 @@ void main() {
expect(floatFinder, findsOneWidget);
expect(frame().size, start.size + const Offset(80, 50));
await tester.tap(find.byTooltip('Close'));
// The X minimises too: the window stays listed, hidden, with its shells.
await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle();
expect(layout.visible, isFalse);
expect(manager.windows, isEmpty);
expect(manager.windows.single.minimized, isTrue);
expect(floatFinder, findsNothing);
expect(hub.tabs, hasLength(2));
await ctrlBacktick(tester);
expect(floatFinder, findsOneWidget);
@@ -0,0 +1,208 @@
import 'package:flutter/foundation.dart';
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_runs_pipelines_shortcut.dart';
import 'package:pipelines_app/ui/input/keyboard_owner.dart';
const _a = KeyDownEvent(
physicalKey: PhysicalKeyboardKey.keyA,
logicalKey: LogicalKeyboardKey.keyA,
timeStamp: Duration.zero,
);
void main() {
test('Ctrl+A matches only with Ctrl alone', () {
bool chord(Set<LogicalKeyboardKey> held, [KeyEvent event = _a]) =>
shellRunsPipelinesShortcut(event, _FakeKeyboard(held));
expect(chord({}), isFalse);
expect(chord({LogicalKeyboardKey.controlLeft}), isTrue);
expect(chord({LogicalKeyboardKey.controlRight}), isTrue);
expect(
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.altLeft}),
isFalse,
);
expect(
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.shiftLeft}),
isFalse,
);
expect(
chord({LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.metaLeft}),
isFalse,
);
expect(chord({LogicalKeyboardKey.altLeft}), isFalse);
expect(chord({LogicalKeyboardKey.metaLeft}), isFalse);
expect(
shellRunsPipelinesShortcut(
const KeyUpEvent(
physicalKey: PhysicalKeyboardKey.keyA,
logicalKey: LogicalKeyboardKey.keyA,
timeStamp: Duration.zero,
),
_FakeKeyboard({LogicalKeyboardKey.controlLeft}),
),
isFalse,
);
});
test('Runs goes to Pipelines; every other destination goes to Runs', () {
expect(
shellRunsPipelinesTarget(AppDestination.runs),
AppDestination.pipelines,
);
expect(
shellRunsPipelinesTarget(AppDestination.pipelines),
AppDestination.runs,
);
expect(shellRunsPipelinesTarget(AppDestination.chat), AppDestination.runs);
expect(
shellRunsPipelinesTarget(AppDestination.search),
AppDestination.runs,
);
expect(
shellRunsPipelinesTarget(AppDestination.settings),
AppDestination.runs,
);
});
testWidgets('Ctrl+A bounces Chat, Runs, Pipelines, Runs', (tester) async {
await _onAndroid(() async {
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: {
for (final destination in shellTabDestinations)
destination: (_) => Text('${destination.name} body'),
},
),
),
);
expect(find.text('pipelines body'), isOnstage);
Future<void> pressCtrl(LogicalKeyboardKey key) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(key);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
}
// Reach Chat first with Ctrl+K, then start the Ctrl+A sequence.
await pressCtrl(LogicalKeyboardKey.keyK);
expect(find.text('chat body'), isOnstage);
expect(find.text('pipelines body'), findsNothing);
await pressCtrl(LogicalKeyboardKey.keyA);
expect(find.text('runs body'), isOnstage);
expect(find.text('chat body'), findsNothing);
await pressCtrl(LogicalKeyboardKey.keyA);
expect(find.text('pipelines body'), isOnstage);
expect(find.text('runs body'), findsNothing);
await pressCtrl(LogicalKeyboardKey.keyA);
expect(find.text('runs body'), isOnstage);
expect(find.text('pipelines body'), findsNothing);
expect(tester.takeException(), isNull);
});
});
testWidgets('Ctrl+A is left to a focused text field', (tester) async {
await _onAndroid(() async {
final field = TextEditingController(text: 'draft message');
final focus = FocusNode();
addTearDown(field.dispose);
addTearDown(focus.dispose);
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: {
AppDestination.pipelines: (_) =>
TextField(controller: field, focusNode: focus),
AppDestination.runs: (_) => const Text('runs body'),
},
),
),
);
focus.requestFocus();
await tester.pump();
expect(focus.hasPrimaryFocus, isTrue);
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyA);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
// Destination unchanged; the field took the chord (select all on this
// platform), so the text is still there and fully selected.
expect(find.text('runs body'), findsNothing);
expect(field.text, 'draft message');
expect(field.selection.baseOffset, 0);
expect(field.selection.extentOffset, field.text.length);
expect(tester.takeException(), isNull);
});
});
testWidgets('Ctrl+A is left to the terminal while it has focus', (
tester,
) async {
await _onAndroid(() async {
final terminal = FocusNode();
addTearDown(terminal.dispose);
final received = <KeyEvent>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: {
AppDestination.pipelines: (_) => TypingSurface(
child: Focus(
focusNode: terminal,
onKeyEvent: (node, event) {
if (event.logicalKey == LogicalKeyboardKey.keyA) {
received.add(event);
}
return KeyEventResult.ignored;
},
child: const Text('terminal'),
),
),
AppDestination.runs: (_) => const Text('runs body'),
},
),
),
);
terminal.requestFocus();
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
await tester.sendKeyEvent(LogicalKeyboardKey.keyA);
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
await tester.pumpAndSettle();
expect(find.text('runs body'), findsNothing);
expect(find.text('terminal'), isOnstage);
expect(received.whereType<KeyDownEvent>(), hasLength(1));
expect(tester.takeException(), isNull);
});
});
}
/// Runs [body] with the platform pinned to Android, so Ctrl+A in a text field
/// means select all everywhere. flutter_test requires the debug override to be
/// cleared before the test body returns, hence the `finally`.
Future<void> _onAndroid(Future<void> Function() body) async {
debugDefaultTargetPlatformOverride = TargetPlatform.android;
try {
await body();
} finally {
debugDefaultTargetPlatformOverride = null;
}
}
class _FakeKeyboard extends HardwareKeyboard {
_FakeKeyboard(this.pressed);
final Set<LogicalKeyboardKey> pressed;
@override
bool isLogicalKeyPressed(LogicalKeyboardKey key) => pressed.contains(key);
}
+24 -6
View File
@@ -25,9 +25,11 @@ void main() {
const Rect.fromLTWH(100, 80, 360, 420),
);
expect(find.byTooltip('Probe action'), findsOneWidget);
for (final tip in ['Minimise', 'Maximise', 'Close']) {
for (final tip in ['Minimise', 'Maximise']) {
expect(find.byTooltip(tip), findsOneWidget);
}
// There is no separate Minimise button: the X is the one minimise.
expect(find.byTooltip('Close'), findsNothing);
expect(find.text('sheet').hitTestable(), findsOneWidget);
// The title bar, the content and the app behind all keep their
// semantics (a page route's barrier hides what is behind it).
@@ -172,14 +174,30 @@ void main() {
expect(find.text('typed'), findsOneWidget);
});
testWidgets('X closes the window', (tester) async {
testWidgets('X minimises the window and never closes it', (tester) async {
final entry = manager.open('probe', 'a');
await pumpProbe(tester, manager);
await tester.tap(find.byTooltip('Close'));
await tester.enterText(find.byKey(const ValueKey('a-field')), 'kept');
final state = tester.state<ProbeContentState>(find.byType(ProbeContent));
await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle();
expect(manager.windows, isEmpty);
expect(find.byType(ProbeContent, skipOffstage: false), findsNothing);
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, [entry.id]);
expect(manager.windows.single.id, entry.id);
expect(manager.byId(entry.id)!.minimized, isTrue);
expect(find.text('Probe a').hitTestable(), findsNothing);
// Not a close: the kind's closed hook does not run, and the content
// stays alive with its state.
expect((manager.kinds['probe']! as ProbeWindowKind).closed_, isEmpty);
expect(
tester.state<ProbeContentState>(
find.byType(ProbeContent, skipOffstage: false),
),
same(state),
);
// Listed and brought back by the group, as Minimise always was.
manager.toggleGroup('probe');
await tester.pumpAndSettle();
expect(find.text('Probe a').hitTestable(), findsOneWidget);
expect(find.text('kept'), findsOneWidget);
});
testWidgets('pressing a window brings it to the top and keeps both alive', (
@@ -209,14 +209,17 @@ void main() {
probeTooltipColor,
);
await mouse.moveTo(tester.getCenter(find.byTooltip('Close').last));
await mouse.moveTo(tester.getCenter(find.byTooltip('Minimise').last));
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.text('Close'), findsOneWidget);
expect(find.text('Minimise'), findsOneWidget);
// Not clipped to the window: tooltips paint in an overlay as large
// as the app.
final overlay = tester.renderObject<RenderBox>(
find
.ancestor(of: find.text('Close'), matching: find.byType(Overlay))
.ancestor(
of: find.text('Minimise'),
matching: find.byType(Overlay),
)
.first,
);
expect(overlay.size, const Size(1280, 800));
@@ -0,0 +1,141 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/ui/motion/container_transform_flight.dart';
import 'package:pipelines_app/ui/motion/container_transform_source.dart';
import 'package:pipelines_app/ui/motion/motion.dart';
const _screen = Size(390, 844);
/// A phone-style owner: its selected row opens a detail page that grows from
/// the row, as the chat screen's page does.
class _Owner extends StatefulWidget {
const _Owner({required this.selection, required this.sources});
final ValueNotifier<String?> selection;
final ContainerTransformSources sources;
@override
State<_Owner> createState() => _OwnerState();
}
class _OwnerState extends State<_Owner> {
final DetailPageHost page = DetailPageHost();
/// Stands in for work the owner might await when the page closes (a draft
/// or scroll save). It never completes, so any pop that waited on it would
/// never start.
final Completer<void> neverSaved = Completer<void>();
int closed = 0;
@override
void dispose() {
page.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => ValueListenableBuilder<String?>(
valueListenable: widget.selection,
builder: (context, selected, _) {
page.sync(
context,
selected: selected != null,
destination: AppDestination.chat,
growFrom: widget.sources.link(() => widget.selection.value),
onClosed: () {
closed++;
unawaited(_save());
widget.selection.value = null;
},
builder: (context) =>
ShellBar(title: 'Chat', child: const Text('chat body')),
);
return ContainerTransformScope(
sources: widget.sources,
child: const Column(
children: [
SizedBox(height: 200),
ContainerTransformSource(
id: '7',
color: Color(0xFFE3F2FD),
child: SizedBox(
key: Key('row-7'),
height: 72,
child: Text('row 7'),
),
),
],
),
);
},
);
Future<void> _save() => neverSaved.future;
}
Future<void> _pumpOwner(
WidgetTester tester,
ValueNotifier<String?> selection,
ContainerTransformSources sources,
) async {
tester.view.physicalSize = _screen;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: _Owner(selection: selection, sources: sources),
),
);
}
void main() {
testWidgets(
'system Back changes the route in one frame and shrinks the page at once',
(tester) async {
final selection = ValueNotifier<String?>(null);
final sources = ContainerTransformSources();
await _pumpOwner(tester, selection, sources);
selection.value = '7';
await tester.pumpAndSettle();
final row = tester.getRect(
find.byKey(const Key('row-7'), skipOffstage: false),
);
final route = ModalRoute.of(
tester.element(find.byKey(containerTransformSurfaceKey)),
)!;
expect(route.isCurrent, isTrue);
// The owner's close work never completes, yet Back starts at once.
await tester.binding.handlePopRoute();
await tester.pump();
expect(route.isCurrent, isFalse);
expect(route.animation!.status, AnimationStatus.reverse);
// Two frames after the pop the page is visibly shrinking toward the row.
await tester.pump(const Duration(milliseconds: 16));
final height = tester
.getRect(find.byKey(containerTransformSurfaceKey))
.height;
final travel = _screen.height - row.height;
final shrunk = (_screen.height - height) / travel;
expect(shrunk, greaterThan(0.1));
expect(shrunk, lessThan(1));
// The reverse stays within the standard Material container transform.
expect(
Motion.containerTransformReverse,
lessThanOrEqualTo(const Duration(milliseconds: 300)),
);
await tester.pumpAndSettle();
expect(find.text('chat body'), findsNothing);
expect(selection.value, isNull);
expect(tester.state<_OwnerState>(find.byType(_Owner)).closed, 1);
},
);
}
+12 -10
View File
@@ -611,10 +611,12 @@ func (c *Chat) Answer(ctx context.Context, request protocol.ChatAnswerRequest) e
answers[question] = fmt.Sprint(typed)
}
}
response = map[string]any{
"behavior": "allow",
"updatedInput": map[string]any{"questions": form.rawQuestions, "answers": answers},
}
// The tool's own input comes back unchanged ({"questions": [...]} and
// any other fields) with the answers added.
updated := map[string]any{}
_ = json.Unmarshal(form.rawInput, &updated)
updated["answers"] = answers
response = map[string]any{"behavior": "allow", "updatedInput": updated}
}
s.mu.Lock()
form.answering = true
@@ -704,11 +706,11 @@ type pendingApproval struct {
}
type pendingForm struct {
form protocol.ChatForm
rawQuestions json.RawMessage
questions []string
proc *process
answering bool
form protocol.ChatForm
rawInput json.RawMessage
questions []string
proc *process
answering bool
}
func (s *session) receivePermission(p *process, requestID string, request toolRequest) {
@@ -819,7 +821,7 @@ func (s *session) receiveQuestion(p *process, requestID string, request toolRequ
form.Fields = append(form.Fields, field)
}
s.mu.Lock()
s.forms[requestID] = &pendingForm{form: form, rawQuestions: request.Input, questions: questions, proc: p}
s.forms[requestID] = &pendingForm{form: form, rawInput: request.Input, questions: questions, proc: p}
s.mu.Unlock()
s.emit(protocol.ChatEventFrame{SessionID: s.id, Kind: protocol.ChatEventForm, Form: &form})
}
+6 -1
View File
@@ -269,7 +269,12 @@ def handle(line):
tool_result("Error: " + str(result.get("message") or "denied"), True)
return
if pending["kind"] == "question":
answers = (result.get("updatedInput") or {}).get("answers") or {}
updated = result.get("updatedInput") or {}
# Like Claude Code: updatedInput must still match the tool's schema.
if not isinstance(updated.get("questions"), list):
tool_result("Error: The parameter `questions` type is expected as `array`", True)
return
answers = updated.get("answers") or {}
tool_result("Your questions have been answered: " + json.dumps(answers))
else:
tool_result("File created successfully")