-
Notifications
You must be signed in to change notification settings - Fork 130
Add deeplink manager #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add deeplink manager #487
Conversation
✅ Deploy Preview for cv-mobile-app-web ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughAdds a DeepLinkManager service that listens for incoming app links and routes /simulator/edit/:id and /simulator/embed/:id to SimulatorView (using a Project.idOnly placeholder and an isEmbed flag) and /users/:userId/projects/:projectId to ProjectDetailsView (fetching project details); registers and initializes the manager via the service locator at app startup; adds Project.idOnly factory; expands SimulatorView/SimulatorViewModel to accept and propagate an isEmbed parameter; switches several DropdownButtonFormField uses from Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🤖 Fix all issues with AI agents
In `@lib/main.dart`:
- Around line 24-26: The DeepLinkManager.init() currently returns void and calls
the asynchronous _checkInitialLink() without awaiting it, risking a race where
the initial deep link is missed; change init() to be async and await
_checkInitialLink() (or otherwise block until _checkInitialLink() completes)
before setting up the app link stream subscription (the subscription created
alongside _appLinks.getInitialLink()), ensuring the initial link returned by
_appLinks.getInitialLink() is handled before continuing initialization.
In `@lib/services/deep_link_manager.dart`:
- Around line 74-83: The code in _fetchAndNavigateToProject calls
ProjectsApi.getProjectDetails and silently does nothing when it returns null;
update the null branch to surface an error to the user (e.g., call
SnackBarUtils.showDark with a descriptive message) instead of just returning,
keeping the existing try/catch for thrown errors; ensure you still only call
Get.offNamed(ProjectDetailsView.id, arguments: project) when project is non-null
so navigation behavior is unchanged.
- Around line 86-118: The deep-link logic in generateRoute currently uses
name.startsWith(...) which fails for full URLs; update generateRoute to use the
already-parsed uri and its pathSegments for matching (e.g., inspect segments[0],
segments[1], segments[2] to detect simulator modes and projectId) and add host
validation consistent with _handleLink() (check uri.host against allowed host(s)
before routing) so full URLs like https://circuitverse.org/simulator/edit/123
are correctly recognized; adjust the SimulatorView route construction to use the
extracted mode/projectId/isEmbed as before once the pathSegments and host checks
pass.
In `@pubspec.yaml`:
- Line 66: Update the app_links dependency in pubspec.yaml from ^6.4.1 to ^7.0.0
by changing the version string for the app_links entry so the project uses the
latest stable release; ensure you run flutter pub get (or dart pub get)
afterward and verify there are no new analyzer or build warnings related to the
app_links API.
🧹 Nitpick comments (3)
lib/ui/views/simulator/simulator_view.dart (1)
24-33: Consider extracting arguments outside ofbuild().Argument extraction runs on every widget rebuild. While the current implementation works correctly, extracting
projectandisEmbedonce ininitState()(storing them as instance fields) would be more efficient and idiomatic.♻️ Suggested refactor
class _SimulatorViewState extends State<SimulatorView> { InAppWebViewController? webViewController; + Project? _project; + bool _isEmbed = false; + + `@override` + void initState() { + super.initState(); + final args = Get.arguments; + if (args is Project) { + _project = args; + } else if (args is Map) { + _project = args['project'] as Project?; + _isEmbed = args['isEmbed'] as bool? ?? false; + } + } `@override` Widget build(BuildContext context) { - final args = Get.arguments; - Project? project; - bool isEmbed = false; - - if (args is Project) { - project = args; - } else if (args is Map) { - project = args['project'] as Project?; - isEmbed = args['isEmbed'] as bool? ?? false; - } - return Scaffold( body: SafeArea( child: BaseView<SimulatorViewModel>( onModelReady: - (model) => model.onModelReady(project, isEmbed: isEmbed), + (model) => model.onModelReady(_project, isEmbed: _isEmbed),lib/viewmodels/simulator/simulator_viewmodel.dart (1)
331-333: Reset embed state on teardown to avoid state bleed.If this view model instance is reused (e.g., via a singleton locator),
_isEmbedcan persist into later sessions. Consider clearing it inonModelDestroy.♻️ Suggested adjustment
void onModelDestroy() { _projectToEdit = null; + _isEmbed = false; SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); }lib/models/projects.dart (1)
37-55: Guard placeholder metadata from leaking into UI.
Project.idOnlyfills fields with empty strings andDateTime.now(). If any UI renders these before a real fetch, it can show misleading metadata. Consider sentinel values or ensure these fields are ignored in embed/simulator flows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@android/app/src/main/AndroidManifest.xml`:
- Around line 73-80: The intent-filter's separate <data> tags currently combine
across attributes and produce overly broad matches; update the <intent-filter
android:autoVerify="true"> to use explicit <data> entries that combine
scheme+host in the same tag and add path constraints for only the supported
routes (e.g., use android:scheme="http" and android:host="circuitverse.org" plus
android:pathPrefix or android:pathPattern for /simulator/edit/,
/simulator/embed/ and for /users/{userId}/projects/{projectId}; duplicate those
combined <data> entries for both http and https schemes and include the www host
variants) so the filter only matches those specific simulator and user-project
paths rather than any URL.
|
@tachyons Please review this PR. One check is currently failing (build apk), but that won’t be an issue for this PR, already someone has raised a separate issue to address it. |
Fixes #482
Describe the changes you have made in this PR
Screenshots of the changes (If any) -
A demonstration video on how the links would work (in the video i have used adb for deeplinks but once assets is hosted, if we click on any link example: "https://circuitverse.org/simulator/embed/5010", it would open our app the same way as in video.
Screen.Recording.2026-01-28.at.21.18.25.mp4
Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.