Skip to content

fix(router): Missing platform default route information#90

Merged
definev merged 8 commits into
mainfrom
fix/information-provider
Feb 27, 2026
Merged

fix(router): Missing platform default route information#90
definev merged 8 commits into
mainfrom
fix/information-provider

Conversation

@definev
Copy link
Copy Markdown
Owner

@definev definev commented Feb 27, 2026

This pull request updates the way the initial route URI is resolved in the Coordinator class to handle edge cases more robustly. The main improvement is the introduction of a new private method that ensures the initial route is set correctly, even when the platform's default route is empty.

Routing improvements:

  • Added a private _resolveInitialUri method to Coordinator to handle cases where the platform's default route is empty, ensuring the initial route falls back to / or uses the provided initialRoutePath as appropriate.
  • Updated the initialization of routeInformationProvider to use the new _resolveInitialUri method for determining the initial URI.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zenrouter Ready Ready Preview, Comment Feb 27, 2026 10:20am

…initial URI resolution logic, including a fix for empty path checks and streamlining its constructor.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 27, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (682d7f4) to head (f88d4bb).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #90   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        16    +1     
  Lines          597       610   +13     
=========================================
+ Hits           597       610   +13     
Flag Coverage Δ
zenrouter 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves initial route resolution for Coordinator by introducing a custom RouteInformationProvider that derives the initial URI from the platform default route name and the coordinator’s initialRoutePath, aiming to handle empty-platform-route edge cases more robustly.

Changes:

  • Added CoordinatorRouteInformationProvider with resolveInitialUri logic and accompanying tests.
  • Switched Coordinator.routeInformationProvider to use the new provider.
  • Bumped package version to 2.0.1 and updated CHANGELOG.md.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/zenrouter/lib/src/coordinator/route_information_provider.dart New provider to compute initial RouteInformation.uri using platform default route + coordinator initial route.
packages/zenrouter/lib/src/coordinator/base.dart Replaces the default PlatformRouteInformationProvider with CoordinatorRouteInformationProvider.
packages/zenrouter/lib/zenrouter.dart Exports the new provider as part of the public API.
packages/zenrouter/test/coordinator/route_information_provider_test.dart Adds tests for provider behavior and resolveInitialUri edge cases.
packages/zenrouter/test/coordinator/restoration_test.dart Minor cleanup to remove an unused local variable.
packages/zenrouter/pubspec.yaml Version bump to 2.0.1.
packages/zenrouter/CHANGELOG.md Adds 2.0.1 release notes describing the change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/zenrouter/lib/src/coordinator/route_information_provider.dart Outdated
Comment thread packages/zenrouter/lib/src/coordinator/base.dart Outdated
Comment on lines 236 to +237
late final RouteInformationProvider routeInformationProvider =
PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(
uri: initialRoutePath ?? Uri.parse('/'),
),
);
CoordinatorRouteInformationProvider(coordinator: this);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions adding a private _resolveInitialUri method on Coordinator, but the implementation introduces CoordinatorRouteInformationProvider.resolveInitialUri instead. Please update the PR description (or move the helper onto Coordinator if that was the intent) so the documentation matches the actual change.

Copilot uses AI. Check for mistakes.
@@ -1,3 +1,7 @@
## 2.0.1
- **Fix**: Revert `hasEmptyPath` back to `pathSegments.isEmpty` in `resolveInitialUri` for correct path empty checks.
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG entry says hasEmptyPath was reverted back to pathSegments.isEmpty in resolveInitialUri, but the current implementation still uses hasEmptyPath (for the empty-path normalization branch). Please adjust the wording to match what the code actually does so readers aren’t misled.

Suggested change
- **Fix**: Revert `hasEmptyPath` back to `pathSegments.isEmpty` in `resolveInitialUri` for correct path empty checks.
- **Fix**: Correct empty-path normalization logic in `resolveInitialUri` to ensure accurate empty-path checks.

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +167
'returns "/" when platformRouteName is invalid and initialUri is provided',
() {
final initialUri = Uri.parse('/initial');
final result = CoordinatorRouteInformationProvider.resolveInitialUri(
'::invalid::',
initialUri,
);
expect(result.toString(), equals('/'));
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test asserts that an invalid platformRouteName causes resolveInitialUri to return '/' even when an initialUri is provided. That seems inconsistent with the goal of falling back to initialRoutePath when the platform default route is missing/invalid. If resolveInitialUri is updated to prefer initialUri when parsing fails, update this expectation accordingly.

Suggested change
'returns "/" when platformRouteName is invalid and initialUri is provided',
() {
final initialUri = Uri.parse('/initial');
final result = CoordinatorRouteInformationProvider.resolveInitialUri(
'::invalid::',
initialUri,
);
expect(result.toString(), equals('/'));
'returns initialUri when platformRouteName is invalid and initialUri is provided',
() {
final initialUri = Uri.parse('/initial');
final result = CoordinatorRouteInformationProvider.resolveInitialUri(
'::invalid::',
initialUri,
);
expect(result, equals(initialUri));

Copilot uses AI. Check for mistakes.
definev and others added 3 commits February 27, 2026 17:08
…der.dart

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…der.dart

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@definev definev merged commit 4ecef5d into main Feb 27, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants