( env: TestEnvironment, workspaceId: string, toolCallId: string )
| 23 | } |
| 24 | |
| 25 | async function waitForForegroundToolCallId( |
| 26 | env: TestEnvironment, |
| 27 | workspaceId: string, |
| 28 | toolCallId: string |
| 29 | ): Promise<void> { |
| 30 | const controller = new AbortController(); |
| 31 | let iterator: AsyncIterator<{ foregroundToolCallIds: string[] }> | null = null; |
| 32 | |
| 33 | try { |
| 34 | const subscribedIterator = await env.orpc.workspace.backgroundBashes.subscribe( |
| 35 | { workspaceId }, |
| 36 | { signal: controller.signal } |
| 37 | ); |
| 38 | |
| 39 | iterator = subscribedIterator; |
| 40 | |
| 41 | for await (const state of subscribedIterator) { |
| 42 | if (state.foregroundToolCallIds.includes(toolCallId)) { |
| 43 | return; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | throw new Error("backgroundBashes.subscribe ended before foreground bash was observed"); |
| 48 | } finally { |
| 49 | controller.abort(); |
| 50 | void iterator?.return?.(); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | async function getActiveTextarea(container: HTMLElement): Promise<HTMLTextAreaElement> { |
| 55 | return waitFor( |
no test coverage detected