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

Function waitForCondition

src/node/services/agentSession.queueDispatch.test.ts:47–56  ·  view source on GitHub ↗
(condition: () => boolean, timeoutMs = 500)

Source from the content-addressed store, hash-verified

45}
46
47async function waitForCondition(condition: () => boolean, timeoutMs = 500): Promise<boolean> {
48 const deadline = Date.now() + timeoutMs;
49 while (Date.now() < deadline) {
50 if (condition()) {
51 return true;
52 }
53 await new Promise((resolve) => setTimeout(resolve, 10));
54 }
55 return condition();
56}
57
58describe("AgentSession queued message tool-call dispatch", () => {
59 test("soft-stops the current stream after a real tool call when a tool-end message is queued", async () => {

Calls

no outgoing calls

Tested by

no test coverage detected