Runs: failure banner actions, immediate run menu; pipeline rows get Run

- "Why it failed" banner offers Retry (the retry prompt), Run again… (New
  run form pre-filled; now allowed for failed runs from the banner) and
  Open in chat (the run's existing send-to-chat flow).
- The run ⋮ menu shows while the detail loads: items listed from the run's
  list row, disabled until get_run answers (the loading placeholder had no
  actions, so the menu waited for the full detail).
- Pipelines list rows: Run… in the row menu (not for archived pipelines)
  and a trailing Run button when the list sits beside its detail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:32:57 +00:00
parent accb9970b6
commit 072db8f749
15 changed files with 578 additions and 22 deletions
@@ -11,12 +11,19 @@ bool canRetryRun(JsonMap? run) {
/// Whether [run] can be started again with its inputs: a finished run that
/// succeeded, was canceled or was interrupted, and names its pipeline. A
/// failed run has Retry instead.
bool canRunAgain(JsonMap? run) {
/// failed run has Retry instead in menus (see [canStartRunAgain]).
bool canRunAgain(JsonMap? run) =>
canStartRunAgain(run) && run!['status'] != 'failed';
/// Whether the New run form can be pre-filled from [run]: any finished run,
/// failed included, that names its pipeline. A failed run's banner offers it
/// beside Retry.
bool canStartRunAgain(JsonMap? run) {
if (run == null || run['executing'] == true) return false;
final pipeline = run['pipeline_id'];
return const {
'succeeded',
'failed',
'canceled',
'interrupted',
}.contains(run['status']) &&
+1 -1
View File
@@ -38,7 +38,7 @@ Future<void> startRunAgainFlow({
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
}) async {
if (!canRunAgain(run)) return;
if (!canStartRunAgain(run)) return;
final pipelineId = (run['pipeline_id'] as num).toInt();
final JsonMap full;
final PipelineDetail detail;
@@ -26,9 +26,11 @@ Widget buildMaterialRunDetail({
String? initialStageKey,
int? initialVisit,
void Function(String draft)? onSendToChat,
Widget? failureActions,
}) {
return RunDetailTabs(
run: run,
failureActions: failureActions,
copying: copying,
copyStatus: copyStatus,
onCopy: onCopy,
@@ -30,6 +30,7 @@ Widget runDetailSummaryTab({
ExpansibleController? inputController,
ExpansibleController? outputController,
Widget? graphPreview,
Widget? failureActions,
}) {
final rows = detailSummaryRows(run);
final identity = detailSummaryIdentity(run);
@@ -61,7 +62,9 @@ Widget runDetailSummaryTab({
),
),
),
SliverToBoxAdapter(child: RunFailureBanner(run: run)),
SliverToBoxAdapter(
child: RunFailureBanner(run: run, actions: failureActions),
),
SliverToBoxAdapter(
child: WarningsSection(messages: warningMessages(run['warnings'])),
),
@@ -56,10 +56,15 @@ class RunDetailTabs extends StatefulWidget {
this.initialStageKey,
this.initialVisit,
this.onSendToChat,
this.failureActions,
});
final JsonMap run;
/// What a failed run's "Why it failed" banner offers (Retry, Run again…,
/// Open in chat); null offers none.
final Widget? failureActions;
/// The host's own header: status, the run actions and notices. It floats
/// outside the tab body, so switching tabs never drops an action.
final Widget header;
@@ -458,6 +463,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
onCopy: widget.onCopy,
inputController: _inputSection,
outputController: _outputSection,
failureActions: widget.failureActions,
graphPreview: RunGraphPreview(
graph: detailGraph(widget.run),
run: widget.run,
@@ -12,6 +12,7 @@ import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
import 'run_detail_content.dart';
import 'run_detail_material.dart';
import 'run_failure_actions.dart';
import 'runs_controller.dart';
import '../../../core/error_advice.dart';
import '../../../ui/status/error_notice.dart';
@@ -96,6 +97,14 @@ class _RunDetailViewState extends State<RunDetailView> {
onSendToChat: widget.onSendToChat == null
? null
: (draft) => widget.onSendToChat!(context, run, draft),
failureActions: RunFailureActions(
run: run,
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
onRunOpened: widget.onRunOpened,
onRunAgain: widget.onRunAgain,
onOpenInChat: widget.onOpenInChat,
),
);
// The top bar becomes the run's: Back to the list, its title over its
// number, pipeline and version (a link to that pipeline when the host
@@ -181,14 +190,41 @@ class _RunDetailViewState extends State<RunDetailView> {
: widget.controller.error ?? 'Run details unavailable.';
// Back stays available while the detail is pending as well as after a
// failure, so a slow or refused request can never trap the destination.
// The more menu is there from the first frame: while the detail loads its
// items are listed from the run's list row, disabled until the detail
// they act on arrives.
final pending = _pendingRun();
return ShellBar(
title: 'Run',
onBack: widget.onBack,
hideNavigation: true,
actions: [
if (loading && pending != null)
RunMoreMenu(
run: pending,
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
onDeleted: widget.controller.applyDeletion,
onOpenInChat: widget.onOpenInChat,
onRunAgain: widget.onRunAgain,
pending: true,
),
],
child: _placeholderBody(loading, message),
);
}
/// The selected run as its list row knows it, else only its id; null when
/// no run is selected.
JsonMap? _pendingRun() {
final id = widget.controller.selectedRunId;
if (id == null) return null;
for (final run in widget.controller.runs) {
if (run['id'] == id) return run;
}
return {'id': id};
}
Widget _placeholderBody(bool loading, String message) {
return Center(
child: Column(
@@ -0,0 +1,95 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../actions/retry_action.dart';
import '../actions/retry_eligibility.dart';
import '../actions/retry_wording.dart';
import 'run_again_flow.dart';
const runFailureRetryKey = ValueKey<String>('run-failure-retry');
const runFailureRunAgainKey = ValueKey<String>('run-failure-run-again');
const runFailureOpenInChatKey = ValueKey<String>('run-failure-open-in-chat');
const runFailureOpenInChatLabel = 'Open in chat';
/// What a failed run's "Why it failed" banner offers: Retry (the server's
/// retry, as the more menu's), Run again… (the New run form pre-filled from
/// the run) and Open in chat (the run's send-to-chat flow, with its context).
///
/// Each is the existing action; one the host cannot apply is omitted. It stays
/// mounted while a picked flow runs, so a retry's result reaches the run.
class RunFailureActions extends StatefulWidget {
const RunFailureActions({
super.key,
required this.run,
required this.gateway,
required this.onRunChanged,
this.onRunOpened,
this.onRunAgain,
this.onOpenInChat,
});
final JsonMap run;
final ApiGateway gateway;
final ValueChanged<JsonMap> onRunChanged;
final ValueChanged<num>? onRunOpened;
final ValueChanged<JsonMap>? onRunAgain;
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
@override
State<RunFailureActions> createState() => _RunFailureActionsState();
}
class _RunFailureActionsState extends State<RunFailureActions> {
void _retry() => openRetryRunPrompt(
context,
run: widget.run,
gateway: widget.gateway,
onRunChanged: widget.onRunChanged,
onRunOpened: widget.onRunOpened,
owns: (owned) => mounted && retryRunId(widget.run) == owned,
);
@override
Widget build(BuildContext context) {
final run = widget.run;
final scheme = Theme.of(context).colorScheme;
final onBanner = TextButton.styleFrom(
foregroundColor: scheme.onErrorContainer,
);
final runAgain = widget.onRunAgain;
final openInChat = widget.onOpenInChat;
return Wrap(
spacing: 8,
runSpacing: 4,
children: [
if (retryRunId(run) != null && canRetryRun(run))
FilledButton.icon(
key: runFailureRetryKey,
style: FilledButton.styleFrom(
backgroundColor: scheme.error,
foregroundColor: scheme.onError,
),
onPressed: _retry,
icon: const Icon(Icons.replay),
label: const Text(retryActionLabel),
),
if (runAgain != null && canStartRunAgain(run))
TextButton.icon(
key: runFailureRunAgainKey,
style: onBanner,
onPressed: () => runAgain(run),
icon: const Icon(Icons.edit_note),
label: const Text(runAgainActionLabel),
),
if (openInChat != null)
TextButton.icon(
key: runFailureOpenInChatKey,
style: onBanner,
onPressed: () => openInChat(context, run),
icon: const Icon(Icons.chat_bubble_outline),
label: const Text(runFailureOpenInChatLabel),
),
],
);
}
}
@@ -6,10 +6,15 @@ import '../domain/run_outcome_line.dart';
/// The run Summary's prominent "Why it failed" note: a failed run's recorded
/// failure reason (else its diagnostic), selectable, at the top of the
/// Summary so the reason is read before the facts. Nothing for other runs.
///
/// [actions] (the run's Retry, Run again… and Open in chat; see
/// `RunFailureActions`) sit under the reason, so what to do next is beside
/// why it failed.
class RunFailureBanner extends StatelessWidget {
const RunFailureBanner({super.key, required this.run});
const RunFailureBanner({super.key, required this.run, this.actions});
final JsonMap run;
final Widget? actions;
@override
Widget build(BuildContext context) {
@@ -53,6 +58,10 @@ class RunFailureBanner extends StatelessWidget {
color: scheme.onErrorContainer,
),
),
if (actions case final actions?) ...[
const SizedBox(height: 8),
actions,
],
],
),
),
@@ -72,8 +72,13 @@ class RunMoreMenu extends StatefulWidget {
this.onOpenInChat,
this.onRunAgain,
this.menuKey = runMoreMenuKey,
this.pending = false,
});
/// The run's detail is still loading: [run] is its list row (or only its
/// id), so the items are listed but disabled until the detail arrives.
final bool pending;
/// Opens the New run form pre-filled from this run (finished runs that
/// did not fail); without it the menu offers no Run again.
final ValueChanged<JsonMap>? onRunAgain;
@@ -168,6 +173,7 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
_RunMoreItem.openInChat => Icons.chat_bubble_outline,
},
destructive: item == _RunMoreItem.delete,
enabled: !widget.pending,
),
],
onSelected: _pick,