Skip to content

fix: stop multiple js error modal popup#1175

Merged
hexqi merged 1 commit intorelease/v2.3.0from
fix/jsPluginMultipleErrDialog
Mar 4, 2025
Merged

fix: stop multiple js error modal popup#1175
hexqi merged 1 commit intorelease/v2.3.0from
fix/jsPluginMultipleErrDialog

Conversation

@chilingling
Copy link
Copy Markdown
Member

@chilingling chilingling commented Mar 4, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

【问题描述】
页面 JS 插件,如果有错误,一直点击 ctrl + s。会重复出现 代码静态检查有错误 弹窗。

【问题分析】
增加了 ctrl + s 快捷键,需要判断重复点击保存的场景,防止重复出现弹窗。

【修复方案】
增加变量判断当前是否已经有错误弹窗,如果已经有错误弹窗,则不再弹出错误弹窗,直接返回。

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling during save operations to prevent duplicate error alerts.
    • Improved alert reset functionality ensures users only see a single notification per error event.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 4, 2025

Walkthrough

This change introduces a new state property, hasErrorPopup, within the script plugin module. The saveMethods function now returns early not only when no changes are detected but also if an error popup is active. When an error occurs, the state property is set to true to prevent duplicate popups, and an associated exec function resets this property once the error is acknowledged.

Changes

File(s) Change Summary
packages/plugins/.../method.js - Added new state property hasErrorPopup initialized to false.
- Modified saveMethods to return early when hasErrorPopup is true.
- Enhanced error handling by setting hasErrorPopup to true when an error is detected and resetting it via an exec function in the error message.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant S as saveMethods
    participant E as ErrorHandler Popup

    U->>S: Initiate save action
    S-->>S: Check changes & state.hasErrorPopup
    alt Error Detected
        S->>E: Set hasErrorPopup = true
        E-->>U: Display error popup with exec function
        U->>E: Acknowledge popup
        E-->>S: Reset hasErrorPopup = false
    else No Error or Popup Active
        S-->>U: Proceed with save
    end
Loading

Suggested reviewers

  • rhlin
  • hexqi

Poem

I'm a rabbit in the code field, hopping along so light,
I spot an error popup and set it to "true" in sight.
With a nibble here and a hop to mend,
I reset the state, making the bugs bend.
Celebrating each fix with a twitch of my nose—code flows!
🐇💻

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • 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.

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
Copy Markdown
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)
packages/plugins/script/src/js/method.js (1)

99-100: Consider adding more specific error information.

The error message is quite generic. Consider enhancing user experience by providing more specific information about the errors detected in the static check.

-      message: '代码静态检查有错误,请先修改后再保存',
+      message: '代码静态检查有错误,请先修改后再保存。错误详情请查看编辑器中的提示。',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a5d2fd4 and cc14696.

📒 Files selected for processing (1)
  • packages/plugins/script/src/js/method.js (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: push-check
  • GitHub Check: push-check
🔇 Additional comments (4)
packages/plugins/script/src/js/method.js (4)

28-30: Good addition to prevent duplicate error popups.

The new hasErrorPopup state property with its explanatory comment effectively addresses a UX issue by preventing multiple error popups when users press Ctrl+S repeatedly while errors exist.


91-91: Early return logic enhanced to handle popup state.

Adding the state.hasErrorPopup check to the early return condition is a good improvement that prevents additional save attempts or error messages when an error popup is already being displayed.


96-103: Proper state management for error popup lifecycle.

The implementation properly sets state.hasErrorPopup to true when an error is detected and resets it to false in the exec function when the user acknowledges the popup. This ensures the popup state is correctly tracked throughout its lifecycle.


90-106:

Details

❓ Verification inconclusive

Verify if the new error popup mechanism is tested.

The changes improve the error popup handling, but it's important to ensure this functionality is properly tested, especially for edge cases like:

  1. Multiple rapid save attempts with errors
  2. Saving after dismissing an error popup
  3. Interaction with other dialogs or popups

🏁 Script executed:

#!/bin/bash
# Search for tests related to the script plugin and error handling

echo "Looking for test files related to the script plugin..."
fd -t f "test" --full-path "**/packages/plugins/script/**"

echo "Looking for tests that might verify error popup behavior..."
rg -i "error.*popup|errorPopup|hasErrorPopup" --type js --type vue --type ts

Length of output: 530


Action Required: Verify Comprehensive Testing for Error Popup Mechanism

The updated error popup handling looks promising. However, our initial automated search for tests (using fd and rg) did not yield conclusive results—likely due to path mismatches and file type filters (e.g., the wildcard path and the "vue" file type issue). This makes it unclear whether the following edge cases are covered:

  • Multiple rapid save attempts with errors
  • Saving after dismissing an error popup
  • Interaction with other dialogs or popups

Please manually verify that your test suite covers these scenarios or consider adding tests to ensure robust handling.

@chilingling chilingling changed the title chore: update version v2.3.0-rc.0 (#1130) fix: stop multiple js error modal popup Mar 4, 2025
@github-actions github-actions Bot added the bug Something isn't working label Mar 4, 2025
@hexqi hexqi merged commit db82e00 into release/v2.3.0 Mar 4, 2025
SonyLeo pushed a commit to SonyLeo/tiny-engine that referenced this pull request Mar 7, 2025
SonyLeo pushed a commit to SonyLeo/tiny-engine that referenced this pull request Mar 7, 2025
1degrees pushed a commit to 1degrees/tiny-engine that referenced this pull request Mar 13, 2025
@chilingling chilingling deleted the fix/jsPluginMultipleErrDialog branch March 29, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants