Skip to content

Enhance Android app actions, deep linking, and SvelteNavigate integration#2353

Open
hahn-kev wants to merge 6 commits into
developfrom
add-app-shortcut-home
Open

Enhance Android app actions, deep linking, and SvelteNavigate integration#2353
hahn-kev wants to merge 6 commits into
developfrom
add-app-shortcut-home

Conversation

@hahn-kev

@hahn-kev hahn-kev commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

This adds an android app shortcut to launch the home page. Test different race conditions between starting the app fresh, vs when the app is already running.

image

Share debug log will trigger sharing the logs, this should bypass any bugs with the UI of the app.

@github-actions github-actions Bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

UI unit Tests

  1 files  ±0   62 suites  ±0   29s ⏱️ -3s
186 tests ±0  186 ✅ ±0  0 💤 ±0  0 ❌ ±0 
258 runs  ±0  258 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 102f66b. ± Comparison against base commit 78e3f97.

♻️ This comment has been updated with latest results.

@argos-ci

argos-ci Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jun 17, 2026, 10:37 AM

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

C# Unit Tests

165 tests  ±0   165 ✅ ±0   20s ⏱️ -2s
 23 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 102f66b. ± Comparison against base commit 78e3f97.

♻️ This comment has been updated with latest results.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b302a2c1-f383-431a-b8a5-fe0344845057

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces app shortcuts for MAUI that allow native app actions (and Android intent actions) to override the startup URL, refactors app initialization to separate preference-loading from app construction, exposes Svelte routing to native hosts via a global JavaScript bridge, and adds an idempotency guard to the IL patcher.

Changes

App Shortcuts and Native Startup URL Routing

Layer / File(s) Summary
Shortcut system definition
backend/FwLite/FwLiteMaui/Shortcuts.cs
Shortcuts static class centralizes shortcut IDs and URL mappings. Exports Home constant, a Declarations list for system UI, and TryGetUrl helper to resolve IDs to URLs.
Frontend Svelte navigation bridge
frontend/viewer/src/lib/services/service-declaration.ts, frontend/viewer/src/main.ts
Global Lexbox interface adds SvelteNavigate function type. main.ts imports Svelte's navigate and exposes it as window.lexbox.SvelteNavigate for host environments to trigger Svelte route changes.
App startup refactoring and URL override mechanism
backend/FwLite/FwLiteMaui/App.xaml.cs, backend/FwLite/FwLiteMaui/MainPage.xaml.cs
App removes IPreferencesService dependency, adds OverrideStartupUrl static property, and introduces LoadAppUrl method. MainPage constructor now accepts IPreferencesService, loads persisted last-URL preference, sets initial StartPath conditionally from override/preference/default during BlazorWebViewInitialized, and implements LoadAppUrl to update StartPath and dispatch JavaScript navigation via SvelteNavigate.
Android app-action intent handling and lifecycle forwarding
backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs
Activity attribute enables resizeable activity and expanded configuration changes. IntentFilter added for Platform.Intent.ActionAppAction. OnCreate detects action intents, resolves shortcut IDs to URLs via Shortcuts.TryGetUrl, and sets App.OverrideStartupUrl. OnResume and OnNewIntent overrides forward lifecycle events to Platform handlers.
Shortcut registration in app startup
backend/FwLite/FwLiteMaui/MauiProgram.cs
CreateMauiApp iterates Shortcuts.Declarations, registers each via essentialsBuilder.AddAppAction, and installs OnAppAction handler to resolve action IDs to URLs and dispatch UI-thread execution to App.LoadAppUrl.
IL patcher idempotency guard
backend/FwLite/FwLiteMaui/build/Linq2DbCctorPatcher/Program.cs
Linq2Db .cctor patcher detects already-patched state (single ret instruction) and exits without re-patching, ensuring idempotency on repeated runs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes


Possibly related PRs

  • sillsdev/languageforge-lexbox#2190: Refactors the same MAUI app startup URL flow by introducing OverrideStartupUrl and LoadAppUrl mechanism to replace earlier preference-service wiring.
  • sillsdev/languageforge-lexbox#2158: Introduces IPreferencesService cross-platform service that this PR now depends on in MainPage constructor to load persisted last-URL preference.
  • sillsdev/languageforge-lexbox#2285: Modifies the same MainActivity system-bar layout and restoration flow that this PR extends with app-action intent handling.

Suggested labels

📦 Lexbox


Suggested reviewers

  • myieye

Poem

🐰 A rabbit hops through shortcuts bright,
With startup URLs taking flight—
Android intents now route with care,
Svelte navigation fills the air!
Each tap, each intent, finds its way home. 🏡

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately summarizes the main changes: adding Android app actions, implementing deep linking, and integrating SvelteNavigate across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description is related to the changeset, describing the addition of an Android app shortcut to launch the home page with testing guidance.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-app-shortcut-home

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs (1)

26-33: ⚡ Quick win

Avoid depending on MAUI's internal app-action extra name here.

Line 29 keys cold-start routing off "EXTRA_XE_APP_ACTION_ID", which the comment already identifies as an internal MAUI detail. If that extra changes, shortcut routing will diverge by launch state: warm starts still go through OnAppAction, but cold starts fall back to the saved/default URL. Prefer a public constant/API if MAUI exposes one, or isolate this behind a single compatibility shim plus a version-locked verification test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs` around lines 26
- 33, Remove the hardcoded internal extra name and centralize app-action
extraction behind a compatibility shim: replace direct use of
"EXTRA_XE_APP_ACTION_ID" in the MainActivity block (the code using Intent,
Platform.Intent.ActionAppAction, Shortcuts.TryGetUrl and setting
App.OverrideStartupUrl) with a single helper method (e.g.,
AppActionsCompat.GetAppActionId(Intent intent)) that first tries any public MAUI
constant/API, then falls back to the internal extra for older MAUI versions;
call that shim here and use its result (and add a unit/compat test that verifies
the shim returns the same id for known intents to lock behavior).
backend/FwLite/FwLiteMaui/MainPage.xaml.cs (1)

37-47: ⚡ Quick win

Call the host bridge directly instead of going through eval.

frontend/viewer/src/main.ts already exposes window.lexbox.SvelteNavigate, so building a JS string here just makes this path more brittle and hides navigation failures behind fire-and-forget interop. Prefer a direct call like InvokeVoidAsync("lexbox.SvelteNavigate", url, new { replace = true }) (or a small wrapper function) and handle the dispatch result explicitly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/FwLite/FwLiteMaui/MainPage.xaml.cs` around lines 37 - 47, The current
code builds and evals a JS string to call window.lexbox.SvelteNavigate inside
blazorWebView.TryDispatchAsync, which is brittle and fire-and-forget; replace
the eval approach by resolving IJSRuntime and calling InvokeVoidAsync directly
(e.g. jsRuntime.InvokeVoidAsync("lexbox.SvelteNavigate", url, new { replace =
true })) inside the TryDispatchAsync callback (or call a small JS wrapper
exposed as a global function), and await/handle the returned ValueTask to
surface failures instead of ignoring the dispatch result; update the block that
references IJSRuntime and the JsonSerializer.Serialize(url) usage to pass the
raw url object and options as separate args.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/FwLite/FwLiteMaui/build/Linq2DbCctorPatcher/Program.cs`:
- Around line 56-61: The current idempotency check in the static constructor
early-return (symbol cctor) is too weak because it only checks for a single
OpCodes.Ret and then writes markerPath and returns, which can falsely mark
dllPath as patched even if the Quote() method wasn't transformed into the
patched throw form; update the logic to instead locate the Quote() method
(method name Quote) and verify its body matches the expected patched throw
pattern (e.g., the specific IL sequence or exception-throwing implementation
your patch applies) before treating the assembly as already patched—only if
Quote() is present and matches the patched IL should you write markerPath and
return; otherwise proceed with the patch so the fail-loud guards run and the DLL
is correctly transformed.

---

Nitpick comments:
In `@backend/FwLite/FwLiteMaui/MainPage.xaml.cs`:
- Around line 37-47: The current code builds and evals a JS string to call
window.lexbox.SvelteNavigate inside blazorWebView.TryDispatchAsync, which is
brittle and fire-and-forget; replace the eval approach by resolving IJSRuntime
and calling InvokeVoidAsync directly (e.g.
jsRuntime.InvokeVoidAsync("lexbox.SvelteNavigate", url, new { replace = true }))
inside the TryDispatchAsync callback (or call a small JS wrapper exposed as a
global function), and await/handle the returned ValueTask to surface failures
instead of ignoring the dispatch result; update the block that references
IJSRuntime and the JsonSerializer.Serialize(url) usage to pass the raw url
object and options as separate args.

In `@backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs`:
- Around line 26-33: Remove the hardcoded internal extra name and centralize
app-action extraction behind a compatibility shim: replace direct use of
"EXTRA_XE_APP_ACTION_ID" in the MainActivity block (the code using Intent,
Platform.Intent.ActionAppAction, Shortcuts.TryGetUrl and setting
App.OverrideStartupUrl) with a single helper method (e.g.,
AppActionsCompat.GetAppActionId(Intent intent)) that first tries any public MAUI
constant/API, then falls back to the internal extra for older MAUI versions;
call that shim here and use its result (and add a unit/compat test that verifies
the shim returns the same id for known intents to lock behavior).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e22a61eb-5a2e-4d50-a46a-845dc0c4c5d7

📥 Commits

Reviewing files that changed from the base of the PR and between 78e3f97 and 2e2432c.

📒 Files selected for processing (8)
  • backend/FwLite/FwLiteMaui/App.xaml.cs
  • backend/FwLite/FwLiteMaui/MainPage.xaml.cs
  • backend/FwLite/FwLiteMaui/MauiProgram.cs
  • backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs
  • backend/FwLite/FwLiteMaui/Shortcuts.cs
  • backend/FwLite/FwLiteMaui/build/Linq2DbCctorPatcher/Program.cs
  • frontend/viewer/src/lib/services/service-declaration.ts
  • frontend/viewer/src/main.ts

Comment thread backend/FwLite/FwLiteMaui/build/Linq2DbCctorPatcher/Program.cs
…pdating the App class to accept an IServiceProvider, and improving app action handling for better integration with troubleshooting services.
@hahn-kev hahn-kev requested a review from myieye June 16, 2026 04:05

@myieye myieye left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Devin didn't find anything concerning:
https://app.devin.ai/review/sillsdev/languageforge-lexbox/pull/2353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants