Librechat-Mobile / app
CLAUDE.md106 starsChanged 59 days agoMITView on GitHub
Single Activity architecture. MainActivity is the sole entry point. LibreChatNavHost (in this module) is the Android-specific entry point. It wraps the shared module's LibreChatNavHost via a content lambda, adding: - Deep link handling (librechat://conversation/{conversationId}) - Share intent routing (addresses the share to the chat on screen; navigates to NewChat first if the user is not on one — see Share Intents below) - Tablet layout branching based on WindowSizeClass The shared module owns the core navigation: Navigator, NavHostViewModel, MainNavDisplay, PhoneLayout,…
In this repository9 other files it gives its agents.
- build-logic/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .github/CLAUDE.mdCLAUDE.md
- shared/CLAUDE.mdCLAUDE.md
- audit-depsSkill
- audit-i18nSkill
- release-highlightsSkill
- sync-upstreamSkill
- update-web-assetsSkill
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 37
Start destination is NewChat if logged in, ServerUrl otherwise
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
App Module
Single Activity architecture. MainActivity is the sole entry point.
Navigation
LibreChatNavHost (in this module) is the Android-specific entry point. It wraps the shared module's LibreChatNavHost via a content lambda, adding:
- Deep link handling (
librechat://conversation/{conversationId}) - Share intent routing (addresses the share to the chat on screen; navigates to NewChat first if the user is not on one — see Share Intents below)
- Tablet layout branching based on
WindowSizeClass
The shared module owns the core navigation: Navigator, NavHostViewModel, MainNavDisplay, PhoneLayout, TabletLayout, sidebar/drawer composables, and all feature entry providers. See shared/CLAUDE.md for details.
Layout Modes
- Phone: Delegates to shared
PhoneLayout—ModalNavigationDrawersidebar-first pattern. - Tablet (600dp+ width): Delegates to shared
TabletLayout— persistent side panel that pushes the content aside, with swipe gesture and back handling. - Android picks the layout here from
WindowSizeClass; iOS gets the same two layouts from the shared host, which reads the window width against the same 600dp line. Change the breakpoint in both places. - iOS switches layouts in place (rotation, Split View, fold), so both layouts must place the one
rememberMovableNavDisplayinstance — aMainNavDisplaythat leaves the composition clears every back-stack entry's ViewModels. Keep the layout choice in the host's own composition rather than a subcomposition such asBoxWithConstraints— only the single-composition case is covered, byMovableNavDisplayTest.
Feature modules provide entries via EntryProviderScope<NavKey> extensions (e.g., authEntries(), chatEntries()). Navigation is driven by onNavigate: (NavKey) -> Unit and onBack: () -> Unit lambdas — feature modules never receive NavBackStack directly.
Android-Only Files in This Module
LibreChatNavHost.kt— Thin wrapper adding deep links, share intents, and tablet/phone branching
Top-Level Destinations
Top-level routes: NewChat (Chat), Conversations, AgentMarketplace (Agents), Files, SettingsTabbed (Settings).
Conversations are integrated into the drawer body. Agents, Files, and Settings are accessible via drawer footer links. All routes are registered in the shared MainNavDisplay entry provider.
Auth & Session
NavHostViewModel(in shared) observes auth state viaisLoggedInflow- Start destination is
NewChatif logged in,ServerUrlotherwise sessionExpiredflow triggers nav to auth flow with full back stack clear- Drawer gestures are hidden during auth flow
Deep Linking
- Scheme
librechat://. Hosts:conversation/{id},artifact/{uuid},oauth(cookie-consumed; see below). - Single source of truth:
DeepLinks.resolve()in:shared/commonMainmaps a URI to aDeepLinkResolution(Route(target, requiresAuth)/Consumed/None). Add a new deep link by adding one branch there — do NOT reintroduce a per-host allowlist here. MainActivity.handleDeepLink()calls the resolver to accept/drop the intent (via the AndroidUri → DeepLinkUriadapter inDeepLinkUriAdapter.kt), then forwards to this module'sLibreChatNavHost, which resolves again to place the target on the back stack.requiresAuthlinks (conversation) redirect to login when logged out; non-auth links (device-scoped artifact) open logged-out.oauthisConsumed— sign-in completes in the app's own WebView, so nothing arrives this way any more; the mapping survives so a link from an older build still brings the app forward rather than being dropped.onNewIntenthandles deep links when the app is already running.
Share Intents
MainActivity.handleShareIntent()only stages the payload onShareIntentConsumer; it does not deliver it. This module'sLibreChatNavHostthen readsnavigator.currentRouteand callsdispatchTo(conversationId)—nullfor theNewChatlanding — navigating there first if the user is not on a chat at all.- A share must be addressed, never broadcast. Several
ChatViewModels are alive at once (the landing sits in the back stack beneath an openChat), so an unaddressed share is claimed by whichever one collects first — usually the invisible landing, which put the user's text in a composer they weren't looking at.ShareIntentConsumer.sharesFor(conversationId)gives each screen its own channel; the nav host is the only place that knows both that a share is waiting and which chat is on screen, so addressing lives there. - Delivery is driven off
ShareIntentConsumer.undelivered, not an activity-held counter: the launch intent is processed only on a fresh start, so a recreation during the theme/locale warm-up gate would otherwise strand a share nothing had addressed yet.
Connectivity
ConnectivityObserverinjected intoMainActivity- Offline banner animates in/out at top of screen when connection is lost
Dependencies
This module depends on :shared, all :core:*, and all :feature:* modules.
It applies convention plugins: librechat.mobile.application, librechat.mobile.compose, librechat.mobile.koin.
Server Banners
GET /api/bannerreturns one banner object, or a 200 with an empty body and noContent-Type— never an array.BannerApireads the raw body for that reason; anything else still throws, so a proxy answering for the API can't read as "no banner configured"NavHostViewModel(shared) fetches the banner viaBannerRepositoryon init, on account switch and on auth-complete. There is no timer- The server applies the
displayFrom/displayTowindow and filterstype: 'banner'itself, so the client does neither — a client-side re-check can only ever subtract from the server's decision, and did so on device-clock skew - Dismissal is resolved in
BannerStateHolder, not the UI: it nulls the banner and records a (serverId, bannerId) key, in-memory for the process. Both halves of that key are load-bearing and pull opposite ways — keyed by banner alone, a fleet seeding one bannerId across its servers delivers the next server's banner pre-dismissed; cleared on switch, dismissing A's banner and switching away and back brings A's right back BannerStateHolder.clearForAccountChange()drops the banner (scoped to a deployment) on switch and sign-out. It deliberately does not touch dismissalsBannerDisplaycomposable shown at top of content in bothPhoneLayoutandTabletLayout(both shared). It takes a nullable banner and decides visibility itself — hoisting the null check to the callers would add/remove it from the tree and kill its enter/exit animation- One visual treatment, from
secondaryContainer/onSecondaryContainer. Do not re-introduce atype-keyed palette or hardcoded hex: the server only ever sendstype: "banner", and fixed colours ignore the accent seed and break in dark mode - A
persistablebanner hides the dismiss control (matching web); a banner with nobannerIdis not rendered at all, since nothing could ever remove it
Preset Navigation
PresetManagerroute registered inSettingsNavigation.ktPresetManagerScreenaccessible from Settings → Chat section- Navigation wired through shared
MainNavDisplayentry provider, accessible from both phone and tablet layouts
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

