Skip to content

Conversation

@JatsuAkaYashvant
Copy link
Member

@JatsuAkaYashvant JatsuAkaYashvant commented Jul 28, 2025

Fixes #410

Description of Changes

This PR introduces several improvements to the project editing workflow and UI components:

1. Simulator Project Editing Integration

  • Added project editing capability to the simulator
  • Modified SimulatorView to accept a Project argument
  • Updated SimulatorViewModel to handle project-specific URLs
  • Adjusted router to pass project data to simulator

2. Rich Text Editor Improvements

  • Added 16px padding around editor content in CVHtmlEditor
  • Maintained all existing toolbar functionality
  • Improved visual spacing and readability

3. Edit Project View Enhancements

  • Added new "Open in Simulator" button
  • Implemented navigation to simulator with project context
  • Maintained existing form validation logic

4. Router Updates

  • Modified simulator route to accept project arguments
  • Ensured proper type safety for route arguments

Code Changes

Simulator Integration

// SimulatorView now accepts project argument
final Project? project = Get.arguments as Project?;

// ViewModel handles project-specific URLs
String get url {
  if (_projectToEdit != null) {
    return '${EnvironmentConfig.CV_BASE_URL}/simulator/edit/${_projectToEdit!.id}';
  }
  return '${EnvironmentConfig.CV_BASE_URL}/simulator';
}

Video of working

WhatsApp.Video.2025-07-28.at.17.54.31_804a9fce.mp4

Summary by CodeRabbit

  • New Features

    • Added a button in the project edit screen to open the current project in the simulator view.
    • The simulator now supports editing a specific project when opened from the project edit screen.
  • Localization

    • Added new translations for "Open in Simulator" in English, Arabic, and Hindi.
  • UI Improvements

    • Increased padding around the project description editor for better readability.

@coderabbitai
Copy link

coderabbitai bot commented Jul 28, 2025

Walkthrough

This change introduces a new "Open in Simulator" feature to the project editing interface. It adds corresponding localization strings and translations, updates the simulator view and its viewmodel to accept and handle a specific project, and modifies routing logic to support passing project arguments. UI adjustments and supporting methods are included.

Changes

Cohort / File(s) Change Summary
Localization String Getters
lib/gen_l10n/app_localizations.dart, lib/gen_l10n/app_localizations_en.dart, lib/gen_l10n/app_localizations_ar.dart, lib/gen_l10n/app_localizations_hi.dart
Added edit_open_in_simulator string getter to base and language-specific localization classes, with appropriate translations.
Localization Resource Files
lib/l10n/app_en.arb, lib/l10n/app_ar.arb, lib/l10n/app_hi.arb
Added "edit_open_in_simulator" key with translations in English, Arabic, and Hindi ARB files.
Edit Project View Feature
lib/ui/views/projects/edit_project_view.dart
Added "Open in Simulator" button and supporting methods to navigate to the simulator with the current project, including snackbar feedback and layout adjustments.
Simulator View Argument Handling
lib/ui/views/simulator/simulator_view.dart
Updated to accept and pass a Project argument from navigation to the viewmodel. Minor parameter renaming for clarity.
Simulator ViewModel Enhancements
lib/viewmodels/simulator/simulator_viewmodel.dart
Added support for editing a specific project in the simulator, including new fields, a computed URL getter, argument handling, and minor logic improvements.
Routing Update for Simulator
lib/utils/router.dart
Modified route generation to forward the Project argument to the simulator view.
UI Padding Adjustment
lib/ui/components/cv_html_editor.dart
Added 16.0 units of padding around the HTML editor widget.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Suggested labels

released, GSoC 25'

Suggested reviewers

  • hardik17771
  • tachyons

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between be12ee4 and 7da2b40.

📒 Files selected for processing (1)
  • lib/viewmodels/simulator/simulator_viewmodel.dart (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/viewmodels/simulator/simulator_viewmodel.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: build (windows-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest)
✨ Finishing Touches
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 3

🧹 Nitpick comments (3)
lib/ui/components/cv_html_editor.dart (1)

55-57: Use const EdgeInsets.all to avoid unnecessary allocations

The padding value is immutable. Marking it const lets the widget tree reuse the same EdgeInsets instance and prevents a minor allocation on every rebuild.

-              padding: EdgeInsets.all(16.0),
+              padding: const EdgeInsets.all(16.0),
lib/ui/views/projects/edit_project_view.dart (2)

168-182: Improve error handling and use localized strings.

The navigation logic is correct, but there are opportunities for improvement:

  1. The hardcoded strings should use localized messages
  2. The generic error handling could be more specific
 Future<void> _openInSimulator() async {
   try {
     // Navigate to simulator with the project for editing
     final result = await Get.toNamed(
       SimulatorView.id,
       arguments: widget.project,
     );

     if (result != null) {
-      SnackBarUtils.showDark('Simulator', 'Returned from simulator');
+      // Consider adding localized success message if needed
     }
   } catch (e) {
-    SnackBarUtils.showDark('Error', 'Failed to open project in simulator');
+    SnackBarUtils.showDark(
+      AppLocalizations.of(context)!.edit_project_error,
+      'Failed to open project in simulator', // Consider adding this to localizations
+    );
   }
 }

194-194: Fix parameter naming convention.

The parameter name Context should follow Dart naming conventions and be lowercase.

-Widget _buildOpenInSimulatorButton(BuildContext Context) {
+Widget _buildOpenInSimulatorButton(BuildContext context) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d89eecd and be12ee4.

📒 Files selected for processing (12)
  • lib/gen_l10n/app_localizations.dart (1 hunks)
  • lib/gen_l10n/app_localizations_ar.dart (1 hunks)
  • lib/gen_l10n/app_localizations_en.dart (1 hunks)
  • lib/gen_l10n/app_localizations_hi.dart (1 hunks)
  • lib/l10n/app_ar.arb (1 hunks)
  • lib/l10n/app_en.arb (1 hunks)
  • lib/l10n/app_hi.arb (1 hunks)
  • lib/ui/components/cv_html_editor.dart (1 hunks)
  • lib/ui/views/projects/edit_project_view.dart (4 hunks)
  • lib/ui/views/simulator/simulator_view.dart (2 hunks)
  • lib/utils/router.dart (1 hunks)
  • lib/viewmodels/simulator/simulator_viewmodel.dart (4 hunks)
🧰 Additional context used
🧠 Learnings (7)
lib/l10n/app_en.arb (2)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:766-796
Timestamp: 2025-06-17T13:38:03.098Z
Learning: In Flutter localization, ARB files (like app_en.arb) are the source files that get compiled into generated localization classes (like app_localizations_en.dart). Issues with incorrect language content should be fixed in the source ARB files rather than the generated files.

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

lib/l10n/app_hi.arb (2)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:766-796
Timestamp: 2025-06-17T13:38:03.098Z
Learning: In Flutter localization, ARB files (like app_en.arb) are the source files that get compiled into generated localization classes (like app_localizations_en.dart). Issues with incorrect language content should be fixed in the source ARB files rather than the generated files.

lib/gen_l10n/app_localizations_hi.dart (1)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

lib/gen_l10n/app_localizations_en.dart (1)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

lib/l10n/app_ar.arb (2)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:766-796
Timestamp: 2025-06-17T13:38:03.098Z
Learning: In Flutter localization, ARB files (like app_en.arb) are the source files that get compiled into generated localization classes (like app_localizations_en.dart). Issues with incorrect language content should be fixed in the source ARB files rather than the generated files.

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

lib/gen_l10n/app_localizations_ar.dart (2)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:766-796
Timestamp: 2025-06-17T13:38:03.098Z
Learning: In Flutter localization, ARB files (like app_en.arb) are the source files that get compiled into generated localization classes (like app_localizations_en.dart). Issues with incorrect language content should be fixed in the source ARB files rather than the generated files.

lib/gen_l10n/app_localizations.dart (1)

Learnt from: JatsuAkaYashvant
PR: #381
File: lib/gen_l10n/app_localizations_en.dart:797-811
Timestamp: 2025-06-17T13:37:11.440Z
Learning: When fixing localization issues in Flutter, always fix the source ARB files (like app_en.arb, app_hi.arb) rather than the generated Dart files (like app_localizations_en.dart). The generated localization files are auto-generated from ARB files and any manual changes to them will be overwritten when the localization files are regenerated.

⏰ 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: build (ubuntu-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
🔇 Additional comments (20)
lib/l10n/app_hi.arb (1)

373-376: Hindi translation addition looks good

The new key "edit_open_in_simulator" and its translation are correctly added in the source ARB file.
No further action needed.

lib/gen_l10n/app_localizations_hi.dart (1)

1072-1074: ARB Source File Updated Correctly

  • Verified that the key "edit_open_in_simulator": "सिम्युलेटर में खोलें" exists in lib/l10n/app_hi.arb.
  • The generated getter in lib/gen_l10n/app_localizations_hi.dart accurately reflects the ARB entry.
  • The Hindi translation “सिम्युलेटर में खोलें” is appropriate.

No further changes are needed.

lib/l10n/app_ar.arb (1)

378-378: LGTM! Proper localization workflow followed.

The Arabic translation "فتح في محاكي" (Open in Simulator) is accurate and follows the correct localization workflow by updating the source ARB file rather than the generated localization classes. The JSON formatting is consistent with the rest of the file.

lib/gen_l10n/app_localizations_ar.dart (1)

1056-1058: LGTM - Generated localization addition is correct.

The Arabic translation "فتح في محاكي" for "Open in Simulator" looks appropriate. As expected for generated localization files, this change was properly created from the source ARB files.

lib/l10n/app_en.arb (1)

377-377: LGTM - Proper localization key addition.

The new localization key "edit_open_in_simulator" with value "Open in Simulator" is correctly added to the ARB source file within the appropriate "@edit_project_view" section. This follows the proper localization workflow.

lib/ui/views/simulator/simulator_view.dart (3)

5-5: LGTM - Appropriate model import.

The Project model import is correctly added to support the new project editing functionality.


16-18: LGTM - Safe argument retrieval.

The project argument retrieval using nullable casting (Get.arguments as Project?) is a safe approach that handles cases where no project is passed during navigation.


22-22: LGTM - Proper view model integration.

Passing the project to the view model's onModelReady method follows the correct MVVM pattern and enables the simulator to handle project-specific editing scenarios.

lib/utils/router.dart (1)

41-45: LGTM - Proper route argument handling.

The routing logic correctly extracts the Project argument and passes it through RouteSettings, ensuring the SimulatorView receives the project data via navigation arguments. This implementation is consistent with the existing routing patterns in the file.

lib/ui/views/projects/edit_project_view.dart (3)

12-12: LGTM - Appropriate import addition.

The SimulatorView import is correctly added to support the new navigation functionality.


195-202: LGTM - Consistent button implementation.

The button widget follows the existing UI patterns and correctly uses the localized string for the title.


227-228: LGTM - Proper UI placement and spacing.

The button is well-positioned between the description input and the update button with appropriate spacing.

lib/viewmodels/simulator/simulator_viewmodel.dart (8)

9-9: LGTM!

The import of the Project model is necessary for the new project editing functionality.


29-30: LGTM!

The private _projectToEdit field is properly declared and follows Dart naming conventions.


32-37: LGTM!

The URL getter correctly handles both general simulator access and project-specific editing. The null check before using the null assertion operator is appropriate, and the URL construction follows REST conventions.


46-49: LGTM!

The setProjectToEdit method follows proper Flutter state management patterns by updating the field and calling notifyListeners() to trigger UI updates.


109-109: LGTM!

Good catch on fixing the typo from "occured" to "occurred" in the debug print statement.


135-138: LGTM!

The enhanced URL matching logic correctly identifies project save/update actions and follows the established pattern of the method.


147-151: LGTM!

The modification to onModelReady correctly handles the optional project parameter and maintains existing functionality while adding project editing support.


159-159: LGTM!

Proper cleanup of the _projectToEdit field in onModelDestroy prevents memory leaks and follows good lifecycle management practices.

@hardik17771 hardik17771 merged commit 45f80fa into CircuitVerse:master Jul 29, 2025
8 checks passed
@github-actions
Copy link
Contributor

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@coderabbitai coderabbitai bot mentioned this pull request Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project re-editing feature

2 participants