Merge branch 'main' into flutter/pipeline-stage-deeplink

This commit is contained in:
2026-10-22 11:42:14 +01:00
31 changed files with 2187 additions and 43 deletions
+28 -6
View File
@@ -11,13 +11,24 @@ class AppRouteParser extends RouteInformationParser<AppRoute> {
@override
Future<AppRoute> parseRouteInformation(
RouteInformation routeInformation,
) async => AppRoute.parse(routeInformation.uri.path);
) async => AppRoute.parse(routeLocation(routeInformation.uri));
@override
RouteInformation restoreRouteInformation(AppRoute configuration) =>
RouteInformation(uri: Uri(path: configuration.path));
// The route's path already carries its query (`?visit=N`, `?action=…`).
// Parsing it keeps that query a query instead of percent-encoding the
// `?` into the path, which would make a reload read one bogus key.
RouteInformation(uri: Uri.parse(configuration.path));
}
/// The app-relative location of [uri]: its path plus query, without origin.
///
/// [AppRoute.parse] understands this form, so a browser location such as
/// `/runs/7/stage/plan?visit=1` keeps the query instead of losing it to
/// `Uri.path`. A fragment is not part of an app route.
String routeLocation(Uri uri) =>
uri.hasQuery ? '${uri.path}?${uri.query}' : uri.path;
/// Owns the app's current route and builds the shell for it.
///
/// Route changes made by the operator go through [goTo]; the Router reports
@@ -217,10 +228,21 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
/// The location a web launch starts at, or the Pipelines list elsewhere.
///
/// Only the path is meaningful to [AppRouteParser]; the origin stays out of
/// route configuration so a serialised route is always app-relative.
/// The origin stays out of route configuration so a serialised route is always
/// app-relative, but the path and its query are both part of the route: a
/// launch at `/runs/7/stage/plan?visit=1` must open exactly that visit.
RouteInformation initialRouteInformation() {
if (!kIsWeb) return RouteInformation(uri: Uri(path: '/pipelines'));
final path = Uri.base.path;
return RouteInformation(uri: Uri(path: path.isEmpty ? '/' : path));
return routeInformationForLocation(Uri.base);
}
/// The app-relative route information for a browser [base] location.
///
/// Exposed for the boot test: [Uri.base] cannot be changed inside a widget
/// test, so the web launch seam is exercised through this function.
@visibleForTesting
RouteInformation routeInformationForLocation(Uri base) {
final path = base.path.isEmpty ? '/' : base.path;
final query = base.hasQuery ? '?${base.query}' : '';
return RouteInformation(uri: Uri.parse('$path$query'));
}
+8 -3
View File
@@ -83,10 +83,13 @@ class _PipelinesAppState extends State<PipelinesApp> {
);
// A malformed or unknown boot path renders Pipelines, so make the address
// bar agree with the rendered destination instead of showing a dead link.
final initial = AppRoute.parse(_provider.value.uri.path);
if (_provider.value.uri.path != initial.path) {
// The comparison includes the query: `?visit=N` is part of the route, while
// a dropped or unknown query is canonicalised away.
final location = routeLocation(_provider.value.uri);
final initial = AppRoute.parse(location);
if (location != initial.path) {
_provider.routerReportsNewRouteInformation(
RouteInformation(uri: Uri(path: initial.path)),
RouteInformation(uri: Uri.parse(initial.path)),
type: RouteInformationReportingType.neglect,
);
}
@@ -218,6 +221,8 @@ class _PipelinesAppState extends State<PipelinesApp> {
session: _session,
server: widget.server,
initialRunId: route.runId,
initialStageKey: route.stageKey,
initialVisit: route.visit,
listRefreshToken: _runsRefresh,
notifications: _notifications,
onRunSelected: (id) => _delegate.goTo(AppRoute.run(id)),
+11
View File
@@ -19,6 +19,8 @@ class RunsDestination extends StatelessWidget {
required this.session,
required this.server,
this.initialRunId,
this.initialStageKey,
this.initialVisit,
this.onRunSelected,
this.onBack,
this.listRefreshToken = 0,
@@ -28,6 +30,13 @@ class RunsDestination extends StatelessWidget {
final AppSession session;
final ServerEndpoint server;
final int? initialRunId;
/// The stage key and optional visit a `/runs/:id/stage/:key[?visit=N]` route
/// names. They reach the detail only through [RunsScreen]; the destination
/// does not read the route itself.
final String? initialStageKey;
final int? initialVisit;
final ValueChanged<int>? onRunSelected;
final VoidCallback? onBack;
@@ -73,6 +82,8 @@ class RunsDestination extends StatelessWidget {
Widget _runsScreen() => RunsScreen(
gateway: session.gateway,
initialRunId: initialRunId,
initialStageKey: initialStageKey,
initialVisit: initialVisit,
syncToken: session.connectionEpoch,
listRefreshToken: listRefreshToken,
notifications: notifications,