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

Method refreshAll

src/browser/stores/PRStatusStore.ts:597–649  ·  view source on GitHub ↗

* Refresh PR status for all subscribed workspaces. * Called via RefreshController (focus + debounced refresh).

()

Source from the content-addressed store, hash-verified

595 * Called via RefreshController (focus + debounced refresh).
596 */
597 private async refreshAll(): Promise<void> {
598 if (!this.client || !this.isActive) return;
599
600 const workspaceIds = Array.from(this.workspaceSubscriptionCounts.keys());
601 if (workspaceIds.length === 0) {
602 return;
603 }
604
605 const now = Date.now();
606 const refreshes: Array<Promise<void>> = [];
607
608 for (const workspaceId of workspaceIds) {
609 const cached = this.workspacePRCache.get(workspaceId);
610 if (this.shouldFetchWorkspace(cached, now)) {
611 // Skip passive PR refresh for devcontainer workspaces whose runtime is
612 // not already running, to avoid waking stopped containers.
613 const metadata = this.workspaceMetadata.get(workspaceId);
614 if (
615 metadata &&
616 !canRunPassiveRuntimeCommand(
617 metadata.runtimeConfig,
618 this.runtimeStatusStore.getStatus(workspaceId)
619 )
620 ) {
621 // Arm a one-shot retry so the workspace gets a PR refresh once the
622 // runtime becomes passively runnable again.
623 if (!this.runtimeRetryUnsubscribers.has(workspaceId)) {
624 let firedSynchronously = false;
625 const unsubscribe = onPassiveRuntimeEligible(
626 workspaceId,
627 metadata.runtimeConfig,
628 this.runtimeStatusStore,
629 () => {
630 firedSynchronously = true;
631 this.runtimeRetryUnsubscribers.delete(workspaceId);
632 // Clear PR cache so TTL doesn't suppress the deferred retry.
633 this.workspacePRCache.delete(workspaceId);
634 this.refreshController.requestImmediate();
635 }
636 );
637 if (!firedSynchronously) {
638 this.runtimeRetryUnsubscribers.set(workspaceId, unsubscribe);
639 }
640 }
641 continue;
642 }
643
644 refreshes.push(this.detectWorkspacePR(workspaceId));
645 }
646 }
647
648 await Promise.all(refreshes);
649 }
650
651 /**
652 * Dispose the store.

Callers 1

constructorMethod · 0.95

Calls 11

shouldFetchWorkspaceMethod · 0.95
detectWorkspacePRMethod · 0.95
onPassiveRuntimeEligibleFunction · 0.90
requestImmediateMethod · 0.80
setMethod · 0.80
getMethod · 0.65
getStatusMethod · 0.65
pushMethod · 0.65
hasMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected