Skip to content

fix(event-monitor): scope high-frequency monitors to pop button#1128

Merged
tisfeng merged 2 commits intodevfrom
fix/long-runtime-lag
Apr 1, 2026
Merged

fix(event-monitor): scope high-frequency monitors to pop button#1128
tisfeng merged 2 commits intodevfrom
fix/long-runtime-lag

Conversation

@tisfeng
Copy link
Copy Markdown
Owner

@tisfeng tisfeng commented Mar 29, 2026

This pull request introduces significant improvements to the event monitoring system, particularly for handling high-frequency events (like mouse movement and scrolling) only when necessary, and refines screenshot overlay state management for better resource cleanup. It also updates documentation to clarify AI-assisted development practices.

Event Monitoring Enhancements:

  • Introduced a dedicated highFrequencyEventMonitorEngine in EventMonitor to monitor high-frequency events (mouseMoved, scrollWheel) only while the pop button is visible, reducing unnecessary CPU usage. This includes new methods startHighFrequencyEventMonitor and stopHighFrequencyEventMonitor, and a specialized event handler. [1] [2] [3] [4] [5] [6] [7]
  • Updated addBothMonitor to conditionally start/stop high-frequency monitoring based on the isAutoSelectTextEnabled flag and pop button visibility. [1] [2]
  • Removed handling of high-frequency events from the main event handler to avoid blocking the main thread when not needed.
  • Ensured proper stopping of both regular and high-frequency event monitors in the stop method.

Screenshot Overlay State Management:

  • Refactored overlay state cleanup in Screenshot by introducing tearDownOverlayStates, which calls a new cleanup method on each ScreenshotState to ensure local event monitors are removed and resources are released. [1] [2] [3] [4] [5] [6]

Documentation Updates:

  • Updated README.md and README_ZH.md to recommend using the latest AI models (such as GPT-5.4) for codebase exploration and patch generation, and added guidelines for reviewing AI-generated changes. [1] [2]
  • Removed the requirement for all communication to be in Simplified Chinese from AGENTS.md.

Limit mouse-moved and scroll-wheel monitoring to the pop button visibility
lifecycle instead of keeping them active all the time.

Also clean up screenshot state monitors during reset, deinit, and overlay
teardown to prevent long-lived local monitor leaks.
@tisfeng
Copy link
Copy Markdown
Owner Author

tisfeng commented Mar 29, 2026

This is a supplement to #1118

@tisfeng
Copy link
Copy Markdown
Owner Author

tisfeng commented Mar 30, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Collaborator

@Jerry23011 Jerry23011 left a comment

Choose a reason for hiding this comment

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

LGTM

@tisfeng tisfeng merged commit 37637d4 into dev Apr 1, 2026
4 checks passed
@tisfeng tisfeng deleted the fix/long-runtime-lag branch April 1, 2026 09:01
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.

2 participants