Skip to content

feat: implement unified deep link routing for Kotlin Multiplatform#4910

Merged
jamesarich merged 4 commits intomainfrom
feat/deeplinks
Mar 25, 2026
Merged

feat: implement unified deep link routing for Kotlin Multiplatform#4910
jamesarich merged 4 commits intomainfrom
feat/deeplinks

Conversation

@jamesarich
Copy link
Copy Markdown
Collaborator

This commit introduces a centralized deep link handling system and a type-safe DeepLinkRouter to support navigation and resource importing across Android and Desktop platforms. It transitions the project toward a more robust navigation architecture using Navigation 3.

Key Changes:

  • Core Navigation & Routing:

    • Introduced DeepLinkRouter in core:navigation to parse Meshtastic URIs into type-safe NavKey backstacks.
    • Supported comprehensive route mapping for share, messages, nodes, settings, map, and firmware segments.
    • Added logic to synthesize parent hierarchies (e.g., automatically adding NodesGraph when deep linking to a NodeDetail).
  • Unified UI Deep Link Handling:

    • Consolidated handleNavigationDeepLink and handleScannedUri into a single handleDeepLink method within UIViewModel.
    • Updated MainActivity (Android) and Main.kt (Desktop) to use the new unified handler.
    • Implemented a LaunchedEffect in MainScreen and DesktopMainScreen to collect and apply deep link navigation events to the NavBackStack.
  • Feature Integration:

    • Refactored feature:node and feature:messaging to propagate onHandleDeepLink callbacks through adaptive and list screens.
    • Removed redundant contact/channel request logic from NodeListViewModel, moving responsibility to the shared UIViewModel.
    • Updated NodesNavigation and desktopNavGraph to support deep link handling via dependency injection.
  • Infrastructure & Dependencies:

    • Added navigation3-ui and kermit dependencies to core:navigation.
    • Added navigation3-ui to core:ui.
    • Renamed internal parameters from scannedUri to deepLink across various composables for consistency.

This commit introduces a centralized deep link handling system and a type-safe `DeepLinkRouter` to support navigation and resource importing across Android and Desktop platforms. It transitions the project toward a more robust navigation architecture using Navigation 3.

### Key Changes:

- **Core Navigation & Routing:**
  - Introduced `DeepLinkRouter` in `core:navigation` to parse Meshtastic URIs into type-safe `NavKey` backstacks.
  - Supported comprehensive route mapping for `share`, `messages`, `nodes`, `settings`, `map`, and `firmware` segments.
  - Added logic to synthesize parent hierarchies (e.g., automatically adding `NodesGraph` when deep linking to a `NodeDetail`).

- **Unified UI Deep Link Handling:**
  - Consolidated `handleNavigationDeepLink` and `handleScannedUri` into a single `handleDeepLink` method within `UIViewModel`.
  - Updated `MainActivity` (Android) and `Main.kt` (Desktop) to use the new unified handler.
  - Implemented a `LaunchedEffect` in `MainScreen` and `DesktopMainScreen` to collect and apply deep link navigation events to the `NavBackStack`.

- **Feature Integration:**
  - Refactored `feature:node` and `feature:messaging` to propagate `onHandleDeepLink` callbacks through adaptive and list screens.
  - Removed redundant contact/channel request logic from `NodeListViewModel`, moving responsibility to the shared `UIViewModel`.
  - Updated `NodesNavigation` and `desktopNavGraph` to support deep link handling via dependency injection.

- **Infrastructure & Dependencies:**
  - Added `navigation3-ui` and `kermit` dependencies to `core:navigation`.
  - Added `navigation3-ui` to `core:ui`.
  - Renamed internal parameters from `scannedUri` to `deepLink` across various composables for consistency.

Signed-off-by: James Rich <[email protected]>
This commit introduces support for modern RESTful deep links (App Links) via `meshtastic.org` and cleans up the routing logic to maintain a consistent path structure.

Specific changes include:
- **AndroidManifest Updates**: Added a new `intent-filter` with `autoVerify="true"` to handle `http/https` links for `meshtastic.org`. Registered path prefixes for `share`, `connections`, `map`, `messages`, `quickchat`, `nodes`, `settings`, `channels`, and `firmware`.
- **Router Refactoring**: Simplified `DeepLinkRouter.kt` by removing redundant path aliases like `conversations`, `contacts`, and the singular `node` to favor a more standardized RESTful routing pattern.
- **Message Routing**: Updated the `routeContacts` logic to remove the deprecated `conversations` segment.

Signed-off-by: James Rich <[email protected]>
…ling

This commit enhances the navigation system to support RESTful path patterns for deep linking and unifies URI handling within the `UIViewModel`. These changes allow for more descriptive, hierarchical routing across the multiplatform application.

Specific changes include:
- **RESTful Deep Linking**: Updated `DeepLinkRouter` to support modern path patterns (e.g., `/nodes/{id}`, `/messages/{key}`, `/settings/{id}/{page}`) alongside legacy query-parameter URIs.
- **Unified URI Dispatching**: Refactored `UIViewModel.handleDeepLink` to first attempt typed navigation via `DeepLinkRouter` before falling back to legacy data import (contacts/channels).
- **Navigation Documentation**: Updated `AGENTS.md`, `GEMINI.md`, `README.md`, and the DI/Navigation playbook to reflect the shift toward RESTful multiplatform routing.
- **Code Maintenance**:
    - Added comprehensive documentation to `MeshtasticCommonAppSetup` regarding its role in global UI logic and deep link interception.
    - Improved Kdoc for `DeepLinkRouter` and `UIViewModel` to clarify deep link orchestration.

Signed-off-by: James Rich <[email protected]>
Signed-off-by: James Rich <[email protected]>
@github-actions github-actions bot added the enhancement New feature or request label Mar 25, 2026
@jamesarich jamesarich added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit b0e91a3 Mar 25, 2026
8 checks passed
@jamesarich jamesarich deleted the feat/deeplinks branch March 25, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant