From 4d9ee1ea787450f8be1f5278ef12526b5c59b749 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 2 Nov 2026 18:35:37 +0000 Subject: [PATCH] Give glass control bars equal end and edge gaps Inside a glass bar the first and last controls now keep the same gap from the pill's sides as from its top and bottom, from shared GlassBarMetrics (48/44 targets, 8 edge gap). Applies to the artifact viewer bar (hugs its actions without a pager), the chevron pagers (position text inset like an icon), and the chat composer's Cupertino Send/Stop (centred circle). Run 7 in the full-app probe now records change captures for diff captures. --- .../actions/artifact_file_actions.dart | 18 +- .../artifacts/ui/artifact_viewer_body.dart | 55 ++- .../changes/widgets/changes_viewer.dart | 4 +- .../changes/widgets/file_diff_viewer.dart | 4 +- .../chat/conversation/chat_composer_bar.dart | 43 +- app/lib/ui/adaptive/glass_bar.dart | 71 ++++ app/lib/ui/navigation/chevron_pager.dart | 59 +-- app/notes/glass-bar-edge-gaps.md | 29 ++ app/test/ui/adaptive/glass_bar_test.dart | 366 ++++++++++++++++++ app/tool/search_selection_probe_entry.dart | 31 ++ 10 files changed, 597 insertions(+), 83 deletions(-) create mode 100644 app/lib/ui/adaptive/glass_bar.dart create mode 100644 app/notes/glass-bar-edge-gaps.md create mode 100644 app/test/ui/adaptive/glass_bar_test.dart diff --git a/app/lib/features/artifacts/actions/artifact_file_actions.dart b/app/lib/features/artifacts/actions/artifact_file_actions.dart index 9f4b2801..ee24e616 100644 --- a/app/lib/features/artifacts/actions/artifact_file_actions.dart +++ b/app/lib/features/artifacts/actions/artifact_file_actions.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../../ui/adaptive/glass_bar.dart'; import '../../../ui/adaptive/host.dart'; import '../domain/artifact_record.dart'; import '../domain/artifact_url.dart'; @@ -236,7 +237,6 @@ class ArtifactIconAction extends StatelessWidget { required this.cupertinoIcon, required this.onPressed, this.busy = false, - this.inBar = false, }); final String label; @@ -245,10 +245,6 @@ class ArtifactIconAction extends StatelessWidget { final VoidCallback? onPressed; final bool busy; - /// Sized like the top bar's other actions (a standard icon button), so the - /// bar's round pill is centred on it; compact otherwise. - final bool inBar; - @override Widget build(BuildContext context) { if (usesCupertinoHost(context)) { @@ -256,18 +252,20 @@ class ArtifactIconAction extends StatelessWidget { button: true, label: label, child: CupertinoButton( - padding: inBar ? EdgeInsets.zero : const EdgeInsets.all(8), - minimumSize: const Size(44, 44), + // One square touch target, like the top bar's other actions, so a + // round pill is centred on it and a glass bar's edge gaps hold. + padding: EdgeInsets.zero, + minimumSize: GlassBarMetrics.cupertinoMinimumSize(), onPressed: onPressed, child: busy ? const CupertinoActivityIndicator(radius: 9) - : Icon(cupertinoIcon, size: 30), + : Icon(cupertinoIcon, size: GlassBarMetrics.iconSize(true)), ), ); } return IconButton( tooltip: label, - constraints: const BoxConstraints(minWidth: 48, minHeight: 48), + constraints: GlassBarMetrics.materialConstraints(), padding: EdgeInsets.zero, onPressed: onPressed, icon: busy @@ -276,7 +274,7 @@ class ArtifactIconAction extends StatelessWidget { height: 18, child: CircularProgressIndicator(strokeWidth: 2), ) - : Icon(icon, size: 28), + : Icon(icon, size: GlassBarMetrics.iconSize(false)), ); } } diff --git a/app/lib/features/artifacts/ui/artifact_viewer_body.dart b/app/lib/features/artifacts/ui/artifact_viewer_body.dart index ce6cdb10..ed4b5420 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_body.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_body.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/glass_pill.dart'; +import '../../../ui/adaptive/glass_bar.dart'; import '../actions/artifact_file_actions.dart'; import '../actions/artifact_file_bridge.dart'; import '../domain/artifact_preview.dart'; @@ -122,33 +122,32 @@ class ArtifactViewerBody extends StatelessWidget { bar: SafeArea( top: false, minimum: const EdgeInsets.all(8), - child: SizedBox( - height: 56, - child: GlassPill( + // Without a pager the bar is as wide as its actions, so its last + // control keeps the same gap from the bar's end as the first. + child: Align( + alignment: AlignmentDirectional.centerStart, + heightFactor: 1, + child: GlassControlBar( cupertino: usesCupertinoHost(context), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2), - child: Row( - key: const Key('artifact-viewer-actions'), - children: [ - if (resolved != null && !resolved.external) - ArtifactFileActions( - key: ValueKey( - 'viewer-files-${page.group.stageKey}\u0000' - '${page.group.visit}\u0000${page.artifact.url}', - ), - artifact: page.artifact, - resolved: resolved, - fetch: fetch, - bridge: fileBridge, - compact: true, - ), - if (resolved != null) - _Actions( - resolved: resolved, - onOpen: onOpen, - onCopy: onCopy, + child: Row( + key: const Key('artifact-viewer-actions'), + mainAxisSize: count > 1 ? MainAxisSize.max : MainAxisSize.min, + children: [ + if (resolved != null && !resolved.external) + ArtifactFileActions( + key: ValueKey( + 'viewer-files-${page.group.stageKey}\u0000' + '${page.group.visit}\u0000${page.artifact.url}', ), + artifact: page.artifact, + resolved: resolved, + fetch: fetch, + bridge: fileBridge, + compact: true, + ), + if (resolved != null) + _Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy), + if (count > 1) Expanded( child: _Pager( index: index, @@ -157,8 +156,7 @@ class ArtifactViewerBody extends StatelessWidget { onNext: onNext, ), ), - ], - ), + ], ), ), ), @@ -383,7 +381,6 @@ class ArtifactViewerInfoAction extends StatelessWidget { Widget build(BuildContext context) { return ArtifactIconAction( key: const Key('artifact-info'), - inBar: true, label: 'Details', icon: Icons.info_outline, cupertinoIcon: CupertinoIcons.info, diff --git a/app/lib/features/changes/widgets/changes_viewer.dart b/app/lib/features/changes/widgets/changes_viewer.dart index ec169e1d..fadc4df3 100644 --- a/app/lib/features/changes/widgets/changes_viewer.dart +++ b/app/lib/features/changes/widgets/changes_viewer.dart @@ -10,7 +10,7 @@ import 'change_style.dart'; import 'file_diff_viewer.dart'; import 'visit_pager.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/glass_pill.dart'; +import '../../../ui/adaptive/glass_bar.dart'; import '../../../ui/adaptive/host.dart'; /// The run's Changes surface: an honest final-state summary followed by the @@ -247,7 +247,7 @@ class _ChangesViewerState extends State { child: Padding( padding: const EdgeInsets.all(8), child: IntrinsicWidth( - child: GlassPill( + child: GlassControlBar( cupertino: usesCupertinoHost(context), child: pager, ), diff --git a/app/lib/features/changes/widgets/file_diff_viewer.dart b/app/lib/features/changes/widgets/file_diff_viewer.dart index 9a978e25..8d5db5bd 100644 --- a/app/lib/features/changes/widgets/file_diff_viewer.dart +++ b/app/lib/features/changes/widgets/file_diff_viewer.dart @@ -8,7 +8,7 @@ import 'package:flutter/services.dart'; import '../../../ui/navigation/chevron_pager.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/glass_pill.dart'; +import '../../../ui/adaptive/glass_bar.dart'; import '../domain/change_kind.dart'; import '../domain/change_wording.dart'; import '../domain/file_change.dart'; @@ -315,7 +315,7 @@ class _FileDiffPageState extends State { child: SafeArea( top: false, minimum: const EdgeInsets.all(8), - child: GlassPill(cupertino: cupertino, child: pager), + child: GlassControlBar(cupertino: cupertino, child: pager), ), ), child: viewer, diff --git a/app/lib/features/chat/conversation/chat_composer_bar.dart b/app/lib/features/chat/conversation/chat_composer_bar.dart index 004e88c1..372cac39 100644 --- a/app/lib/features/chat/conversation/chat_composer_bar.dart +++ b/app/lib/features/chat/conversation/chat_composer_bar.dart @@ -21,6 +21,7 @@ import 'chat_command_actions.dart'; import 'chat_command_palette.dart'; import 'chat_composer_controller.dart'; import '../ui/transcript/chat_attachment_frame.dart'; +import '../../../ui/adaptive/glass_bar.dart'; import '../../../ui/adaptive/glass_pill.dart'; import 'chat_reading_width.dart'; import 'composer_focus_restore.dart'; @@ -764,7 +765,12 @@ class _ChatComposerBarState extends State { shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(28)), ), - child: Padding(padding: const EdgeInsets.all(4), child: child), + // The end controls keep the same gap from the pill's sides as from its + // bottom (and its top while the field is one line). + child: Padding( + padding: const EdgeInsets.all(GlassBarMetrics.fieldEdgeGap), + child: child, + ), ); /// The attach control: a host button that opens the picker, disabled when the @@ -781,6 +787,7 @@ class _ChatComposerBarState extends State { child: CupertinoButton( key: const Key('chat-composer-attach'), padding: EdgeInsets.zero, + minimumSize: GlassBarMetrics.cupertinoMinimumSize(), onPressed: onPressed, child: const Icon(CupertinoIcons.add), ), @@ -1091,16 +1098,30 @@ class _ChatComposerBarState extends State { button: true, label: label, excludeSemantics: true, - child: CupertinoButton.filled( - key: key, - sizeStyle: CupertinoButtonSize.small, - color: stop ? CupertinoColors.systemRed.resolveFrom(context) : null, - onPressed: enabled ? press : null, - child: stop - ? const ChatStopIcon( - child: Icon(CupertinoIcons.stop_fill, size: 18), - ) - : const Icon(CupertinoIcons.arrow_up, size: 18), + // A filled circle centred in a full touch target, like Material's + // filled icon button, so it keeps the pill's edge gap on every side. + child: SizedBox.square( + dimension: GlassBarMetrics.controlExtent(true), + child: Center( + child: CupertinoButton.filled( + key: key, + sizeStyle: CupertinoButtonSize.small, + padding: EdgeInsets.zero, + minimumSize: Size.square(GlassBarMetrics.filledExtent(true)), + borderRadius: BorderRadius.circular( + GlassBarMetrics.filledExtent(true) / 2, + ), + color: stop + ? CupertinoColors.systemRed.resolveFrom(context) + : null, + onPressed: enabled ? press : null, + child: stop + ? const ChatStopIcon( + child: Icon(CupertinoIcons.stop_fill, size: 18), + ) + : const Icon(CupertinoIcons.arrow_up, size: 18), + ), + ), ), ); } diff --git a/app/lib/ui/adaptive/glass_bar.dart b/app/lib/ui/adaptive/glass_bar.dart new file mode 100644 index 00000000..21df1217 --- /dev/null +++ b/app/lib/ui/adaptive/glass_bar.dart @@ -0,0 +1,71 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'glass_pill.dart'; + +/// The shared geometry of a floating glass control bar: a [GlassPill] holding +/// a row of icon controls (a viewer's actions, a pager, a canvas's controls). +/// +/// Like the floating tab bar, the first and last controls keep the same gap +/// from the pill's sides as every control keeps from its top and bottom, so +/// a control at either end sits concentric with the pill's round cap. +/// Neighbouring controls touch target to target: their icons are spaced by +/// the targets' own padding, the same everywhere along the bar. +abstract final class GlassBarMetrics { + /// The gap between the controls' targets and every edge of the pill. + static const double edgeGap = 8; + + /// The tighter gap of a bar around a text field (the chat composer), so + /// the field keeps its width; its end controls keep it on every side too. + static const double fieldEdgeGap = 4; + + /// The square target of one control: the platform's minimum touch target. + static double controlExtent(bool cupertino) => + cupertino ? kMinInteractiveDimensionCupertino : kMinInteractiveDimension; + + /// The icon drawn inside a control's target. + static double iconSize(bool cupertino) => cupertino ? 30 : 28; + + /// The space between a control's icon and the edge of its target. + static double iconInset(bool cupertino) => + (controlExtent(cupertino) - iconSize(cupertino)) / 2; + + /// The visible circle of a filled control (Send) inside its target: the + /// Material filled icon button's 40 in 48, and the same inset on Cupertino. + static double filledExtent(bool cupertino) => controlExtent(cupertino) - 8; + + /// The pill's height around one row of controls. + static double height(bool cupertino) => + controlExtent(cupertino) + 2 * edgeGap; + + /// The Material target constraints of one control. + static BoxConstraints materialConstraints() => BoxConstraints( + minWidth: controlExtent(false), + minHeight: controlExtent(false), + ); + + /// The Cupertino minimum size of one control. + static Size cupertinoMinimumSize() => Size.square(controlExtent(true)); +} + +/// A [GlassPill] padded by [GlassBarMetrics.edgeGap] on every side around +/// [child], a row of controls each [GlassBarMetrics.controlExtent] tall. +class GlassControlBar extends StatelessWidget { + const GlassControlBar({ + super.key, + required this.cupertino, + required this.child, + }); + + final bool cupertino; + final Widget child; + + @override + Widget build(BuildContext context) => GlassPill( + cupertino: cupertino, + child: Padding( + padding: const EdgeInsets.all(GlassBarMetrics.edgeGap), + child: child, + ), + ); +} diff --git a/app/lib/ui/navigation/chevron_pager.dart b/app/lib/ui/navigation/chevron_pager.dart index 247448be..c96a1fc4 100644 --- a/app/lib/ui/navigation/chevron_pager.dart +++ b/app/lib/ui/navigation/chevron_pager.dart @@ -1,6 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../adaptive/glass_bar.dart'; import '../adaptive/host.dart'; /// Previous and next as chevrons in one row at the bottom right, with the @@ -49,13 +50,13 @@ class ChevronPager extends StatelessWidget { child: CupertinoButton( key: key, padding: EdgeInsets.zero, - minimumSize: const Size(44, 44), + minimumSize: GlassBarMetrics.cupertinoMinimumSize(), onPressed: onPressed, child: Icon( previous ? CupertinoIcons.chevron_left : CupertinoIcons.chevron_right, - size: 30, + size: GlassBarMetrics.iconSize(true), ), ), ); @@ -63,26 +64,27 @@ class ChevronPager extends StatelessWidget { return IconButton( key: key, tooltip: label, - constraints: const BoxConstraints(minWidth: 48, minHeight: 48), + constraints: GlassBarMetrics.materialConstraints(), padding: EdgeInsets.zero, onPressed: onPressed, icon: Icon( previous ? Icons.chevron_left : Icons.chevron_right, - size: 28, + size: GlassBarMetrics.iconSize(false), ), ); } - return Padding( - // The surrounding glass pill supplies the edge gap. Keeping this row's - // horizontal padding at zero also leaves room for four 48px controls on - // a narrow phone at large text sizes. - padding: EdgeInsets.zero, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Flexible( - fit: FlexFit.tight, + // The surrounding glass bar supplies the edge gap ([GlassBarMetrics]). + // The position keeps an icon's inset on each side, so it sits as far from + // the bar's edge and from the chevrons as an icon would. + final inset = GlassBarMetrics.iconInset(cupertino); + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Flexible( + fit: FlexFit.tight, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: inset), child: Text( '${index + 1} of $count', key: positionKey, @@ -90,21 +92,20 @@ class ChevronPager extends StatelessWidget { overflow: TextOverflow.ellipsis, ), ), - const SizedBox(width: 0), - chevron( - key: previousKey, - previous: true, - label: previousLabel, - onPressed: onPrevious, - ), - chevron( - key: nextKey, - previous: false, - label: nextLabel, - onPressed: onNext, - ), - ], - ), + ), + chevron( + key: previousKey, + previous: true, + label: previousLabel, + onPressed: onPrevious, + ), + chevron( + key: nextKey, + previous: false, + label: nextLabel, + onPressed: onNext, + ), + ], ); } } diff --git a/app/notes/glass-bar-edge-gaps.md b/app/notes/glass-bar-edge-gaps.md new file mode 100644 index 00000000..82be056b --- /dev/null +++ b/app/notes/glass-bar-edge-gaps.md @@ -0,0 +1,29 @@ +# Glass control bars: equal edge gaps + +Operator report: in the viewers the first controls sat too close to the bar's +left end while the top and bottom had room. + +Rule (`lib/ui/adaptive/glass_bar.dart`, `GlassBarMetrics`): inside a glass +bar the first and last controls keep the same gap from the pill's sides as +from its top and bottom, `(pill height - control height) / 2`, and +neighbours touch target to target (even icon spacing). Targets are the +platform minimum (48 Material, 44 Cupertino), icons 28/30, edge gap 8, so a +bar is 64/60 tall. `GlassControlBar` applies it. + +- Artifact viewer bottom bar: `GlassControlBar`; Cupertino actions lost their + extra 8px padding (46px targets) for 44px squares; without a pager the bar + hugs its actions instead of spanning the width. +- `ChevronPager` (diff page pager, Changes visit pager, artifact pager): the + position text keeps an icon's inset on each side, so it starts where an + icon at that end would be drawn; it had no gap from the pill's edge. +- Chat composer: Cupertino Send/Stop is a 36px filled circle centred in a + 44px target (it was a 28px-high small button pinned to the bottom); the + pill gap is the shared `fieldEdgeGap` (4). +- Verified unchanged: top bar actions pill (controls fill it, 0 gap on every + side), graph viewport controls (same), artifact gallery grid/list switch and + stage/visit section controls (native segmented controls, not glass bars), + run header strip (status text, not a control row). + +Tests: `test/ui/adaptive/glass_bar_test.dart` (both hosts, 390px, text 1.0 +and 1.3). Captures: `/tmp/bar-padding/` (full-app probe; run 7 now records +change captures so Changes opens paged diffs). diff --git a/app/test/ui/adaptive/glass_bar_test.dart b/app/test/ui/adaptive/glass_bar_test.dart new file mode 100644 index 00000000..9c758696 --- /dev/null +++ b/app/test/ui/adaptive/glass_bar_test.dart @@ -0,0 +1,366 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart'; +import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart'; +import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart'; +import 'package:pipelines_app/features/artifacts/ui/artifact_row_labels.dart'; +import 'package:pipelines_app/features/changes/domain/change_kind.dart'; +import 'package:pipelines_app/features/changes/domain/file_change.dart'; +import 'package:pipelines_app/features/changes/widgets/changes_viewer.dart'; +import 'package:pipelines_app/features/changes/widgets/file_diff_viewer.dart'; +import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart'; +import 'package:pipelines_app/features/chat/conversation/chat_composer_controller.dart'; +import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart'; +import 'package:pipelines_app/ui/adaptive/glass_bar.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; + +import '../../features/artifacts/ui/artifact_visit_list_fixture.dart'; +import '../../features/chat/conversation/chat_composer_bar_fixtures.dart'; + +/// Every glass control bar keeps its first and last controls as far from the +/// pill's sides as from its top and bottom, and spaces neighbours evenly, on +/// both hosts, at phone width and at a larger text size. + +const _phone = Size(390, 844); +const _scales = [1.0, 1.3]; +const _hosts = [false, true]; + +final Uint8List _png = base64Decode( + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAE' + 'hQGAhKmMIQAAAABJRU5ErkJggg==', +); + +Widget _host(bool cupertino, Widget child) => cupertino + ? CupertinoApp(home: CupertinoPageScaffold(child: child)) + : MaterialApp(home: Scaffold(body: child)); + +Future _setUp(WidgetTester tester, double scale) async { + tester.view.physicalSize = _phone * tester.view.devicePixelRatio; + tester.platformDispatcher.textScaleFactorTestValue = scale; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue); +} + +/// The host controls inside [pill], left to right. +List _controls(WidgetTester tester, Finder pill) { + final found = find.descendant( + of: pill, + matching: find.byWidgetPredicate( + (widget) => widget is IconButton || widget is CupertinoButton, + ), + ); + final rects = [ + for (var i = 0; i < found.evaluate().length; i++) + tester.getRect(found.at(i)), + ]; + rects.sort((a, b) => a.left.compareTo(b.left)); + return rects; +} + +/// The rule: an end control's gap from the pill's side equals its gap from +/// the pill's top and bottom, (pill height - control height) / 2. +void _expectEnd( + Rect pill, + Rect control, { + required bool start, + bool top = true, +}) { + final gap = (pill.height - control.height) / 2; + expect(pill.bottom - control.bottom, closeTo(gap, 1), reason: 'bottom'); + if (top) expect(control.top - pill.top, closeTo(gap, 1), reason: 'top'); + expect( + start ? control.left - pill.left : pill.right - control.right, + closeTo(gap, 1), + reason: start ? 'left' : 'right', + ); +} + +void _expectEqualEnds(Rect pill, Rect first, Rect last, {bool top = true}) { + _expectEnd(pill, first, start: true, top: top); + _expectEnd(pill, last, start: false, top: top); +} + +/// Neighbouring controls in [rects] are evenly spaced. +void _expectEvenNeighbours(List rects) { + if (rects.length < 3) return; + final gaps = [ + for (var i = 1; i < rects.length; i++) rects[i].left - rects[i - 1].right, + ]; + for (final gap in gaps) { + expect(gap, closeTo(gaps.first, 1), reason: 'neighbour gaps $gaps'); + } +} + +Rect _pillOf(WidgetTester tester, Finder inside) => tester.getRect( + find.ancestor(of: inside, matching: find.byType(GlassPill)).first, +); + +void main() { + for (final cupertino in _hosts) { + final host = cupertino ? 'Cupertino' : 'Material'; + for (final scale in _scales) { + final when = '$host, text x$scale'; + + testWidgets('artifact viewer bar: equal end gaps ($when)', ( + tester, + ) async { + await _setUp(tester, scale); + for (final count in [1, 3]) { + final artifacts = [ + for (var i = 0; i < count; i++) + recordedArtifact( + 'shot-$i.png', + url: '/artifacts/1/1/shot-$i.png', + contentType: 'image/png', + ), + ]; + final group = ArtifactGroup( + stageKey: 'review', + visit: 1, + artifacts: artifacts, + ); + await tester.pumpWidget( + _host( + cupertino, + ArtifactViewerPage( + key: ValueKey(count), + groups: [group], + selectedIdentity: artifactVisitIdentity(group, artifacts.first), + configuredEndpoint: 'ws://127.0.0.1:8081/connect', + fetch: (_) async => + ArtifactFetchResult(status: 200, bytes: _png), + markdownBuilder: (context, value) => Text(value), + openExternal: (_) async => true, + ), + ), + ); + await tester.pumpAndSettle(); + final row = find.byKey(const Key('artifact-viewer-actions')); + final pill = _pillOf(tester, row); + final controls = _controls(tester, row); + expect(controls.length, greaterThanOrEqualTo(2)); + _expectEqualEnds(pill, controls.first, controls.last); + _expectEvenNeighbours( + count > 1 ? controls.sublist(0, controls.length - 2) : controls, + ); + if (count > 1) { + _expectEvenNeighbours(controls.sublist(controls.length - 2)); + } + expect(pill.height, closeTo(GlassBarMetrics.height(cupertino), 1)); + expect(tester.takeException(), isNull); + } + }); + + testWidgets('diff page pager: position and chevrons inset ($when)', ( + tester, + ) async { + await _setUp(tester, scale); + await tester.pumpWidget( + _host( + cupertino, + FileDiffPage( + files: [ + for (final name in ['a', 'b', 'c']) + FileChange( + path: 'lib/$name.dart', + kind: ChangeKind.modified, + patch: + '--- a/lib/$name.dart\n+++ b/lib/$name.dart\n' + '@@ -1 +1 @@\n-x\n+y\n', + ), + ], + ), + ), + ); + await tester.pumpAndSettle(); + final pager = find.byKey(const ValueKey('file-diff-pager')); + _expectPager(tester, pager, cupertino, find.text('1 of 3')); + }); + + testWidgets('changes visit pager: equal end gaps ($when)', ( + tester, + ) async { + await _setUp(tester, scale); + Map visit(String stage, int sequence) => { + 'stage': stage, + 'sequence': sequence, + 'status': 'completed', + 'file_changes': { + 'status': 'complete', + 'scope': 'Git tracked files', + 'skipped': 0, + 'omitted': 0, + 'diagnostic': '', + 'files': [ + {'path': 'lib/$stage.dart', 'kind': 'added'}, + ], + }, + }; + await tester.pumpWidget( + _host( + cupertino, + ChangesViewer( + steps: [visit('build', 1), visit('review', 2)], + showSummary: false, + ), + ), + ); + await tester.pumpAndSettle(); + final position = find.byKey( + const ValueKey('changes-visit-position'), + ); + _expectPager( + tester, + find.ancestor(of: position, matching: find.byType(Row)).first, + cupertino, + position, + ); + }); + + testWidgets('chat composer: + and Send keep the pill gap ($when)', ( + tester, + ) async { + await _setUp(tester, scale); + final gateway = ComposerBarGateway(); + addTearDown(gateway.close); + final composer = ChatComposerController( + gateway, + 's', + drafts: MemoryChatDraftStore(), + ); + addTearDown(composer.dispose); + await tester.pumpWidget( + _host( + cupertino, + Align( + alignment: Alignment.bottomCenter, + child: ChatComposerBar( + composer: composer, + running: false, + placeholder: 'Message', + ), + ), + ), + ); + await tester.pumpAndSettle(); + final pill = tester.getRect( + find.byKey(const Key('chat-composer-pill')), + ); + final attach = tester.getRect( + find.byKey(const Key('chat-composer-attach')), + ); + final send = tester.getRect( + find.byKey(const Key('chat-composer-primary')), + ); + // The controls keep to the field's last line: each end control is as + // far from the pill's side as from its bottom, and while the field is + // one line (no taller than a control) as far from its top. + final row = GlassBarMetrics.controlExtent(cupertino); + final oneLine = + pill.height <= row + 2 * GlassBarMetrics.fieldEdgeGap + 0.5; + for (final (control, start) in [(attach, true), (send, false)]) { + final bottom = pill.bottom - control.bottom; + final side = start + ? control.left - pill.left + : pill.right - control.right; + expect(side, closeTo(bottom, 1), reason: 'side vs bottom'); + if (oneLine) { + expect(control.top - pill.top, closeTo(bottom, 1), reason: 'top'); + expect(bottom, closeTo((pill.height - control.height) / 2, 1)); + } + } + if (scale == 1.0) expect(oneLine, isTrue, reason: 'pill $pill'); + expect(tester.takeException(), isNull); + }); + + testWidgets('top bar actions pill: controls fill it evenly ($when)', ( + tester, + ) async { + await _setUp(tester, scale); + final actions = [ + for (final name in ['a', 'b', 'c']) + cupertino + ? CupertinoButton( + key: Key('action-$name'), + padding: EdgeInsets.zero, + onPressed: () {}, + child: const Icon(CupertinoIcons.info), + ) + : IconButton( + key: Key('action-$name'), + onPressed: () {}, + icon: const Icon(Icons.info_outline), + ), + ]; + await tester.pumpWidget( + cupertino + ? CupertinoApp( + home: CupertinoPageScaffold( + navigationBar: SegmentedBar( + cupertino: true, + title: 'Title', + actions: actions, + ), + child: const SizedBox.expand(), + ), + ) + : MaterialApp( + home: Scaffold( + appBar: SegmentedBar( + cupertino: false, + title: 'Title', + actions: actions, + ), + ), + ), + ); + await tester.pumpAndSettle(); + final first = find.byKey(const Key('action-a')); + final pill = _pillOf(tester, first); + final controls = [ + for (final name in ['a', 'b', 'c']) + tester.getRect(find.byKey(Key('action-$name'))), + ]; + _expectEqualEnds(pill, controls.first, controls.last); + _expectEvenNeighbours(controls); + expect(tester.takeException(), isNull); + }); + } + } +} + +/// A pager row: its position text starts an icon's inset in from the pill's +/// edge (where an icon at that end would be drawn), and its chevrons keep the +/// rule's equal gaps at the other end. +void _expectPager( + WidgetTester tester, + Finder inside, + bool cupertino, + Finder position, +) { + final pill = _pillOf(tester, inside); + final controls = _controls(tester, inside); + expect(controls, hasLength(2)); + final last = controls.last; + _expectEnd(pill, last, start: false); + _expectEvenNeighbours(controls); + final text = tester.getRect(position); + final gap = (pill.height - last.height) / 2; + expect( + text.left - pill.left, + closeTo(gap + GlassBarMetrics.iconInset(cupertino), 1), + ); + // The chevrons keep the same gap from the position as from each other's + // icons: one icon inset on each side. + expect( + controls.first.left - text.right, + greaterThanOrEqualTo(GlassBarMetrics.iconInset(cupertino) - 1), + ); + expect(pill.height, closeTo(GlassBarMetrics.height(cupertino), 1)); + expect(tester.takeException(), isNull); +} diff --git a/app/tool/search_selection_probe_entry.dart b/app/tool/search_selection_probe_entry.dart index 2990b8a6..fb3d3b21 100644 --- a/app/tool/search_selection_probe_entry.dart +++ b/app/tool/search_selection_probe_entry.dart @@ -55,6 +55,7 @@ JsonMap probeRunDetail() => { 'started_at': '2026-10-20T08:30:00Z', 'finished_at': '2026-10-20T08:31:00Z', 'diagnostic': 'release plan accepted', + 'file_changes': _probeChanges(['docs/release-plan.md']), }, { 'stage': 'build', @@ -72,6 +73,11 @@ JsonMap probeRunDetail() => { 'url': '/artifacts/7/2/release-report.txt', }, ], + 'file_changes': _probeChanges([ + 'lib/release/train.dart', + 'lib/release/notes.dart', + 'test/release/train_test.dart', + ]), }, { 'stage': 'plan', @@ -87,6 +93,31 @@ JsonMap probeRunDetail() => { if (perfRunGraph) 'graph': perfRunGraphFixture(), }; +/// A complete change capture modifying [paths], so Changes shows visit pages +/// and each file opens a paged diff. +JsonMap _probeChanges(List paths) => { + 'status': 'complete', + 'scope': 'Git tracked and nonignored files in the run directory', + 'skipped': 0, + 'omitted': 0, + 'diagnostic': '', + 'files': [ + for (final path in paths) + { + 'path': path, + 'kind': 'modified', + 'patch': + '--- "a/$path"\n' + '+++ "b/$path"\n' + '@@ -1,3 +1,3 @@\n' + ' // Release train\n' + '-const stage = \'draft\';\n' + '+const stage = \'shipped\';\n' + ' // end\n', + }, + ], +}; + /// Extra rows for scroll-performance captures (`?runs=N`, `?steps=N`). Both /// default to none, so every other capture sees the fixture unchanged. int _fillerRunCount = 0;