feat(app): Retry sits beside a failed run's status

This commit is contained in:
2026-10-23 16:05:15 +01:00
parent ba484f044f
commit e0e3517d0b
5 changed files with 115 additions and 7 deletions
@@ -19,6 +19,7 @@ class RunDetailActions extends StatelessWidget {
required this.gateway,
required this.onRunChanged,
this.onRunOpened,
this.retry = true,
});
final JsonMap run;
@@ -28,6 +29,9 @@ class RunDetailActions extends StatelessWidget {
/// Opens the new run named by an accepted retry reply; see [RetryRunAction].
final ValueChanged<num>? onRunOpened;
/// False when the host draws Retry beside the run's failed status instead.
final bool retry;
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
@@ -51,7 +55,7 @@ class RunDetailActions extends StatelessWidget {
),
if (canScheduleRun(run))
ScheduleRunAction(run: run, gateway: gateway),
if (retryRunId(run) != null && canRetryRun(run))
if (retry && retryRunId(run) != null && canRetryRun(run))
RetryRunAction(
run: run,
gateway: gateway,
@@ -15,6 +15,7 @@ Widget buildCupertinoRunDetail({
required BuildContext context,
required JsonMap run,
required Widget headerActions,
Widget? statusAction,
required bool detailLoading,
required String? error,
required bool copying,
@@ -72,9 +73,17 @@ Widget buildCupertinoRunDetail({
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
?statusAction,
],
),
const SizedBox(height: 4),
Text(
@@ -15,6 +15,7 @@ Widget buildMaterialRunDetail({
required BuildContext context,
required JsonMap run,
required Widget headerActions,
Widget? statusAction,
required bool detailLoading,
required String? error,
required bool copying,
@@ -62,9 +63,17 @@ Widget buildMaterialRunDetail({
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
child: Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
?statusAction,
],
),
),
),
@@ -5,6 +5,8 @@ import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/pipelines_client.dart';
import '../../../ui/adaptive/host.dart';
import '../actions/retry_action.dart';
import '../actions/retry_eligibility.dart';
import 'run_detail_actions.dart';
import 'run_detail_content.dart';
import 'run_detail_cupertino.dart';
@@ -60,12 +62,23 @@ class _RunDetailViewState extends State<RunDetailView> {
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
onRunOpened: widget.onRunOpened,
retry: false,
);
// Retry sits next to the status it answers, and only for a failed run.
final statusAction = retryRunId(run) != null && canRetryRun(run)
? RetryRunAction(
run: run,
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
onRunOpened: widget.onRunOpened,
)
: null;
return cupertino
? buildCupertinoRunDetail(
context: context,
run: run,
headerActions: headerActions,
statusAction: statusAction,
detailLoading: widget.controller.detailLoading,
error: widget.controller.error,
copying: _copying,
@@ -82,6 +95,7 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context,
run: run,
headerActions: headerActions,
statusAction: statusAction,
detailLoading: widget.controller.detailLoading,
error: widget.controller.error,
copying: _copying,
@@ -0,0 +1,72 @@
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/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/ui/status/run_status_icon.dart';
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@override
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type != 'get_run') throw UnsupportedError(type);
return Future.value({'run_detail': detail});
}
}
Future<void> _pump(WidgetTester tester, String status, bool cupertino) async {
tester.view.physicalSize = const Size(390, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final controller = RunsController(
RunsRepository(
_FakeGateway({
'id': 21,
'title': 'Nightly build',
'name': 'nightly',
'status': status,
'executing': false,
}),
),
);
await controller.select(21);
final view = RunDetailView(
controller: controller,
gateway: _FakeGateway(const {}),
onBack: () {},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: view))
: MaterialApp(home: Scaffold(body: view)),
);
await tester.pumpAndSettle();
}
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'cupertino' : 'material';
testWidgets('$host: Retry sits beside the failed status', (tester) async {
await _pump(tester, 'failed', cupertino);
final retry = find.text('Retry');
expect(retry, findsOneWidget);
final kicker = tester.getRect(find.byType(RunStatusKicker));
final button = tester.getRect(retry);
expect(button.center.dy, moreOrLessEquals(kicker.center.dy, epsilon: 8));
expect(button.left, greaterThan(kicker.right));
});
testWidgets('$host: a succeeded run offers no Retry', (tester) async {
await _pump(tester, 'succeeded', cupertino);
expect(find.text('Retry'), findsNothing);
});
}
}