Enhance Android app actions, deep linking, and SvelteNavigate integration#2353
Enhance Android app actions, deep linking, and SvelteNavigate integration#2353hahn-kev wants to merge 6 commits into
Conversation
… and improve URL state persistence in FwLiteMaui
…tcut handling in FwLiteMaui
…ON serialization of URLs, and clean up unused imports.
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis 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. ChangesApp Shortcuts and Native Startup URL Routing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs (1)
26-33: ⚡ Quick winAvoid 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 throughOnAppAction, 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 winCall the host bridge directly instead of going through
eval.
frontend/viewer/src/main.tsalready exposeswindow.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 likeInvokeVoidAsync("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
📒 Files selected for processing (8)
backend/FwLite/FwLiteMaui/App.xaml.csbackend/FwLite/FwLiteMaui/MainPage.xaml.csbackend/FwLite/FwLiteMaui/MauiProgram.csbackend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.csbackend/FwLite/FwLiteMaui/Shortcuts.csbackend/FwLite/FwLiteMaui/build/Linq2DbCctorPatcher/Program.csfrontend/viewer/src/lib/services/service-declaration.tsfrontend/viewer/src/main.ts
…pdating the App class to accept an IServiceProvider, and improving app action handling for better integration with troubleshooting services.
There was a problem hiding this comment.
Looks good 👍
Devin didn't find anything concerning:
https://app.devin.ai/review/sillsdev/languageforge-lexbox/pull/2353
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.
Share debug log will trigger sharing the logs, this should bypass any bugs with the UI of the app.