From 7aa7007aeebb7b94def79cb3b4053008dc447230 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 22 Oct 2026 09:58:09 +0100 Subject: [PATCH] feat(app): open pipeline and template deep links and route search results --- app/PARITY.md | 4 +- app/WORK.md | 6 +++ app/lib/application/pipelines_app.dart | 30 ++++++++++--- .../application/pipelines_destination.dart | 8 ++++ .../application/templates_destination.dart | 5 +++ app/lib/features/pipelines/screen.dart | 21 +++++++++ app/lib/features/templates/screen.dart | 8 ++++ .../pipelines/pipeline_deep_link_test.dart | 44 +++++++++++++++++++ 8 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 app/test/features/pipelines/pipeline_deep_link_test.dart diff --git a/app/PARITY.md b/app/PARITY.md index 76f10802..a2c8483b 100644 --- a/app/PARITY.md +++ b/app/PARITY.md @@ -22,7 +22,7 @@ or scratch servers only, never real operator sessions/runs/workflows. | Area | Current state | Remaining acceptance | | --- | --- | --- | | Shared transport/settings connection | Preview | foreground recovery, persisted endpoint boot, protocol warning, complete refresh semantics | -| Native shell/run URLs | Preview | pipeline/version/stage/template/chat URLs, action/visit queries and native deep-link handling | +| Native shell/run URLs | Preview: full route vocabulary including pipeline/version/stage, template detail, run visit/stage and decide, runs pipeline filter; pipeline and template links open their detail | run visit/stage and decide destinations still open the run only; no native OS deep-link registration | | Pipeline list/filter/sort/detail/source/versions | Preview | latest summary metadata/miniatures, pinned detail URLs | | Definition graph | Source nodes/layout/routes/edges; active canvas71 | compose measured native nodes+labels, graph tab, pan/zoom, expanded view, definition stage pane | | Start a pipeline | Preview: native Run action, prompt/workspace/notify dialog, pinned run request, response-loss check/retry | Report format, recent-directory suggestions, pending intent across a reload | @@ -51,7 +51,7 @@ or scratch servers only, never real operator sessions/runs/workflows. | Chat commands/notices/scroll | Missing | slash palette/actions, unknown-command send-as-message, dismissible local notices, saved scroll/follow intent | | Saved schedule list | Source | pipeline entry and route registration, exact timer provenance vocabulary | | Schedule editor | Preview: pipeline Summary section creates/edits/pauses/deletes with the lossless draft and revision guard; conflict keeps the draft and shows the server words | Schedule-this-run seeding, schedules list entry/route | -| Search | Preview: shell entry, /search route, focused field, restore on close; exact target model for every hit kind | navigation wiring for pipeline/version/field/visit/artifact (run targets already open) | +| Search | Preview: exact target model and navigation to pipeline, pinned version, run and recorded stage; unresolvable hits stay read-only | field/artifact hits open the run (their pane selection is a later slice) | | Needs you | Preview: runs-list bell/count from the same list rows, native sheet, open/dismiss/clear persistence, live fold and reconnect reseed | notification permission/transition notices, authenticated preview smoke | | Notifications | Preview: Settings permission tile over live platform state, transition-only dedupe, tap opens the run | background question notices; permission/browser smoke only in fixtures | | Mobile replacement build | Scaffold only | Android build at end; all source portable to iOS, isolated IDs; device/OS behavior clearly separate | diff --git a/app/WORK.md b/app/WORK.md index e11f4635..706b7a0b 100644 --- a/app/WORK.md +++ b/app/WORK.md @@ -71,6 +71,12 @@ All work under app/. Existing applications remain running and unchanged. | Chat sessions | Create/rename/star/close/hide | run98 retained + canceled | oversized run cancelled after 3h; manager verified 155 chat tests, rebased, merged; 1259 suite | merged main | directory groups/search | | Turn documents | Gallery document slots | run102 retained + canceled | oversized run cancelled; 148 artifact tests, rebased; manager fixed visit drill-down to keep session.html out of stage files | merged main | 1284 suite | | Attach picker | Host file input seam | run112 micro | single behaviour; 193 chat tests | merged main | chips/send next | +| Routes | Full URL vocabulary | run113 micro | parse/serialise every web route form; 1327 suite | merged main | stage panes next | +| Session export | Recorded state surface | run110 micro | state wording + reasons read-only | merged main | repair request next | +| Activity overlay | Expanded recorded activity | run111 micro | expand/collapse with recorded fields | merged main | - | +| Graph expand | Expand from pipeline Graph tab | run114 micro | same canvas, selection survives | merged main | run detail entry | +| Attach wire | Base64 attachment parts | run115 micro | exact wire shape, 1 MiB bound | merged main | composer send | +| Miniature | Pipeline row preview | run116 micro | recorded preview only, external never fetched | merged main | - | | Schedules list | (no change needed) | run109 no-op | list screen already landed; only route registration remains (manager) | - | route wiring | | Pipeline metadata | Recorded list-row facts | run108 micro | single behaviour; pipelines tests | merged main | miniature next | | Search target | Exact hit identity model | run105 /cbba026c | micro lane (single behaviour, no probe); 41 search tests | merged main | navigation wiring next | diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index 421b7873..7e6af5ea 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -10,6 +10,7 @@ import '../shell/adaptive_shell.dart'; import '../shell/destination.dart'; import '../features/attention/notify/notification_controller.dart'; import '../features/attention/notify/notification_store.dart'; +import '../features/search/domain/search_target.dart'; import '../features/settings/settings_screen.dart'; import 'app.dart'; import 'app_route.dart'; @@ -136,12 +137,28 @@ class _PipelinesAppState extends State { ), ); - /// Open a result through an existing app route only. A run target uses the - /// route the Runs destination already owns; the hit map itself is unchanged, - /// and pipeline/version hits have no route yet, so they are not guessed. + /// Open a result through the exact identity the hit records. An unresolvable + /// hit navigates nowhere: the screen already presents it read-only rather than + /// guessing a destination. void _openSearchResult(JsonMap hit) { - final runId = searchHitRunId(hit); - if (runId != null) _delegate.goTo(AppRoute.run(runId)); + final resolved = searchTargetFor(hit); + if (resolved is! ResolvedSearchTarget) return; + final route = switch (resolved.target) { + SearchPipelineTarget(:final pipelineId) => AppRoute.pipeline(pipelineId), + SearchVersionTarget(:final pipelineId, :final version) => + AppRoute.pipeline(pipelineId, version: version), + SearchRunTarget(:final runId) => AppRoute.run(runId), + SearchStepTarget(:final runId, :final stage, :final visit) => + stage == null + ? AppRoute.run(runId) + : AppRoute.run.stage(runId, stage, visit: visit), + // A field or artifact names a visit inside the run; the run detail owns + // that pane, so open the run rather than inventing a stage route. + SearchFieldTarget(:final runId) => AppRoute.run(runId), + SearchArtifactTarget(:final runId) => + runId == null ? null : AppRoute.run(runId), + }; + if (route != null) _delegate.goTo(route); } /// The Templates page above Settings. Closing it restores the same Settings @@ -151,6 +168,7 @@ class _PipelinesAppState extends State { server: widget.server, onBack: _delegate.closeTemplates, onCreated: _templateCreated, + initialKey: _delegate.route.templateKey, ); /// An accepted create only invalidates Pipelines; the list is re-read and the @@ -183,6 +201,8 @@ class _PipelinesAppState extends State { server: widget.server, refreshToken: _pipelinesRefresh, onRunStarted: _runStarted, + initialPipelineId: route.pipelineId, + initialVersion: route.version, ), AppDestination.runs: (_) => RunsDestination( session: _session, diff --git a/app/lib/application/pipelines_destination.dart b/app/lib/application/pipelines_destination.dart index 1ca9b8ba..6e653a14 100644 --- a/app/lib/application/pipelines_destination.dart +++ b/app/lib/application/pipelines_destination.dart @@ -19,6 +19,8 @@ class PipelinesDestination extends StatelessWidget { required this.server, this.refreshToken = 0, this.onRunStarted, + this.initialPipelineId, + this.initialVersion = 0, }); final AppSession session; @@ -32,6 +34,10 @@ class PipelinesDestination extends StatelessWidget { /// Receives the run id an accepted launch named; the shell opens that route. final ValueChanged? onRunStarted; + /// The pipeline and pinned version a deep link names. + final int? initialPipelineId; + final int initialVersion; + @override Widget build(BuildContext context) => AnimatedBuilder( animation: session, @@ -67,6 +73,8 @@ class PipelinesDestination extends StatelessWidget { gateway: session.gateway, embedded: true, onRunStarted: onRunStarted, + initialPipelineId: initialPipelineId, + initialVersion: initialVersion, // A reconnect or an accepted template create both advance this counter; // either change re-reads through the mounted controller. syncToken: session.connectionEpoch + refreshToken, diff --git a/app/lib/application/templates_destination.dart b/app/lib/application/templates_destination.dart index 343992ce..eebbbfde 100644 --- a/app/lib/application/templates_destination.dart +++ b/app/lib/application/templates_destination.dart @@ -28,6 +28,7 @@ class TemplatesDestination extends StatelessWidget { required this.server, required this.onBack, this.onCreated, + this.initialKey, }); final AppSession session; @@ -37,6 +38,9 @@ class TemplatesDestination extends StatelessWidget { final VoidCallback onBack; final ValueChanged? onCreated; + /// The template detail the route names, or null for the gallery. + final String? initialKey; + @override Widget build(BuildContext context) { final cupertino = usesCupertinoHost(context); @@ -67,6 +71,7 @@ class TemplatesDestination extends StatelessWidget { gateway: session.gateway, embedded: true, onCreated: onCreated, + initialKey: initialKey, ), ), ], diff --git a/app/lib/features/pipelines/screen.dart b/app/lib/features/pipelines/screen.dart index 3a2eaecf..d4b55191 100644 --- a/app/lib/features/pipelines/screen.dart +++ b/app/lib/features/pipelines/screen.dart @@ -27,6 +27,8 @@ class PipelinesScreen extends StatefulWidget { this.embedded = false, this.syncToken = 0, this.onRunStarted, + this.initialPipelineId, + this.initialVersion = 0, }); final ApiGateway gateway; @@ -42,6 +44,12 @@ class PipelinesScreen extends StatefulWidget { /// the existing run route. The feature never navigates on its own. final ValueChanged? onRunStarted; + /// The pipeline a deep link names, opened after the list read starts. + final int? initialPipelineId; + + /// The pinned version for [initialPipelineId]; 0 means latest. + final int initialVersion; + @override State createState() => _PipelinesScreenState(); } @@ -54,6 +62,11 @@ class _PipelinesScreenState extends State { super.initState(); _controller = PipelinesController(PipelinesRepository(widget.gateway)) ..load(); + final id = widget.initialPipelineId; + if (id != null) { + // The detail read owns its own failure state; the list read continues. + _controller.openPipeline(id, version: widget.initialVersion); + } } @override @@ -67,6 +80,14 @@ class _PipelinesScreenState extends State { // The socket was replaced; re-read through the existing controller so the // selected pipeline and requested version survive the reconnect. _controller.load(); + } else if (oldWidget.initialPipelineId != widget.initialPipelineId || + oldWidget.initialVersion != widget.initialVersion) { + final id = widget.initialPipelineId; + if (id != null) { + _controller.openPipeline(id, version: widget.initialVersion); + } else { + _controller.clearSelection(); + } } } diff --git a/app/lib/features/templates/screen.dart b/app/lib/features/templates/screen.dart index 20bc130d..a23bad26 100644 --- a/app/lib/features/templates/screen.dart +++ b/app/lib/features/templates/screen.dart @@ -50,12 +50,16 @@ class TemplatesScreen extends StatefulWidget { required this.gateway, this.embedded = false, this.onCreated, + this.initialKey, }); final ApiGateway gateway; final bool embedded; final ValueChanged? onCreated; + /// The template detail a deep link names, or null for the gallery. + final String? initialKey; + @override State createState() => _TemplatesScreenState(); } @@ -72,12 +76,16 @@ class _TemplatesScreenState extends State { @override void initState() { super.initState(); + _selectedKey = widget.initialKey; unawaited(_load()); } @override void didUpdateWidget(TemplatesScreen oldWidget) { super.didUpdateWidget(oldWidget); + if (oldWidget.initialKey != widget.initialKey) { + _selectedKey = widget.initialKey; + } if (oldWidget.gateway == widget.gateway) return; // A different gateway is a different server: never keep this one's rows or // selection while the replacement is read. diff --git a/app/test/features/pipelines/pipeline_deep_link_test.dart b/app/test/features/pipelines/pipeline_deep_link_test.dart new file mode 100644 index 00000000..188585f9 --- /dev/null +++ b/app/test/features/pipelines/pipeline_deep_link_test.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/pipelines/screen.dart'; + +import 'fixtures.dart'; +import 'test_helpers.dart'; + +/// A deep link opens the pipeline and version it names, not the list. +void main() { + testWidgets('an initial pipeline route opens that pinned detail', ( + tester, + ) async { + final fixture = PipelineFixture(); + final gateway = gatewayFor(fixture); + tester.view.physicalSize = const Size(1100, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.resetPhysicalSize); + addTearDown(tester.view.resetDevicePixelRatio); + + await tester.pumpWidget( + MaterialApp( + home: PipelinesScreen( + gateway: gateway, + initialPipelineId: 1, + initialVersion: 2, + ), + ), + ); + await tester.pumpAndSettle(); + + // The detail is open (not the "Select a pipeline." placeholder), and the + // detail request names the route's pinned version. + expect(find.text('Select a pipeline.'), findsNothing); + expect(find.text('Alpha review'), findsWidgets); + expect( + gateway.callsOf('get_pipeline').where( + (call) => + '${call.fields['pipeline_id']}' == '1' && + '${call.fields['version']}' == '2', + ), + isNotEmpty, + ); + }); +}