Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new debouncing utility to the NVDA codebase and applies it to the browse mode elements list filter functionality. The debouncer provides a reusable mechanism for rate-limiting function calls by executing the first call immediately and debouncing subsequent calls within a cooldown period.
Changes:
- Added a new
debounceLimiterdecorator insource/utils/debounce.pythat supports GUI and daemon thread targets - Replaced manual
wx.CallLatertimer management in browse mode's elements list filter with the new debouncer - Updated type hints in
browseMode.pyfromOptional[X]/Union[X, Y]to modern PEP 604 syntax (X | None,X | Y)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| source/utils/debounce.py | New utility module providing the debounceLimiter decorator for debouncing function calls with configurable cooldown and delay times, supporting both GUI and daemon thread execution |
| tests/unit/test_util/test_debounce.py | Comprehensive unit tests for the debouncer covering immediate execution, coalescing, cooldown behavior, and per-instance state tracking |
| source/browseMode.py | Refactored elements list filter to use the new debouncer, removed manual timer management, and modernized type hints throughout the file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Sascha Cowley <16543535+SaschaCowley@users.noreply.github.com>
Link to issue number:
Inspired by #19686
Summary of the issue:
We regularly run into problems where the GUI being updated frequently causing issues.
We fix this using a ratelimiter/debouncer.
We do not have a generic debouncer in NVDA.
Description of user facing changes:
none
Description of developer facing changes:
Adds a generic debouncer to NVDA
Description of development approach:
This pull request introduces a new debouncing utility for limiting the frequency of function calls, primarily to improve GUI responsiveness and reduce unnecessary processing in NVDA. The main changes include the addition of the
debounceLimiterdecorator, its integration into thebrowseMode.pyfile for filtering elements, and comprehensive unit tests to verify its behavior. The pull request also modernizes type annotations throughoutbrowseMode.pyfor improved readability and consistency.Debounce utility and integration:
debounceLimiterdecorator inutils/debounce.pyto control the execution rate of functions, supporting both GUI and daemon threads.debounceLimiterinto the filtering logic of the elements list dialog inbrowseMode.py, replacing manual timer handling for improved efficiency and code clarity. [1] [2]Testing
Introduced
tests/unit/test_util/test_debounce.pywith unit tests covering various debounce scenarios, including cooldown, delay, call coalescing, and per-instance limiting.Manually tested filtering the elements list dialog
Known issues with pull request:
None
Code Review Checklist: