Skip to content

Conversation

@ShashwatXD
Copy link
Contributor

@ShashwatXD ShashwatXD commented Dec 29, 2025

Fixes #447

Changes:

  • Added detection for sign_out URL in the shouldOverrideUrlLoading callback
  • Sign in redirects to app's native login flow
  • Used existing viewmodel logic to handle navigation events
  • WebView intercepts and cancels sign_out/sign_in URLs before they load

Screenshots of the changes (If any) -

Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.

@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

Walkthrough

Delegates WebView URL decision-making to a new async handler: SimulatorView now calls SimulatorViewModel.handleNavigation(url, webViewController) from the updated shouldOverrideUrlLoading signature, cancels navigation when handler returns "cancel", preserves external PDF launches, and removes a host-based routing check.

Changes

Cohort / File(s) Summary
Simulator view (navigation interception)
lib/ui/views/simulator/simulator_view.dart
Updated shouldOverrideUrlLoading to the (controller, navigationAction) signature, read URL from navigationAction.request.url, call model.handleNavigation(urlStr, webViewController) asynchronously, cancel navigation when the handler returns "cancel", and retain external PDF launch logic. Removed host-based routing check for learn.circuitverse.org.
Simulator viewmodel (navigation logic & API)
lib/viewmodels/simulator/simulator_viewmodel.dart
Replaced findMatchInString(String) with Future<String?> handleNavigation(String url, InAppWebViewController? controller); handleNavigation returns "cancel" for handled paths (sign_in, sign_out, ib landing) or null otherwise. Changed clearCookies() to Future<void> clearCookies() async. Added import for lib/ui/views/cv_landing_view.dart. Removed many legacy URL-pattern branches and simplified control flow.
Related imports / routing
lib/viewmodels/simulator/..., lib/ui/views/...
Added import for cv_landing_view.dart and moved navigation decisions into the viewmodel async handler (uses Get routing and webview header reload path when applicable).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix(simulator): syncing webview and native' describes a general synchronization goal, but the actual changes implement specific URL interception logic for sign_out, sign_in, and learn routes with detailed navigation handling. Clarify the title to reflect the primary implementation detail, such as 'fix(simulator): handle sign out navigation in webview' or reference the specific URL handling mechanism being introduced.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the core requirement from #447: integrating findMatchInString logic into WebView callbacks to handle sign_out URLs and update native app state accordingly.
Out of Scope Changes check ✅ Passed The changes are within scope: refactored handleNavigation method to replace findMatchInString, integrated it into shouldOverrideUrlLoading callback, and added support for sign_out, sign_in, and learn.circuitverse.org URLs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 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: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 597f9fc and fe3fc04.

📒 Files selected for processing (1)
  • lib/ui/views/simulator/simulator_view.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test & Analyze (windows-latest)
  • GitHub Check: Test & Analyze (macos-latest)
  • GitHub Check: Test & Analyze (ubuntu-latest)

@coveralls
Copy link

coveralls commented Dec 29, 2025

Pull Request Test Coverage Report for Build 20578349741

Details

  • 0 of 15 (0.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 54.403%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/ui/views/simulator/simulator_view.dart 0 5 0.0%
lib/viewmodels/simulator/simulator_viewmodel.dart 0 10 0.0%
Totals Coverage Status
Change from base Build 20505877834: 0.0%
Covered Lines: 4887
Relevant Lines: 8983

💛 - Coveralls

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

🧹 Nitpick comments (1)
lib/viewmodels/simulator/simulator_viewmodel.dart (1)

295-322: Implementation looks good with a minor suggestion for error handling.

The navigation handler correctly implements the PR objective. The sign-out flow (lines 316-320) properly clears cookies before closing the view.

Consider adding error handling around the clearCookies() call to ensure the view closes even if cookie clearing fails:

🔎 Suggested error handling
 } else if (url.contains('sign_out')) {
-  await clearCookies();
+  try {
+    await clearCookies();
+  } catch (e) {
+    debugPrint('Failed to clear cookies: $e');
+  }
   Navigator.of(context).pop();
   return 'cancel';
 }

Optional: The string literal 'cancel' is repeated multiple times. Consider extracting it to a constant for maintainability.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe3fc04 and 700af5d.

📒 Files selected for processing (2)
  • lib/ui/views/simulator/simulator_view.dart
  • lib/viewmodels/simulator/simulator_viewmodel.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/ui/views/simulator/simulator_view.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test & Analyze (windows-latest)
  • GitHub Check: Test & Analyze (macos-latest)
  • GitHub Check: Test & Analyze (ubuntu-latest)
🔇 Additional comments (1)
lib/viewmodels/simulator/simulator_viewmodel.dart (1)

291-293: Good improvement to the method signature.

Changing the return type from void to Future<void> properly represents the async nature of this method and follows Dart best practices.

import 'package:mobile_app/models/projects.dart';
import 'package:mobile_app/services/local_storage_service.dart';
import 'package:mobile_app/ui/views/authentication/login_view.dart';
import 'package:mobile_app/ui/views/cv_landing_view.dart';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

rg -nP '\bCvLandingView\b' --type dart -C3

Repository: CircuitVerse/mobile-app

Length of output: 49


🏁 Script executed:

rg -n 'cv_landing|CvLanding' --type dart

Repository: CircuitVerse/mobile-app

Length of output: 1514


🏁 Script executed:

rg -n 'IbLandingView' --type dart -C2

Repository: CircuitVerse/mobile-app

Length of output: 8893


🏁 Script executed:

cat lib/viewmodels/simulator/simulator_viewmodel.dart | head -50

Repository: CircuitVerse/mobile-app

Length of output: 1825


🏁 Script executed:

rg -n '\bCvLandingView\b' lib/viewmodels/simulator/simulator_viewmodel.dart

Repository: CircuitVerse/mobile-app

Length of output: 49


Remove unused import of cv_landing_view.dart.

The cv_landing_view.dart import on line 12 is not used in this file. The navigation handler correctly references IbLandingView instead.

🤖 Prompt for AI Agents
In lib/viewmodels/simulator/simulator_viewmodel.dart around line 12, the import
of package:mobile_app/ui/views/cv_landing_view.dart is unused; remove that
import line and save the file (or run the Dart analyzer/format/fix command) so
the file only imports types actually referenced (the navigation already uses
IbLandingView), eliminating the unused-import warning.

@ShashwatXD ShashwatXD changed the title fix(simulator): pop view on sign out button press fix(simulator): syncing webview and native Dec 29, 2025
@ShashwatXD
Copy link
Contributor Author

ShashwatXD commented Dec 29, 2025

@JatsuAkaYashvant , please review

@JatsuAkaYashvant
Copy link
Member

@ShashwatXD Is there a reproducible case where this PR now works and earlier didn’t? Please attach the video.

@ShashwatXD
Copy link
Contributor Author

ShashwatXD commented Dec 30, 2025

Earlier:

  • Here user isnt signed in
Record_2025-12-30-15-24-05.mp4
  • Already Signed In
Record_2025-12-30-15-26-36.mp4

Now, we have a better UX as user can handle things natively, can also come out of the simulator if he tries to sign out, i have also added a few more checks , if the user is already signed in to our app, and he tries to login in the simulator, it automatically fetches the token from app's preferences and lauches the simulator on his account.

  • Here user isnt signed in
Record_2025-12-30-15-21-46.mp4
  • Already Signed In
VID_20251230152909.mp4

@tachyons
Copy link
Member

tachyons commented Jan 1, 2026

We need to better here, login should from the app interface, it should not depend on the web view to render web login page

@ShashwatXD
Copy link
Contributor Author

ShashwatXD commented Jan 1, 2026

We need to better here, login should from the app interface, it should not depend on the web view to render web login page

Their's a very small possibility for that to happen best i can do is disable the
use of the circuit verse logo on simulator view.

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.

Simulator WebView fails to handle app navigation (Sign Out, Edit, etc.)

4 participants