App: run failure reasons, Run again, labelled tabs, actionable errors, nav fixes

- Run rows show a failed run's reason (else its diagnostic's first line,
  full text in a tooltip) or a short result preview; the Summary leads
  with "Why it failed".
- Run again for succeeded/canceled/interrupted runs opens the New run form
  pre-filled (prompt, workspace, report format) at the latest version with
  the original offered.
- Run detail and stage tabs show their names; touch shows captions on the
  Runs header and artifact viewer actions (desktop keeps tooltips).
- ErrorNotice maps not connected / server too old / permission / timeout
  to what to do, raw detail behind Details (Schedules, create chat, Runs,
  Pipelines banners).
- Settings has no Back arrow; Schedules keeps the rail on wide windows;
  phone Settings leads with Connection and Notifications and has a
  Jump to topic menu.
- Walkthrough: Open Connection (skipped when connected), labelled Copy.
- Pluralised counts; no duplicate status/rail names for screen readers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 20:16:22 +00:00
parent c441400f36
commit 545291e04a
68 changed files with 1719 additions and 156 deletions
@@ -0,0 +1,116 @@
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/pending_run_store.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/run_pipeline_intent.dart';
import 'package:pipelines_app/features/pipelines/run_pipeline_seed.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_version_field.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/runs/actions/retry_eligibility.dart';
import 'package:pipelines_app/features/runs/ui/run_again_flow.dart';
import '../../pipelines/fixtures.dart';
import '../../pipelines/ui/run_pipeline_launch_test.dart'
show acceptedRun, launchGateway;
/// Run again: a finished run that did not fail opens the New run form for its
/// pipeline, pre-filled with its prompt, workspace and report requirement,
/// at the latest version with the original offered.
void main() {
JsonMap finished({String status = 'succeeded', bool withInput = true}) => {
'id': 9,
'status': status,
'executing': false,
'pipeline_id': 1,
'version': 1,
'workspace': '/work/alpha',
'output_format': 'markdown',
if (withInput) 'input': {'prompt': 'Ship the release notes.'},
};
test('only finished runs that did not fail can run again', () {
expect(canRunAgain(finished()), isTrue);
expect(canRunAgain(finished(status: 'canceled')), isTrue);
expect(canRunAgain(finished(status: 'interrupted')), isTrue);
expect(canRunAgain(finished(status: 'failed')), isFalse);
expect(canRunAgain(finished()..['executing'] = true), isFalse);
expect(canRunAgain(finished()..remove('pipeline_id')), isFalse);
});
test('the seed carries the run inputs and its version', () {
final seed = runAgainSeed(finished());
expect(seed.prompt, 'Ship the release notes.');
expect(seed.workspace, '/work/alpha');
expect(seed.originalVersion, 1);
expect(seed.outputFormat, RunOutputFormat.markdown);
expect(runPipelineVersionChoices(2, 1), [2, 1]);
expect(runPipelineVersionChoices(2, 2), [2]);
});
testWidgets('the form opens pre-filled at the latest version and can '
'start the original one', (tester) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final launched = <JsonMap>[];
final fixture = PipelineFixture();
final gateway = launchGateway(
fixture,
onLaunch: (fields) {
launched.add(fields);
return acceptedRun(30);
},
onLookup: (_) => {'type': 'run', 'run_detail': finished()},
);
final controller = PipelinesController(
PipelinesRepository(gateway),
pendingRunStore: MemoryPendingRunStore(),
);
addTearDown(controller.dispose);
final started = <int>[];
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) => TextButton(
onPressed: () => startRunAgainFlow(
context: context,
// A list row carries no input: the run is read first.
run: finished(withInput: false),
controller: controller,
gateway: gateway,
onRunStarted: started.add,
),
child: const Text('again'),
),
),
),
);
await tester.tap(find.text('again'));
await tester.pumpAndSettle();
final prompt = tester.widget<TextField>(find.byKey(runPipelinePromptKey));
expect(prompt.controller!.text, 'Ship the release notes.');
final workspace = tester.widget<TextField>(
find.byKey(runPipelineWorkspaceKey),
);
expect(workspace.controller!.text, '/work/alpha');
expect(find.text('Latest (v2)'), findsOneWidget);
await tester.tap(find.byKey(runPipelineVersionKey));
await tester.pumpAndSettle();
await tester.tap(find.text('Original run (v1)').last);
await tester.pumpAndSettle();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
expect(launched, hasLength(1));
expect(launched.single['pipeline_id'], 1);
expect(launched.single['version'], 1);
expect(launched.single['workspace'], '/work/alpha');
expect(launched.single['input'], {'prompt': 'Ship the release notes.'});
expect(launched.single['output_format'], 'markdown');
expect(started, [30]);
});
}
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'run_detail_graph_support.dart';
@@ -81,7 +82,13 @@ void main() {
final rest = tester.getTopLeft(facts).dy;
expect(rest, greaterThanOrEqualTo(barBottom));
// The tabs float at the bottom over the section.
final tabs = pieceOf(tester, find.byKey(const Key('run-visit-tabs')));
// The labelled row (buttons over their captions) ends above the margin.
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('run-visit-tabs')),
matching: find.byKey(FloatingDestinationBar.rowKey),
),
);
expect(tabs.bottom, 844 - 16);
expect(tester.getRect(summary).bottom, 844);
@@ -97,11 +97,8 @@ void main() {
),
);
final body = find.byKey(const Key('run-detail-tab-body-summary'));
// Sized to its tabs at the right, floating above the bottom.
expect(
pill.width,
FloatingDestinationBar.rowWidth(tabs: renderedRunDetailTabs.length),
);
// Sized to its labelled tabs at the right, floating above the bottom.
expect(pill.width, lessThan(390 * 0.85));
expect(pill.right, 390 - 16);
expect(pill.bottom, 844 - 16);
// The tab's content reaches the bottom edge, behind the bar.
@@ -294,8 +294,8 @@ void main() {
);
expect(pill.right, size.width - 16);
expect(pill.bottom, size.height - 16);
// Sized to its tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.7));
// Sized to its labelled tabs at the right on every width.
expect(pill.width, lessThan(size.width * 0.8));
},
);
}
@@ -0,0 +1,149 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show SemanticsNode;
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/domain/run_outcome_line.dart';
import 'package:pipelines_app/features/runs/ui/run_again_flow.dart';
import 'package:pipelines_app/features/runs/ui/run_failure_banner.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
JsonMap _run(String status, [JsonMap extra = const {}]) => {
'id': 7,
'title': 'Nightly release',
'name': 'release',
'status': status,
'executing': false,
'pipeline_id': 3,
'created_at': '2026-10-21T12:00:00Z',
'finished_at': '2026-10-21T12:02:05Z',
...extra,
};
class _FakeGateway implements ApiGateway {
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async => {};
@override
Stream<JsonMap> get frames => const Stream.empty();
}
/// A run row says why a run failed (its failure reason, else its
/// diagnostic's first line) in one line with the full text in a tooltip, and
/// a succeeded run's short result; its status is read once.
void main() {
test('the outcome line prefers the failure reason, then the diagnostic', () {
final reason = runOutcomeLine(
_run('failed', {
'failure_reason': 'Stage review timed out',
'diagnostic': 'trace\nmore',
}),
);
expect(reason?.line, 'Stage review timed out');
expect(reason?.failed, isTrue);
final diagnostic = runOutcomeLine(
_run('failed', {'diagnostic': '\n exit status 2\nstack trace'}),
);
expect(diagnostic?.line, 'exit status 2');
expect(diagnostic?.full, 'exit status 2\nstack trace');
expect(runOutcomeLine(_run('failed')), isNull);
expect(
runOutcomeLine(
_run('succeeded', {'result_preview': 'Released 1.2'}),
)?.line,
'Released 1.2',
);
// A long or multi-line preview is left to the detail.
expect(
runOutcomeLine(_run('succeeded', {'result_preview': 'x' * 200})),
isNull,
);
expect(
runOutcomeLine(_run('succeeded', {'result_preview': 'a\nb'})),
isNull,
);
expect(runOutcomeLine(_run('running', {'failure_reason': 'x'})), isNull);
});
Future<void> pumpRow(WidgetTester tester, JsonMap run) async {
tester.view.physicalSize = const Size(800, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunListRow(
run: run,
now: DateTime.utc(2026, 10, 22),
gateway: _FakeGateway(),
onRunChanged: (_) {},
onRunAgain: (_) {},
),
),
),
);
await tester.pumpAndSettle();
}
testWidgets('a failed row shows its reason with the full text in a '
'tooltip', (tester) async {
const reason = 'Stage review timed out after 30 minutes';
await pumpRow(tester, _run('failed', {'failure_reason': reason}));
expect(find.text(reason), findsOneWidget);
final tooltip = tester.widget<Tooltip>(
find.byKey(const ValueKey('run-row-outcome-7')),
);
expect(tooltip.message, reason);
});
testWidgets('the row reads its status once', (tester) async {
final semantics = tester.ensureSemantics();
await pumpRow(tester, _run('failed', {'failure_reason': 'Boom'}));
final labels = <String>[];
void collect(SemanticsNode node) {
final data = node.getSemanticsData();
labels.add('${data.label} ${data.tooltip}');
node.visitChildren((child) {
collect(child);
return true;
});
}
collect(tester.getSemantics(find.byType(RunListRow)));
final all = labels.join(' ');
expect(RegExp(r'\bfailed\b').allMatches(all), hasLength(1), reason: all);
semantics.dispose();
});
testWidgets('a succeeded run offers Run again; a failed one does not', (
tester,
) async {
await pumpRow(tester, _run('succeeded'));
await tester.tap(find.byKey(const ValueKey('run-list-more-menu-7')));
await tester.pumpAndSettle();
expect(find.byKey(runAgainActionKey), findsOneWidget);
await tester.tapAt(Offset.zero);
await tester.pumpAndSettle();
await pumpRow(tester, _run('failed', {'failure_reason': 'Boom'}));
await tester.tap(find.byKey(const ValueKey('run-list-more-menu-7')));
await tester.pumpAndSettle();
expect(find.byKey(runAgainActionKey), findsNothing);
});
testWidgets('the Summary leads with why a failed run failed', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunFailureBanner(
run: _run('failed', {'diagnostic': 'exit status 2'}),
),
),
),
);
expect(find.text('Why it failed'), findsOneWidget);
expect(find.text('exit status 2'), findsOneWidget);
await tester.pumpWidget(
MaterialApp(home: RunFailureBanner(run: _run('succeeded'))),
);
expect(find.text('Why it failed'), findsNothing);
});
}