(
workspaceId: string,
options?: { signal?: AbortSignal; manualFollowUp?: boolean }
)
| 2768 | } |
| 2769 | |
| 2770 | async waitForWorkspaceIdle( |
| 2771 | workspaceId: string, |
| 2772 | options?: { signal?: AbortSignal; manualFollowUp?: boolean } |
| 2773 | ): Promise<void> { |
| 2774 | assert(typeof workspaceId === "string", "waitForWorkspaceIdle requires a workspaceId string"); |
| 2775 | const trimmed = workspaceId.trim(); |
| 2776 | assert(trimmed.length > 0, "waitForWorkspaceIdle requires a non-empty workspaceId"); |
| 2777 | |
| 2778 | let releaseManualFollowUp: (() => void) | undefined; |
| 2779 | try { |
| 2780 | for (;;) { |
| 2781 | if (options?.signal?.aborted === true) { |
| 2782 | throw new Error(WORKSPACE_IDLE_WAIT_CANCELED_MESSAGE); |
| 2783 | } |
| 2784 | |
| 2785 | const session = |
| 2786 | this.sessions.get(trimmed) ?? this.transientStartupRecoverySessions.get(trimmed); |
| 2787 | if (session?.isBusy() !== true) { |
| 2788 | return; |
| 2789 | } |
| 2790 | |
| 2791 | if (options?.manualFollowUp === true && releaseManualFollowUp == null) { |
| 2792 | releaseManualFollowUp = session.registerExternalManualFollowUp(options.signal); |
| 2793 | } |
| 2794 | await waitForAgentSessionIdle(session, options?.signal); |
| 2795 | } |
| 2796 | } finally { |
| 2797 | releaseManualFollowUp?.(); |
| 2798 | } |
| 2799 | } |
| 2800 | |
| 2801 | /** |
| 2802 | * Register an externally-created AgentSession so that WorkspaceService |
no test coverage detected