Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/redrob/test/cli/acp/acp-test-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from "bun:test"
import type { SessionConfigOption, SessionConfigSelectOption } from "@agentclientprotocol/sdk"
import { Duration, Effect } from "effect"
import type { AcpHandle } from "../../lib/cli-process"
import { slowPlatform } from "../../lib/cli-process"

type JsonRpcRequest = {
readonly jsonrpc: "2.0"
Expand Down Expand Up @@ -44,15 +45,19 @@ export function createAcpClient(acp: AcpHandle): AcpClient {
yield* acp.send(message)

while (true) {
const received = yield* acp.receive.pipe(Effect.timeout(Duration.seconds(15)))
const received = yield* acp.receive.pipe(Effect.timeout(Duration.millis(slowPlatform(15_000))))
if (isJsonRpcResponse<T>(received) && received.id === id) return received
}
})

/*
The default is scaled for the slow platform, as are the explicit values callers pass -- every wait in
this client is on a subprocess round trip, and Windows is where these bounds flake.
*/
const waitForNotification = <T>(method: string, predicate: (params: T) => boolean, timeoutMs = 15_000) =>
Effect.gen(function* () {
while (true) {
const received = yield* acp.receive.pipe(Effect.timeout(Duration.millis(timeoutMs)))
const received = yield* acp.receive.pipe(Effect.timeout(Duration.millis(slowPlatform(timeoutMs))))
if (!isJsonRpcNotification<T>(received)) continue
if (received.method === method && predicate(received.params as T)) return received
}
Expand Down
7 changes: 5 additions & 2 deletions packages/redrob/test/cli/acp/lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
ResumeSessionResponse,
} from "@agentclientprotocol/sdk"
import { Duration, Effect } from "effect"
import { cliIt } from "../../lib/cli-process"
import { cliIt, slowPlatform } from "../../lib/cli-process"
import { expectOk, selectConfigOption } from "./acp-test-client"
import { createAcpClient, initialize, newSession, verifierConfig } from "./helpers"

Expand All @@ -18,7 +18,10 @@ describe("redrob acp lifecycle subprocess", () => {
const acp = yield* redrob.acp()
acp.close()

const code = yield* Effect.promise(() => acp.exited).pipe(Effect.timeout(Duration.seconds(5)))
/* Scaled: Windows process teardown is slower, and five seconds was tight enough to flake. */
const code = yield* Effect.promise(() => acp.exited).pipe(
Effect.timeout(Duration.millis(slowPlatform(5_000))),
)
expect(code).toBe(0)
}),
60_000,
Expand Down
Loading