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
14 changes: 4 additions & 10 deletions packages/opencode/test/session/compaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { Provider } from "@/provider/provider"
import * as SessionProcessorModule from "../../src/session/processor"
import { Snapshot } from "../../src/snapshot"
import { ProviderTest } from "../fake/provider"
import { awaitWithTimeout, testEffect } from "../lib/effect" // kilocode_change
import { testEffect } from "../lib/effect"
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
import { TestConfig } from "../fixture/config"
import { SyncEvent } from "@/sync"
Expand Down Expand Up @@ -1296,15 +1296,9 @@ describe("session.compaction.process", () => {
.pipe(Effect.forkChild)

yield* Deferred.await(ready).pipe(Effect.timeout("1 second"))
// kilocode_change start - Windows CI can take longer than 250ms to schedule interrupt finalizers
const exit = yield* awaitWithTimeout(
Effect.gen(function* () {
yield* Fiber.interrupt(fiber)
return yield* Fiber.await(fiber)
}),
"compaction did not stop after retry-backoff interrupt",
"2 seconds",
)
// kilocode_change start - avoid a scheduler-sensitive inner deadline on loaded CI runners
yield* Fiber.interrupt(fiber)
const exit = yield* Fiber.await(fiber)
// kilocode_change end

expect(Exit.isFailure(exit)).toBe(true)
Expand Down
20 changes: 13 additions & 7 deletions packages/opencode/test/session/prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ it.live(
const a = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* llm.wait(1)
const b = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* Effect.sleep(50)
yield* Effect.yieldNow // kilocode_change - let the queued caller join without a wall-clock race

yield* prompt.cancel(chat.id)
const [exitA, exitB] = yield* Effect.all([Fiber.await(a), Fiber.await(b)])
Expand Down Expand Up @@ -1287,7 +1287,7 @@ it.live(
const a = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* llm.wait(1)
const b = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* Effect.sleep(50)
yield* Effect.yieldNow // kilocode_change - let the queued caller join without a wall-clock race
gate.resolve()

const [ea, eb] = yield* Effect.all([Fiber.await(a), Fiber.await(b)])
Expand Down Expand Up @@ -1692,7 +1692,7 @@ it.live(
// kilocode_change end

const loop = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* Effect.sleep(50)
yield* Effect.yieldNow // kilocode_change - give the queued loop a scheduler turn instead of a wall-clock window

expect(yield* llm.calls).toBe(0)

Expand Down Expand Up @@ -1734,7 +1734,7 @@ it.live(

const a = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
const b = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* Effect.sleep(50)
yield* Effect.yieldNow // kilocode_change - give the queued loops a scheduler turn instead of a wall-clock window

expect(yield* llm.calls).toBe(0)

Expand Down Expand Up @@ -1964,14 +1964,17 @@ unix(
(_dir) =>
Effect.gen(function* () {
const { prompt, chat } = yield* boot()
const status = yield* SessionStatus.Service // kilocode_change

const sh = yield* prompt
.shell({ sessionID: chat.id, agent: "build", command: "sleep 30" })
.pipe(Effect.forkChild)
yield* Effect.sleep(50)
// kilocode_change start - wait for shell to actually be running before forking the queued loop
yield* waitFor("shell busy", status.get(chat.id).pipe(Effect.map((s) => (s.type === "busy" ? s : undefined))))
// kilocode_change end

const loop = yield* prompt.loop({ sessionID: chat.id }).pipe(Effect.forkChild)
yield* Effect.sleep(50)
yield* Effect.yieldNow // kilocode_change - give the queued loop a scheduler turn before cancelling

yield* prompt.cancel(chat.id)

Expand All @@ -1997,11 +2000,14 @@ unix(
(_dir) =>
Effect.gen(function* () {
const { prompt, chat } = yield* boot()
const status = yield* SessionStatus.Service // kilocode_change

const a = yield* prompt
.shell({ sessionID: chat.id, agent: "build", command: "sleep 30" })
.pipe(Effect.forkChild)
yield* Effect.sleep(50)
// kilocode_change start - wait for shell to actually be running before exercising the busy guard
yield* waitFor("shell busy", status.get(chat.id).pipe(Effect.map((s) => (s.type === "busy" ? s : undefined))))
// kilocode_change end

const exit = yield* prompt
.shell({ sessionID: chat.id, agent: "build", command: "echo hi" })
Expand Down
Loading