From 6eb2a7b85cb3f0079ae81e8c619a4344c9deab59 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:37:32 +0100 Subject: [PATCH] feat(app): add report format to pipeline launch --- .../pipelines/run_pipeline_intent.dart | 14 +++++ .../pipelines/ui/run_pipeline_action.dart | 1 + .../pipelines/ui/run_pipeline_dialog.dart | 6 ++ .../pipelines/ui/run_pipeline_fields.dart | 63 +++++++++++++++++++ .../pipelines/ui/run_pipeline_wording.dart | 4 ++ .../ui/run_pipeline_launch_test.dart | 13 ++++ 6 files changed, 101 insertions(+) diff --git a/app/lib/features/pipelines/run_pipeline_intent.dart b/app/lib/features/pipelines/run_pipeline_intent.dart index 5c1ca13a..ce66548d 100644 --- a/app/lib/features/pipelines/run_pipeline_intent.dart +++ b/app/lib/features/pipelines/run_pipeline_intent.dart @@ -21,6 +21,18 @@ enum RunNotifyMode { }; } +/// Optional report requirement requested for a manually started run. +enum RunOutputFormat { + none('No report requirement', ''), + html('HTML report', 'html'), + markdown('Markdown report', 'markdown'); + + const RunOutputFormat(this.label, this.wireValue); + + final String label; + final String wireValue; +} + /// One confirmed launch intent: the pinned pipeline identity, the operator's /// fields and the idempotency key that belongs to them. /// @@ -34,6 +46,7 @@ class RunPipelineIntent { required this.prompt, required this.workspace, required this.notifyMode, + this.outputFormat = RunOutputFormat.none, required this.requestKey, }); @@ -42,6 +55,7 @@ class RunPipelineIntent { final String prompt; final String workspace; final RunNotifyMode notifyMode; + final RunOutputFormat outputFormat; final String requestKey; /// The same key is only ever reused for the same pinned definition. diff --git a/app/lib/features/pipelines/ui/run_pipeline_action.dart b/app/lib/features/pipelines/ui/run_pipeline_action.dart index 668cd6c5..a8111940 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_action.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_action.dart @@ -102,6 +102,7 @@ class _RunPipelineActionState extends State { workspace: intent.workspace, requestKey: intent.requestKey, notifyMode: intent.notifyMode.wireValue, + outputFormat: intent.outputFormat.wireValue, ); final accepted = _accept(run); if (accepted is RunPipelineAccepted) return accepted; diff --git a/app/lib/features/pipelines/ui/run_pipeline_dialog.dart b/app/lib/features/pipelines/ui/run_pipeline_dialog.dart index ec360f20..b3c724e8 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_dialog.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_dialog.dart @@ -68,6 +68,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { late final TextEditingController _prompt; late final TextEditingController _workspace; late RunNotifyMode _notify; + late RunOutputFormat _outputFormat; late RunPipelineIntent? _intent; bool _sending = false; String? _error; @@ -83,6 +84,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { : null; _intent = restored; _notify = restored?.notifyMode ?? RunNotifyMode.pipelineDefault; + _outputFormat = restored?.outputFormat ?? RunOutputFormat.none; _prompt = TextEditingController(text: restored?.prompt ?? ''); _workspace = TextEditingController(text: restored?.workspace ?? ''); _error = restored == null ? null : runPipelineUnknownAdmission; @@ -122,6 +124,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { prompt: prompt, workspace: workspace.trim(), notifyMode: _notify, + outputFormat: _outputFormat, requestKey: newRunPipelineRequestKey( widget.detail.id, widget.detail.resolvedVersion, @@ -214,8 +217,11 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { prompt: _prompt, workspace: _workspace, notifyMode: _notify, + outputFormat: _outputFormat, locked: _locked, onNotifyChanged: (mode) => setState(() => _notify = mode), + onOutputFormatChanged: (format) => + setState(() => _outputFormat = format), ), if (_error case final error?) Padding( diff --git a/app/lib/features/pipelines/ui/run_pipeline_fields.dart b/app/lib/features/pipelines/ui/run_pipeline_fields.dart index c863ea54..95ae5d57 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_fields.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_fields.dart @@ -15,15 +15,19 @@ class RunPipelineFields extends StatelessWidget { required this.prompt, required this.workspace, required this.notifyMode, + required this.outputFormat, required this.locked, required this.onNotifyChanged, + required this.onOutputFormatChanged, }); final TextEditingController prompt; final TextEditingController workspace; final RunNotifyMode notifyMode; + final RunOutputFormat outputFormat; final bool locked; final ValueChanged onNotifyChanged; + final ValueChanged onOutputFormatChanged; @override Widget build(BuildContext context) { @@ -41,6 +45,10 @@ class RunPipelineFields extends StatelessWidget { const SizedBox(height: 12), _FieldLabel(runPipelineNotifyLabel, cupertino: cupertino), _notifyField(context, cupertino), + const SizedBox(height: 12), + _FieldLabel(runPipelineOutputFormatLabel, cupertino: cupertino), + _outputFormatField(context, cupertino), + _helper(context, runPipelineOutputFormatHelper, cupertino), ], ); } @@ -156,6 +164,61 @@ class RunPipelineFields extends StatelessWidget { if (chosen != null) onNotifyChanged(chosen); } + Widget _outputFormatField(BuildContext context, bool cupertino) { + if (cupertino) { + return CupertinoButton( + key: runPipelineOutputFormatKey, + padding: EdgeInsets.zero, + alignment: AlignmentDirectional.centerStart, + onPressed: locked ? null : () => _chooseOutputFormat(context), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Flexible(child: Text(outputFormat.label)), + const SizedBox(width: 4), + const Icon(CupertinoIcons.chevron_down, size: 14), + ], + ), + ); + } + return DropdownButtonFormField( + key: runPipelineOutputFormatKey, + initialValue: outputFormat, + decoration: const InputDecoration(border: OutlineInputBorder()), + items: [ + for (final format in RunOutputFormat.values) + DropdownMenuItem(value: format, child: Text(format.label)), + ], + onChanged: locked + ? null + : (format) { + if (format != null) onOutputFormatChanged(format); + }, + ); + } + + Future _chooseOutputFormat(BuildContext context) async { + final chosen = await showCupertinoModalPopup( + context: context, + builder: (sheetContext) => CupertinoActionSheet( + title: const Text(runPipelineOutputFormatLabel), + actions: [ + for (final format in RunOutputFormat.values) + CupertinoActionSheetAction( + onPressed: () => Navigator.of(sheetContext).pop(format), + child: Text(format.label), + ), + ], + cancelButton: CupertinoActionSheetAction( + isDefaultAction: true, + onPressed: () => Navigator.of(sheetContext).pop(), + child: const Text(runPipelineCancelLabel), + ), + ), + ); + if (chosen != null) onOutputFormatChanged(chosen); + } + TextStyle _cupertinoPlaceholder(BuildContext context) { // The host's own dynamic placeholder colour (light and dark), resolved for // the dialog's inherited Cupertino brightness. diff --git a/app/lib/features/pipelines/ui/run_pipeline_wording.dart b/app/lib/features/pipelines/ui/run_pipeline_wording.dart index 3cda4a28..54ad56de 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_wording.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_wording.dart @@ -13,6 +13,9 @@ const runPipelineWorkspaceHelper = 'Choose a recent directory or type an absolute path.'; const runPipelineWorkspacePlaceholder = '/absolute/path/on/the/server'; const runPipelineNotifyLabel = 'Notifications for this run'; +const runPipelineOutputFormatLabel = 'Report format'; +const runPipelineOutputFormatHelper = + 'Requires a nonempty server-written report before success. Structure only; facts are not verified.'; const runPipelineCancelLabel = 'Cancel'; const runPipelineConfirmLabel = 'Run'; const runPipelineSendingLabel = 'Starting…'; @@ -37,6 +40,7 @@ const runPipelineActionKey = ValueKey('run-pipeline-action'); const runPipelinePromptKey = ValueKey('run-pipeline-prompt'); const runPipelineWorkspaceKey = ValueKey('run-pipeline-workspace'); const runPipelineNotifyKey = ValueKey('run-pipeline-notify'); +const runPipelineOutputFormatKey = ValueKey('run-pipeline-output-format'); const runPipelineCancelKey = ValueKey('run-pipeline-cancel'); const runPipelineConfirmKey = ValueKey('run-pipeline-confirm'); const runPipelineErrorKey = ValueKey('run-pipeline-error'); diff --git a/app/test/features/pipelines/ui/run_pipeline_launch_test.dart b/app/test/features/pipelines/ui/run_pipeline_launch_test.dart index d9dcf76f..57e8866b 100644 --- a/app/test/features/pipelines/ui/run_pipeline_launch_test.dart +++ b/app/test/features/pipelines/ui/run_pipeline_launch_test.dart @@ -93,6 +93,8 @@ void main() { expect(find.text(runPipelinePromptLabel), findsOneWidget); expect(find.text(runPipelineWorkspaceLabel), findsOneWidget); expect(find.text(runPipelineNotifyLabel), findsOneWidget); + expect(find.text(runPipelineOutputFormatLabel), findsOneWidget); + expect(find.text(runPipelineOutputFormatHelper), findsOneWidget); expect(find.text(runPipelineCancelLabel), findsOneWidget); expect( find.descendant( @@ -112,6 +114,10 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.text('Silent').last); await tester.pumpAndSettle(); + await tester.tap(find.byKey(runPipelineOutputFormatKey)); + await tester.pumpAndSettle(); + await tester.tap(find.text('HTML report').last); + await tester.pumpAndSettle(); await tester.tap(find.byKey(runPipelineConfirmKey)); await tester.pumpAndSettle(); @@ -123,6 +129,7 @@ void main() { 'workspace': '/work/alpha', 'input': {'prompt': 'Review the change.'}, 'notify_mode': 'off', + 'output_format': 'html', }); expect(fields['request_key'], startsWith('app-run-1-2-')); expect('${fields['request_key']}'.length, lessThanOrEqualTo(128)); @@ -317,6 +324,12 @@ void main() { // The fields stay locked while admission is unknown. final prompt = tester.widget(find.byKey(runPipelinePromptKey)); expect(prompt.enabled, isFalse); + expect( + tester.widget>( + find.byKey(runPipelineOutputFormatKey), + ).onChanged, + isNull, + ); await tester.tap(find.byKey(runPipelineConfirmKey)); await tester.pumpAndSettle();