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:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import '../../ui/adaptive/segmented_bar.dart';
|
import '../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../shell/destination.dart';
|
import '../../shell/destination.dart';
|
||||||
import '../../shell/detail_page.dart';
|
import '../../shell/detail_page.dart';
|
||||||
@@ -15,6 +17,7 @@ import 'pending_run_store.dart';
|
|||||||
import 'widgets/pipeline_bar_buttons.dart';
|
import 'widgets/pipeline_bar_buttons.dart';
|
||||||
import 'widgets/pipeline_detail_panel.dart';
|
import 'widgets/pipeline_detail_panel.dart';
|
||||||
import 'widgets/pipeline_list_panel.dart';
|
import 'widgets/pipeline_list_panel.dart';
|
||||||
|
import 'ui/run_pipeline_from_list.dart';
|
||||||
|
|
||||||
export 'pipeline_models.dart' show PipelineDetail, PipelineVersion;
|
export 'pipeline_models.dart' show PipelineDetail, PipelineVersion;
|
||||||
|
|
||||||
@@ -223,6 +226,18 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
return _isRoutePin(detail) ? key : null;
|
return _isRoutePin(detail) ? key : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A list row's Run: the same start flow as the detail's Run button.
|
||||||
|
void _runFromList(BuildContext context, PipelineSummary pipeline) =>
|
||||||
|
unawaited(
|
||||||
|
startPipelineRunFromList(
|
||||||
|
context: context,
|
||||||
|
pipeline: pipeline,
|
||||||
|
controller: _controller,
|
||||||
|
gateway: widget.gateway,
|
||||||
|
onRunStarted: widget.onRunStarted,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
@@ -262,6 +277,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
child: PipelineListPanel(
|
child: PipelineListPanel(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
onOpenInChat: widget.onOpenPipelineInChat,
|
onOpenInChat: widget.onOpenPipelineInChat,
|
||||||
|
onRun: _runFromList,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -270,6 +286,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
|||||||
child: PipelineListPanel(
|
child: PipelineListPanel(
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
onOpenInChat: widget.onOpenPipelineInChat,
|
onOpenInChat: widget.onOpenPipelineInChat,
|
||||||
|
onRun: _runFromList,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
detailIdentity: _controller.selectedId,
|
detailIdentity: _controller.selectedId,
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../pipeline_models.dart';
|
||||||
|
import '../pipeline_repository.dart';
|
||||||
|
import '../pipelines_controller.dart';
|
||||||
|
import 'run_pipeline_flow.dart';
|
||||||
|
import 'run_pipeline_wording.dart';
|
||||||
|
|
||||||
|
/// A list row's Run: reads the row's pipeline at its listed version, then
|
||||||
|
/// opens the same start flow as the detail's Run button. Nothing starts until
|
||||||
|
/// the form's own confirm; a refused read is shown, never a guessed form.
|
||||||
|
Future<void> startPipelineRunFromList({
|
||||||
|
required BuildContext context,
|
||||||
|
required PipelineSummary pipeline,
|
||||||
|
required PipelinesController controller,
|
||||||
|
required ApiGateway gateway,
|
||||||
|
ValueChanged<int>? onRunStarted,
|
||||||
|
}) async {
|
||||||
|
if (pipeline.archived) return;
|
||||||
|
final PipelineDetail detail;
|
||||||
|
try {
|
||||||
|
detail = await PipelinesRepository(
|
||||||
|
gateway,
|
||||||
|
).getPipeline(pipeline.id, pipeline.version);
|
||||||
|
} catch (error) {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
ScaffoldMessenger.maybeOf(
|
||||||
|
context,
|
||||||
|
)?.showSnackBar(SnackBar(content: Text(describeRunPipelineError(error))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!context.mounted) return;
|
||||||
|
await openRunPipelineFlow(
|
||||||
|
context: context,
|
||||||
|
controller: controller,
|
||||||
|
detail: detail,
|
||||||
|
gateway: gateway,
|
||||||
|
onRunStarted: onRunStarted,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ import '../pipelines_controller.dart';
|
|||||||
import 'pipeline_controls.dart';
|
import 'pipeline_controls.dart';
|
||||||
import 'pipeline_filter_page.dart';
|
import 'pipeline_filter_page.dart';
|
||||||
import 'pipeline_scope_control.dart';
|
import 'pipeline_scope_control.dart';
|
||||||
import '../../../ui/layout/app_overflow_menu.dart';
|
import '../../../shell/list_detail_policy.dart';
|
||||||
|
import 'pipeline_row_actions.dart';
|
||||||
|
|
||||||
/// The list's horizontal rhythm, matching the web's toolbar and row inset
|
/// The list's horizontal rhythm, matching the web's toolbar and row inset
|
||||||
/// (`var(--space-s)`: 12px). The detail pane keeps its own content padding.
|
/// (`var(--space-s)`: 12px). The detail pane keeps its own content padding.
|
||||||
@@ -26,12 +27,17 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
this.onOpenInChat,
|
this.onOpenInChat,
|
||||||
|
this.onRun,
|
||||||
});
|
});
|
||||||
|
|
||||||
final PipelinesController controller;
|
final PipelinesController controller;
|
||||||
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
||||||
onOpenInChat;
|
onOpenInChat;
|
||||||
|
|
||||||
|
/// Opens the New run form for a row's pipeline (its menu's Run…, and its
|
||||||
|
/// trailing Run button on a wide list); null offers neither.
|
||||||
|
final void Function(BuildContext, PipelineSummary)? onRun;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final filters = controller.filters;
|
final filters = controller.filters;
|
||||||
@@ -230,6 +236,23 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
// The default padding is the media padding: the controls start below the
|
// The default padding is the media padding: the controls start below the
|
||||||
// top bar and the last row clears the floating tab bar.
|
// top bar and the last row clears the floating tab bar.
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) =>
|
||||||
|
_rows(context, header, items, now, constraints.maxWidth),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _rows(
|
||||||
|
BuildContext context,
|
||||||
|
List<Widget> header,
|
||||||
|
List<PipelineSummary> items,
|
||||||
|
DateTime now,
|
||||||
|
double width,
|
||||||
|
) {
|
||||||
|
// A wide layout's list, beside its detail and wide enough, gives each row
|
||||||
|
// its own Run button beside its menu; a phone keeps Run in the menu.
|
||||||
|
final wide =
|
||||||
|
showsListBesideDetail(context) && width >= kPipelineRowRunButtonWidth;
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
key: const Key('pipeline-list'),
|
key: const Key('pipeline-list'),
|
||||||
itemCount: header.length + items.length,
|
itemCount: header.length + items.length,
|
||||||
@@ -271,22 +294,16 @@ class PipelineListPanel extends StatelessWidget {
|
|||||||
: Text(
|
: Text(
|
||||||
ServerContext.metadata(context, runStateLabel(badge.state)),
|
ServerContext.metadata(context, runStateLabel(badge.state)),
|
||||||
),
|
),
|
||||||
menu: onOpenInChat == null
|
menu: pipelineRowActions(
|
||||||
? null
|
pipeline: pipeline,
|
||||||
: AppOverflowMenu<bool>(
|
wide: wide,
|
||||||
key: Key('pipeline-row-more-menu-${pipeline.id}'),
|
onRun: onRun == null
|
||||||
label: 'Pipeline actions',
|
? null
|
||||||
sheetTitle: pipeline.displayName,
|
: (context) => onRun!(context, pipeline),
|
||||||
actions: const [
|
onOpenInChat: onOpenInChat == null
|
||||||
AppMenuAction<bool>(
|
? null
|
||||||
value: true,
|
: (context) => onOpenInChat!(context, pipeline, run),
|
||||||
label: 'Send to chat…',
|
),
|
||||||
icon: Icons.chat_bubble_outline,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onSelected: (context, _) =>
|
|
||||||
onOpenInChat!(context, pipeline, run),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/layout/app_overflow_menu.dart';
|
||||||
|
import '../pipeline_models.dart';
|
||||||
|
import '../ui/run_pipeline_wording.dart';
|
||||||
|
|
||||||
|
/// The pipeline list's width from which each row shows its own Run button
|
||||||
|
/// beside its menu; a narrower list keeps Run in the menu only.
|
||||||
|
const double kPipelineRowRunButtonWidth = 360;
|
||||||
|
|
||||||
|
const pipelineRowRunLabel = 'Run…';
|
||||||
|
|
||||||
|
Key pipelineRowRunKey(int id) => ValueKey('pipeline-row-run-$id');
|
||||||
|
Key pipelineRowRunMenuKey(int id) => ValueKey('pipeline-row-run-menu-$id');
|
||||||
|
Key pipelineRowMenuKey(int id) => ValueKey('pipeline-row-more-menu-$id');
|
||||||
|
|
||||||
|
enum _PipelineRowAction { run, sendToChat }
|
||||||
|
|
||||||
|
/// A pipeline row's trailing actions: its menu (Run…, Send to chat…) and, on
|
||||||
|
/// a [wide] list, a Run button before it. Run is not offered for an archived
|
||||||
|
/// pipeline, as its detail offers none. Null when there is nothing to offer.
|
||||||
|
Widget? pipelineRowActions({
|
||||||
|
required PipelineSummary pipeline,
|
||||||
|
required bool wide,
|
||||||
|
void Function(BuildContext)? onRun,
|
||||||
|
void Function(BuildContext)? onOpenInChat,
|
||||||
|
}) {
|
||||||
|
final run = pipeline.archived ? null : onRun;
|
||||||
|
final actions = [
|
||||||
|
if (run != null)
|
||||||
|
AppMenuAction(
|
||||||
|
key: pipelineRowRunMenuKey(pipeline.id),
|
||||||
|
value: _PipelineRowAction.run,
|
||||||
|
label: pipelineRowRunLabel,
|
||||||
|
icon: Icons.play_arrow_rounded,
|
||||||
|
),
|
||||||
|
if (onOpenInChat != null)
|
||||||
|
const AppMenuAction(
|
||||||
|
value: _PipelineRowAction.sendToChat,
|
||||||
|
label: 'Send to chat…',
|
||||||
|
icon: Icons.chat_bubble_outline,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
if (actions.isEmpty) return null;
|
||||||
|
final menu = AppOverflowMenu<_PipelineRowAction>(
|
||||||
|
key: pipelineRowMenuKey(pipeline.id),
|
||||||
|
label: 'Pipeline actions',
|
||||||
|
sheetTitle: pipeline.displayName,
|
||||||
|
actions: actions,
|
||||||
|
onSelected: (context, action) => switch (action) {
|
||||||
|
_PipelineRowAction.run => run!(context),
|
||||||
|
_PipelineRowAction.sendToChat => onOpenInChat!(context),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (!wide || run == null) return menu;
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Builder(
|
||||||
|
builder: (context) => TextButton.icon(
|
||||||
|
key: pipelineRowRunKey(pipeline.id),
|
||||||
|
onPressed: () => run(context),
|
||||||
|
icon: const Icon(Icons.play_arrow_rounded),
|
||||||
|
label: Text(
|
||||||
|
runPipelineActionLabel,
|
||||||
|
semanticsLabel: 'Run ${pipeline.displayName}',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
menu,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,12 +11,19 @@ bool canRetryRun(JsonMap? run) {
|
|||||||
|
|
||||||
/// Whether [run] can be started again with its inputs: a finished run that
|
/// Whether [run] can be started again with its inputs: a finished run that
|
||||||
/// succeeded, was canceled or was interrupted, and names its pipeline. A
|
/// succeeded, was canceled or was interrupted, and names its pipeline. A
|
||||||
/// failed run has Retry instead.
|
/// failed run has Retry instead in menus (see [canStartRunAgain]).
|
||||||
bool canRunAgain(JsonMap? run) {
|
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;
|
if (run == null || run['executing'] == true) return false;
|
||||||
final pipeline = run['pipeline_id'];
|
final pipeline = run['pipeline_id'];
|
||||||
return const {
|
return const {
|
||||||
'succeeded',
|
'succeeded',
|
||||||
|
'failed',
|
||||||
'canceled',
|
'canceled',
|
||||||
'interrupted',
|
'interrupted',
|
||||||
}.contains(run['status']) &&
|
}.contains(run['status']) &&
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ Future<void> startRunAgainFlow({
|
|||||||
required ApiGateway gateway,
|
required ApiGateway gateway,
|
||||||
ValueChanged<int>? onRunStarted,
|
ValueChanged<int>? onRunStarted,
|
||||||
}) async {
|
}) async {
|
||||||
if (!canRunAgain(run)) return;
|
if (!canStartRunAgain(run)) return;
|
||||||
final pipelineId = (run['pipeline_id'] as num).toInt();
|
final pipelineId = (run['pipeline_id'] as num).toInt();
|
||||||
final JsonMap full;
|
final JsonMap full;
|
||||||
final PipelineDetail detail;
|
final PipelineDetail detail;
|
||||||
|
|||||||
@@ -26,9 +26,11 @@ Widget buildMaterialRunDetail({
|
|||||||
String? initialStageKey,
|
String? initialStageKey,
|
||||||
int? initialVisit,
|
int? initialVisit,
|
||||||
void Function(String draft)? onSendToChat,
|
void Function(String draft)? onSendToChat,
|
||||||
|
Widget? failureActions,
|
||||||
}) {
|
}) {
|
||||||
return RunDetailTabs(
|
return RunDetailTabs(
|
||||||
run: run,
|
run: run,
|
||||||
|
failureActions: failureActions,
|
||||||
copying: copying,
|
copying: copying,
|
||||||
copyStatus: copyStatus,
|
copyStatus: copyStatus,
|
||||||
onCopy: onCopy,
|
onCopy: onCopy,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ Widget runDetailSummaryTab({
|
|||||||
ExpansibleController? inputController,
|
ExpansibleController? inputController,
|
||||||
ExpansibleController? outputController,
|
ExpansibleController? outputController,
|
||||||
Widget? graphPreview,
|
Widget? graphPreview,
|
||||||
|
Widget? failureActions,
|
||||||
}) {
|
}) {
|
||||||
final rows = detailSummaryRows(run);
|
final rows = detailSummaryRows(run);
|
||||||
final identity = detailSummaryIdentity(run);
|
final identity = detailSummaryIdentity(run);
|
||||||
@@ -61,7 +62,9 @@ Widget runDetailSummaryTab({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SliverToBoxAdapter(child: RunFailureBanner(run: run)),
|
SliverToBoxAdapter(
|
||||||
|
child: RunFailureBanner(run: run, actions: failureActions),
|
||||||
|
),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: WarningsSection(messages: warningMessages(run['warnings'])),
|
child: WarningsSection(messages: warningMessages(run['warnings'])),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -56,10 +56,15 @@ class RunDetailTabs extends StatefulWidget {
|
|||||||
this.initialStageKey,
|
this.initialStageKey,
|
||||||
this.initialVisit,
|
this.initialVisit,
|
||||||
this.onSendToChat,
|
this.onSendToChat,
|
||||||
|
this.failureActions,
|
||||||
});
|
});
|
||||||
|
|
||||||
final JsonMap run;
|
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
|
/// The host's own header: status, the run actions and notices. It floats
|
||||||
/// outside the tab body, so switching tabs never drops an action.
|
/// outside the tab body, so switching tabs never drops an action.
|
||||||
final Widget header;
|
final Widget header;
|
||||||
@@ -458,6 +463,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
|||||||
onCopy: widget.onCopy,
|
onCopy: widget.onCopy,
|
||||||
inputController: _inputSection,
|
inputController: _inputSection,
|
||||||
outputController: _outputSection,
|
outputController: _outputSection,
|
||||||
|
failureActions: widget.failureActions,
|
||||||
graphPreview: RunGraphPreview(
|
graphPreview: RunGraphPreview(
|
||||||
graph: detailGraph(widget.run),
|
graph: detailGraph(widget.run),
|
||||||
run: widget.run,
|
run: widget.run,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import 'run_more_menu.dart';
|
|||||||
import 'run_pipeline_link.dart';
|
import 'run_pipeline_link.dart';
|
||||||
import 'run_detail_content.dart';
|
import 'run_detail_content.dart';
|
||||||
import 'run_detail_material.dart';
|
import 'run_detail_material.dart';
|
||||||
|
import 'run_failure_actions.dart';
|
||||||
import 'runs_controller.dart';
|
import 'runs_controller.dart';
|
||||||
import '../../../core/error_advice.dart';
|
import '../../../core/error_advice.dart';
|
||||||
import '../../../ui/status/error_notice.dart';
|
import '../../../ui/status/error_notice.dart';
|
||||||
@@ -96,6 +97,14 @@ class _RunDetailViewState extends State<RunDetailView> {
|
|||||||
onSendToChat: widget.onSendToChat == null
|
onSendToChat: widget.onSendToChat == null
|
||||||
? null
|
? null
|
||||||
: (draft) => widget.onSendToChat!(context, run, draft),
|
: (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
|
// 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
|
// 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.';
|
: widget.controller.error ?? 'Run details unavailable.';
|
||||||
// Back stays available while the detail is pending as well as after a
|
// 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.
|
// 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(
|
return ShellBar(
|
||||||
title: 'Run',
|
title: 'Run',
|
||||||
onBack: widget.onBack,
|
onBack: widget.onBack,
|
||||||
hideNavigation: true,
|
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),
|
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) {
|
Widget _placeholderBody(bool loading, String message) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
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
|
/// 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
|
/// failure reason (else its diagnostic), selectable, at the top of the
|
||||||
/// Summary so the reason is read before the facts. Nothing for other runs.
|
/// 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 {
|
class RunFailureBanner extends StatelessWidget {
|
||||||
const RunFailureBanner({super.key, required this.run});
|
const RunFailureBanner({super.key, required this.run, this.actions});
|
||||||
|
|
||||||
final JsonMap run;
|
final JsonMap run;
|
||||||
|
final Widget? actions;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -53,6 +58,10 @@ class RunFailureBanner extends StatelessWidget {
|
|||||||
color: scheme.onErrorContainer,
|
color: scheme.onErrorContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (actions case final actions?) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
actions,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -72,8 +72,13 @@ class RunMoreMenu extends StatefulWidget {
|
|||||||
this.onOpenInChat,
|
this.onOpenInChat,
|
||||||
this.onRunAgain,
|
this.onRunAgain,
|
||||||
this.menuKey = runMoreMenuKey,
|
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
|
/// Opens the New run form pre-filled from this run (finished runs that
|
||||||
/// did not fail); without it the menu offers no Run again.
|
/// did not fail); without it the menu offers no Run again.
|
||||||
final ValueChanged<JsonMap>? onRunAgain;
|
final ValueChanged<JsonMap>? onRunAgain;
|
||||||
@@ -168,6 +173,7 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
|||||||
_RunMoreItem.openInChat => Icons.chat_bubble_outline,
|
_RunMoreItem.openInChat => Icons.chat_bubble_outline,
|
||||||
},
|
},
|
||||||
destructive: item == _RunMoreItem.delete,
|
destructive: item == _RunMoreItem.delete,
|
||||||
|
enabled: !widget.pending,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
onSelected: _pick,
|
onSelected: _pick,
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||||
|
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
|
||||||
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_row_actions.dart';
|
||||||
|
|
||||||
|
import 'package:pipelines_app/features/pipelines/pipeline_models.dart';
|
||||||
|
import 'package:pipelines_app/ui/layout/app_overflow_menu.dart';
|
||||||
|
|
||||||
|
import '../fixtures.dart';
|
||||||
|
import 'run_pipeline_launch_test.dart' show acceptedRun, launchGateway;
|
||||||
|
|
||||||
|
Future<void> _pump(WidgetTester tester, Size size, FakeGateway gateway) async {
|
||||||
|
tester.view.physicalSize = size;
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
await tester.pumpWidget(MaterialApp(home: PipelinesScreen(gateway: gateway)));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
|
||||||
|
testWidgets('a wide list row has its own Run button opening the form', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final fixture = PipelineFixture();
|
||||||
|
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(9));
|
||||||
|
await _pump(tester, const Size(1440, 900), gateway);
|
||||||
|
|
||||||
|
expect(find.byKey(pipelineRowRunKey(1)), findsOneWidget);
|
||||||
|
await tester.tap(find.byKey(pipelineRowRunKey(1)));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
// The same New run form as the detail's Run, for the row's pipeline at
|
||||||
|
// its listed version; opening it starts nothing.
|
||||||
|
expect(find.byKey(runPipelinePromptKey), findsOneWidget);
|
||||||
|
expect(gateway.callsOf('get_pipeline').last.fields, {
|
||||||
|
'pipeline_id': 1,
|
||||||
|
'version': 2,
|
||||||
|
});
|
||||||
|
expect(gateway.callsOf('run_pipeline'), isEmpty);
|
||||||
|
// The row did not open the pipeline.
|
||||||
|
expect(find.byKey(const Key('pipeline-detail')), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a phone row offers Run… in its menu and no button', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final fixture = PipelineFixture();
|
||||||
|
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(9));
|
||||||
|
await _pump(tester, const Size(560, 900), gateway);
|
||||||
|
|
||||||
|
expect(find.byKey(pipelineRowRunKey(2)), findsNothing);
|
||||||
|
await tester.tap(find.byKey(pipelineRowMenuKey(2)));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text(pipelineRowRunLabel));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.byKey(runPipelinePromptKey), findsOneWidget);
|
||||||
|
expect(gateway.callsOf('get_pipeline').last.fields['pipeline_id'], 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an archived pipeline offers no Run, as its detail offers none', () {
|
||||||
|
final archived = PipelineSummary.fromJson({
|
||||||
|
...pipelineSummary(id: 4, name: 'Old'),
|
||||||
|
'archived_at': '2026-10-01T00:00:00Z',
|
||||||
|
});
|
||||||
|
void run(BuildContext _) {}
|
||||||
|
|
||||||
|
expect(
|
||||||
|
pipelineRowActions(pipeline: archived, wide: true, onRun: run),
|
||||||
|
isNull,
|
||||||
|
);
|
||||||
|
// Send to chat stays; only Run is withheld.
|
||||||
|
expect(
|
||||||
|
pipelineRowActions(
|
||||||
|
pipeline: archived,
|
||||||
|
wide: true,
|
||||||
|
onRun: run,
|
||||||
|
onOpenInChat: run,
|
||||||
|
),
|
||||||
|
isA<AppOverflowMenu<Object?>>(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
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/actions/retry_wording.dart';
|
||||||
|
import 'package:pipelines_app/features/runs/actions/title_wording.dart';
|
||||||
|
import 'package:pipelines_app/features/runs/screen.dart';
|
||||||
|
import 'package:pipelines_app/features/runs/ui/run_failure_actions.dart';
|
||||||
|
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||||
|
|
||||||
|
import 'run_retry_wiring_support.dart';
|
||||||
|
|
||||||
|
Future<void> _mount(
|
||||||
|
WidgetTester tester,
|
||||||
|
ApiGateway gateway, {
|
||||||
|
Future<void> Function(BuildContext, JsonMap)? onOpenInChat,
|
||||||
|
bool settle = true,
|
||||||
|
}) async {
|
||||||
|
tester.view.physicalSize = const Size(1200, 900);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: RunsScreen(
|
||||||
|
gateway: gateway,
|
||||||
|
initialRunId: 7,
|
||||||
|
onOpenInChat: onOpenInChat,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (settle) await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A gateway that lists run 7 but never answers its detail.
|
||||||
|
class _SlowDetailGateway implements ApiGateway {
|
||||||
|
final pending = Completer<JsonMap>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<JsonMap> get frames => const Stream.empty();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) =>
|
||||||
|
switch (type) {
|
||||||
|
'list_runs' => Future.value({
|
||||||
|
'runs': [
|
||||||
|
{'id': 7, 'title': 'Slow run', 'status': 'failed', 'name': 'p'},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
'get_run' => pending.future,
|
||||||
|
_ => Future.error(UnsupportedError(type)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('the failure banner offers Retry, Run again… and Open in chat', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final gateway = RetryWiringGateway();
|
||||||
|
addTearDown(gateway.framesController.close);
|
||||||
|
gateway.details[7] = {
|
||||||
|
...retryFailedDetail(),
|
||||||
|
'pipeline_id': 3,
|
||||||
|
'version': 2,
|
||||||
|
'failure_reason': 'The build stage exited with status 2.',
|
||||||
|
};
|
||||||
|
final opened = <JsonMap>[];
|
||||||
|
await _mount(
|
||||||
|
tester,
|
||||||
|
gateway,
|
||||||
|
onOpenInChat: (context, run) async => opened.add(run),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(find.text('The build stage exited with status 2.'), findsOneWidget);
|
||||||
|
expect(find.byKey(runFailureRetryKey), findsOneWidget);
|
||||||
|
expect(find.byKey(runFailureRunAgainKey), findsOneWidget);
|
||||||
|
expect(find.byKey(runFailureOpenInChatKey), findsOneWidget);
|
||||||
|
|
||||||
|
// Retry is the menu's retry prompt; nothing is sent until its confirm.
|
||||||
|
await tester.tap(find.byKey(runFailureRetryKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text(retryDialogTitle(7)), findsOneWidget);
|
||||||
|
await tester.tap(find.byKey(retryKeepKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(gateway.retryCalls, isEmpty);
|
||||||
|
|
||||||
|
// Open in chat hands the run to the host's send-to-chat flow.
|
||||||
|
await tester.tap(find.byKey(runFailureOpenInChatKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(opened.single['id'], 7);
|
||||||
|
|
||||||
|
// Run again reads the run's pipeline for the pre-filled New run form.
|
||||||
|
await tester.tap(find.byKey(runFailureRunAgainKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(gateway.calls.map((call) => call.type), contains('get_pipeline'));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a failed run without a pipeline offers no Run again', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final gateway = RetryWiringGateway();
|
||||||
|
addTearDown(gateway.framesController.close);
|
||||||
|
gateway.details[7] = {...retryFailedDetail(), 'failure_reason': 'Boom.'};
|
||||||
|
await _mount(tester, gateway);
|
||||||
|
|
||||||
|
expect(find.byKey(runFailureRetryKey), findsOneWidget);
|
||||||
|
expect(find.byKey(runFailureRunAgainKey), findsNothing);
|
||||||
|
expect(find.byKey(runFailureOpenInChatKey), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('the more menu shows while the detail loads, items disabled', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final gateway = _SlowDetailGateway();
|
||||||
|
await _mount(tester, gateway, settle: false);
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(milliseconds: 50));
|
||||||
|
|
||||||
|
expect(find.text('Loading run details…'), findsOneWidget);
|
||||||
|
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||||
|
await tester.tap(find.byKey(runMoreMenuKey));
|
||||||
|
await tester.pump();
|
||||||
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
|
final rename = tester.widget<PopupMenuItem<Object?>>(
|
||||||
|
find.ancestor(
|
||||||
|
of: find.text(runTitleActionLabel),
|
||||||
|
matching: find.byWidgetPredicate((w) => w is PopupMenuItem),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(rename.enabled, isFalse);
|
||||||
|
|
||||||
|
gateway.pending.complete({
|
||||||
|
'run_detail': {
|
||||||
|
'id': 7,
|
||||||
|
'title': 'Slow run',
|
||||||
|
'status': 'failed',
|
||||||
|
'name': 'p',
|
||||||
|
'steps': const <JsonMap>[],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await tester.tapAt(const Offset(2, 2));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(runMoreMenuKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final loaded = tester.widget<PopupMenuItem<Object?>>(
|
||||||
|
find.ancestor(
|
||||||
|
of: find.text(runTitleActionLabel),
|
||||||
|
matching: find.byWidgetPredicate((w) => w is PopupMenuItem),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(loaded.enabled, isTrue);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user