Skip to content

Ignore the launching Intent's deep link when setting the graph - #224

Merged
mbarta merged 3 commits into
mainfrom
launch-intent-navigation
Nov 5, 2026
Merged

mbarta merged 3 commits into
mainfrom
launch-intent-navigation

Conversation

@mbarta

@mbarta mbarta commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Setting a NavController graph makes the Navigation library navigate to the launching Intent's deep link: the destination and arguments in its deep-link extras, or the destination whose deep link matches its data. Hotwire picks its start destination from the configuration's start location and navigates through its own visits, so it never needs that.

NavigatorHost now sets a graph only while the Activity holds a copy of its launching Intent without the data and the deep-link extras, then gives the Activity its launching Intent back unchanged.

  • During NavHostFragment.onCreate(), which sets a graph supplied through arguments or XML, the Activity holds an empty Intent, since that graph can match a deep link by action alone.
  • App code that runs while the graph is set, like a FragmentFactory or a destination listener, still sees the Intent's action and the app's own extras.
  • If the extras can't be read, the Activity holds an empty Intent instead.

This replaces ensureDeeplinkStartLocationValid(), which rewrote parts of the launching Intent's extras. That function was public for tests, so a subclass that called it needs to drop the call.

The tests launch a real NavigatorHost with deep-link data or deep-link extras and check that only the start destination opens, that the Activity's Intent is unchanged, and what app code sees while the graph is set. The navigation tests fail on main, where the launching Intent opens the bottom sheet destination.

🤖 Generated with Claude Code

Milan Barta and others added 3 commits November 5, 2026 15:43
Setting a NavController graph makes the Navigation library navigate to the
launching Intent's deep link: the destination and arguments in its deep-link
extras, or the destination whose deep link matches its data. Hotwire navigates
from the configuration's start location and its own visits, so NavigatorHost
now sets the graph while the Activity holds an empty Intent, then gives the
Activity its launching Intent back unchanged.

This replaces ensureDeeplinkStartLocationValid(), which rewrote parts of the
launching Intent's extras and isn't needed anymore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Setting the graph creates the start fragment and calls destination listeners
right away, so app code saw an empty Intent in that moment. The Activity now
holds a copy of its launching Intent without the data and the deep-link extras,
so the action and the app's own extras stay visible. If the extras can't be
read, it falls back to an empty Intent.

NavHostFragment.onCreate() sets a graph supplied through its arguments or XML,
so the same copy is in place while it runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A graph supplied through NavHostFragment's arguments or XML can match a deep
link by the Intent's action alone, so the copy that keeps the action isn't
enough there. super.onCreate() now runs while the Activity holds an empty
Intent. Hotwire's own graph only has deep links by uri, so its setup keeps
the copy with the action and the app's extras.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mbarta
mbarta marked this pull request as ready for review November 5, 2026 15:52
@mbarta
mbarta merged commit 1257b77 into main Nov 5, 2026
1 check passed
@mbarta
mbarta deleted the launch-intent-navigation branch November 5, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant