merge(app): land retry and restart actions in the native run detail
This commit is contained in:
@@ -22,12 +22,20 @@ class RetryRunAction extends StatefulWidget {
|
||||
required this.run,
|
||||
required this.gateway,
|
||||
required this.onRunChanged,
|
||||
this.onRunOpened,
|
||||
});
|
||||
|
||||
final JsonMap run;
|
||||
final ApiGateway gateway;
|
||||
final ValueChanged<JsonMap> onRunChanged;
|
||||
|
||||
/// Receives the id the accepted server reply names for the new retry run.
|
||||
///
|
||||
/// The reply is first delivered through [onRunChanged] like every other
|
||||
/// accepted detail. This callback then opens that run; it is never called
|
||||
/// with a guessed id, and a reply without a usable id changes no selection.
|
||||
final ValueChanged<num>? onRunOpened;
|
||||
|
||||
@override
|
||||
State<RetryRunAction> createState() => _RetryRunActionState();
|
||||
}
|
||||
@@ -70,7 +78,11 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
||||
mode: intent.mode.wireMode,
|
||||
);
|
||||
if (!mounted) return null;
|
||||
if (_owns(id)) widget.onRunChanged(run);
|
||||
if (_owns(id)) {
|
||||
widget.onRunChanged(run);
|
||||
final opened = retryRunId(run);
|
||||
if (opened != null && opened != id) widget.onRunOpened?.call(opened);
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
return ActionRefusal(
|
||||
|
||||
@@ -20,10 +20,16 @@ class RetryIntent {
|
||||
final String requestKey;
|
||||
}
|
||||
|
||||
/// The entropy bound for a fresh key.
|
||||
///
|
||||
/// Written as a literal: on the web a bitwise `1 << 32` wraps to 0, which makes
|
||||
/// `Random.nextInt` reject every retry with a `RangeError`.
|
||||
const _entropyBound = 0x100000000;
|
||||
|
||||
/// A fresh `request_key` for one retry intent. The server requires one and caps
|
||||
/// it at 128 characters; this stays well inside that bound and unique per call.
|
||||
String newRetryRequestKey(num runId, {DateTime? now, int? random}) {
|
||||
final stamp = (now ?? DateTime.now()).microsecondsSinceEpoch;
|
||||
final entropy = random ?? Random().nextInt(1 << 32);
|
||||
final entropy = random ?? Random().nextInt(_entropyBound);
|
||||
return 'app-retry-$runId-$stamp-${entropy.toRadixString(36)}';
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
controller: controller,
|
||||
gateway: widget.gateway,
|
||||
onBack: _back,
|
||||
onRunOpened: _select,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -2,7 +2,10 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../artifacts/ui/artifact_gallery_action.dart';
|
||||
import '../actions/cancel_eligibility.dart';
|
||||
import '../actions/cancel_run_action.dart';
|
||||
import '../actions/retry_action.dart';
|
||||
import '../actions/retry_eligibility.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import 'run_decision_notice.dart';
|
||||
|
||||
@@ -14,29 +17,48 @@ class RunDetailActions extends StatelessWidget {
|
||||
required this.run,
|
||||
required this.gateway,
|
||||
required this.onRunChanged,
|
||||
this.onRunOpened,
|
||||
});
|
||||
|
||||
final JsonMap run;
|
||||
final ApiGateway gateway;
|
||||
final ValueChanged<JsonMap> onRunChanged;
|
||||
|
||||
/// Opens the new run named by an accepted retry reply; see [RetryRunAction].
|
||||
final ValueChanged<num>? onRunOpened;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Standard native spacing keeps adjacent outlines and fills distinct.
|
||||
// Only actions that render are included: a hidden zero-size child still
|
||||
// consumes Wrap spacing and would double the visible gap.
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
RunTitleAction(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
),
|
||||
CancelRunAction(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
),
|
||||
if (runTitleId(run) != null)
|
||||
RunTitleAction(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
),
|
||||
if (retryRunId(run) != null && canRetryRun(run))
|
||||
RetryRunAction(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
onRunOpened: onRunOpened,
|
||||
),
|
||||
if (cancelRunId(run) != null && canCancelRun(run))
|
||||
CancelRunAction(
|
||||
run: run,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
),
|
||||
if (showRunArtifactsAction(run))
|
||||
RunArtifactsButton(run: run, gateway: gateway),
|
||||
],
|
||||
|
||||
@@ -16,6 +16,7 @@ class RunDetailView extends StatefulWidget {
|
||||
required this.controller,
|
||||
required this.gateway,
|
||||
required this.onBack,
|
||||
this.onRunOpened,
|
||||
});
|
||||
|
||||
final RunsController controller;
|
||||
@@ -24,6 +25,10 @@ class RunDetailView extends StatefulWidget {
|
||||
final ApiGateway gateway;
|
||||
final VoidCallback onBack;
|
||||
|
||||
/// Opens the run named by an accepted retry reply, so the host route follows
|
||||
/// the server-identified new run. Null keeps the detail on the retried run.
|
||||
final ValueChanged<num>? onRunOpened;
|
||||
|
||||
@override
|
||||
State<RunDetailView> createState() => _RunDetailViewState();
|
||||
}
|
||||
@@ -44,6 +49,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
run: run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
);
|
||||
return cupertino
|
||||
? buildCupertinoRunDetail(
|
||||
|
||||
Reference in New Issue
Block a user