merge(app): land search-pane
This commit is contained in:
@@ -97,6 +97,15 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
|
||||
/// The saved-schedule list page, opened above Settings.
|
||||
bool get schedulesOpen => _route.kind == AppRouteKind.schedules;
|
||||
|
||||
/// The route the shell renders underneath the transient Search, Templates
|
||||
/// and Schedules pages. Those pages keep the shell mounted, so the route the
|
||||
/// operator last opened there is still the shell's own destination.
|
||||
AppRoute get shellRoute => searchOpen
|
||||
? _searchReturn
|
||||
: templatesOpen || schedulesOpen
|
||||
? _templatesReturn
|
||||
: _route;
|
||||
|
||||
@override
|
||||
AppRoute get currentConfiguration => _route;
|
||||
|
||||
|
||||
@@ -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';
|
||||
@@ -75,6 +76,13 @@ 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 cleared after the detail applies it or when the
|
||||
/// shell leaves that run, so an abandoned hit never replays later.
|
||||
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(
|
||||
@@ -117,6 +125,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
schedulesBuilder: _buildSchedules,
|
||||
builder: _buildShell,
|
||||
);
|
||||
_delegate.addListener(_routeChanged);
|
||||
_config = RouterConfig<AppRoute>(
|
||||
routeInformationParser: const AppRouteParser(),
|
||||
routerDelegate: _delegate,
|
||||
@@ -129,6 +138,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_notifications.dispose();
|
||||
_delegate.removeListener(_routeChanged);
|
||||
_delegate.dispose();
|
||||
if (_ownsProvider) {
|
||||
(_provider as PlatformRouteInformationProvider).dispose();
|
||||
@@ -171,25 +181,65 @@ 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);
|
||||
}
|
||||
|
||||
/// Drops a pending request once the shell leaves the run it names.
|
||||
///
|
||||
/// The mounted detail is the only consumer, and it exists only after the run's
|
||||
/// detail has loaded. Backing out while that read is still pending, or leaving
|
||||
/// a failed detail, would otherwise keep the request for the next unrelated
|
||||
/// visit to the same run. Search/Templates/Schedules pages above the run keep
|
||||
/// it, because the shell route underneath them still names that run.
|
||||
void _routeChanged() {
|
||||
final pending = _pendingRunSearch;
|
||||
if (!mounted || pending == null) return;
|
||||
final route = _delegate.shellRoute;
|
||||
if (route.kind == AppRouteKind.runs && route.runId == pending.runId) return;
|
||||
setState(() => _pendingRunSearch = null);
|
||||
}
|
||||
|
||||
/// The Templates page above Settings. Closing it restores the same Settings
|
||||
@@ -243,17 +293,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,
|
||||
|
||||
Reference in New Issue
Block a user