Files
pipelines/app/lib/features/runs/ui/run_failure_actions.dart
T
alan 072db8f749 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>
2026-12-03 00:32:57 +00:00

96 lines
3.1 KiB
Dart

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),
),
],
);
}
}