Skip to content

refactor: consolidate duplicate navigation code between app and shared modules#14

Merged
garfiec merged 1 commit into
developfrom
refactor/consolidate-navigation
Apr 6, 2026
Merged

refactor: consolidate duplicate navigation code between app and shared modules#14
garfiec merged 1 commit into
developfrom
refactor/consolidate-navigation

Conversation

@garfiec

@garfiec garfiec commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Description:

Problem

The KMP migration duplicated the entire navigation layer into both app/ (Android) and shared/ (iOS/common) — 10 files with near-identical implementations maintained independently. The shared version had KMP-safe improvements (no runBlocking, defensive error handling, CMP resources) while the app version had Android-specific features (tablet layout, deep links, share intents). Changes to one required manual mirroring to
the other.

Solution

Consolidated into a single source of truth in the shared module. The app module now depends on :shared and retains only two thin Android-specific files:

  • LibreChatNavHost.kt — wrapper adding WindowSizeClass branching, deep link handling, and share intent handling
  • TabletLayout.kt — Android-only tablet layout using BackHandler, android.net.Uri, and custom sidebar gesture

MainNavDisplay extracted as a public composable in shared, reused by both the shared PhoneLayout and app's TabletLayout.

firstBlocking expect/actual added to core:common so the shared NavHostViewModel can synchronously read persisted sidebar state on Android (runBlocking) while returning a safe default on iOS.

@garfiec garfiec self-assigned this Apr 5, 2026
@garfiec garfiec force-pushed the refactor/consolidate-navigation branch 2 times, most recently from b792793 to fc82101 Compare April 6, 2026 01:38
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.

1 participant