Skip to content

refactor(web): add toggle-button to plugin and rename plugin name #1504

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

Merged
merged 12 commits into from
Mar 17, 2025

Conversation

mulengawilfred
Copy link
Contributor

@mulengawilfred mulengawilfred commented Mar 16, 2025

Overview

This PR addresses several issues documented in the Plugin playground general Notion page:
Improvements

  • Refactored Terrain and Shadow Styles plugin to use a toggle button.
  • Added documentation for mouse event handling in the preset plugin.
  • Fixed a typo in the screenshot plugin

Naming and Organization

  • Renamed UI Extension Messenger plugin to the more descriptive Messenger between Extension and Visualizer
  • Removed the Show Label plugin as it duplicates functionality that should be requested through client-specific plugins (open to discussion on this decision)

What I've done

What I haven't done

Would need to confirm the translation for Messenger between Extension and Visualizer

How I tested

Locally

Which point I want you to review particularly

None

Memo

Summary by CodeRabbit

  • Refactor
    • Renamed plugin labels and updated translations to display "Messenger between Extension and Visualizer" and "Messenger between Extensions" for improved clarity.
    • Removed an outdated plugin option from the viewer scene.
  • New Features
    • Upgraded shadow and terrain controls by replacing traditional buttons with modern toggle switch interfaces, offering immediate visual feedback.
  • Style
    • Corrected the screenshot button label to use consistent capitalization.
  • Documentation
    • Added a reference link to developer documentation for testing mouse events.

Copy link
Contributor

coderabbitai bot commented Mar 16, 2025

Walkthrough

This pull request standardizes plugin identifiers and names and updates related translations. It refactors the UI messenger plugin by renaming its identifiers and corresponding keys in title mappings and translation files. Additionally, a deprecated plugin is removed from the preset list. The user interface for toggling shadow and terrain functionality is updated by replacing button controls with toggle switches, accompanied by revised event handling and error logging. Minor adjustments include adding a documentation comment for mouse events and correcting a button label typo.

Changes

File(s) Change Summary
web/src/.../presets/data/uiExtensionMessenger.ts, web/src/.../presets/useTitles.ts, web/src/services/i18n/translations/en.yml, web/src/services/i18n/translations/ja.yml Updated plugin identifiers and names from “UI Extension Messenger” to “Messenger between Extension and Visualizer” across configuration, title mapping, and translations.
web/src/.../presets/index.ts Removed the showLabel plugin import and its usage from the presetPlugins array in the viewerScene category.
web/src/.../presets/viewer/enableShadowStyle.ts, web/src/.../presets/viewer/enableTerrain.ts Replaced button-based UIs with toggle switch interfaces; updated event listeners, status text updates, and added error handling for toggling shadow and terrain features.
web/src/.../presets/viewer/mouseEvent.ts, web/src/.../presets/viewer/takeScreenshot.ts Added a documentation comment with a link for mouse events; corrected a typo in the screenshot button label.
web/src/.../presets/data/messengerBetweenExtensions.ts Renamed identifiers related to messaging between extensions, updating the id and sourceCode fields accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Toggle
    participant Plugin
    participant Parent
    User->>Toggle: Toggle switch changed
    Toggle->>Plugin: Emit change event
    Plugin->>Plugin: Update status display ("ON"/"OFF")
    Plugin->>Parent: Send message to update shadow/terrain state
    Parent-->>Plugin: Acknowledge change
Loading

Possibly related PRs

Suggested reviewers

  • mkumbobeaty
  • OpeDada
  • airslice
  • ZTongci

Poem

I'm a coding bunny on a digital spree,
Hopping through toggles and renames with glee,
Changing labels and streams with a clever hop,
Sending messages neatly—never a flop,
With carrots of code and joyful delight,
I celebrate these changes from morning till night 🐰!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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

netlify bot commented Mar 16, 2025

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit 700a625
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/67d7abbd5a0c28000829ceda
😎 Deploy Preview https://deploy-preview-1504--reearth-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 site configuration.

Copy link
Contributor

@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

🔭 Outside diff range comments (2)
web/src/beta/features/PluginPlayground/Plugins/presets/data/uiExtensionMessenger.ts (2)

26-28: ⚠️ Potential issue

File identifiers need to be updated

The widget file identifiers still use the old naming convention, which could cause reference issues.

Update the file identifiers to match the new naming scheme:

-  id: "ui-extension-messenger-widget",
-  title: "ui-extension-messenger.js",
+  id: "messenger-between-extension-and-visualizer-widget",
+  title: "messenger-between-extension-and-visualizer.js",

160-163: ⚠️ Potential issue

Exported plugin type ID needs updating

The exported constant still uses the old ID, which will cause inconsistencies when the plugin is referenced elsewhere in the codebase.

Update the exported type ID:

export const uiExtensionMessenger: PluginType = {
-  id: "ui-extension-messenger",
+  id: "messenger-between-extension-and-visualizer",
  files: [yamlFile, widgetFile]
};

You may also want to consider renaming the exported constant itself for consistency:

-export const uiExtensionMessenger: PluginType = {
+export const messengerBetweenExtensionAndVisualizer: PluginType = {

However, this would require updating all import references elsewhere in the codebase.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90c76f3 and 724e8a5.

📒 Files selected for processing (9)
  • web/src/beta/features/PluginPlayground/Plugins/presets/data/uiExtensionMessenger.ts (1 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/index.ts (2 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/useTitles.ts (1 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/viewer/enableShadowStyle.ts (1 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/viewer/enableTerrain.ts (1 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/viewer/mouseEvent.ts (1 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/viewer/takeScreenshot.ts (1 hunks)
  • web/src/services/i18n/translations/en.yml (1 hunks)
  • web/src/services/i18n/translations/ja.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: ci-server / ci-server-lint
  • GitHub Check: ci-web / ci
  • GitHub Check: ci-server / ci-server-test
🔇 Additional comments (13)
web/src/beta/features/PluginPlayground/Plugins/presets/viewer/takeScreenshot.ts (1)

56-56: Corrected capitalization in button label

Fixed the capitalization of "Screenshot" in the button label for consistency with standard capitalization practices.

web/src/services/i18n/translations/en.yml (1)

343-343: Updated plugin name for clarity

The translation key has been changed from "UI Extension Messenger" to "Messenger between Extension and Visualizer", which better describes the plugin's purpose and functionality.

web/src/beta/features/PluginPlayground/Plugins/presets/viewer/mouseEvent.ts (1)

78-78: Added helpful documentation link

Added a reference link to the official documentation for mouse events, which improves developer experience by providing easy access to relevant API documentation.

web/src/services/i18n/translations/ja.yml (1)

346-346: Updated Japanese translation key for consistency

The translation key has been updated to match the new English key "Messenger between Extension and Visualizer" while maintaining the same Japanese translation text.

web/src/beta/features/PluginPlayground/Plugins/presets/index.ts (2)

39-39: Commented out unused import

The import for showLabel has been commented out as part of removing this plugin from the available options.


71-71: Removed redundant plugin with explanatory comment

The showLabel plugin has been removed from the preset plugins list with a clear comment explaining the rationale: it could cause conflicts when clients request the same functionality in another plugin.

web/src/beta/features/PluginPlayground/Plugins/presets/useTitles.ts (1)

28-30: Plugin name updated correctly in title mappings

The change from "UI Extension Messenger" to "Messenger between Extension and Visualizer" aligns with the PR objectives to improve clarity. The updated name better describes the plugin's functionality as a communication bridge.

web/src/beta/features/PluginPlayground/Plugins/presets/viewer/enableShadowStyle.ts (3)

32-91: Good UI enhancement with toggle switch implementation

The replacement of a button with a modern toggle switch provides a clearer visual indication of the current state (on/off). The CSS styling follows best practices for toggle switches with appropriate transitions and visual feedback.


93-99: Well-structured toggle container with clear status indicator

The HTML structure provides a clean layout with the toggle switch and a status indicator that clearly shows the current state of the shadow.


100-124: Improved error handling and event management

The implementation now includes proper error handling with console error logging if required elements aren't found. The event listener is appropriately set up for the toggle switch and includes clear status updates.

web/src/beta/features/PluginPlayground/Plugins/presets/viewer/enableTerrain.ts (3)

32-91: Consistent UI approach with shadow toggle implementation

The terrain toggle uses the same UI pattern as the shadow toggle, maintaining consistency across the application. The CSS styling is well-structured and follows modern toggle switch design patterns.


93-99: Well-structured toggle container with clear status indicator

The HTML structure provides a clean layout with the toggle switch and a status indicator that clearly shows the current state of the terrain feature.


100-124: Good error handling and event management

Similar to the shadow toggle implementation, this includes proper error handling and clear status updates. The code is well-organized and follows best practices for event handling.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
web/src/beta/features/PluginPlayground/Plugins/presets/data/uiExtensionMessenger.ts (1)

1-3: Consider renaming the file to match new plugin name

While all internal identifiers have been updated, the filename itself (uiExtensionMessenger.ts) still reflects the old naming convention. Consider renaming the file to messengerBetweenExtensionAndVisualizer.ts for complete consistency, though this would require updating imports in other files.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 724e8a5 and 085aabd.

📒 Files selected for processing (1)
  • web/src/beta/features/PluginPlayground/Plugins/presets/data/uiExtensionMessenger.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Redirect rules - reearth-web
  • GitHub Check: Header rules - reearth-web
  • GitHub Check: Pages changed - reearth-web
  • GitHub Check: ci-server / ci-server-test
  • GitHub Check: ci-web / ci
  • GitHub Check: ci-server / ci-server-lint
🔇 Additional comments (3)
web/src/beta/features/PluginPlayground/Plugins/presets/data/uiExtensionMessenger.ts (3)

4-23: YAML file definition consistently renamed

The renaming from "UI Extension Messenger" to "Messenger between Extension and Visualizer" has been applied consistently throughout the YAML file definition, including the file ID, plugin ID, name, and extension properties. This change aligns with the PR objective to improve clarity about the plugin's functionality.


25-28: Widget file identifiers properly updated

The widget file identifiers have been correctly updated to match the new naming convention, addressing the inconsistencies pointed out in the previous review. Both the ID and title now use the "messenger-between-extension-and-visualizer" naming pattern.


160-163: Exported constant ID updated

The exported constant's ID has been updated to "messenger-between-extension-and-visualizer", maintaining consistency with the renaming throughout the file and addressing the previous review feedback.

@mulengawilfred mulengawilfred changed the title fix(web): refactor preset-plugin names in plugin playground fix(web): add toggle-button to plugin and rename plugin name Mar 16, 2025
@mulengawilfred mulengawilfred changed the title fix(web): add toggle-button to plugin and rename plugin name refactor(web): add toggle-button to plugin and rename plugin name Mar 16, 2025
Copy link
Contributor

@ShogoHirasawa ShogoHirasawa left a comment

Choose a reason for hiding this comment

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

Thank you for updating them. I left some comment. Could you check them, when you have time?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for your contribution! I have one idea of UI.
Looking at other examples, the plugin UI features rounded corners, while this plugin has square corners. I think it might be better to standardize the design to one style. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Unifying the design across plugins is correctly in progress in another task. So okay to have this one as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.
Looking at other examples, the plugin UI features rounded corners, while this plugin has square corners. I think it might be better to standardize the design to one style. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Unifying the design across plugins is correctly in progress in another task. So okay to have this one as is.

@@ -343,7 +343,7 @@ Sidebar: サイドバー
Header: ヘッダー
Popup: ポップアップ
Modal Window: モーダルウィンドウ
UI Extension Messenger: エクステンションとコアとの通信
Messenger between Extension and Visualizer: エクステンションとコアとの通信
Copy link
Contributor

Choose a reason for hiding this comment

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

I think below Japanese is more natural and suitable.

Messenger between Extension and Visualizer: エクステンションとVisualizerとの通信

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for confirming this translation. I have updated it.

Copy link
Contributor

@ShogoHirasawa ShogoHirasawa left a comment

Choose a reason for hiding this comment

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

It looks good! Thank you for countribution!

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
web/src/beta/features/PluginPlayground/Plugins/presets/data/messengerBetweenExtensions.ts (1)

8-9: Consider updating plugin display name for consistency

While the IDs have been updated to "messenger-between-extensions", the display name on line 9 still shows "Extension To Extension Messenger". Consider updating this for full naming consistency.

-name: Extension To Extension Messenger
+name: Messenger Between Extensions
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 619b832 and 700a625.

📒 Files selected for processing (5)
  • web/src/beta/features/PluginPlayground/Plugins/presets/data/messengerBetweenExtensions.ts (2 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/index.ts (4 hunks)
  • web/src/beta/features/PluginPlayground/Plugins/presets/useTitles.ts (1 hunks)
  • web/src/services/i18n/translations/en.yml (2 hunks)
  • web/src/services/i18n/translations/ja.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • web/src/beta/features/PluginPlayground/Plugins/presets/useTitles.ts
  • web/src/services/i18n/translations/en.yml
  • web/src/services/i18n/translations/ja.yml
  • web/src/beta/features/PluginPlayground/Plugins/presets/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Redirect rules - reearth-web
  • GitHub Check: Header rules - reearth-web
  • GitHub Check: Pages changed - reearth-web
  • GitHub Check: ci-server / ci-server-test
  • GitHub Check: ci-server / ci-server-lint
  • GitHub Check: ci-web / ci
🔇 Additional comments (3)
web/src/beta/features/PluginPlayground/Plugins/presets/data/messengerBetweenExtensions.ts (3)

6-8: YAML file identifiers consistently renamed

The renaming from "extension-to-extension-messenger" to "messenger-between-extensions" in the YAML file identifiers improves clarity and aligns with the PR objective to use more descriptive naming.


231-238: Extension file identifiers consistently renamed

Both extension file identifiers have been appropriately updated to match the new naming convention, maintaining consistency throughout the plugin.


243-245:

❓ Verification inconclusive

Exported constant renamed for better clarity

The exported constant has been renamed from extensionExtensionMessenger to messengerBetweenExtensions, which is more descriptive of its purpose and consistent with the new naming pattern throughout the codebase.


🏁 Script executed:

#!/bin/bash
# Verify that all imports of the old constant name have been updated 
# to use the new name throughout the codebase

echo "Checking for any remaining references to the old constant name..."
rg "extensionExtensionMessenger" --type ts

Length of output: 183


Renamed constant applied consistently—please verify manually

The constant has been successfully renamed from extensionExtensionMessenger to messengerBetweenExtensions in
web/src/beta/features/PluginPlayground/Plugins/presets/data/messengerBetweenExtensions.ts (lines 243-245). The grep check did not return any lingering references to the old name, suggesting the renaming is complete. Please manually verify that the integration and runtime behavior remain unaffected.

  • File affected: web/src/beta/features/PluginPlayground/Plugins/presets/data/messengerBetweenExtensions.ts
  • Change: Renamed constant to better reflect its purpose and align with the current naming pattern.
  • Next step: Manual verification is encouraged to ensure no indirect dependencies or side-effects remain.

@mulengawilfred mulengawilfred merged commit 435b158 into main Mar 17, 2025
19 checks passed
@mulengawilfred mulengawilfred deleted the fix/refactor-preset-plugins branch March 17, 2025 05:13
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.

3 participants