fix(browser): cancel trailing debounce timeout on immediate refresh

TimeBasedDebouncer can schedule a trailing setTimeout when refresh
requests are throttled. If the debounce window later elapses and an
immediate refresh runs, that pending timeout was left armed and could
fire afterward, causing a duplicate _innerRefresh (e.g. extra live
region updates for screen readers).

Clear any pending timeout and reset _additionalRefreshRequested before
running the immediate refresh path.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Daniel Imms
2026-06-01 15:28:07 +00:00
committed by Cursor Agent
co-authored by Cursor
parent 1dd113b38a
commit 98d7c25bd5
+6 -1
View File
@@ -49,7 +49,12 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
// enough time to pass before refreshing again.
const refreshRequestTime: number = performance.now();
if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) {
// Enough time has lapsed since the last refresh; refresh immediately
// Enough time has elapsed since the last refresh; refresh immediately
if (this._refreshTimeoutID !== undefined) {
clearTimeout(this._refreshTimeoutID);
this._refreshTimeoutID = undefined;
this._additionalRefreshRequested = false;
}
this._lastRefreshMs = refreshRequestTime;
this._innerRefresh();
} else if (!this._additionalRefreshRequested) {