feat(app): open pipeline and template deep links and route search results

This commit is contained in:
2026-10-22 09:58:09 +01:00
parent edfcfb0bc9
commit 7aa7007aee
8 changed files with 119 additions and 7 deletions
+25 -5
View File
@@ -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<PipelinesApp> {
),
);
/// 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<PipelinesApp> {
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<PipelinesApp> {
server: widget.server,
refreshToken: _pipelinesRefresh,
onRunStarted: _runStarted,
initialPipelineId: route.pipelineId,
initialVersion: route.version,
),
AppDestination.runs: (_) => RunsDestination(
session: _session,
@@ -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<int>? 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,
@@ -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<JsonMap>? 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,
),
),
],
+21
View File
@@ -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<int>? 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<PipelinesScreen> createState() => _PipelinesScreenState();
}
@@ -54,6 +62,11 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
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<PipelinesScreen> {
// 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();
}
}
}
+8
View File
@@ -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<JsonMap>? onCreated;
/// The template detail a deep link names, or null for the gallery.
final String? initialKey;
@override
State<TemplatesScreen> createState() => _TemplatesScreenState();
}
@@ -72,12 +76,16 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
@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.