From 98cdf6307930249681bc89492103ef9c81ed8217 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 02:05:30 +0000 Subject: [PATCH 1/2] Prevent floating window content rebuilds Keep window content scope independent from frame changes, and retain the page theme and root page across layer rebuilds. Add repaint boundaries and regression coverage so dragging and resizing avoid unrelated content work while content changes still propagate. --- app/lib/shell/windows/window_layer.dart | 76 ++++++---- app/lib/shell/windows/window_navigator.dart | 37 +++-- app/lib/shell/windows/window_scope.dart | 39 ++++-- app/notes/perf-round5.md | 102 ++++++++++++++ .../shell/windows/window_rebuild_test.dart | 130 ++++++++++++++++++ app/tool/capture/window_probe.dart | 5 + 6 files changed, 336 insertions(+), 53 deletions(-) create mode 100644 app/notes/perf-round5.md create mode 100644 app/test/shell/windows/window_rebuild_test.dart diff --git a/app/lib/shell/windows/window_layer.dart b/app/lib/shell/windows/window_layer.dart index df969711..f17c23da 100644 --- a/app/lib/shell/windows/window_layer.dart +++ b/app/lib/shell/windows/window_layer.dart @@ -55,6 +55,16 @@ class _WindowLayerState extends State final GlobalKey _navigator = GlobalKey(); late final LocalKey _rootPage = ValueKey('window-root-${widget.entry.id}'); + /// The page-transition theme handed to the window's navigator, rebuilt only + /// when the app's theme itself changes. + ThemeData? _themeSource; + ThemeData? _pageTheme; + + /// The root page kept across builds: a new page object would rebuild the + /// window's content on every move and resize. + WindowKind? _pageKind; + Page? _page; + String get _id => widget.entry.id; @override @@ -160,6 +170,22 @@ class _WindowLayerState extends State widget.manager.raise(_id); } + ThemeData _pageThemeFor(ThemeData theme) { + if (identical(theme, _themeSource)) return _pageTheme!; + _themeSource = theme; + return _pageTheme = WindowNavigator.themeData(theme); + } + + Page _rootPageFor(WindowKind kind) { + final page = _page; + if (page != null && identical(kind, _pageKind)) return page; + _pageKind = kind; + return _page = MaterialPage( + key: _rootPage, + child: _WindowContent(kind: kind), + ); + } + @override Widget build(BuildContext context) { final manager = widget.manager; @@ -174,6 +200,7 @@ class _WindowLayerState extends State frame.bottom, ); final title = kind.title(context, entry); + final pageTheme = _pageThemeFor(Theme.of(context)); final hiding = !widget.visible; final content = Stack( fit: StackFit.expand, @@ -185,17 +212,21 @@ class _WindowLayerState extends State explicitChildNodes: true, label: 'Window: $title', identifier: 'window-${entry.kind}', - child: WindowFrame( - title: title, - icon: kind.icon, - actions: kind.actions(context, entry), - maximized: entry.maximized, - onMove: _move, - onMoveEnd: _moveEnded, - onMinimize: () => manager.setMinimized(_id, true), - onToggleMaximized: () => - manager.setMaximized(_id, !entry.maximized), - onClose: () => manager.close(_id), + // Its own layer: moving the window moves the title bar without + // repainting it. + child: RepaintBoundary( + child: WindowFrame( + title: title, + icon: kind.icon, + actions: kind.actions(context, entry), + maximized: entry.maximized, + onMove: _move, + onMoveEnd: _moveEnded, + onMinimize: () => manager.setMinimized(_id, true), + onToggleMaximized: () => + manager.setMaximized(_id, !entry.maximized), + onClose: () => manager.close(_id), + ), ), ), ), @@ -210,19 +241,16 @@ class _WindowLayerState extends State child: WindowScope( manager: manager, entry: entry, - body: body, - child: ScaffoldMessenger( - child: WindowNavigator.theme( - context, - child: WindowNavigator( - key: _navigator, - pages: [ - MaterialPage( - key: _rootPage, - child: _WindowContent(kind: kind), - ), - ], - onDidRemovePage: (_) {}, + child: WindowBodyScope( + body: body, + child: ScaffoldMessenger( + child: Theme( + data: pageTheme, + child: WindowNavigator( + key: _navigator, + pages: [_rootPageFor(kind)], + onDidRemovePage: (_) {}, + ), ), ), ), diff --git a/app/lib/shell/windows/window_navigator.dart b/app/lib/shell/windows/window_navigator.dart index 5d594c2c..26e5f1da 100644 --- a/app/lib/shell/windows/window_navigator.dart +++ b/app/lib/shell/windows/window_navigator.dart @@ -18,23 +18,21 @@ import 'window_scope.dart'; class WindowNavigator extends Navigator { const WindowNavigator({super.key, super.pages, super.onDidRemovePage}); - /// [child] with page transitions that keep every `MaterialPageRoute` of a - /// window navigator below it inside the window's content area. - static Widget theme(BuildContext context, {required Widget child}) { - final theme = Theme.of(context); + /// [theme] with page transitions that keep every `MaterialPageRoute` of a + /// window navigator inside the window's content area. The caller keeps the + /// result, so rebuilding a window layer does not hand its contents a new + /// theme. + static ThemeData themeData(ThemeData theme) { final builders = theme.pageTransitionsTheme.builders; - return Theme( - data: theme.copyWith( - pageTransitionsTheme: PageTransitionsTheme( - builders: { - for (final platform in TargetPlatform.values) - platform: _WindowPageTransitions( - builders[platform] ?? const ZoomPageTransitionsBuilder(), - ), - }, - ), + return theme.copyWith( + pageTransitionsTheme: PageTransitionsTheme( + builders: { + for (final platform in TargetPlatform.values) + platform: _WindowPageTransitions( + builders[platform] ?? const ZoomPageTransitionsBuilder(), + ), + }, ), - child: child, ); } @@ -117,9 +115,8 @@ class WindowPageBox extends StatelessWidget { @override Widget build(BuildContext context) { - final scope = WindowScope.maybeOf(context); - if (scope == null) return child; - final body = scope.body; + final body = WindowBodyScope.maybeOf(context); + if (body == null) return child; const radius = Radius.circular(windowCornerRadius); return Stack( children: [ @@ -140,7 +137,9 @@ class WindowPageBox extends StatelessWidget { child: Scaffold( backgroundColor: Colors.transparent, primary: false, - body: child, + // Its own layer: moving or resizing the window repositions the + // page without repainting it. + body: RepaintBoundary(child: child), ), ), ), diff --git a/app/lib/shell/windows/window_scope.dart b/app/lib/shell/windows/window_scope.dart index 0bbf7abd..e490e9e8 100644 --- a/app/lib/shell/windows/window_scope.dart +++ b/app/lib/shell/windows/window_scope.dart @@ -1,27 +1,26 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'window_entry.dart'; import 'window_manager.dart'; -/// The floating window some content is in: its entry, the manager, and where -/// the content area is drawn in the window host. Absent outside a window, so -/// shared content can tell the tiled app from a window. +/// The floating window some content is in: its entry and the manager. Absent +/// outside a window, so shared content can tell the tiled app from a window. +/// +/// Content depends on what it can read of the entry, not on where the window +/// is drawn: moving, resizing, minimising or maximising a window keeps its +/// content as it is. class WindowScope extends InheritedWidget { const WindowScope({ super.key, required this.manager, required this.entry, - required this.body, required super.child, }); final WindowManager manager; final WindowEntry entry; - /// The content area (the window less its title bar), in the host's - /// coordinates. - final Rect body; - static WindowScope? maybeOf(BuildContext context) => context.dependOnInheritedWidgetOfExactType(); @@ -30,6 +29,26 @@ class WindowScope extends InheritedWidget { @override bool updateShouldNotify(WindowScope oldWidget) => oldWidget.manager != manager || - oldWidget.entry != entry || - oldWidget.body != body; + oldWidget.entry.id != entry.id || + oldWidget.entry.kind != entry.kind || + oldWidget.entry.contentId != entry.contentId || + oldWidget.entry.serverKey != entry.serverKey || + !mapEquals(oldWidget.entry.data, entry.data); +} + +/// Where a window's content area is drawn in the window host. Kept apart from +/// [WindowScope] so a move or a resize repositions the page without rebuilding +/// what the page shows. +class WindowBodyScope extends InheritedWidget { + const WindowBodyScope({super.key, required this.body, required super.child}); + + /// The content area (the window less its title bar), in the host's + /// coordinates. + final Rect body; + + static Rect? maybeOf(BuildContext context) => + context.dependOnInheritedWidgetOfExactType()?.body; + + @override + bool updateShouldNotify(WindowBodyScope oldWidget) => oldWidget.body != body; } diff --git a/app/notes/perf-round5.md b/app/notes/perf-round5.md new file mode 100644 index 00000000..91022c70 --- /dev/null +++ b/app/notes/perf-round5.md @@ -0,0 +1,102 @@ +# Performance round 5: moving a window does not rebuild its content + +Round 5's candidate: every pointer event of a window drag rebuilt every +window's whole content. `WindowScope` carried the body `Rect` and compared the +whole `WindowEntry`, the navigator's `ThemeData` was rebuilt with `copyWith` on +every build, and the root `MaterialPage` was a new object on every build. + +## Change + +`lib/shell/windows/`: + +- `window_scope.dart`: `WindowScope` keeps only `manager` and `entry`, and + notifies only when what content can read changes (id, kind, contentId, + serverKey, `data`). A new `WindowBodyScope` (an `InheritedWidget` with the + body `Rect`) carries the position and size that used to be in `WindowScope`. +- `window_navigator.dart`: `WindowNavigator.theme(context, child:)` became + `WindowNavigator.themeData(theme)`, so the layer can keep the + page-transition `ThemeData`. `WindowPageBox` reads the body from + `WindowBodyScope`, and its page child is a `RepaintBoundary`. +- `window_layer.dart`: `_WindowLayerState` keeps the page-transition theme in a + field and rebuilds it only when `Theme.of(context)` is a different object; it + keeps the root `MaterialPage` in a field (same key) and rebuilds it only when + the kind changes. `WindowFrame` is wrapped in a `RepaintBoundary`. + +No behaviour change: frames, snapping, resize limits, popups, pushed pages, +minimise/maximise, focus and the shell's APIs are as before. + +`tool/capture/window_probe.dart`: `ProbeContentState.lastSize` records the +`MediaQuery` size the content built at, so tests can see a resize reach it +(no visual change). + +## Deterministic build counts + +`test/shell/windows/window_rebuild_test.dart`: + +- dragging a window's title over 8 pointer moves: the dragged window's content + and the other window's content keep their `builds` count (0 rebuilds); +- resizing a window over 5 pointer moves: the other window keeps its count, + the resized window's content rebuilds and sees the new `MediaQuery` size + (360x380 -> 280x330 body); +- `manager.setContent` retargets a content whose element is keyed stably: the + same state rebuilds with the new contentId. + +Against the old implementation (lib changes stashed, test run unchanged): 2 +failed — `dragged window rebuilt at move 0` (builds 2 -> 3) and `other window +rebuilt at move 0` (2 -> 3). The new code passes all 3. + +## Browser bench + +Built twice: the old code (lib/shell/windows changes stashed) into +`build/probe-before`, and this branch into `build/probe-app`: + +``` +/Users/alan/development/flutter/bin/flutter build web \ + --target tool/search_selection_probe_entry.dart --output build/probe-before +/Users/alan/development/flutter/bin/flutter build web \ + --target tool/search_selection_probe_entry.dart --output build/probe-app +``` + +Run, from `app/`, against each build in turn: + +``` +node tool/perf/interaction_bench.mjs --build build/probe-before --out /tmp/bench \ + --gpu --only 'desktop: drag a probe window' --repeat 3 +node tool/perf/interaction_bench.mjs --build build/probe-app --out /tmp/bench \ + --gpu --only 'desktop: drag a probe window' --repeat 3 +``` + +Three before/after rounds (the machine was shared with other pipeline test +runs; load average 9-14 during these, so frame counts vary. `buildMs/frame = +buildSum / frames`): + +| round | code | frames | buildSum | ms/frame | buildMax | longest | over16 | rasterSum | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | +| 1 | before | 50 | 952.2 | 19.0 | 63.5 | 73.9 | 31 | 107.4 | +| 1 | after | 49 | 824.8 | 16.8 | 59.1 | 74.0 | 27 | 107.9 | +| 2 | before | 49 | 615.6 | 12.6 | 25.5 | 28.4 | 15 | 62.1 | +| 2 | after | 51 | 583.0 | 11.4 | 37.4 | 39.9 | 13 | 87.2 | +| 3 | before | 51 | 527.9 | 10.4 | 16.2 | 20.3 | 9 | 68.3 | +| 3 | after | 47 | 606.8 | 12.9 | 24.1 | 26.9 | 18 | 83.5 | + +The browser numbers are inconclusive on this loaded machine: only round 1 +shows less build work, and the spread between rounds (10.4-19.0 ms/frame on the +same code) is larger than the change. The reliable result is the build count: +the drag went from one content build per pointer event per window (120 builds +over a 40-move drag with three windows) to none. Window chrome and framework +layout still run on every pointer event; that is the remaining build cost in +this scenario, not content. + +## Checks + +- `tool/memwatch/full.sh 'test/shell/windows test/features/chat/chat_floating_pane_test.dart test/features/terminal'`: + 119 passed, 0 failed. +- `tool/analyze.sh`: clean. + +## Affected UI states (for ui-review) + +`/runs?windows=2` at 1280x800 light: the windows after a title drag +(`drag=250,132>300,150`), after a corner resize +(`drag=483,523>120,80`), and a page pushed inside a window (click `page`) then +dragged: the content must follow the window, stay inside it, and show no stale +or clipped frame. diff --git a/app/test/shell/windows/window_rebuild_test.dart b/app/test/shell/windows/window_rebuild_test.dart new file mode 100644 index 00000000..dcbf9252 --- /dev/null +++ b/app/test/shell/windows/window_rebuild_test.dart @@ -0,0 +1,130 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/shell/windows/window_entry.dart'; +import 'package:pipelines_app/shell/windows/window_kind.dart'; +import 'package:pipelines_app/shell/windows/window_layer.dart'; +import 'package:pipelines_app/shell/windows/window_manager.dart'; + +import 'window_test_harness.dart'; + +/// A probe kind whose content keeps its element when the window is retargeted, +/// so a rebuild is visible in the same state's counter. +class _StableProbeKind extends WindowKind { + @override + String get key => 'stable'; + @override + bool get serverScoped => false; + @override + IconData get icon => Icons.science_outlined; + @override + String title(BuildContext context, WindowEntry entry) => + 'Probe ${entry.contentId}'; + @override + Widget build(BuildContext context, WindowEntry entry) => + ProbeContent(key: const ValueKey('stable-content'), id: entry.contentId); +} + +void main() { + late WindowManager manager; + setUp(() => manager = probeManager()); + + Finder window(String title) => find.byWidgetPredicate( + (w) => w is WindowLayer && 'Probe ${w.entry.contentId}' == title, + ); + Finder inWindow(String title, Finder what) => + find.descendant(of: window(title), matching: what); + ProbeContentState content(WidgetTester tester, String id) => + tester.state(find.byKey(ValueKey('content-$id'))); + + Future openTwo(WidgetTester tester) async { + manager.open('probe', 'a', frame: const Rect.fromLTWH(100, 80, 360, 420)); + manager.open('probe', 'b', frame: const Rect.fromLTWH(600, 200, 360, 420)); + await pumpProbe(tester, manager); + } + + testWidgets('dragging a window moves it without rebuilding any content', ( + tester, + ) async { + await openTwo(tester); + final a = content(tester, 'a'); + final b = content(tester, 'b'); + final beforeA = a.builds; + final beforeB = b.builds; + final start = windowRect(tester, 'Probe a').topLeft; + final fieldStart = tester + .getRect(find.byKey(const ValueKey('a-field'))) + .topLeft; + final gesture = await tester.startGesture( + tester.getCenter( + inWindow('Probe a', find.byKey(const ValueKey('window-title'))), + ), + ); + for (var i = 0; i < 8; i++) { + await gesture.moveBy(const Offset(12, 6)); + await tester.pump(); + expect(a.builds, beforeA, reason: 'dragged window rebuilt at move $i'); + expect(b.builds, beforeB, reason: 'other window rebuilt at move $i'); + } + await gesture.up(); + await tester.pumpAndSettle(); + // It really moved, and its content followed it. + expect(windowRect(tester, 'Probe a').topLeft, start + const Offset(96, 48)); + expect( + tester.getRect(find.byKey(const ValueKey('a-field'))).topLeft, + fieldStart + const Offset(96, 48), + ); + expect(content(tester, 'a').builds, beforeA); + expect(content(tester, 'b').builds, beforeB); + }); + + testWidgets('resizing a window keeps another window and sees the new size', ( + tester, + ) async { + await openTwo(tester); + final a = content(tester, 'a'); + final b = content(tester, 'b'); + final beforeA = a.builds; + final beforeB = b.builds; + final beforeSize = b.lastSize!; + final gesture = await tester.startGesture( + tester.getCenter( + inWindow('Probe b', find.byKey(const ValueKey('window-resize'))), + ), + ); + for (var i = 0; i < 5; i++) { + await gesture.moveBy(const Offset(-16, -10)); + await tester.pump(); + expect(a.builds, beforeA, reason: 'other window rebuilt at move $i'); + } + await gesture.up(); + await tester.pumpAndSettle(); + expect(content(tester, 'a').builds, beforeA); + final state = content(tester, 'b'); + expect(state.builds, greaterThan(beforeB)); + expect(state.lastSize!.width, beforeSize.width - 80); + expect(state.lastSize!.height, beforeSize.height - 50); + }); + + testWidgets('content still rebuilds when its window is retargeted', ( + tester, + ) async { + manager = WindowManager( + kinds: WindowKinds()..register(_StableProbeKind()), + ); + final entry = manager.open('stable', 'a'); + await pumpProbe(tester, manager); + final state = tester.state( + find.byKey(const ValueKey('stable-content')), + ); + final before = state.builds; + manager.setContent(entry.id, 'c'); + await tester.pumpAndSettle(); + final after = tester.state( + find.byKey(const ValueKey('stable-content')), + ); + expect(after, same(state)); + expect(after.builds, greaterThan(before)); + expect(after.widget.id, 'c'); + expect(find.text('Probe c'), findsOneWidget); + }); +} diff --git a/app/tool/capture/window_probe.dart b/app/tool/capture/window_probe.dart index ec2c7f34..8a8e3de7 100644 --- a/app/tool/capture/window_probe.dart +++ b/app/tool/capture/window_probe.dart @@ -52,6 +52,10 @@ class ProbeContentState extends State { int builds = 0; String? picked; + /// The size the content was last laid out at (the window's content area), + /// so tests can see a resize reach it. + Size? lastSize; + @override void dispose() { text.dispose(); @@ -67,6 +71,7 @@ class ProbeContentState extends State { @override Widget build(BuildContext context) { builds++; + lastSize = MediaQuery.sizeOf(context); final id = widget.id; return ListView( children: [ From 88cb76f2208c424d301e581d2a7a8bc4891f13c0 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 02:26:12 +0000 Subject: [PATCH 2/2] Remove Cupertino graph branches Keep the Material graph implementation while preserving public Cupertino parameters for callers. Remove unreachable Cupertino widgets, routes, theme branches, imports, and Cupertino-only tests because the app runs exclusively under MaterialApp. --- .../graph/viewport/graph_expanded_view.dart | 61 ++----- .../graph/viewport/graph_viewport.dart | 45 ++--- .../graph/widgets/definition_graph_view.dart | 1 - .../graph/widgets/graph_canvas_style.dart | 22 +-- .../graph/widgets/graph_stage_node.dart | 19 +-- .../graph/widgets/run_graph_canvas.dart | 7 +- .../graph/widgets/run_graph_header.dart | 13 +- .../graph/widgets/stage_definition_view.dart | 52 +----- .../viewport/graph_expanded_view_test.dart | 95 ++--------- .../graph_viewport_controls_test.dart | 156 ++++++++---------- .../viewport/graph_viewport_fixtures.dart | 10 -- .../widgets/definition_graph_view_test.dart | 39 ----- .../widgets/graph_stage_node_render_test.dart | 76 +++------ .../graph/widgets/graph_stage_node_test.dart | 112 ++++++------- .../graph/widgets/run_graph_view_test.dart | 65 -------- .../widgets/stage_definition_view_test.dart | 72 +------- 16 files changed, 200 insertions(+), 645 deletions(-) diff --git a/app/lib/features/graph/viewport/graph_expanded_view.dart b/app/lib/features/graph/viewport/graph_expanded_view.dart index 9efa09bc..012196d7 100644 --- a/app/lib/features/graph/viewport/graph_expanded_view.dart +++ b/app/lib/features/graph/viewport/graph_expanded_view.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/adaptive/segmented_bar.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; import 'graph_viewport.dart'; import 'graph_viewport_controller.dart'; @@ -100,23 +98,6 @@ class _GraphExpandedViewState extends State { Expanded(child: viewport), ], ); - if (usesCupertinoHost(context)) { - return CupertinoPageScaffold( - navigationBar: SegmentedBar( - cupertino: true, - automaticallyImplyLeading: false, - leading: SegmentedBackButton(cupertino: true, onPressed: _close), - title: widget.title, - actions: [ - _GraphFitButton( - cupertino: true, - onPressed: _controller.fitToViewport, - ), - ], - ), - child: BelowTopBar(child: body), - ); - } return Scaffold( extendBodyBehindAppBar: true, appBar: SegmentedBar( @@ -124,12 +105,7 @@ class _GraphExpandedViewState extends State { title: widget.title, automaticallyImplyLeading: false, leading: SegmentedBackButton(cupertino: false, onPressed: _close), - actions: [ - _GraphFitButton( - cupertino: false, - onPressed: _controller.fitToViewport, - ), - ], + actions: [_GraphFitButton(onPressed: _controller.fitToViewport)], ), body: BelowTopBar(child: body), ); @@ -137,9 +113,8 @@ class _GraphExpandedViewState extends State { } class _GraphFitButton extends StatelessWidget { - const _GraphFitButton({required this.cupertino, required this.onPressed}); + const _GraphFitButton({required this.onPressed}); - final bool cupertino; final VoidCallback onPressed; @override @@ -147,22 +122,15 @@ class _GraphFitButton extends StatelessWidget { child: Semantics( button: true, label: graphFitLabel, - child: cupertino - ? CupertinoButton( - key: const Key('graph-fit'), - padding: const EdgeInsets.all(8), - onPressed: onPressed, - child: const ExcludeSemantics(child: Icon(CupertinoIcons.resize)), - ) - : Tooltip( - message: graphFitLabel, - excludeFromSemantics: true, - child: IconButton( - key: const Key('graph-fit'), - onPressed: onPressed, - icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)), - ), - ), + child: Tooltip( + message: graphFitLabel, + excludeFromSemantics: true, + child: IconButton( + key: const Key('graph-fit'), + onPressed: onPressed, + icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)), + ), + ), ), ); } @@ -190,8 +158,9 @@ Future openGraphExpanded( selectedStage: selectedStage, header: header, ); - final route = usesCupertinoHost(context) - ? CupertinoPageRoute(fullscreenDialog: true, builder: (_) => page) - : MaterialPageRoute(fullscreenDialog: true, builder: (_) => page); + final route = MaterialPageRoute( + fullscreenDialog: true, + builder: (_) => page, + ); return Navigator.of(context).push(route); } diff --git a/app/lib/features/graph/viewport/graph_viewport.dart b/app/lib/features/graph/viewport/graph_viewport.dart index 071b432d..787741fd 100644 --- a/app/lib/features/graph/viewport/graph_viewport.dart +++ b/app/lib/features/graph/viewport/graph_viewport.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/glass_pill.dart'; import 'graph_viewport_controller.dart'; @@ -121,20 +119,20 @@ class _GraphViewportState extends State { top: 8, end: 8, child: GlassPill( - cupertino: usesCupertinoHost(context), + cupertino: false, child: Wrap( spacing: 2, children: [ _ViewportButton( buttonKey: const Key('graph-fit'), - icon: _fitIcon(context), + icon: Icons.fit_screen, label: graphFitLabel, onPressed: widget.controller.fitToViewport, ), if (widget.onExpand != null) _ViewportButton( buttonKey: const Key('graph-expand'), - icon: _expandIcon(context), + icon: Icons.fullscreen, label: graphExpandLabel, onPressed: widget.onExpand, ), @@ -147,12 +145,6 @@ class _GraphViewportState extends State { }, ); } - - IconData _fitIcon(BuildContext context) => - usesCupertinoHost(context) ? CupertinoIcons.resize : Icons.fit_screen; - - IconData _expandIcon(BuildContext context) => - usesCupertinoHost(context) ? CupertinoIcons.fullscreen : Icons.fullscreen; } /// One native graph control inside the shared floating glass pill. @@ -160,7 +152,7 @@ class _GraphViewportState extends State { /// The label and the button's own tap action must reach the same semantics /// node: the icon is the only excluded child, and [MergeSemantics] folds the /// host button's action into the labelled node, so a screen reader can activate -/// Fit and Expand on either host. A hand-written `Semantics` sibling around an +/// Fit and Expand. A hand-written `Semantics` sibling around an /// excluded button would announce the control with no action at all. class _ViewportButton extends StatelessWidget { const _ViewportButton({ @@ -181,24 +173,17 @@ class _ViewportButton extends StatelessWidget { child: Semantics( button: true, label: label, - child: usesCupertinoHost(context) - ? CupertinoButton( - key: buttonKey, - padding: const EdgeInsets.all(8), - onPressed: onPressed, - child: ExcludeSemantics(child: Icon(icon)), - ) - : Tooltip( - message: label, - // The merged node already carries the label; the tooltip is - // only the pointer affordance. - excludeFromSemantics: true, - child: IconButton( - key: buttonKey, - onPressed: onPressed, - icon: ExcludeSemantics(child: Icon(icon)), - ), - ), + child: Tooltip( + message: label, + // The merged node already carries the label; the tooltip is + // only the pointer affordance. + excludeFromSemantics: true, + child: IconButton( + key: buttonKey, + onPressed: onPressed, + icon: ExcludeSemantics(child: Icon(icon)), + ), + ), ), ); } diff --git a/app/lib/features/graph/widgets/definition_graph_view.dart b/app/lib/features/graph/widgets/definition_graph_view.dart index c1285fb5..7eed93ee 100644 --- a/app/lib/features/graph/widgets/definition_graph_view.dart +++ b/app/lib/features/graph/widgets/definition_graph_view.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; diff --git a/app/lib/features/graph/widgets/graph_canvas_style.dart b/app/lib/features/graph/widgets/graph_canvas_style.dart index b4c97ef6..03347dce 100644 --- a/app/lib/features/graph/widgets/graph_canvas_style.dart +++ b/app/lib/features/graph/widgets/graph_canvas_style.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../layout/layout_models.dart'; import '../routing/route_models.dart'; @@ -32,9 +30,9 @@ RoutingConfig graphCanvasRoutingConfig() => RoutingConfig( /// The native theme roles one definition graph canvas needs. /// /// No palette, font family or size is defined here: every value comes from the -/// ambient Material or Cupertino theme, so light/dark and text scaling follow -/// the host exactly. Edge labels and diagnostics are metadata, so they use the -/// host's secondary-label role rather than the node's own label style. +/// ambient Material theme, so light/dark and text scaling follow the host +/// exactly. Edge labels and diagnostics are metadata, so they use the host's +/// secondary-label role rather than the node's own label style. class GraphCanvasStyle { const GraphCanvasStyle({ required this.labelStyle, @@ -44,20 +42,6 @@ class GraphCanvasStyle { }); factory GraphCanvasStyle.of(BuildContext context) { - if (usesCupertinoHost(context)) { - final theme = CupertinoTheme.of(context); - final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - return GraphCanvasStyle( - labelStyle: theme.textTheme.tabLabelTextStyle.copyWith( - color: secondary, - ), - messageStyle: theme.textTheme.textStyle.copyWith(color: secondary), - edgeColor: CupertinoColors.separator.resolveFrom(context), - // Cupertino has no divider-thickness token; its separators are one - // logical pixel hairlines, so the stroke keeps that native default. - edgeWidth: 1, - ); - } final theme = Theme.of(context); final secondary = theme.colorScheme.onSurfaceVariant; return GraphCanvasStyle( diff --git a/app/lib/features/graph/widgets/graph_stage_node.dart b/app/lib/features/graph/widgets/graph_stage_node.dart index c72ebbd3..2cbf7667 100644 --- a/app/lib/features/graph/widgets/graph_stage_node.dart +++ b/app/lib/features/graph/widgets/graph_stage_node.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../ui/status/run_status_icon.dart'; import '../domain/graph_definition.dart'; @@ -37,7 +35,7 @@ class GraphStageNode extends StatelessWidget { /// Reports [node.key] exactly as the definition recorded it. final ValueChanged onSelected; - /// Content inset shared by both hosts. It is spacing, not a size: the control + /// Content inset for a graph node. It is spacing, not a size: the control /// still takes its size from its label, and the inset keeps wrapped glyphs /// clear of a rounded surface's corners. static const EdgeInsets _contentPadding = EdgeInsets.all(16); @@ -61,9 +59,7 @@ class GraphStageNode extends StatelessWidget { button: true, selected: selected, label: _label, - child: usesCupertinoHost(context) - ? _cupertinoButton(onPressed, content) - : _materialCard(onPressed, content), + child: _materialCard(onPressed, content), ), ); return active ? StageActivityHalo(child: control) : control; @@ -106,12 +102,6 @@ class GraphStageNode extends StatelessWidget { ); } - /// Tinted is Cupertino's stock low-emphasis surface, so an unselected node is - /// still a visible node body; filled raises the selected one. - Widget _cupertinoButton(VoidCallback onPressed, Widget content) => selected - ? CupertinoButton.filled(onPressed: onPressed, child: content) - : CupertinoButton.tinted(onPressed: onPressed, child: content); - Widget _content(BuildContext context) { final status = _status; // The recorded status reads apart from the name: a coloured dot and @@ -215,10 +205,7 @@ class _StageActivityHaloState extends State @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - final color = cupertino - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.primary; + final color = Theme.of(context).colorScheme.primary; return AnimatedBuilder( animation: _controller, builder: (context, child) => CustomPaint( diff --git a/app/lib/features/graph/widgets/run_graph_canvas.dart b/app/lib/features/graph/widgets/run_graph_canvas.dart index 953bb2ba..113a3f1b 100644 --- a/app/lib/features/graph/widgets/run_graph_canvas.dart +++ b/app/lib/features/graph/widgets/run_graph_canvas.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart' show listEquals; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../domain/graph_definition.dart'; import '../domain/run_graph_state.dart'; import '../layout/layout_models.dart'; @@ -200,10 +198,7 @@ class RunGraphCanvas extends StatelessWidget { final executedIds = {for (final route in executed) route.id}; final size = Size(routing.width, routing.height); final activeStage = state.activeStage; - final cupertino = usesCupertinoHost(context); - final executedColor = cupertino - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.primary; + final executedColor = Theme.of(context).colorScheme.primary; return Stack( clipBehavior: Clip.none, children: [ diff --git a/app/lib/features/graph/widgets/run_graph_header.dart b/app/lib/features/graph/widgets/run_graph_header.dart index ac7af652..ef0181bf 100644 --- a/app/lib/features/graph/widgets/run_graph_header.dart +++ b/app/lib/features/graph/widgets/run_graph_header.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../domain/run_graph_state.dart'; import 'graph_canvas_style.dart'; @@ -31,10 +29,7 @@ class RunGraphHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final cupertino = usesCupertinoHost(context); - final executedColor = cupertino - ? CupertinoTheme.of(context).primaryColor - : Theme.of(context).colorScheme.primary; + final executedColor = Theme.of(context).colorScheme.primary; final mutedColor = style.edgeColor; final active = state.activeStage; return Padding( @@ -53,14 +48,12 @@ class RunGraphHeader extends StatelessWidget { crossAxisAlignment: WrapCrossAlignment.center, children: [ _LegendEntry( - icon: cupertino - ? CupertinoIcons.arrow_right - : Icons.arrow_forward, + icon: Icons.arrow_forward, label: runGraphExecuted, color: executedColor, ), _LegendEntry( - icon: cupertino ? CupertinoIcons.minus : Icons.remove, + icon: Icons.remove, label: runGraphNotExecuted, color: mutedColor, ), diff --git a/app/lib/features/graph/widgets/stage_definition_view.dart b/app/lib/features/graph/widgets/stage_definition_view.dart index 3244d9e9..42ba6dc9 100644 --- a/app/lib/features/graph/widgets/stage_definition_view.dart +++ b/app/lib/features/graph/widgets/stage_definition_view.dart @@ -1,14 +1,12 @@ -import '../../../ui/adaptive/segmented_bar.dart'; import 'dart:convert'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../../ui/adaptive/segmented_bar.dart'; import '../../../ui/text/markdown_source_view.dart'; import '../../chat/ui/transcript/chat_markdown_view.dart'; import '../../../core/api_gateway.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/host.dart'; import '../domain/graph_protocol.dart'; import '../domain/stage_definition.dart'; @@ -159,30 +157,14 @@ Future openStageDefinition( // A terminal is a definition target, not its protocol key: the web pane // titles it with `nodeDisplayLabel` (`Failure`/`Success`). final title = '${nodeDisplayLabel(stageKey)} definition'; - final route = usesCupertinoHost(context) - ? CupertinoPageRoute( - settings: settings, - builder: (_) => CupertinoPageScaffold( - navigationBar: SegmentedBar( - cupertino: true, - title: title, - subtitle: identity, - ), - child: SafeArea(top: false, bottom: false, child: view), - ), - ) - : MaterialPageRoute( - settings: settings, - builder: (_) => Scaffold( - extendBodyBehindAppBar: true, - appBar: SegmentedBar( - cupertino: false, - title: title, - subtitle: identity, - ), - body: SafeArea(top: false, bottom: false, child: view), - ), - ); + final route = MaterialPageRoute( + settings: settings, + builder: (_) => Scaffold( + extendBodyBehindAppBar: true, + appBar: SegmentedBar(cupertino: false, title: title, subtitle: identity), + body: SafeArea(top: false, bottom: false, child: view), + ), + ); return Navigator.of(context).push(route); } @@ -263,22 +245,6 @@ class _StageDefinitionStyle { }); factory _StageDefinitionStyle.of(BuildContext context) { - if (usesCupertinoHost(context)) { - final theme = CupertinoTheme.of(context); - final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - return _StageDefinitionStyle( - label: theme.textTheme.tabLabelTextStyle.copyWith(color: secondary), - // SelectableText needs a style it can merge into the default text - // style; Cupertino's textStyle is a complete style with `inherit: false` - // and no baseline. - value: theme.textTheme.textStyle.copyWith(inherit: true), - muted: theme.textTheme.textStyle.copyWith( - inherit: true, - color: secondary, - ), - heading: theme.textTheme.navTitleTextStyle, - ); - } final theme = Theme.of(context); return _StageDefinitionStyle( label: (theme.textTheme.labelMedium ?? const TextStyle()).copyWith( diff --git a/app/test/features/graph/viewport/graph_expanded_view_test.dart b/app/test/features/graph/viewport/graph_expanded_view_test.dart index a1a7d077..84c680e4 100644 --- a/app/test/features/graph/viewport/graph_expanded_view_test.dart +++ b/app/test/features/graph/viewport/graph_expanded_view_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/semantics.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -164,95 +163,27 @@ void main() { expect(clamped, lessThan(panned)); }); - testWidgets('320px at 2x opens and closes on the dark Cupertino host', ( - tester, - ) async { - tester.view.physicalSize = const Size(320, 700); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - final picked = []; + testWidgets('expanded Fit is an activatable labelled button', (tester) async { await tester.pumpWidget( - CupertinoApp( - theme: const CupertinoThemeData(brightness: Brightness.dark), - home: CupertinoPageScaffold( - child: Builder( - builder: (context) => MediaQuery( - data: MediaQuery.of( - context, - ).copyWith(textScaler: const TextScaler.linear(2)), - child: DefinitionGraphView( - graph: linearGraph(), - selectedStage: 'build', - onSelected: picked.add, - ), - ), - ), - ), + _materialHost( + graph: linearGraph(), + selected: 'build', + onSelected: (_) {}, ), ); await _settle(tester); - final inline = _inlineTransform(tester); - final inlineMatrix = Matrix4.copy(inline.value); - await tester.tap(find.byKey(const Key('graph-expand'))); await tester.pumpAndSettle(); - expect(find.byType(GraphExpandedView), findsOneWidget); + + final fit = tester + .getSemantics(_inExpanded(find.byKey(const Key('graph-fit')))) + .getSemanticsData(); + expect(fit.label, graphFitLabel); + expect(fit.flagsCollection.isButton, isTrue); expect( - _inExpanded(find.byType(CupertinoNavigationBarBackButton)), - findsOneWidget, - ); - expect(_inExpanded(find.byKey(const Key('graph-fit'))), findsOneWidget); - expect( - tester.widget(_inExpanded(_node('build'))).selected, + fit.hasAction(SemanticsAction.tap), isTrue, + reason: 'Fit must expose its tap action on the labelled node', ); - expect(tester.takeException(), isNull); - - await tester.tap(find.byType(CupertinoNavigationBarBackButton)); - await tester.pumpAndSettle(); - expect(find.byType(GraphExpandedView), findsNothing); - expect(tester.widget(_node('build')).selected, isTrue); - expect(inline.value.storage, orderedEquals(inlineMatrix.storage)); - expect(picked, isEmpty); - expect(tester.takeException(), isNull); - }); - - testWidgets('expanded Fit is an activatable labelled button on both hosts', ( - tester, - ) async { - for (final cupertino in [false, true]) { - final host = cupertino ? 'Cupertino' : 'Material'; - await tester.pumpWidget( - cupertino - ? CupertinoApp( - home: CupertinoPageScaffold( - child: DefinitionGraphView( - graph: linearGraph(), - selectedStage: 'build', - onSelected: (_) {}, - ), - ), - ) - : _materialHost( - graph: linearGraph(), - selected: 'build', - onSelected: (_) {}, - ), - ); - await _settle(tester); - await tester.tap(find.byKey(const Key('graph-expand'))); - await tester.pumpAndSettle(); - - final fit = tester - .getSemantics(_inExpanded(find.byKey(const Key('graph-fit')))) - .getSemanticsData(); - expect(fit.label, graphFitLabel, reason: '$host Fit must be labelled'); - expect(fit.flagsCollection.isButton, isTrue); - expect( - fit.hasAction(SemanticsAction.tap), - isTrue, - reason: '$host Fit must expose its tap action on the labelled node', - ); - } }); } diff --git a/app/test/features/graph/viewport/graph_viewport_controls_test.dart b/app/test/features/graph/viewport/graph_viewport_controls_test.dart index cba0ed0a..7c305052 100644 --- a/app/test/features/graph/viewport/graph_viewport_controls_test.dart +++ b/app/test/features/graph/viewport/graph_viewport_controls_test.dart @@ -7,101 +7,79 @@ import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; import 'graph_viewport_fixtures.dart'; void main() { - testWidgets('Fit and Expand stay labelled, activatable buttons on both hosts', ( + testWidgets('Fit and Expand stay labelled, activatable buttons', ( tester, ) async { - for (final cupertino in [false, true]) { - final host = cupertino ? 'cupertino' : 'material'; - final controller = GraphViewportController(); - addTearDown(controller.dispose); - var expands = 0; - await tester.pumpWidget( - viewportHost( - controller: controller, - child: viewportTargets([]), - cupertino: cupertino, - onExpand: () => expands += 1, - ), - ); - await settleViewport(tester); - final fitted = controller.snapshot; - expect( - find.ancestor( - of: find.byKey(const Key('graph-fit')), - matching: find.byType(GlassPill), - ), - findsOneWidget, - ); + final controller = GraphViewportController(); + addTearDown(controller.dispose); + var expands = 0; + await tester.pumpWidget( + viewportHost( + controller: controller, + child: viewportTargets([]), + onExpand: () => expands += 1, + ), + ); + await settleViewport(tester); + final fitted = controller.snapshot; + expect( + find.ancestor( + of: find.byKey(const Key('graph-fit')), + matching: find.byType(GlassPill), + ), + findsOneWidget, + ); - for (final control in viewportControls().entries) { - final node = tester.getSemantics(find.byKey(control.key)); - final data = node.getSemanticsData(); - expect( - data.label, - control.value, - reason: '$host ${control.key} must have the web name', - ); - expect( - data.flagsCollection.isButton, - isTrue, - reason: '$host ${control.key} must be announced as a button', - ); - // A labelled button with no action is unusable with VoiceOver/TalkBack; - // this is the regression the excluded-button wrapper introduced. - expect( - data.hasAction(SemanticsAction.tap), - isTrue, - reason: '$host ${control.key} must expose a tap action', - ); - } - - // The exposed action must run the real callback, not just be announced. - await pinchViewport(tester, const Offset(200, 150), 2); - await tester.pumpAndSettle(); - expect(controller.snapshot, isNot(fitted)); - performViewportTap(tester, find.byKey(const Key('graph-fit'))); - await tester.pump(); - expect(controller.scale, closeTo(fitted.scale, 1e-9)); - - performViewportTap(tester, find.byKey(const Key('graph-expand'))); - await tester.pump(); - expect(expands, 1, reason: '$host Expand must activate'); + for (final control in viewportControls().entries) { + final node = tester.getSemantics(find.byKey(control.key)); + final data = node.getSemanticsData(); + expect(data.label, control.value); + expect(data.flagsCollection.isButton, isTrue); + // A labelled button with no action is unusable with a screen reader; + // this is the regression the excluded-button wrapper introduced. + expect(data.hasAction(SemanticsAction.tap), isTrue); } + + // The exposed action must run the real callback, not just be announced. + await pinchViewport(tester, const Offset(200, 150), 2); + await tester.pumpAndSettle(); + expect(controller.snapshot, isNot(fitted)); + performViewportTap(tester, find.byKey(const Key('graph-fit'))); + await tester.pump(); + expect(controller.scale, closeTo(fitted.scale, 1e-9)); + + performViewportTap(tester, find.byKey(const Key('graph-expand'))); + await tester.pump(); + expect(expands, 1); }); - testWidgets('320px at 2x keeps native controls and gestures on both hosts', ( - tester, - ) async { - for (final cupertino in [false, true]) { - final controller = GraphViewportController(); - addTearDown(controller.dispose); - await tester.pumpWidget( - viewportHost( - controller: controller, - child: viewportTargets([]), - cupertino: cupertino, - dark: cupertino, - textScale: 2, - viewport: const Size(320, 300), - onExpand: () {}, - ), - ); - await settleViewport(tester); - expect(find.byKey(const Key('graph-fit')), findsOneWidget); - expect(find.byKey(const Key('graph-expand')), findsOneWidget); - expect(tester.takeException(), isNull); + testWidgets('320px at 2x keeps native controls and gestures', (tester) async { + final controller = GraphViewportController(); + addTearDown(controller.dispose); + await tester.pumpWidget( + viewportHost( + controller: controller, + child: viewportTargets([]), + textScale: 2, + viewport: const Size(320, 300), + onExpand: () {}, + ), + ); + await settleViewport(tester); + expect(find.byKey(const Key('graph-fit')), findsOneWidget); + expect(find.byKey(const Key('graph-expand')), findsOneWidget); + expect(tester.takeException(), isNull); - final before = controller.offset; - await dragViewport( - tester, - find.byKey(const Key('graph-viewport')), - const Offset(-30, -10), - ); - expect(controller.offset, isNot(before)); - await pinchViewport(tester, const Offset(160, 150), 2); - await tester.pumpAndSettle(); - expect(controller.scale, greaterThan(0.3)); - expect(tester.takeException(), isNull); - } + final before = controller.offset; + await dragViewport( + tester, + find.byKey(const Key('graph-viewport')), + const Offset(-30, -10), + ); + expect(controller.offset, isNot(before)); + await pinchViewport(tester, const Offset(160, 150), 2); + await tester.pumpAndSettle(); + expect(controller.scale, greaterThan(0.3)); + expect(tester.takeException(), isNull); }); } diff --git a/app/test/features/graph/viewport/graph_viewport_fixtures.dart b/app/test/features/graph/viewport/graph_viewport_fixtures.dart index 72b7eb88..f467ffaa 100644 --- a/app/test/features/graph/viewport/graph_viewport_fixtures.dart +++ b/app/test/features/graph/viewport/graph_viewport_fixtures.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -48,7 +47,6 @@ Widget viewportHost({ required GraphViewportController controller, required Widget child, VoidCallback? onExpand, - bool cupertino = false, bool dark = false, double textScale = 1, Size viewport = defaultViewportSize, @@ -65,14 +63,6 @@ Widget viewportHost({ ), ), ); - if (cupertino) { - return CupertinoApp( - theme: CupertinoThemeData( - brightness: dark ? Brightness.dark : Brightness.light, - ), - home: CupertinoPageScaffold(child: Center(child: graph)), - ); - } return MaterialApp( theme: dark ? ThemeData.dark() : ThemeData.light(), home: Scaffold(body: Center(child: graph)), diff --git a/app/test/features/graph/widgets/definition_graph_view_test.dart b/app/test/features/graph/widgets/definition_graph_view_test.dart index 1051d604..d80fda54 100644 --- a/app/test/features/graph/widgets/definition_graph_view_test.dart +++ b/app/test/features/graph/widgets/definition_graph_view_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -57,21 +56,6 @@ Widget _materialHost( ); } -Widget _cupertinoHost(JsonMap graph, {ValueChanged? onSelected}) { - return CupertinoApp( - home: CupertinoPageScaffold( - child: SizedBox( - width: 900, - height: 700, - child: DefinitionGraphView( - graph: graph, - onSelected: onSelected ?? (_) {}, - ), - ), - ), - ); -} - /// Settles the two-frame measure-then-place contract. Future _settle(WidgetTester tester) async { await tester.pump(); @@ -315,27 +299,4 @@ void main() { expect(find.byType(GraphStageNode), findsNothing); expect(find.byType(InteractiveViewer), findsNothing); }); - - testWidgets('cupertino host composes native buttons and keeps identity', ( - tester, - ) async { - final picked = []; - await tester.pumpWidget( - _cupertinoHost(linearGraph(), onSelected: picked.add), - ); - await _settle(tester); - - expect( - find.descendant( - of: find.byType(GraphStageNode), - matching: find.byType(CupertinoButton), - ), - findsNWidgets(5), - ); - expect(find.byType(Card), findsNothing); - _expectNoOverlaps(tester); - - await _tapNode(tester, '#failure'); - expect(picked, ['#failure']); - }); } diff --git a/app/test/features/graph/widgets/graph_stage_node_render_test.dart b/app/test/features/graph/widgets/graph_stage_node_render_test.dart index 113a09ae..9135044d 100644 --- a/app/test/features/graph/widgets/graph_stage_node_render_test.dart +++ b/app/test/features/graph/widgets/graph_stage_node_render_test.dart @@ -1,7 +1,6 @@ import 'dart:typed_data'; import 'dart:ui' as ui; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -21,10 +20,6 @@ Widget _material(Widget child) => MaterialApp( home: Scaffold(body: Center(child: child)), ); -Widget _cupertino(Widget child) => CupertinoApp( - home: CupertinoPageScaffold(child: Center(child: child)), -); - /// The node centred on an opaque page, inside its own repaint boundary so the /// painted result can be read back as pixels. Widget _framed(Key key, Widget Function(Widget) wrap, Widget child) => wrap( @@ -153,58 +148,27 @@ void main() { } }); - testWidgets('unselected cupertino node paints a visible container', ( - tester, - ) async { - final key = GlobalKey(); - await tester.pumpWidget( - _framed( - key, - _cupertino, - GraphStageNode(node: _stage, onSelected: (_) {}), - ), - ); - final shot = await _shot(tester, key); - final rect = tester.getRect(find.byType(CupertinoButton)); - // Just inside the left edge of the control, clear of the label's inset. - final body = shot.at(rect.centerLeft + const Offset(4, 0)); - final page = shot.at(const Offset(4, 4)); - expect( - _distance(body, page), - greaterThan(24), - reason: 'an unselected cupertino node needs its own visible surface', - ); - }); - - testWidgets('selected state changes the painted surface in both hosts', ( - tester, - ) async { - for (final wrap in [_material, _cupertino]) { - final colors = {}; - for (final selected in [false, true]) { - final key = GlobalKey(); - await tester.pumpWidget( - _framed( - key, - wrap, - GraphStageNode( - node: _stage, - selected: selected, - onSelected: (_) {}, - ), - ), - ); - final shot = await _shot(tester, key); - final rect = tester.getRect(find.byType(GraphStageNode)); - colors[selected] = shot.at(rect.centerLeft + const Offset(4, 0)); - } - expect( - _distance(colors[false]!, colors[true]!), - greaterThan(16), - reason: - 'selection must be visible, not only announced: the surface fill ' - 'and the outlined border change together', + testWidgets('selected state changes the painted surface', (tester) async { + final colors = {}; + for (final selected in [false, true]) { + final key = GlobalKey(); + await tester.pumpWidget( + _framed( + key, + _material, + GraphStageNode(node: _stage, selected: selected, onSelected: (_) {}), + ), ); + final shot = await _shot(tester, key); + final rect = tester.getRect(find.byType(GraphStageNode)); + colors[selected] = shot.at(rect.centerLeft + const Offset(4, 0)); } + expect( + _distance(colors[false]!, colors[true]!), + greaterThan(16), + reason: + 'selection must be visible, not only announced: the surface fill ' + 'and the outlined border change together', + ); }); } diff --git a/app/test/features/graph/widgets/graph_stage_node_test.dart b/app/test/features/graph/widgets/graph_stage_node_test.dart index 3d2ade29..34b0e428 100644 --- a/app/test/features/graph/widgets/graph_stage_node_test.dart +++ b/app/test/features/graph/widgets/graph_stage_node_test.dart @@ -1,6 +1,5 @@ import 'dart:ui' show Tristate; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -17,10 +16,6 @@ Widget _material(Widget child) => MaterialApp( home: Scaffold(body: Center(child: child)), ); -Widget _cupertino(Widget child) => CupertinoApp( - home: CupertinoPageScaffold(child: Center(child: child)), -); - /// Applies a 2x text scale below the app so the fixture renders as a real /// scale-2 layout rather than a test-only text property. Widget _scaled(Widget child) => Builder( @@ -65,9 +60,7 @@ void main() { expect(_semantics(tester).label, 'Success'); }); - testWidgets('selected node is announced selected in both native hosts', ( - tester, - ) async { + testWidgets('selected node is announced selected', (tester) async { await tester.pumpWidget( _material( GraphStageNode(node: _stage, selected: true, onSelected: (_) {}), @@ -76,15 +69,6 @@ void main() { expect(find.byType(Card), findsOneWidget); expect(find.byType(InkWell), findsOneWidget); _expectSelectable(tester, selected: true); - - await tester.pumpWidget( - _cupertino( - GraphStageNode(node: _stage, selected: true, onSelected: (_) {}), - ), - ); - expect(find.byType(CupertinoButton), findsOneWidget); - expect(find.byType(Card), findsNothing); - _expectSelectable(tester, selected: true); }); testWidgets('unselected node is not announced selected', (tester) async { @@ -96,17 +80,15 @@ void main() { }); testWidgets('keyboard activation selects the node', (tester) async { - for (final wrap in [_material, _cupertino]) { - final picked = []; - await tester.pumpWidget( - wrap(GraphStageNode(node: _stage, onSelected: picked.add)), - ); - await tester.sendKeyEvent(LogicalKeyboardKey.tab); - await tester.pumpAndSettle(); - await tester.sendKeyEvent(LogicalKeyboardKey.enter); - await tester.pumpAndSettle(); - expect(picked, ['build']); - } + final picked = []; + await tester.pumpWidget( + _material(GraphStageNode(node: _stage, onSelected: picked.add)), + ); + await tester.sendKeyEvent(LogicalKeyboardKey.tab); + await tester.pumpAndSettle(); + await tester.sendKeyEvent(LogicalKeyboardKey.enter); + await tester.pumpAndSettle(); + expect(picked, ['build']); }); testWidgets('keyboard selection keeps focus inside the material node', ( @@ -144,46 +126,44 @@ void main() { ) async { const label = 'implementer-with-an-unshortened-stage-label'; const node = GraphNode(key: label, terminal: false, stageIndex: 0); - for (final wrap in [_material, _cupertino]) { - await tester.pumpWidget( - wrap( - _scaled( - SizedBox( - width: 150, - child: GraphStageNode(node: node, onSelected: (_) {}), - ), + await tester.pumpWidget( + _material( + _scaled( + SizedBox( + width: 150, + child: GraphStageNode(node: node, onSelected: (_) {}), ), ), - ); + ), + ); - expect(tester.takeException(), isNull); - final text = tester.widget(_visual(label)); - expect(text.data!.replaceAll('\u200B', ''), label); - expect(text.maxLines, isNull); - expect(text.overflow, isNull); - final paragraph = tester.renderObject(_visual(label)); - expect(paragraph.size.width, lessThanOrEqualTo(150)); - expect( - paragraph.size.height, - greaterThan(50), - reason: 'the 2x label must occupy more than one 2x text line', - ); - // No glyph may paint outside the paragraph: every laid-out line, - // including a hyphen-broken segment, fits the width the control gave it. - final painter = TextPainter( - text: paragraph.text, - textDirection: paragraph.textDirection, - textScaler: paragraph.textScaler, - textAlign: paragraph.textAlign, - )..layout(maxWidth: paragraph.size.width); - expect( - painter.computeLineMetrics().every( - (line) => line.width <= paragraph.size.width + 0.5, - ), - isTrue, - reason: 'an unshortened label must wrap, not paint over the control', - ); - } + expect(tester.takeException(), isNull); + final text = tester.widget(_visual(label)); + expect(text.data!.replaceAll('\u200B', ''), label); + expect(text.maxLines, isNull); + expect(text.overflow, isNull); + final paragraph = tester.renderObject(_visual(label)); + expect(paragraph.size.width, lessThanOrEqualTo(150)); + expect( + paragraph.size.height, + greaterThan(50), + reason: 'the 2x label must occupy more than one 2x text line', + ); + // No glyph may paint outside the paragraph: every laid-out line, + // including a hyphen-broken segment, fits the width the control gave it. + final painter = TextPainter( + text: paragraph.text, + textDirection: paragraph.textDirection, + textScaler: paragraph.textScaler, + textAlign: paragraph.textAlign, + )..layout(maxWidth: paragraph.size.width); + expect( + painter.computeLineMetrics().every( + (line) => line.width <= paragraph.size.width + 0.5, + ), + isTrue, + reason: 'an unshortened label must wrap, not paint over the control', + ); }); testWidgets('terminal shows its definition label and no invented status', ( @@ -207,7 +187,7 @@ void main() { testWidgets('a recorded status is shown verbatim', (tester) async { await tester.pumpWidget( - _cupertino( + _material( GraphStageNode( node: _stage, recordedStatus: 'failed', diff --git a/app/test/features/graph/widgets/run_graph_view_test.dart b/app/test/features/graph/widgets/run_graph_view_test.dart index 30a12979..ac47e2af 100644 --- a/app/test/features/graph/widgets/run_graph_view_test.dart +++ b/app/test/features/graph/widgets/run_graph_view_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/semantics.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -113,35 +112,6 @@ Widget _materialHost( ); } -Widget _cupertinoHost( - JsonMap graph, - JsonMap run, { - ValueChanged? onSelected, - double scale = 1, -}) { - return CupertinoApp( - theme: const CupertinoThemeData(brightness: Brightness.dark), - home: CupertinoPageScaffold( - child: Builder( - builder: (context) => MediaQuery( - data: MediaQuery.of( - context, - ).copyWith(textScaler: TextScaler.linear(scale)), - child: SizedBox( - width: 320, - height: 700, - child: RunGraphView( - graph: graph, - run: run, - onStageSelected: onSelected ?? (_) {}, - ), - ), - ), - ), - ), - ); -} - Future _settle(WidgetTester tester) async { await tester.pump(); await tester.pump(); @@ -450,39 +420,4 @@ void main() { _expectNoOverlaps(tester); expect(tester.takeException(), isNull); }); - - testWidgets('dark Cupertino host keeps native nodes and evidence', ( - tester, - ) async { - final picked = []; - await tester.pumpWidget( - _cupertinoHost(linearGraph(), _runningRun(), onSelected: picked.add), - ); - await _settle(tester); - - expect(find.byType(Card), findsNothing); - expect( - find.descendant( - of: find.byType(GraphStageNode), - matching: find.byType(CupertinoButton), - ), - findsNWidgets(5), - ); - expect(find.text(runGraphExecuted), findsOneWidget); - expect(find.text(runGraphNotExecuted), findsOneWidget); - expect( - tester.widget(_node('plan')).recordedStatus, - 'completed', - ); - expect( - tester.widget(_node('build')).recordedStatus, - 'running', - ); - _expectNoOverlaps(tester); - - await tester.tap(_node('plan')); - await tester.pump(); - expect(picked, ['plan']); - expect(tester.takeException(), isNull); - }); } diff --git a/app/test/features/graph/widgets/stage_definition_view_test.dart b/app/test/features/graph/widgets/stage_definition_view_test.dart index 115d89ed..9c345748 100644 --- a/app/test/features/graph/widgets/stage_definition_view_test.dart +++ b/app/test/features/graph/widgets/stage_definition_view_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -37,13 +36,6 @@ Widget _material(Widget child) => MaterialApp( ), ); -Widget _cupertino(Widget child, {bool dark = false}) => CupertinoApp( - theme: CupertinoThemeData( - brightness: dark ? Brightness.dark : Brightness.light, - ), - home: CupertinoPageScaffold(child: child), -); - StageDefinitionView _view({String key = 'plan'}) => StageDefinitionView( graph: _graph(), stageKey: key, @@ -138,26 +130,6 @@ void main() { expect(_text('successful'), findsNothing); }); - testWidgets('Cupertino uses its theme roles in dark mode', (tester) async { - late Color secondary; - await tester.pumpWidget( - _cupertino( - Builder( - builder: (context) { - secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - return _view(); - }, - ), - dark: true, - ), - ); - - final identity = tester.widget(_text('Demo pipeline · v7')); - expect(identity.style?.color, secondary); - expect(_text('Plan the change.'), findsOneWidget); - expect(tester.takeException(), isNull); - }); - testWidgets('the Material helper opens one bar and Back closes it', ( tester, ) async { @@ -198,44 +170,6 @@ void main() { expect(find.byType(StageDefinitionView), findsNothing); }); - testWidgets('the Cupertino helper opens one native bar and Back closes it', ( - tester, - ) async { - await tester.pumpWidget( - CupertinoApp( - home: Builder( - builder: (context) => CupertinoPageScaffold( - child: CupertinoButton( - onPressed: () => openStageDefinition( - context, - graph: _graph(), - stageKey: '#success', - pipelineId: 41, - pipelineName: 'Demo pipeline', - version: 7, - ), - child: const Text('Open terminal'), - ), - ), - ), - ), - ); - - await tester.tap(find.text('Open terminal')); - await tester.pumpAndSettle(); - - expect(_text('Success definition'), findsOneWidget); - expect(_text('#success definition'), findsNothing); - expect(find.byType(SegmentedBar), findsOneWidget); - expect(find.byType(CupertinoNavigationBarBackButton), findsOneWidget); - expect(_text('Incoming routes'), findsOneWidget); - - await tester.tap(find.byType(CupertinoNavigationBarBackButton)); - await tester.pumpAndSettle(); - expect(_text('Open terminal'), findsOneWidget); - expect(find.byType(StageDefinitionView), findsNothing); - }); - testWidgets('the Material helper titles a terminal with its display label', ( tester, ) async { @@ -270,7 +204,11 @@ void main() { testWidgets('selectable blocks force the host strut for one line rhythm', ( tester, ) async { - await tester.pumpWidget(_cupertino(_view())); + // Tall enough that the raw section below the prompt is built. + tester.view.physicalSize = const Size(800, 2000); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(_material(_view())); final selectable = tester .widgetList(find.byType(SelectableText))