merge(app): land sticky sections and stage summary

This commit is contained in:
2026-10-23 20:23:56 +01:00
10 changed files with 569 additions and 324 deletions
@@ -1,10 +1,9 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/artifact_groups.dart';
import '../../../ui/layout/sticky_section.dart';
import 'artifact_document_section.dart';
import 'artifact_record_row.dart';
import 'artifact_tile.dart';
@@ -83,7 +82,8 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
if (widget.groups.isEmpty) return _NoArtifacts(header: header);
final slivers = <Widget>[
if (header != null) SliverToBoxAdapter(child: header),
SliverToBoxAdapter(child: _modeSwitch(context)),
// The grid/list switch stays reachable while the gallery scrolls.
StickyBar(child: _modeSwitch(context)),
];
for (final group in widget.groups) {
final identity = '${group.stageKey}\u0000${group.visit}';
@@ -130,27 +130,19 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
required String title,
required int count,
required Widget body,
}) {
final open = !_closed.contains(key);
final scale = MediaQuery.textScalerOf(context).scale(16);
return SliverMainAxisGroup(
key: ValueKey<String>('artifact-section:$key'),
slivers: [
PinnedHeaderSliver(
child: SizedBox(
height: math.max(44, scale + 28),
child: _SectionTitle(
title: title,
count: count,
open: open,
onTap: () => _toggle(key),
),
),
),
if (open) SliverToBoxAdapter(child: body),
],
);
}
}) => StickySection(
key: ValueKey<String>('artifact-section:$key'),
title: title,
open: !_closed.contains(key),
onToggle: () => _toggle(key),
trailing: [
Padding(
padding: const EdgeInsetsDirectional.only(start: 6, end: 8),
child: Text('$count'),
),
],
body: body,
);
Widget _modeSwitch(BuildContext context) {
final cupertino = usesCupertinoHost(context);
@@ -266,83 +258,6 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
);
}
/// A section's pinned title bar: its name, how many items, and the chevron.
class _SectionTitle extends StatelessWidget {
const _SectionTitle({
required this.title,
required this.count,
required this.open,
required this.onTap,
});
final String title;
final int count;
final bool open;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final background = cupertino
? CupertinoColors.systemGroupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface;
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final style = TextStyle(
fontWeight: FontWeight.w600,
color: cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface,
);
// `container` keeps the heading a separate semantics node.
return Semantics(
container: true,
header: true,
button: true,
expanded: open,
label: title,
value: '$count',
excludeSemantics: true,
onTap: onTap,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: ColoredBox(
color: background,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Expanded(
child: Text(
title,
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
Text('$count', style: TextStyle(color: muted)),
const SizedBox(width: 6),
Icon(
open
? (cupertino
? CupertinoIcons.chevron_up
: Icons.expand_less)
: (cupertino
? CupertinoIcons.chevron_down
: Icons.expand_more),
color: muted,
),
],
),
),
),
),
);
}
}
class _NoArtifacts extends StatelessWidget {
const _NoArtifacts({this.header});
@@ -1,10 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import 'run_detail_summary_fields.dart';
import 'run_detail_visit_facts.dart';
import 'run_field_body.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/sticky_section.dart';
import '../../../ui/text/monospace.dart';
/// The Summary tab: the run's identity, the recorded facts as key/value rows,
@@ -29,86 +32,153 @@ Widget runDetailSummaryTab({
final rows = detailSummaryRows(run);
final identity = detailSummaryIdentity(run);
// No separate "Original prompt": the run's Input carries it, as data.
if (cupertino) {
return ListView(
key: const Key('run-detail-tab-body-summary'),
children: [
?graphPreview,
_cupertinoIdentity(context, identity),
if (rows.any((row) => !row.block))
CupertinoListSection.insetGrouped(
children: [
_summaryFacts(context, [
for (final row in rows)
if (!row.block) row,
], cupertino: true),
],
final facts = [
for (final row in rows)
if (!row.block) row,
];
return CustomScrollView(
key: const Key('run-detail-tab-body-summary'),
slivers: [
if (graphPreview != null) SliverToBoxAdapter(child: graphPreview),
SliverToBoxAdapter(
child: cupertino
? _cupertinoIdentity(context, identity)
: Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Text(
identity,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
),
if (facts.isNotEmpty)
SliverToBoxAdapter(
child: cupertino
? CupertinoListSection.insetGrouped(
children: [_summaryFacts(context, facts, cupertino: true)],
)
: _summaryFacts(context, facts, cupertino: false),
),
// Long blocks (the Diagnostic), Input and Output are sticky
// collapsibles: each title stays pinned while its content scrolls.
for (final row in rows)
if (row.block)
_StickyField(
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
title: row.label,
body: cupertino
? _cupertinoBlock(context, row)
: _materialBlock(context, row),
),
for (final row in rows.where((row) => row.block))
CupertinoListSection.insetGrouped(
children: [_cupertinoBlock(context, row)],
),
_cupertinoFieldSection(
context,
key: 'run-detail-summary-input',
title: 'Input',
_StickyField(
key: const ValueKey('run-detail-summary-input'),
title: 'Input',
controller: inputController,
copyText: runFieldCopyText(run['input']),
body: RunFieldBody(
value: run['input'],
empty: visitEmptyInput,
controller: inputController,
cupertino: cupertino,
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
),
_cupertinoFieldSection(
context,
key: 'run-detail-summary-output',
title: 'Output',
),
_StickyField(
key: const ValueKey('run-detail-summary-output'),
title: 'Output',
controller: outputController,
copyText: runFieldCopyText(run['output']),
body: RunFieldBody(
value: run['output'],
empty: visitEmptyOutput,
controller: outputController,
),
],
);
}
final theme = Theme.of(context);
return ListView(
key: const Key('run-detail-tab-body-summary'),
padding: const EdgeInsets.only(bottom: 16),
children: [
?graphPreview,
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Text(
identity,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
cupertino: cupertino,
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
),
),
if (rows.any((row) => !row.block))
_summaryFacts(context, [
for (final row in rows)
if (!row.block) row,
], cupertino: false),
for (final row in rows)
if (row.block) _materialBlock(context, row),
_materialFieldSection(
context,
key: 'run-detail-summary-input',
title: 'Input',
value: run['input'],
empty: visitEmptyInput,
controller: inputController,
),
_materialFieldSection(
context,
key: 'run-detail-summary-output',
title: 'Output',
value: run['output'],
empty: visitEmptyOutput,
controller: outputController,
),
const SliverToBoxAdapter(child: SizedBox(height: 16)),
],
);
}
/// A summary section that starts closed, follows its [controller] (so a
/// search hit can open it), and offers a copy of its recorded text.
class _StickyField extends StatefulWidget {
const _StickyField({
super.key,
required this.title,
required this.body,
this.controller,
this.copyText,
});
final String title;
final Widget body;
final ExpansibleController? controller;
final String? copyText;
@override
State<_StickyField> createState() => _StickyFieldState();
}
class _StickyFieldState extends State<_StickyField> {
ExpansibleController? _own;
bool _copied = false;
ExpansibleController get _controller =>
widget.controller ?? (_own ??= ExpansibleController());
@override
void dispose() {
_own?.dispose();
super.dispose();
}
Future<void> _copy() async {
await Clipboard.setData(ClipboardData(text: widget.copyText ?? ''));
if (mounted) setState(() => _copied = true);
}
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final copyText = widget.copyText;
return ListenableBuilder(
listenable: _controller,
builder: (context, _) => StickySection(
title: widget.title,
open: _controller.isExpanded,
onToggle: () => _controller.isExpanded
? _controller.collapse()
: _controller.expand(),
trailing: [
if (copyText != null && copyText.isNotEmpty)
cupertino
? CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: _copy,
child: Icon(
_copied
? CupertinoIcons.checkmark_alt
: CupertinoIcons.doc_on_doc,
semanticLabel: 'Copy ${widget.title}',
),
)
: IconButton(
tooltip: 'Copy ${widget.title}',
onPressed: _copy,
icon: Icon(_copied ? Icons.check : Icons.copy),
),
],
body: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: widget.body,
),
),
);
}
}
/// One recorded Input or Output field as its own tab, used by a visit pane.
Widget runDetailFieldTab({
required String tabKey,
@@ -215,45 +285,19 @@ Widget _summaryFacts(
/// A long recorded block (the Diagnostic) starts collapsed under its label.
Widget _materialBlock(BuildContext context, DetailSummaryRow row) {
final theme = Theme.of(context);
return ExpansionTile(
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
title: Text(row.label),
expandedCrossAxisAlignment: CrossAxisAlignment.start,
childrenPadding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
children: [
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
),
child: SelectableText(
row.value,
style: theme.textTheme.bodySmall?.copyWith(
fontFamily: appMonospaceFamily,
),
),
return Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
),
child: SelectableText(
row.value,
style: theme.textTheme.bodySmall?.copyWith(
fontFamily: appMonospaceFamily,
),
],
);
}
Widget _materialFieldSection(
BuildContext context, {
required String key,
required String title,
required dynamic value,
required String empty,
ExpansibleController? controller,
}) {
return ExpansionTile(
key: ValueKey(key),
controller: controller,
title: Text(title),
expandedCrossAxisAlignment: CrossAxisAlignment.start,
childrenPadding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
children: [RunFieldBody(value: value, empty: empty, cupertino: false)],
),
);
}
@@ -275,57 +319,17 @@ Widget _cupertinoIdentity(BuildContext context, String identity) {
/// A long recorded block (the Diagnostic) starts collapsed under its label.
Widget _cupertinoBlock(BuildContext context, DetailSummaryRow row) {
final theme = CupertinoTheme.of(context);
return CupertinoExpansionTile(
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
title: Text(row.label),
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: CupertinoColors.tertiarySystemFill.resolveFrom(context),
borderRadius: BorderRadius.circular(8),
),
child: Text(
row.value,
style: theme.textTheme.textStyle.copyWith(
fontFamily: appMonospaceFamily,
),
),
),
return Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: CupertinoColors.tertiarySystemFill.resolveFrom(context),
borderRadius: BorderRadius.circular(8),
),
child: Text(
row.value,
style: theme.textTheme.textStyle.copyWith(fontFamily: appMonospaceFamily),
),
);
}
Widget _cupertinoFieldSection(
BuildContext context, {
required String key,
required String title,
required dynamic value,
required String empty,
ExpansibleController? controller,
}) {
return CupertinoListSection.insetGrouped(
key: ValueKey(key),
children: [
CupertinoExpansionTile(
title: Text(title),
controller: controller,
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 16),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: RunFieldBody(
value: value,
empty: empty,
cupertino: true,
textBuilder: _CupertinoSelectableText.new,
),
),
),
),
],
);
}
+58 -10
View File
@@ -1,3 +1,5 @@
import '../../../ui/status/run_status_icon.dart';
import '../../graph/widgets/graph_stage_node.dart' show graphStatusState;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -83,7 +85,7 @@ class _RunVisitPaneState extends State<RunVisitPane> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_bar(style),
for (final fact in facts) _FactRow(fact: fact, style: style),
_FactGrid(facts: facts, style: style),
if (verdict != null) ...[
const SizedBox(height: 8),
Text('Verdict', style: style.heading),
@@ -138,22 +140,68 @@ class _RunVisitPaneState extends State<RunVisitPane> {
);
}
class _FactRow extends StatelessWidget {
const _FactRow({required this.fact, required this.style});
/// The visit's facts several to a line: status and outcome as coloured
/// pills, a long value (the model) on a line of its own.
class _FactGrid extends StatelessWidget {
const _FactGrid({required this.facts, required this.style});
final VisitFact fact;
final List<VisitFact> facts;
final _VisitStyle style;
static String _stateOf(VisitFact fact) {
final value = fact.value.trim().toLowerCase();
if (fact.label == 'Outcome') {
if (value == 'error' || value == 'failed' || value == 'blocked') {
return 'failed';
}
if (value == 'success') return 'succeeded';
return 'running';
}
return graphStatusState(fact.value);
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 4),
child: Text.rich(
TextSpan(
children: [
TextSpan(text: '${fact.label}: ', style: style.muted),
TextSpan(text: fact.value, style: style.value),
],
child: Wrap(
key: const Key('run-visit-facts-grid'),
spacing: 16,
runSpacing: 8,
children: [
for (final fact in facts)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(fact.label, style: style.muted),
const SizedBox(height: 2),
if (fact.label == 'Status' || fact.label == 'Outcome')
_pill(context, fact)
else
Text(fact.value, style: style.value),
],
),
],
),
);
}
Widget _pill(BuildContext context, VisitFact fact) {
final color = runStatusColor(_stateOf(fact)).resolveFrom(context);
return DecoratedBox(
decoration: ShapeDecoration(
color: color.withValues(alpha: 0.16),
shape: const StadiumBorder(),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: Text(
fact.value,
style: style.value.copyWith(
color: color,
fontWeight: FontWeight.w700,
),
),
),
);
@@ -1,11 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../../changes/changes.dart';
import 'run_detail_tab_bodies.dart';
import 'run_field_body.dart';
import '../../../ui/layout/sticky_section.dart';
import 'run_detail_visit_artifacts.dart';
import 'run_detail_visit_definition.dart';
import 'run_detail_visit_facts.dart';
@@ -168,25 +170,12 @@ Widget runVisitSectionBody({
);
switch (section) {
case RunVisitSection.summary:
// Input then Output, each under its own heading.
return ListView(
key: const Key('run-visit-body-summary'),
padding: const EdgeInsets.all(16),
children: [
_heading('Input', cupertino),
RunFieldBody(
value: step['input'],
empty: visitEmptyInput,
cupertino: cupertino,
),
const SizedBox(height: 20),
_heading('Output', cupertino),
RunFieldBody(
value: step['output'],
empty: visitEmptyOutput,
cupertino: cupertino,
),
],
// Input then Output, each a sticky collapsible with a copy button.
return _VisitSummary(
key: ValueKey('run-visit-summary-$visitIndex'),
input: step['input'],
output: step['output'],
cupertino: cupertino,
);
case RunVisitSection.more:
return _MoreSection(
@@ -241,22 +230,6 @@ Widget runVisitSectionBody({
}
}
Widget _heading(String text, bool cupertino) => Builder(
builder: (context) => Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Text(
text,
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 15,
color: cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface,
),
),
),
);
/// Session and Definition behind one tab, with a small switch between them.
class _MoreSection extends StatefulWidget {
const _MoreSection({required this.session, required this.definition});
@@ -305,3 +278,79 @@ class _MoreSectionState extends State<_MoreSection> {
);
}
}
/// The stage's Input and Output as sticky collapsibles, each with a copy
/// button for its recorded text.
class _VisitSummary extends StatefulWidget {
const _VisitSummary({
super.key,
required this.input,
required this.output,
required this.cupertino,
});
final dynamic input;
final dynamic output;
final bool cupertino;
@override
State<_VisitSummary> createState() => _VisitSummaryState();
}
class _VisitSummaryState extends State<_VisitSummary> {
final Set<String> _closed = {};
String? _copied;
Future<void> _copy(String name, dynamic value) async {
await Clipboard.setData(ClipboardData(text: runFieldCopyText(value)));
if (mounted) setState(() => _copied = name);
}
Widget _section(String name, dynamic value, String empty) {
final copy = widget.cupertino
? CupertinoButton(
key: ValueKey('run-visit-copy-$name'),
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: () => _copy(name, value),
child: Icon(
_copied == name
? CupertinoIcons.checkmark_alt
: CupertinoIcons.doc_on_doc,
semanticLabel: 'Copy $name',
),
)
: IconButton(
key: ValueKey('run-visit-copy-$name'),
tooltip: 'Copy $name',
onPressed: () => _copy(name, value),
icon: Icon(_copied == name ? Icons.check : Icons.copy),
);
final open = !_closed.contains(name);
return StickySection(
key: ValueKey('run-visit-section-$name'),
title: name,
open: open,
onToggle: () => setState(() {
if (!_closed.remove(name)) _closed.add(name);
}),
trailing: [copy],
body: Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
child: RunFieldBody(
value: value,
empty: empty,
cupertino: widget.cupertino,
),
),
);
}
@override
Widget build(BuildContext context) => CustomScrollView(
key: const Key('run-visit-body-summary'),
slivers: [
_section('Input', widget.input, visitEmptyInput),
_section('Output', widget.output, visitEmptyOutput),
],
);
}
@@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -15,6 +17,19 @@ String runFieldText(dynamic value) {
return '${value ?? 'null'}';
}
/// The text a copy button puts on the clipboard for a recorded field map: a
/// lone markdown document as itself, anything else as indented JSON.
String runFieldCopyText(dynamic value) {
if (value is Map && value.length == 1) {
final only = value.entries.single;
if ('${only.key}'.toLowerCase() == 'markdown') {
return runFieldText(only.value);
}
}
if (value == null || (value is Map && value.isEmpty)) return '';
return const JsonEncoder.withIndent(' ').convert(value);
}
/// The web's `looksLikeMarkdown`: a heading, fence, list item or table row.
bool runFieldLooksLikeMarkdown(String text) =>
RegExp(r'^#{1,6}\s', multiLine: true).hasMatch(text) ||
+163
View File
@@ -0,0 +1,163 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// A collapsible section for a [CustomScrollView]: its title stays pinned at
/// the top while its content scrolls under it, so it can always be closed
/// without scrolling back. Tapping the title opens or closes it.
class StickySection extends StatelessWidget {
const StickySection({
super.key,
required this.title,
required this.open,
required this.onToggle,
required this.body,
this.trailing = const [],
this.titleColor,
});
final String title;
final bool open;
final VoidCallback onToggle;
/// The content shown while open (a box widget).
final Widget body;
/// Small actions beside the title (a count, a copy button).
final List<Widget> trailing;
final Color? titleColor;
@override
Widget build(BuildContext context) {
final extent = math.max(
44.0,
MediaQuery.textScalerOf(context).scale(16) + 28,
);
return SliverMainAxisGroup(
slivers: [
PinnedHeaderSliver(
child: SizedBox(
height: extent,
child: StickySectionTitle(
title: title,
open: open,
onToggle: onToggle,
trailing: trailing,
color: titleColor,
),
),
),
if (open) SliverToBoxAdapter(child: body),
],
);
}
}
/// A sticky section's title bar: name, actions and the open/close chevron.
class StickySectionTitle extends StatelessWidget {
const StickySectionTitle({
super.key,
required this.title,
required this.open,
required this.onToggle,
this.trailing = const [],
this.color,
});
final String title;
final bool open;
final VoidCallback onToggle;
final List<Widget> trailing;
final Color? color;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final background = cupertino
? CupertinoColors.systemGroupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface;
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final style = TextStyle(
fontWeight: FontWeight.w600,
color:
color ??
(cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface),
);
return ColoredBox(
color: background,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 16, end: 8),
child: Row(
children: [
Expanded(
child: Semantics(
container: true,
header: true,
button: true,
expanded: open,
label: title,
excludeSemantics: true,
onTap: onToggle,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onToggle,
child: Row(
children: [
Expanded(
child: Text(
title,
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
Icon(
open
? (cupertino
? CupertinoIcons.chevron_up
: Icons.expand_less)
: (cupertino
? CupertinoIcons.chevron_down
: Icons.expand_more),
color: muted,
),
],
),
),
),
),
...trailing,
],
),
),
);
}
}
/// A pinned bar for controls that should stay reachable while a list
/// scrolls (a view switch).
class StickyBar extends StatelessWidget {
const StickyBar({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return PinnedHeaderSliver(
child: ColoredBox(
color: cupertino
? CupertinoColors.systemGroupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface,
child: child,
),
);
}
}
@@ -66,7 +66,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-title')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.textContaining('Status:'), findsOneWidget);
expect(find.byKey(const Key('run-visit-facts-grid')), findsOneWidget);
expect(find.textContaining('audit · visit'), findsNothing);
});
@@ -17,14 +17,16 @@ void main() {
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
for (final value in [
'Status: completed',
'Outcome: success',
'Duration: 2m 5s',
'Provider/model: anthropic / claude-x',
'Target: build',
// Each fact as its label over its value; several share a line.
for (final (label, value) in [
('Status', 'completed'),
('Outcome', 'success'),
('Duration', '2m 5s'),
('Provider/model', 'anthropic / claude-x'),
('Target', 'build'),
]) {
expect(find.textContaining(value), findsOneWidget, reason: value);
expect(find.text(label), findsWidgets, reason: label);
expect(find.text(value), findsWidgets, reason: value);
}
for (final value in ['approve', 'Looks good.', 'Plan checked.']) {
expect(find.text(value), findsOneWidget, reason: value);
@@ -32,16 +34,17 @@ void main() {
expect(find.text('Verdict'), findsOneWidget);
expect(find.text('Diagnostic'), findsOneWidget);
// The title, its facts and the section tabs share one leading edge; the
// Cupertino control's own default inset used to push the tabs 16 in.
// The title and its facts share one leading edge.
final title = tester.getTopLeft(find.text('plan · visit 1')).dx;
expect(
tester.getTopLeft(find.textContaining('Status: completed')).dx,
tester.getTopLeft(find.byKey(const Key('run-visit-facts-grid'))).dx,
title,
);
// A centred segment label sits ~49 in from a 16 inset control (65), but
// 81 behind the control's default 16 inset.
expect(tester.getTopLeft(find.text('Input')).dx, lessThan(title + 56));
// Status and duration share a line.
expect(
tester.getTopLeft(find.text('completed')).dy,
moreOrLessEquals(tester.getTopLeft(find.text('2m 5s')).dy, epsilon: 4),
);
});
testWidgets('${platform.name} duration hides without both timestamps', (
@@ -55,7 +58,7 @@ void main() {
expect(find.textContaining('Duration'), findsNothing);
expect(find.textContaining('0s'), findsNothing);
expect(find.textContaining('Status: completed'), findsOneWidget);
expect(find.text('completed'), findsOneWidget);
});
testWidgets('${platform.name} absent provider/model is not invented', (
@@ -153,15 +153,14 @@ void main() {
tester.getTopLeft(find.byKey(const Key('run-status-kicker'))).dy,
lessThan(tester.getTopLeft(find.text('Nightly build')).dy),
);
if (platform == AppPlatform.material) {
expect(
tester.widget(find.byKey(const ValueKey('run-detail-summary-input'))),
isA<ExpansionTile>(),
);
} else {
// Input and Output are sticky collapsibles on both hosts.
expect(
find.byKey(const ValueKey('run-detail-summary-input')),
findsOneWidget,
);
if (platform == AppPlatform.cupertino) {
expect(find.byType(Material), findsNothing);
expect(find.byType(Chip), findsNothing);
expect(find.byType(CupertinoExpansionTile), findsWidgets);
}
Future<void> tapTab(String label) async {
@@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/sticky_section.dart';
class _Host extends StatefulWidget {
const _Host();
@override
State<_Host> createState() => _HostState();
}
class _HostState extends State<_Host> {
bool open = true;
@override
Widget build(BuildContext context) => CustomScrollView(
slivers: [
StickySection(
title: 'Input',
open: open,
onToggle: () => setState(() => open = !open),
body: Column(children: [for (var i = 0; i < 80; i++) Text('line $i')]),
),
const SliverToBoxAdapter(child: SizedBox(height: 900)),
],
);
}
void main() {
testWidgets(
'the title stays pinned while its content scrolls and closes it',
(tester) async {
tester.view.physicalSize = const Size(390, 600);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(const MaterialApp(home: Scaffold(body: _Host())));
await tester.drag(find.byType(CustomScrollView), const Offset(0, -800));
await tester.pumpAndSettle();
// Deep in the content, the title is still at the top.
expect(tester.getTopLeft(find.text('line 0')).dy, lessThan(0));
expect(tester.getTopLeft(find.text('Input')).dy, lessThan(40));
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text('line 40'), findsNothing);
},
);
}