From 88476800c07663f5e080a4126656fe8859d55a9f Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:37:10 +0100 Subject: [PATCH 01/16] docs(app): hand off the open lane wave --- app/WORK.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/WORK.md b/app/WORK.md index c93041aa..bce5aee2 100644 --- a/app/WORK.md +++ b/app/WORK.md @@ -585,3 +585,43 @@ the Pipelines server binds `127.0.0.1:8080` only, so the phone needs a tailnet TLS-terminated TCP forward (`wss://…ts.net:/connect`), which is the operator's call; the native build has no baked endpoint and takes it in Settings. Nothing installed on any device; mobile remains unverified. +## Open wave handoff (2026-10-22 ~18:45) +Briefs with exact web wording for every remaining PARITY gap are in the manager +scratchpad `briefs/` (runs, start-templates-transport, chat-sessions, +chat-surfaces); the run prompts below embed what each lane needs. + +Pipeline runs left executing (Task v6, Luna), one worktree each under `tmp/` +on branch `flutter/`; when a run lands, merge its branch, run the full +suite + analyze, publish by rename: +- 140 chat `/stop` `/help` actions (`flutter/chat-cmd-stop`); the web's accepted + `/stop` notice is `Stopping the running turn…` — add it at merge if missing. +- 143 runs filter menu: Pipeline/Time range sections, duration sorts, Reset + (`flutter/runs-filter-menu`). +- 144 runs day groups (`flutter/runs-day-groups`); the row meta/usage/empty-state + wording lane (brief runs §1 item 5, §2 item 3) is still to start after it. +- 145 runs pipeline filter from the URL + pipeline detail `Runs` action + (`flutter/runs-pipeline-url`). +- 146 run dialog Report format (`flutter/run-report-format`). +- 147 run dialog recent directories (`flutter/run-directories`). +- 148 composer paste attachments (`flutter/chat-paste`). +- 149 background question notices (`flutter/chat-question-notice`). +- 152 chat create dialog parity (`flutter/chat-create-dialog`). + +Direct work in progress (Claude agents, branches `worktree-agent-*` under +`.claude/worktrees/`): chat tasks + model chooser probe; graph pulse + session +repair probe; search selection probe; shell Runs-tab attention badge with a +lifted AttentionController. The `/new` `/close` `/rename` commands are being +implemented directly on `flutter/chat-cmd-session` after Luna blocked three +times (runs 141, 142, 150) on the coordination scope. + +Preserved partial: run 151 live `New` marks is a WIP commit faa5cc00 on +`flutter/chat-live-new` (frame listener + persisted unseen set; needs the lint +fix at chat_session_local.dart:59, focused tests, and an `activeSessionId` clear +when the conversation is left). + +Still to start after this wave: pending run intent persisted across reload; +persisted endpoint boot for native; foreground-while-connected list refresh; +compaction frame fold (`Compacting context…`); dismiss control for the chat row +refusal; hide closing an open conversation + deep-link `markOpened`; run Summary +`Pipeline` row as a link; `Open repaired export` link + recovery attempts line. +Template provenance on runs is a server gap (no template origin recorded). From 4280881436553e00d000ac3bd739e1e0daeb53e0 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:37:18 +0100 Subject: [PATCH 02/16] feat(app): notify on chat questions --- app/lib/application/pipelines_app.dart | 24 +++++ .../notify/chat_question_notices.dart | 73 +++++++++++++ .../attention/notify/notification_models.dart | 6 +- .../notify/chat_question_notices_test.dart | 101 ++++++++++++++++++ 4 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 app/lib/features/attention/notify/chat_question_notices.dart create mode 100644 app/test/features/attention/notify/chat_question_notices_test.dart diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index 14ecb4f6..96dbe405 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -9,6 +9,7 @@ import '../core/transport/pipelines_client.dart'; import '../shell/adaptive_shell.dart'; import '../shell/destination.dart'; import '../features/attention/notify/notification_controller.dart'; +import '../features/attention/notify/chat_question_notices.dart'; import '../features/attention/notify/notification_store.dart'; import '../features/runs/ui/run_search_selection.dart'; import '../features/search/domain/search_target.dart'; @@ -88,6 +89,7 @@ class _PipelinesAppState extends State late final NotificationController _notifications = NotificationController( store: const SharedPreferencesNotificationStore(), ); + ChatQuestionNotices? _chatQuestionNotices; @override void initState() { @@ -126,6 +128,17 @@ class _PipelinesAppState extends State builder: _buildShell, ); _delegate.addListener(_routeChanged); + _chatQuestionNotices = ChatQuestionNotices( + gateway: _session.gateway, + canNotify: () => _notifications.canNotify, + activeChatSessionId: () { + final route = _delegate.shellRoute; + return route.kind == AppRouteKind.chat ? route.chatSessionId : null; + }, + sessionTitle: _chatSessionTitle, + openChat: (id) => _delegate.goTo(AppRoute.chatSession(id)), + bridge: _notifications.bridge, + ); _config = RouterConfig( routeInformationParser: const AppRouteParser(), routerDelegate: _delegate, @@ -138,6 +151,7 @@ class _PipelinesAppState extends State void dispose() { WidgetsBinding.instance.removeObserver(this); _notifications.dispose(); + _chatQuestionNotices?.dispose(); _delegate.removeListener(_routeChanged); _delegate.dispose(); if (_ownsProvider) { @@ -242,6 +256,16 @@ class _PipelinesAppState extends State setState(() => _pendingRunSearch = null); } + Future _chatSessionTitle(String id) async { + final reply = await _session.gateway.call('chat_sessions'); + final sessions = reply['chat_sessions']; + if (sessions is! List) return null; + for (final value in sessions) { + if (value is Map && value['id'] == id) return '${value['title'] ?? ''}'; + } + return null; + } + /// The Templates page above Settings. Closing it restores the same Settings /// screen instance, so an edited field or an open connection state survives. Widget _buildSchedules(BuildContext context) => SchedulesDestination( diff --git a/app/lib/features/attention/notify/chat_question_notices.dart b/app/lib/features/attention/notify/chat_question_notices.dart new file mode 100644 index 00000000..fc4b3fdb --- /dev/null +++ b/app/lib/features/attention/notify/chat_question_notices.dart @@ -0,0 +1,73 @@ +import 'dart:async'; + +import '../../../core/api_gateway.dart'; +import 'notification_bridge.dart'; +import 'notification_models.dart'; + +/// Delivers live unanswered chat questions through the shared notification +/// capability, without coupling chat event folding to platform notifications. +class ChatQuestionNotices { + ChatQuestionNotices({ + required ApiGateway gateway, + required this.canNotify, + required this.activeChatSessionId, + required this.sessionTitle, + required this.openChat, + required this.bridge, + }) { + _frames = gateway.frames.listen(_onEnvelope); + } + + final bool Function() canNotify; + final String? Function() activeChatSessionId; + final Future Function(String sessionId) sessionTitle; + final void Function(String sessionId) openChat; + final NotificationBridge bridge; + late final StreamSubscription _frames; + bool _disposed = false; + + void _onEnvelope(JsonMap envelope) { + if (envelope['type'] != 'chat_event') return; + final event = envelope['chat_event']; + if (event is! Map || event['kind'] != 'form') return; + final sessionId = event['session_id']; + final form = event['form']; + if (sessionId is! String || sessionId.isEmpty || + form is! Map || form['kind'] != 'question' || + form['resolved'] == true || form['cancelled'] == true || + form['id'] == null || !canNotify() || + activeChatSessionId() == sessionId) { + return; + } + unawaited(_show(sessionId, Map.from(form))); + } + + Future _show(String sessionId, JsonMap form) async { + String? session; + try { + session = await sessionTitle(sessionId); + } catch (_) { + // An unavailable session list is equivalent to an unknown session title. + } + if (_disposed || !canNotify() || activeChatSessionId() == sessionId) return; + final title = (session ?? '').trim(); + try { + bridge.show( + NotificationMessage( + chatSessionId: sessionId, + title: '${title.isEmpty ? 'Chat' : title} needs your answer', + body: '${form['title'] ?? 'The agent asked a question.'}', + tag: 'chat-question:${form['id']}', + ), + onTap: () => openChat(sessionId), + ); + } catch (_) { + // Notification delivery must not interfere with the in-page question. + } + } + + void dispose() { + _disposed = true; + unawaited(_frames.cancel()); + } +} diff --git a/app/lib/features/attention/notify/notification_models.dart b/app/lib/features/attention/notify/notification_models.dart index f817c92e..a3d5af33 100644 --- a/app/lib/features/attention/notify/notification_models.dart +++ b/app/lib/features/attention/notify/notification_models.dart @@ -156,13 +156,15 @@ String notificationAlertBody(AttentionEntry entry) { /// the stable identity used as the browser's coalescing tag. class NotificationMessage { const NotificationMessage({ - required this.runId, + this.runId, + this.chatSessionId, required this.title, required this.body, required this.tag, }); - final int runId; + final int? runId; + final String? chatSessionId; final String title; final String body; final String tag; diff --git a/app/test/features/attention/notify/chat_question_notices_test.dart b/app/test/features/attention/notify/chat_question_notices_test.dart new file mode 100644 index 00000000..6b0b1b87 --- /dev/null +++ b/app/test/features/attention/notify/chat_question_notices_test.dart @@ -0,0 +1,101 @@ +import 'dart:async'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/core/api_gateway.dart'; +import 'package:pipelines_app/application/app_route.dart'; +import 'package:pipelines_app/features/attention/notify/chat_question_notices.dart'; + +import 'notification_test_support.dart'; + +class _Gateway implements ApiGateway { + final controller = StreamController.broadcast(); + @override + Stream get frames => controller.stream; + @override + Future call(String type, [JsonMap fields = const {}]) async => {}; +} + +Map _event({ + String id = 'form-1', + String session = 'session_1', + String kind = 'question', + bool resolved = false, + bool cancelled = false, +}) => { + 'type': 'chat_event', + 'chat_event': { + 'session_id': session, + 'kind': 'form', + 'form': { + 'id': id, + 'kind': kind, + 'title': 'Choose an option', + 'resolved': resolved, + 'cancelled': cancelled, + }, + }, +}; + +void main() { + late _Gateway gateway; + late FakeNotificationBridge bridge; + late bool allowed; + late String? active; + late List opened; + late ChatQuestionNotices notices; + + setUp(() { + gateway = _Gateway(); + bridge = FakeNotificationBridge(permission: 'granted'); + allowed = true; + active = null; + opened = []; + notices = ChatQuestionNotices( + gateway: gateway, + canNotify: () => allowed, + activeChatSessionId: () => active, + sessionTitle: (id) async => id == 'session_1' ? ' Design chat ' : null, + openChat: (id) => opened.add(AppRoute.chatSession(id)), + bridge: bridge, + ); + }); + + tearDown(() async { + notices.dispose(); + await gateway.controller.close(); + }); + + test('notifies titled and unknown sessions; tap opens the chat route', () async { + gateway.controller.add(_event()); + await Future.delayed(Duration.zero); + gateway.controller.add(_event(id: 'form-2', session: 'unknown')); + await Future.delayed(Duration.zero); + + expect(bridge.shown.map((message) => message.title), [ + 'Design chat needs your answer', + 'Chat needs your answer', + ]); + expect(bridge.shown.first.body, 'Choose an option'); + expect(bridge.shown.first.tag, 'chat-question:form-1'); + bridge.taps.first?.call(); + expect(opened, [AppRoute.chatSession('session_1')]); + }); + + test('suppresses active, unavailable, resolved, cancelled and non-question frames', () async { + active = 'session_1'; + gateway.controller.add(_event()); + await Future.delayed(Duration.zero); + active = null; + allowed = false; + gateway.controller.add(_event(id: 'form-2')); + await Future.delayed(Duration.zero); + allowed = true; + gateway.controller.add(_event(id: 'form-3', resolved: true)); + await Future.delayed(Duration.zero); + gateway.controller.add(_event(id: 'form-4', cancelled: true)); + await Future.delayed(Duration.zero); + gateway.controller.add(_event(id: 'form-5', kind: 'approval')); + await Future.delayed(Duration.zero); + expect(bridge.shown, isEmpty); + }); +} From 6eb2a7b85cb3f0079ae81e8c619a4344c9deab59 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:37:32 +0100 Subject: [PATCH 03/16] 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(); From b8d18bcb80598e22baf8837b416561150887fcf1 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:37:35 +0100 Subject: [PATCH 04/16] feat(app): suggest server workspaces in run dialog --- .../pipelines/ui/run_pipeline_action.dart | 1 + .../pipelines/ui/run_pipeline_dialog.dart | 56 ++++++++++++ .../pipelines/ui/run_pipeline_fields.dart | 88 ++++++++++++++++--- .../pipelines/ui/run_pipeline_wording.dart | 10 ++- .../ui/run_pipeline_launch_test.dart | 59 ++++++++++--- 5 files changed, 185 insertions(+), 29 deletions(-) diff --git a/app/lib/features/pipelines/ui/run_pipeline_action.dart b/app/lib/features/pipelines/ui/run_pipeline_action.dart index 668cd6c5..c0f0e781 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_action.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_action.dart @@ -51,6 +51,7 @@ class _RunPipelineActionState extends State { await showRunPipelineDialog( context: context, detail: widget.detail, + gateway: widget.gateway, pending: widget.controller.pendingRunFor(_pipelineId, _version), onSubmit: _submit, onPendingChanged: (intent) { diff --git a/app/lib/features/pipelines/ui/run_pipeline_dialog.dart b/app/lib/features/pipelines/ui/run_pipeline_dialog.dart index ec360f20..98730bea 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_dialog.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_dialog.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; +import '../../settings/settings_store.dart'; import '../../../ui/adaptive/host.dart'; import '../pipeline_models.dart'; import '../run_pipeline_intent.dart'; @@ -16,6 +17,7 @@ import 'run_pipeline_wording.dart'; Future showRunPipelineDialog({ required BuildContext context, required PipelineDetail detail, + required ApiGateway gateway, required RunPipelineIntent? pending, required Future Function(RunPipelineIntent intent) onSubmit, @@ -24,6 +26,7 @@ Future showRunPipelineDialog({ }) { final dialog = _RunPipelineDialog( detail: detail, + gateway: gateway, pending: pending, cupertino: usesCupertinoHost(context), onSubmit: onSubmit, @@ -46,6 +49,7 @@ Future showRunPipelineDialog({ class _RunPipelineDialog extends StatefulWidget { const _RunPipelineDialog({ required this.detail, + required this.gateway, required this.pending, required this.cupertino, required this.onSubmit, @@ -54,6 +58,7 @@ class _RunPipelineDialog extends StatefulWidget { }); final PipelineDetail detail; + final ApiGateway gateway; final RunPipelineIntent? pending; final bool cupertino; final Future Function(RunPipelineIntent intent) onSubmit; @@ -70,6 +75,8 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { late RunNotifyMode _notify; late RunPipelineIntent? _intent; bool _sending = false; + bool _directoriesLoading = true; + List _directories = const []; String? _error; @override @@ -86,8 +93,45 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { _prompt = TextEditingController(text: restored?.prompt ?? ''); _workspace = TextEditingController(text: restored?.workspace ?? ''); _error = restored == null ? null : runPipelineUnknownAdmission; + _loadDirectories(restored); } + Future _loadDirectories(RunPipelineIntent? restored) async { + final savedWorkspace = const SharedPreferencesSettingsStore().load().then( + (settings) => settings.workspace, + ); + try { + final reply = await _gateway.call('chat_directories'); + final value = reply['chat_directories']; + final directories = value is List + ? value.whereType().toList() + : []; + final saved = await savedWorkspace; + if (!mounted) return; + setState(() { + _directories = directories + .where((path) => path.startsWith('/')) + .toList(); + if (_workspace.text.isEmpty) { + _workspace.text = saved.startsWith('/') + ? saved + : _directories.isEmpty + ? '' + : _directories.first; + } + _directoriesLoading = false; + }); + } catch (error) { + if (!mounted) return; + setState(() { + _directoriesLoading = false; + _error = '$error'; + }); + } + } + + ApiGateway get _gateway => widget.gateway; + @override void dispose() { _prompt.dispose(); @@ -213,10 +257,18 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { RunPipelineFields( prompt: _prompt, workspace: _workspace, + directories: _directories, + cupertino: widget.cupertino, + onChooseDirectory: _chooseDirectory, notifyMode: _notify, locked: _locked, onNotifyChanged: (mode) => setState(() => _notify = mode), ), + if (_directoriesLoading) + Padding( + padding: const EdgeInsets.only(top: 4), + child: Text(runPipelineDirectoriesLoading), + ), if (_error case final error?) Padding( padding: const EdgeInsets.only(top: 12), @@ -228,4 +280,8 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> { ], ); } + + void _chooseDirectory(String directory) { + _workspace.text = directory; + } } diff --git a/app/lib/features/pipelines/ui/run_pipeline_fields.dart b/app/lib/features/pipelines/ui/run_pipeline_fields.dart index c863ea54..610eb63a 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_fields.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_fields.dart @@ -14,6 +14,9 @@ class RunPipelineFields extends StatelessWidget { super.key, required this.prompt, required this.workspace, + required this.directories, + required this.cupertino, + required this.onChooseDirectory, required this.notifyMode, required this.locked, required this.onNotifyChanged, @@ -21,6 +24,9 @@ class RunPipelineFields extends StatelessWidget { final TextEditingController prompt; final TextEditingController workspace; + final List directories; + final bool cupertino; + final ValueChanged onChooseDirectory; final RunNotifyMode notifyMode; final bool locked; final ValueChanged onNotifyChanged; @@ -77,18 +83,51 @@ class RunPipelineFields extends StatelessWidget { } Widget _workspaceField(BuildContext context, bool cupertino) { - if (cupertino) { - return CupertinoTextField( - key: runPipelineWorkspaceKey, - controller: workspace, - placeholder: runPipelineWorkspacePlaceholder, - placeholderStyle: _cupertinoPlaceholder(context), - style: CupertinoTheme.of(context).textTheme.textStyle, - enabled: !locked, - autocorrect: false, - padding: const EdgeInsets.all(8), - ); - } + final field = cupertino + ? _cupertinoWorkspace(context) + : _materialWorkspace(); + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: field), + if (directories.isNotEmpty) + cupertino + ? CupertinoButton( + key: runPipelineWorkspaceSuggestionsKey, + padding: EdgeInsets.zero, + onPressed: locked + ? null + : () => _chooseCupertinoDirectory(context), + child: const Icon(CupertinoIcons.folder), + ) + : PopupMenuButton( + key: runPipelineWorkspaceSuggestionsKey, + tooltip: runPipelineWorkspaceLabel, + enabled: !locked, + onSelected: onChooseDirectory, + itemBuilder: (_) => [ + for (final path in directories) + PopupMenuItem(value: path, child: Text(path)), + ], + ), + ], + ); + } + + Widget _cupertinoWorkspace(BuildContext context) { + return CupertinoTextField( + key: runPipelineWorkspaceKey, + controller: workspace, + placeholder: runPipelineWorkspacePlaceholder, + placeholderStyle: _cupertinoPlaceholder(context), + style: CupertinoTheme.of(context).textTheme.textStyle, + enabled: !locked, + autocorrect: false, + padding: const EdgeInsets.all(8), + ); + } + + Widget _materialWorkspace() { return TextField( key: runPipelineWorkspaceKey, controller: workspace, @@ -101,6 +140,27 @@ class RunPipelineFields extends StatelessWidget { ); } + Future _chooseCupertinoDirectory(BuildContext context) async { + final chosen = await showCupertinoModalPopup( + context: context, + builder: (sheetContext) => CupertinoActionSheet( + title: const Text(runPipelineWorkspaceLabel), + actions: [ + for (final path in directories) + CupertinoActionSheetAction( + onPressed: () => Navigator.of(sheetContext).pop(path), + child: Text(path), + ), + ], + cancelButton: CupertinoActionSheetAction( + onPressed: () => Navigator.of(sheetContext).pop(), + child: const Text(runPipelineCancelLabel), + ), + ), + ); + if (chosen != null) onChooseDirectory(chosen); + } + Widget _notifyField(BuildContext context, bool cupertino) { if (cupertino) { return CupertinoButton( @@ -159,7 +219,9 @@ class RunPipelineFields extends StatelessWidget { TextStyle _cupertinoPlaceholder(BuildContext context) { // The host's own dynamic placeholder colour (light and dark), resolved for // the dialog's inherited Cupertino brightness. - return TextStyle(color: CupertinoColors.placeholderText.resolveFrom(context)); + return TextStyle( + color: CupertinoColors.placeholderText.resolveFrom(context), + ); } Widget _helper(BuildContext context, String text, bool cupertino) { diff --git a/app/lib/features/pipelines/ui/run_pipeline_wording.dart b/app/lib/features/pipelines/ui/run_pipeline_wording.dart index 3cda4a28..58a2ff1a 100644 --- a/app/lib/features/pipelines/ui/run_pipeline_wording.dart +++ b/app/lib/features/pipelines/ui/run_pipeline_wording.dart @@ -12,6 +12,10 @@ const runPipelineWorkspaceLabel = 'Working directory (on the server)'; const runPipelineWorkspaceHelper = 'Choose a recent directory or type an absolute path.'; const runPipelineWorkspacePlaceholder = '/absolute/path/on/the/server'; +const runPipelineDirectoriesLoading = 'Loading directories…'; +const runPipelineWorkspaceSuggestionsKey = ValueKey( + 'run-pipeline-workspace-suggestions', +); const runPipelineNotifyLabel = 'Notifications for this run'; const runPipelineCancelLabel = 'Cancel'; const runPipelineConfirmLabel = 'Run'; @@ -43,7 +47,5 @@ const runPipelineErrorKey = ValueKey('run-pipeline-error'); /// The server's refusal, verbatim. Only a blank error gets a sentence so the /// prompt never claims a run that was not admitted. -String describeRunPipelineError(Object error) => describeErrorReason( - error, - fallback: 'The server did not start the run.', -); +String describeRunPipelineError(Object error) => + describeErrorReason(error, fallback: 'The server did not start the run.'); 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..a306b7f6 100644 --- a/app/test/features/pipelines/ui/run_pipeline_launch_test.dart +++ b/app/test/features/pipelines/ui/run_pipeline_launch_test.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/core/transport/connection_state.dart'; import 'package:pipelines_app/features/pipelines/screen.dart'; @@ -28,6 +29,10 @@ FakeGateway launchGateway( )!, ), 'list_schedules' => {'type': 'schedules', 'schedules': []}, + 'chat_directories' => { + 'type': 'chat_directories', + 'chat_directories': ['/work/recent', 'relative', '/work/other'], + }, 'run_pipeline' => onLaunch(fields), 'get_run' when onLookup != null => onLookup(fields), _ => errorReply('unexpected $type'), @@ -74,6 +79,45 @@ Future fillFields( } void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + SharedPreferences.setMockInitialValues({}); + testWidgets( + 'workspace directory suggestions load on open and selection is local', + (tester) async { + final fixture = PipelineFixture(); + final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(76)); + await pumpScreen(tester, gateway, []); + await openDetail(tester); + await tester.tap(find.byKey(runPipelineActionKey)); + await tester.pumpAndSettle(); + + expect(gateway.callsOf('chat_directories'), hasLength(1)); + expect(find.text(runPipelineDirectoriesLoading), findsNothing); + expect( + tester + .widget(find.byKey(runPipelineWorkspaceKey)) + .controller + ?.text, + '/work/recent', + ); + await tester.tap(find.byKey(runPipelineWorkspaceSuggestionsKey)); + await tester.pumpAndSettle(); + expect(find.text('/work/other'), findsOneWidget); + expect(find.text('relative'), findsNothing); + await tester.tap(find.text('/work/other')); + await tester.pumpAndSettle(); + expect( + tester + .widget(find.byKey(runPipelineWorkspaceKey)) + .controller + ?.text, + '/work/other', + ); + expect(gateway.callsOf('run_pipeline'), isEmpty); + expect(gateway.callsOf('chat_directories'), hasLength(1)); + }, + ); + testWidgets('the detail Run action sends the web request for the pinned ' 'version and opens only the reply run', (tester) async { final fixture = PipelineFixture(); @@ -104,10 +148,7 @@ void main() { expect(gateway.callsOf('run_pipeline'), isEmpty); await fillFields(tester, prompt: ' Review the change. '); - await tester.enterText( - find.byKey(runPipelineWorkspaceKey), - '/work/alpha ', - ); + await tester.enterText(find.byKey(runPipelineWorkspaceKey), '/work/alpha '); await tester.tap(find.byKey(runPipelineNotifyKey)); await tester.pumpAndSettle(); await tester.tap(find.text('Silent').last); @@ -495,13 +536,7 @@ void main() { final helper = tester .widget(find.text(runPipelineWorkspaceHelper)) .style; - expect( - helper?.color, - CupertinoColors.secondaryLabel.resolveFrom(context), - ); - expect( - helper?.fontSize, - theme.textTheme.tabLabelTextStyle.fontSize, - ); + expect(helper?.color, CupertinoColors.secondaryLabel.resolveFrom(context)); + expect(helper?.fontSize, theme.textTheme.tabLabelTextStyle.fontSize); }); } From 4f0d2aab6ffc88002b3bf1ca17d652f2720f42d7 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 18:40:35 +0100 Subject: [PATCH 05/16] test(app): browser probe for search result selection --- app/notes/search-selection-probe.md | 140 +++++ app/tool/search_selection_probe.mjs | 646 +++++++++++++++++++++ app/tool/search_selection_probe_entry.dart | 469 +++++++++++++++ 3 files changed, 1255 insertions(+) create mode 100644 app/notes/search-selection-probe.md create mode 100644 app/tool/search_selection_probe.mjs create mode 100644 app/tool/search_selection_probe_entry.dart diff --git a/app/notes/search-selection-probe.md b/app/notes/search-selection-probe.md new file mode 100644 index 00000000..2d219e84 --- /dev/null +++ b/app/notes/search-selection-probe.md @@ -0,0 +1,140 @@ +# Search result-target selection: browser probe + +Real-Chrome evidence for the PARITY `Search` row's missing capture: a field hit +and an artifact hit select the recorded run Summary section or visit, and a +retired field / unknown visit falls back to the plain Summary. + +## Files + +- `app/tool/search_selection_probe_entry.dart` — the normal `PipelinesApp` + composition over the shared `PipelinesClient`, with the socket replaced by an + in-process channel that answers `search`, `get_run`, `list_runs`, + `list_pipelines`, `get_pipeline` and `ping` with server-shaped fixtures. + `subscribe`/`unsubscribe` are silent like the real server. A `search` body + that is not exactly `{query, kind, limit: 0}` is answered with an error + envelope, so a wrong request shape fails the captures instead of passing. + No live server; nothing is contacted over the network. +- `app/tool/search_selection_probe.mjs` — CDP driver (same shape as + `changes_probe.mjs`): loopback static server with index fallback for route + paths, headless Chrome, Flutter semantics enabled, exact-label clicks, PNGs. + +Run from `app/`: + +``` +flutter build web --target tool/search_selection_probe_entry.dart --output build/probe-search-selection +node tool/search_selection_probe.mjs --root build/probe-search-selection --out build/search-selection-probe +``` + +Exit code 0 means every assertion held and no defect was recorded; exit code 2 +means the assertions held but at least one recorded state differs from the +expected one (listed under `defects` in the JSON report). A thrown assertion +also writes `failure.png` next to the captures. + +## Fixture + +Run 7 "Release train run" (`name: release-train`), `input {prompt: "ship it"}`, +`output {result: "ok"}`, steps in recorded order plan seq 5, build seq 2 +(artifact `release-report.txt`), plan seq 1 — the sequences are deliberately +not the row indexes, as in `test/features/runs/ui/run_search_selection_test.dart`. + +Search replies (`truncated: false`, `scanned_steps 3`, `scanned_bytes 2048`, +`cap 50`, `scan_bound_bytes 1048576`): + +| query | hits | +| --- | --- | +| `release` | `pipeline:24`, `pipeline:22:v6`, `run:7`, `run:7:5` (plan visit 2), `run:7:5:output`, `/artifacts/7/2/release-report.txt` | +| `retired` | `run:7:5:evidence` (retired field) | +| `missing` | `/artifacts/7/9/missing.log` (sequence 9 is not recorded) | +| `first` | `run:7:1` (plan visit 1) | + +## Captures (`app/build/search-selection-probe/`) + +Light scheme is pinned through `Emulation.setEmulatedMedia`; one dark pass is +included. Phone is 390×844, desktop 1280×800. + +| capture | state | +| --- | --- | +| `search-selection-material-phone-results.png` | Search panel, `release`, one row per kind | +| `search-selection-material-phone-artifact-visit.png` | artifact hit → Timeline, `build · visit 2` pane | +| `search-selection-material-phone-retired-summary.png` | retired field after the open visit → plain Summary | +| `search-selection-material-phone-unknown-visit-summary.png` | unknown-visit artifact after an open visit → plain Summary | +| `search-selection-material-phone-field-summary.png` | field hit (`output`) → Summary, Output expanded, Input collapsed | +| `search-selection-material-phone-retired-after-field-summary.png` | retired field after that field hit (defect 1 evidence) | +| `search-selection-material-phone-step-visit.png` | step hit `plan visit 1` (defect 2 evidence) | +| `search-selection-material-desktop-results.png` | desktop results | +| `search-selection-material-desktop-artifact-visit.png` | desktop artifact visit | +| `search-selection-material-desktop-retired-summary.png` | desktop plain Summary | +| `search-selection-material-desktop-field-summary.png` | desktop field selection | +| `search-selection-material-phone-dark-results.png` | dark results | +| `search-selection-material-phone-dark-field-summary.png` | dark field selection | +| `search-selection-cupertino-phone-results.png` | Cupertino results (`Kind: All kinds` control) | +| `search-selection-cupertino-phone-artifact-visit.png` | Cupertino artifact visit | +| `search-selection-cupertino-phone-retired-summary.png` | Cupertino plain Summary after retired field | +| `search-selection-cupertino-phone-unknown-visit-summary.png` | Cupertino plain Summary after unknown visit | +| `search-selection-cupertino-phone-field-summary.png` | Cupertino field selection | +| `search-selection-cupertino-phone-retired-after-field-summary.png` | Cupertino retired-after-field (defect 1 evidence) | +| `search-selection-cupertino-desktop-results.png` | Cupertino desktop results | +| `search-selection-cupertino-desktop-artifact-visit.png` | Cupertino desktop artifact visit | +| `search-selection-cupertino-desktop-field-summary.png` | Cupertino desktop field selection | + +## Asserted strings (Flutter semantics, exact) + +- Results, every host/width: row titles `Release train`, `pipeline 22 · v6`, + `run #7 · Release train`, `run #7 · plan visit 2`, `run #7 · step 5 · output`, + `release-report.txt`; row meta `Pipeline`, `Pipeline version`, `Run`, `Step`, + `Field`, `Artifact`; snippet `ship the release`; bounds + `6 results · cap 50 · scanned 3 steps · 2.0 KiB scanned · scan limit 1.0 MiB`; + Cupertino also `Kind: All kinds`. +- Every hit: `location.pathname === '/runs/7'`, title `Release train run`, + and the Search page's text gone. +- Field hit: Summary tile `Output` announces `Expanded` and `Input` announces + `Collapsed` (first line of the tile's `aria-description`); no + `Back to timeline`, no `build · visit 2`. +- Artifact hit: `build · visit 2` and `Back to timeline` present; + `Original prompt` (Summary-only text) absent. +- Retired field / unknown visit: `Original prompt` present, `Input` and + `Output` both `Collapsed`, no visit pane text. +- One-shot: after an artifact hit, `Back to list` → row `Release train run` + reopens `/runs/7` on the Summary with no `build · visit 2`. +- Fixture-side: a `search` body other than `{query, kind, limit: 0}` and a + `get_run` for any run but 7 reply with an error envelope; both would have + failed the label assertions above (the JSON report has `pageErrors: []`). + +Semantics limitation: Flutter web renders a read-only `SelectableText` / +read-only `CupertinoTextField` as a `