Skip to content

Chore: Deep link and initialization improvements#3010

Merged
5 commits merged into
developfrom
chore/deep-link-and-initialization-improvements
Jun 29, 2026
Merged

Chore: Deep link and initialization improvements#3010
5 commits merged into
developfrom
chore/deep-link-and-initialization-improvements

Conversation

@StylianosGakis

@StylianosGakis StylianosGakis commented Jun 29, 2026

Copy link
Copy Markdown
Member

Do some small improvements around the initialization and refreshing of isOwnTask so that if it changes it properly gets set in the backstackController

Also make deep links "expire" in case they were not acted upon in a short period of time. If we somehow stash a deep link for a long time and only later login, we can safely discard that.

Add some logs around the initialization and make those tracking logs VERBOSE
Verbose logs are skipped in datadog and firebase, only shown locally

The 'Up arrow tracking logs' commit added logcat calls in BackstackController
that run during BackstackControllerTest and DeepLinkNavigationTest, where the
default NoLog logger throws. Install TestLogcatLoggingRule in both so the suite
stays green.
Two defensive fixes for the report of a 'deep-link stack' (Home shown with a
back arrow instead of the nav bar) appearing after a plain icon launch + login,
with no deep-link action by the user.

1. Snapshot-back BackstackController.isOwnTask. The lone-deep-link chrome derives
   the back-arrow-vs-nav-bar decision partly from isTaskRoot, previously read via
   a non-observable () -> Boolean lambda. A normal lone Home then renders as a
   deep-link stack whenever isTaskRoot is false, and could latch that stale
   reading. isOwnTask is now a mutableStateOf-backed Boolean, refreshed from
   isTaskRoot in onCreate and on every onResume, so the chrome recomposes and
   self-corrects.

2. Time-bound the persisted pendingDeepLink. It survives process death (for the
   mid-OTP case) but was never age-bounded, so a link stashed long ago could
   bleed into an unrelated later login as a lone stack. It now carries a stash
   timestamp; on restore a link older than 30 minutes (or with no timestamp, or a
   backwards clock) is dropped.

Adds regression tests for the isOwnTask toggle, the pending-timestamp lifecycle,
and the 30-minute freshness boundary.
Follow-up cleanups on the two defensive fixes:

- Seed BackstackController.isOwnTask from the Activity's isTaskRoot at first
  construction (threaded through NavRetainedViewModel) instead of relying on the
  true default and the onCreate wiring running before any read. onResume remains
  the authoritative refresh; the default stays only for unit tests.
- Collapse the isOwnTask backing field + explicit accessors into a single
  'by mutableStateOf' delegate.
- In NavigationStateBridge.restoreAndPersist, sample the clock once (was twice,
  letting the logged age disagree with the freshness decision) and use takeIf.
- Express the pending-deep-link window as 30.minutes (kotlin.time.Duration), the
  repo idiom, instead of raw millis arithmetic.
Verbose logs are skipped in datadog and firebase, only shown locally
@StylianosGakis StylianosGakis requested a review from a team as a code owner June 29, 2026 10:22
@StylianosGakis StylianosGakis closed this pull request by merging all changes into develop in b4d45f6 Jun 29, 2026
@StylianosGakis StylianosGakis deleted the chore/deep-link-and-initialization-improvements branch June 29, 2026 14:52
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.

2 participants