feat(app): select a search hit's recorded run section or visit

This commit is contained in:
2026-10-22 15:34:48 +01:00
parent 6b021f1483
commit 133df9301d
7 changed files with 676 additions and 27 deletions
+64 -26
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/runs/ui/run_search_selection.dart';
import '../features/search/domain/search_target.dart';
import '../features/settings/settings_screen.dart';
import 'app.dart';
@@ -65,6 +66,12 @@ class _PipelinesAppState extends State<PipelinesApp> {
/// list once; the run itself is then opened from its route.
int _runsRefresh = 0;
/// One run detail request from Search, delivered through the shell so the
/// mounted run detail can resolve it once the named run's steps have loaded.
/// A field or artifact hit names no addressable URL of its own, so the request
/// is not route state; it is consumed and cleared after it is applied.
RunSearchSelection? _pendingRunSearch;
/// One notification capability for the app: the Runs attention surface
/// publishes live transitions and Settings renders the same permission.
late final NotificationController _notifications = NotificationController(
@@ -145,25 +152,50 @@ class _PipelinesAppState extends State<PipelinesApp> {
/// 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.
///
/// A field or artifact hit has no URL of its own: both open the run and leave
/// a resolved-once request for the mounted detail, which selects the recorded
/// Summary section or visit as soon as that run's steps are available. A
/// sequence or field the run did not record leaves the plain detail.
void _openSearchResult(JsonMap hit) {
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? route;
RunSearchSelection? selection;
switch (resolved.target) {
case SearchPipelineTarget(:final pipelineId):
route = AppRoute.pipeline(pipelineId);
case SearchVersionTarget(:final pipelineId, :final version):
route = AppRoute.pipeline(pipelineId, version: version);
case SearchRunTarget(:final runId):
route = AppRoute.run(runId);
case SearchStepTarget(:final runId, :final stage, :final visit):
route = 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);
: AppRoute.run.stage(runId, stage, visit: visit);
case SearchFieldTarget(:final runId, :final sequence, :final field):
selection = RunSearchSelection(
runId: runId,
sequence: sequence,
field: field,
);
route = AppRoute.run(runId);
case SearchArtifactTarget(:final runId, :final sequence):
if (runId != null) {
selection = RunSearchSelection(runId: runId, sequence: sequence);
route = AppRoute.run(runId);
}
}
if (route == null) return;
setState(() => _pendingRunSearch = selection);
_delegate.goTo(route);
}
/// The mounted run detail applied the pending request; reopening the same run
/// later starts from its plain detail and never replays the search selection.
void _runSearchConsumed() {
if (!mounted || _pendingRunSearch == null) return;
setState(() => _pendingRunSearch = null);
}
/// The Templates page above Settings. Closing it restores the same Settings
@@ -217,17 +249,23 @@ class _PipelinesAppState extends State<PipelinesApp> {
initialVersion: route.version,
initialStageKey: route.stageKey,
),
AppDestination.runs: (_) => RunsDestination(
session: _session,
server: widget.server,
initialRunId: route.runId,
initialStageKey: route.stageKey,
initialVisit: route.visit,
initialDecide: route.decide,
listRefreshToken: _runsRefresh,
notifications: _notifications,
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
onBack: () => _delegate.goTo(AppRoute.runs),
// The one place a field or artifact hit's selection can be resolved: the
// run detail owns the recorded visit and Summary section.
AppDestination.runs: (_) => RunSearchSelectionScope(
selection: _pendingRunSearch,
onConsumed: _runSearchConsumed,
child: RunsDestination(
session: _session,
server: widget.server,
initialRunId: route.runId,
initialStageKey: route.stageKey,
initialVisit: route.visit,
initialDecide: route.decide,
listRefreshToken: _runsRefresh,
notifications: _notifications,
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
onBack: () => _delegate.goTo(AppRoute.runs),
),
),
AppDestination.chat: (_) => ChatDestination(
session: _session,