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

Function waitForForegroundToolCallId

tests/ui/chat/sendModeDropdown.test.ts:25–52  ·  view source on GitHub ↗
(
  env: TestEnvironment,
  workspaceId: string,
  toolCallId: string
)

Source from the content-addressed store, hash-verified

23}
24
25async 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
54async function getActiveTextarea(container: HTMLElement): Promise<HTMLTextAreaElement> {
55 return waitFor(

Callers 1

Calls 3

returnMethod · 0.80
subscribeMethod · 0.65
abortMethod · 0.65

Tested by

no test coverage detected