Merge app warning visibility

This commit is contained in:
2026-11-05 15:36:36 +00:00
8 changed files with 414 additions and 0 deletions
@@ -0,0 +1,114 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/warnings_section.dart';
// The gateway bounds this cache to one server connection. Retain at most sixteen
// sources, so revisiting a Summary tab does not revalidate its unchanged version.
final _checks = Expando<Map<String, Future<JsonMap>>>();
class PipelineDefinitionValidation extends StatefulWidget {
const PipelineDefinitionValidation({
super.key,
required this.gateway,
required this.source,
});
final ApiGateway gateway;
final String source;
@override
State<PipelineDefinitionValidation> createState() =>
_PipelineDefinitionValidationState();
}
class _PipelineDefinitionValidationState
extends State<PipelineDefinitionValidation> {
late Future<JsonMap> _result;
@override
void initState() {
super.initState();
_load();
}
@override
void didUpdateWidget(covariant PipelineDefinitionValidation oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.source != widget.source ||
oldWidget.gateway != widget.gateway) {
_load();
}
}
void _load({bool retry = false}) {
if (widget.source.trim().isEmpty) {
_result = Future.value({'type': 'validated'});
return;
}
final cache = _checks[widget.gateway] ??= {};
if (retry) cache.remove(widget.source);
if (!cache.containsKey(widget.source) && cache.length >= 16) {
cache.remove(cache.keys.first);
}
_result = cache.putIfAbsent(
widget.source,
() => Future.sync(
() => widget.gateway.call('validate', {'source': widget.source}),
),
);
}
@override
Widget build(BuildContext context) {
if (widget.source.trim().isEmpty) return const SizedBox.shrink();
return FutureBuilder<JsonMap>(
future: _result,
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text('Checking definition…'),
);
}
final reply = snapshot.data;
final error = snapshot.hasError
? 'Could not check definition: ${snapshot.error}'
: '${reply?['error'] ?? ''}'.trim();
final messages = warningMessages(reply?['warnings']);
final validReply =
reply?['type'] == 'validated' || reply?['type'] == 'error';
final failure = error.isNotEmpty
? error
: !validReply
? 'The server did not return definition validation.'
: '';
if (messages.isEmpty && failure.isEmpty) return const SizedBox.shrink();
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
WarningsSection(
title: 'Definition warnings',
messages: [if (failure.isNotEmpty) failure, ...messages],
),
if (snapshot.hasError || !validReply)
Align(
alignment: AlignmentDirectional.centerStart,
child: usesCupertinoHost(context)
? CupertinoButton(
onPressed: () => setState(() => _load(retry: true)),
child: const Text('Retry validation'),
)
: TextButton(
onPressed: () => setState(() => _load(retry: true)),
child: const Text('Retry validation'),
),
),
],
);
},
);
}
}
@@ -11,6 +11,7 @@ import '../pipeline_models.dart';
import '../pipeline_query.dart';
import '../pipelines_controller.dart';
import 'pipeline_controls.dart';
import 'pipeline_definition_validation.dart';
import 'pipeline_detail_styles.dart';
/// The Summary's facts grid.
@@ -63,6 +64,7 @@ class PipelineSummaryView extends StatelessWidget {
style: pipelineMutedStyle(context),
),
),
PipelineDefinitionValidation(gateway: gateway, source: detail.source),
_fields(context),
SchedulePipelineSection(
gateway: gateway,
@@ -8,6 +8,7 @@ import 'run_detail_visit_facts.dart';
import 'run_field_body.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/facts_grid.dart';
import '../../../ui/layout/warnings_section.dart';
import '../../../ui/layout/sticky_section.dart';
import '../../../ui/text/live_elapsed_builder.dart';
import '../../../ui/text/monospace.dart';
@@ -64,6 +65,9 @@ Widget runDetailSummaryTab({
),
),
),
SliverToBoxAdapter(
child: WarningsSection(messages: warningMessages(run['warnings'])),
),
// The facts sit on the page as one grid, the same on both hosts: no
// grouped card, so a single fact starts at the leading edge.
SliverToBoxAdapter(
+79
View File
@@ -0,0 +1,79 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import 'section_heading.dart';
/// Protocol warning arrays contain human-readable strings. Ignore malformed
/// entries rather than displaying map/list representations as diagnostics.
List<String> warningMessages(Object? value) => value is List
? value
.whereType<String>()
.map((message) => message.trim())
.where((message) => message.isNotEmpty)
.toList(growable: false)
: const [];
/// A visible, selectable group of server diagnostics; no collapsed disclosure
/// hides a warning from the operator reading the summary.
class WarningsSection extends StatelessWidget {
const WarningsSection({
super.key,
required this.messages,
this.title = 'Warnings',
});
final List<String> messages;
final String title;
@override
Widget build(BuildContext context) => messages.isEmpty
? const SizedBox.shrink()
: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SectionHeading(title: title, header: true),
for (final message in messages)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 8),
child: usesCupertinoHost(context)
? _CupertinoWarningText(message)
: SelectableText(message),
),
],
);
}
class _CupertinoWarningText extends StatefulWidget {
const _CupertinoWarningText(this.message);
final String message;
@override
State<_CupertinoWarningText> createState() => _CupertinoWarningTextState();
}
class _CupertinoWarningTextState extends State<_CupertinoWarningText> {
late final _controller = TextEditingController(text: widget.message);
@override
void didUpdateWidget(covariant _CupertinoWarningText oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.message != oldWidget.message) _controller.text = widget.message;
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => CupertinoTextField(
controller: _controller,
readOnly: true,
maxLines: null,
padding: EdgeInsets.zero,
decoration: const BoxDecoration(),
);
}
+36
View File
@@ -0,0 +1,36 @@
# App warning visibility
Run Summary now displays the server's `run_detail.warnings` as visible,
selectable messages above the facts. Empty/malformed warning entries are not
rendered. An unwarned run has no empty section. Material uses SelectableText;
Cupertino uses a read-only multiline CupertinoTextField like existing details.
Pipeline Summary independently validates the selected recorded source through
the existing read-only `validate` request. Its warning strings and validation
errors are displayed as Definition warnings without hiding historical detail.
Loading does not block source/facts; transport/malformed-reply failures remain
visible with Retry validation. No source means no request. Checks are cached per
gateway and exact source, bounded to sixteen entries, so switching tabs or
revisiting the same source does not repeatedly revalidate it. Source changes
start a new check. No authoring or server changes were made.
Checks:
- Pipelines and runs feature suites: 499 passed through memory watchdog
(`/tmp/memwatch/out.fKnKmB`, peak 2157 MB).
- After adding the no-source guard, focused regression suite: 10 passed
(`/tmp/memwatch/out.yY6KGu`, peak 999 MB).
- Focused analyze clean; fixture web release build and Wasm dry run succeeded.
Real browser evidence (all six PNGs inspected):
- `/tmp/app-warnings-material-final/`, Material 1100x900.
- `/tmp/app-warnings-cupertino-final/`, Cupertino 560x1000.
- In each: run Summary warning, Copy Input interaction retaining warning,
Pipeline Summary definition warning. Captures and reports pass; kit-owned
Chrome instances and loopback servers exited normally.
- The fixture's pre-existing schedules reply is absent, so its Summary shows
Loading schedules; this is not a scheduling verification.
The initial capture attempt used waitfor on a static heading; the kit does not
index that static label, although the saved PNG visibly showed the warning.
Final captures use screenshots and a real Copy Input interaction instead.
No physical device or Safari claim is made here. Nothing was deployed.
@@ -0,0 +1,129 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_definition_validation.dart';
class _Gateway implements ApiGateway {
final calls = <JsonMap>[];
Future<JsonMap> Function() answer = () async => {'type': 'validated'};
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
expect(type, 'validate');
calls.add(fields);
return answer();
}
@override
Stream<JsonMap> get frames => const Stream.empty();
}
Widget _host(
_Gateway gateway, {
bool cupertino = false,
String source = '# stage build',
}) {
final body = Column(
children: [
const Text('Pipeline source remains available'),
PipelineDefinitionValidation(gateway: gateway, source: source),
],
);
return cupertino
? CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: body)),
)
: MaterialApp(home: Scaffold(body: body));
}
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'definition warnings stay visible on ${cupertino ? 'Cupertino' : 'Material'}',
(tester) async {
final gateway = _Gateway()
..answer = () async => {
'type': 'validated',
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
};
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
expect(find.text('Definition warnings'), findsOneWidget);
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
expect(find.text('42'), findsNothing);
expect(gateway.calls.single, {'source': '# stage build'});
expect(tester.takeException(), isNull);
},
);
}
testWidgets(
'loading validation never hides detail and a source is checked once',
(tester) async {
final response = Completer<JsonMap>();
final gateway = _Gateway()..answer = () => response.future;
await tester.pumpWidget(_host(gateway));
expect(find.text('Pipeline source remains available'), findsOneWidget);
expect(find.text('Checking definition…'), findsOneWidget);
response.complete({'type': 'validated'});
await tester.pumpAndSettle();
expect(find.text('Definition warnings'), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(gateway.calls, hasLength(1));
await tester.pumpWidget(_host(gateway, source: '# stage newer'));
await tester.pumpAndSettle();
expect(gateway.calls, hasLength(2));
},
);
testWidgets(
'historical validation errors keep both errors and warnings visible',
(tester) async {
final gateway = _Gateway()
..answer = () async => {
'type': 'error',
'error': 'stage build requires checks',
'warnings': ['Review repeats runner instructions.'],
};
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.text('Pipeline source remains available'), findsOneWidget);
expect(find.text('stage build requires checks'), findsOneWidget);
expect(find.text('Review repeats runner instructions.'), findsOneWidget);
},
);
testWidgets('missing recorded source sends no validation request', (
tester,
) async {
final gateway = _Gateway();
await tester.pumpWidget(_host(gateway, source: ' '));
await tester.pumpAndSettle();
expect(gateway.calls, isEmpty);
expect(find.text('Checking definition…'), findsNothing);
});
testWidgets('transport failure is visible and can be retried', (
tester,
) async {
final gateway = _Gateway()
..answer = () async => throw StateError('offline');
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.textContaining('Could not check definition:'), findsOneWidget);
gateway.answer = () async => {
'type': 'validated',
'warnings': ['Use a bounded review loop.'],
};
await tester.tap(find.text('Retry validation'));
await tester.pumpAndSettle();
expect(find.text('Use a bounded review loop.'), findsOneWidget);
expect(find.text('Retry validation'), findsNothing);
expect(gateway.calls, hasLength(2));
});
}
@@ -0,0 +1,37 @@
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_graph_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets(
'${platform.name} recorded run warnings are visible and selectable',
(tester) async {
final run = graphRunFixture()
..['warnings'] = [
'build visit 1: final result required one repair follow-up.',
'',
{'not': 'a warning'},
];
await pumpRunDetail(tester, platform, run: run);
expect(find.text('Warnings'), findsOneWidget);
expect(
find.text(
'build visit 1: final result required one repair follow-up.',
),
findsOneWidget,
);
expect(find.textContaining('not: a warning'), findsNothing);
expect(tester.takeException(), isNull);
},
);
testWidgets(
'${platform.name} an unwarned run has no empty warnings section',
(tester) async {
await pumpRunDetail(tester, platform, run: graphRunFixture());
expect(find.text('Warnings'), findsNothing);
},
);
}
}
@@ -150,6 +150,7 @@ DateTime? _runningSince;
/// `?html=1` adds `release-dashboard.html` to run 7's build visit; the capture
/// serves its bytes from the build directory (see notes/artifact-fullscreen.md).
bool _htmlArtifact = false;
bool _warnings = false;
/// `?turn=1` adds the runner-internal turn files the server records for a model
/// visit (group `debug`) to run 7's build visit, so the Artifacts tab's hidden
@@ -495,6 +496,10 @@ JsonMap? probeReply(JsonMap request) {
'type': 'run',
'run_detail': {
...detail,
if (_warnings)
'warnings': [
'build visit 1: final result required one repair follow-up.',
],
'steps': [
for (final step in detail['steps'] as List)
withProbeStepUsage(step as JsonMap),
@@ -503,6 +508,13 @@ JsonMap? probeReply(JsonMap request) {
};
case 'list_pipelines':
return {'id': id, 'type': 'pipelines', 'pipelines': probePipelines()};
case 'validate':
return {
'id': id,
'type': 'validated',
if (_warnings)
'warnings': ['Review prompt repeats runner instructions.'],
};
case 'get_pipeline':
final pipelineId = request['pipeline_id'];
if (pipelineId is! int ||
@@ -730,6 +742,7 @@ void main() {
}
probeUsage = params['usage'] == '1';
_htmlArtifact = params['html'] == '1';
_warnings = params['warnings'] == '1';
_turnFiles = params['turn'] == '1';
final cupertino = params['platform'] == 'cupertino';
final route = params['route'];