* Refresh PR status for all subscribed workspaces. * Called via RefreshController (focus + debounced refresh).
()
| 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. |
no test coverage detected