Skip to content

Wrap map in Emitter class with markRaw to avoid Vue reactivity#2944

Merged
nighca merged 1 commit intogoplus:devfrom
nighca:issue-2943
Mar 12, 2026
Merged

Wrap map in Emitter class with markRaw to avoid Vue reactivity#2944
nighca merged 1 commit intogoplus:devfrom
nighca:issue-2943

Conversation

@nighca
Copy link
Collaborator

@nighca nighca commented Mar 12, 2026

fix #2943.

After a simple investigation, it was found that changing the language causes the code editor to be reinitialized. Reinitializing the code editor leads to reinitializing the spx diagnostics provider, which introduces an infinite loop. This is because the emitter's map for recording event handlers was converted into reactive data by Vue, thus incorrectly establishing a dependency during runtime.

@nighca nighca marked this pull request as ready for review March 12, 2026 10:29
Copilot AI review requested due to automatic review settings March 12, 2026 10:29
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where the Emitter class instances might inadvertently become reactive within a Vue application. By explicitly marking the Emitter instance as raw upon creation, it ensures that Vue's reactivity system does not process it, thereby preventing potential performance overhead or unexpected behavior when using the event emitter.

Highlights

  • Reactivity Control: Imported markRaw from the 'vue' library to manage reactivity.
  • Emitter Initialization: Initialized the Emitter class instance with markRaw(this) in its constructor to prevent it from becoming reactive.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • spx-gui/src/utils/emitter.ts
    • Imported markRaw from 'vue'.
    • Added a constructor to the Emitter class that calls super() and then markRaw(this).
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a constructor for the Emitter class to call markRaw(this). This is a sound optimization to prevent Vue from making Emitter instances reactive, which can improve performance and avoid unexpected behavior. The change is implemented correctly and aligns with Vue's best practices for handling non-reactive objects within a reactive context.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR attempts to fix issue #2943 (UI language switching freezing XBuilder) by adding markRaw(this) to the Emitter base class constructor, preventing Vue from wrapping Emitter instances in reactive proxies.

Changes:

  • Added a constructor to Emitter that calls markRaw(this) to opt all Emitter instances out of Vue reactivity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xgopilot

This comment was marked as outdated.

@nighca
Copy link
Collaborator Author

nighca commented Mar 12, 2026

@xgopilot /review

@xgopilot

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nighca
Copy link
Collaborator Author

nighca commented Mar 12, 2026

@xgopilot pull the latest code and review again, as your comments are based on outdated code.

@xgopilot
Copy link
Contributor

xgopilot bot commented Mar 12, 2026

Code Review (updated)

The PR has been updated and the fix is now correct.

private map = markRaw(new Map<keyof Events, Handler[]>()) — this marks only the internal handler map as non-reactive, consistent with the pattern used in Disposable for its disposers array. This prevents Vue from tracking event handler dependencies without affecting subclasses that use reactive(this) (e.g. Runtime).

No issues found with the current code.

View job run

@nighca nighca changed the title Initialize Emitter class with markRaw to avoid Vue reactivity Wrap map in Emitter class with markRaw to avoid Vue reactivity Mar 12, 2026
@nighca nighca enabled auto-merge (squash) March 12, 2026 10:42
@nighca nighca merged commit 73e5e73 into goplus:dev Mar 12, 2026
5 checks passed
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.

Switching UI language on the project edit page can freeze XBuilder

3 participants