Skip to content

Conversation

@ShashwatXD
Copy link
Contributor

@ShashwatXD ShashwatXD commented Jan 28, 2026

Fixes #482

Describe the changes you have made in this PR

  • Added a Deep Link Manager using the app_links dependency.
  • Now, when a user opens a supported (shareable) link and the app is already installed, it correctly opens inside the app instead of the browser.
  • To make this work completely, we need to host our SHA key on the original website as required for app link verification. Related issue: Add assetlinks.json for Android App Links support CircuitVerse#6720

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

    • Deep linking: open projects and simulator views (including embed mode) directly from external links.
  • Improvements

    • Simulator supports embed mode and forwards embed flag during navigation.
    • Routing now evaluates deep links before normal navigation; route handling expanded.
  • Bug Fixes

    • Dropdown initialization updated for correct default selections on first render.
  • Chores

    • Updated Flutter runtime to 3.35.
    • Added deep-linking dependency and platform/plugin registration (Android intent filters, desktop plugin).

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Jan 28, 2026

Deploy Preview for cv-mobile-app-web ready!

Name Link
🔨 Latest commit 25f9839
🔍 Latest deploy log https://app.netlify.com/projects/cv-mobile-app-web/deploys/697a77098ac205000825da05
😎 Deploy Preview https://deploy-preview-487--cv-mobile-app-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Walkthrough

Adds 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 value to initialValue; adds app_links dependency, platform plugin registration, Android intent-filters, and bumps CI/CD Flutter versions to 3.35.

Possibly related PRs

Suggested labels

released, GSoC 25'

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive Flutter version bumps in CI/CD workflows and dropdown form field refactoring appear unrelated to deep link management objectives, though the latter may improve form state handling. Clarify why Flutter version bumps and dropdown initialValue changes are included; consider whether these should be separate PRs or documented as incidental improvements.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add deeplink manager' directly and accurately describes the main change of introducing a DeepLinkManager to handle deep linking functionality.
Linked Issues check ✅ Passed The PR implements all core requirements from issue #482: deep link routing via DeepLinkManager, navigation to appropriate screens (SimulatorView, ProjectDetailsView), Android App Links configuration, and preservation of existing URL patterns.

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

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a 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 of build().

Argument extraction runs on every widget rebuild. While the current implementation works correctly, extracting project and isEmbed once in initState() (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), _isEmbed can persist into later sessions. Consider clearing it in onModelDestroy.

♻️ 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.idOnly fills fields with empty strings and DateTime.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.

Copy link

@coderabbitai coderabbitai bot left a 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.

@ShashwatXD
Copy link
Contributor Author

@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.
Also, I have upgraded the CI/CD workflow flutter versions.

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.

[Feature Request] Deeplink Manager

1 participant