072db8f749
- "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>
67 lines
2.3 KiB
Dart
67 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../pipelines/pipeline_models.dart';
|
|
import '../../pipelines/pipeline_repository.dart';
|
|
import '../../pipelines/pipelines_controller.dart';
|
|
import '../../pipelines/run_pipeline_seed.dart';
|
|
import '../../pipelines/ui/run_pipeline_flow.dart';
|
|
import '../../pipelines/ui/run_pipeline_wording.dart';
|
|
import '../actions/retry_eligibility.dart';
|
|
import '../data/runs_repository.dart';
|
|
import 'run_detail_content.dart' show detailPrompt;
|
|
|
|
const runAgainActionLabel = 'Run again…';
|
|
const runAgainActionKey = ValueKey<String>('run-again-action');
|
|
|
|
/// The seed a Run again pre-fills from [run]: its stored prompt, workspace,
|
|
/// report requirement and the version it ran.
|
|
RunPipelineSeed runAgainSeed(JsonMap run) {
|
|
final version = run['version'];
|
|
return RunPipelineSeed(
|
|
prompt: detailPrompt(run) ?? '',
|
|
workspace: '${run['workspace'] ?? ''}'.trim(),
|
|
originalVersion: version is num ? version.toInt() : null,
|
|
outputFormat: runOutputFormatOf(run['output_format']),
|
|
);
|
|
}
|
|
|
|
/// Run again: opens the New run form for [run]'s pipeline at its latest
|
|
/// version (the original offered), pre-filled with the run's inputs.
|
|
///
|
|
/// A list row carries no input, so the run is read first. Nothing starts until
|
|
/// the form's own confirm, exactly as New run.
|
|
Future<void> startRunAgainFlow({
|
|
required BuildContext context,
|
|
required JsonMap run,
|
|
required PipelinesController controller,
|
|
required ApiGateway gateway,
|
|
ValueChanged<int>? onRunStarted,
|
|
}) async {
|
|
if (!canStartRunAgain(run)) return;
|
|
final pipelineId = (run['pipeline_id'] as num).toInt();
|
|
final JsonMap full;
|
|
final PipelineDetail detail;
|
|
try {
|
|
full = run['input'] is Map
|
|
? run
|
|
: await RunsRepository(gateway).getRun(run['id'] as num);
|
|
detail = await PipelinesRepository(gateway).getPipeline(pipelineId, 0);
|
|
} 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,
|
|
seed: runAgainSeed(full),
|
|
);
|
|
}
|