MCPcopy
hub / github.com/coder/mux / handleReturn

Method handleReturn

src/browser/utils/RefreshController.ts:397–418  ·  view source on GitHub ↗

* Handle focus/visibility return. Call from visibility/focus listeners.

(trigger: "focus" | "visibility")

Source from the content-addressed store, hash-verified

395 * Handle focus/visibility return. Call from visibility/focus listeners.
396 */
397 private handleReturn(trigger: "focus" | "visibility"): void {
398 if (this.disposed) return;
399 if (typeof document !== "undefined" && document.hidden) return;
400
401 // Flush pending hidden refresh
402 if (this.pendingBecauseHidden) {
403 this.pendingBecauseHidden = false;
404 const pendingTrigger = this.pendingTrigger ?? trigger;
405 this.pendingTrigger = null;
406 this.tryRefresh({ trigger: pendingTrigger });
407 return; // Don't double-refresh with proactive
408 }
409
410 // Proactive refresh on focus (with debounce)
411 if (this.refreshOnFocus) {
412 const now = Date.now();
413 if (now - this.lastFocusRefreshMs >= this.focusDebounceMs) {
414 this.lastFocusRefreshMs = now;
415 this.tryRefresh({ trigger });
416 }
417 }
418 }
419
420 /**
421 * Notify that a pause condition has cleared (e.g., user stopped interacting).

Callers 1

bindListenersMethod · 0.95

Calls 1

tryRefreshMethod · 0.95

Tested by

no test coverage detected