Skip to content

Commit 2a33add

Browse files
authored
fix(opencode): avoid shell cancel race (anomalyco#30641)
1 parent 9251e5d commit 2a33add

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎packages/opencode/src/session/run-state.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const layer = Layer.effect(
7878
yield* cancelBackgroundJobs(background, sessionID)
7979
const data = yield* InstanceState.get(state)
8080
const existing = data.runners.get(sessionID)
81-
if (!existing || !existing.busy) {
81+
if (!existing) {
8282
yield* status.set(sessionID, { type: "idle" })
8383
return
8484
}

‎packages/opencode/test/session/prompt.test.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ const useServerConfig = Effect.fn("test.useServerConfig")(function* (config: (ur
320320
return { dir, llm }
321321
})
322322

323-
// Wait for a session's runner to enter a busy state. SessionStatus is flipped to
324-
// "busy" inside Runner.startShell's modifyEffect at the same moment the runner
325-
// is registered, so this is a deterministic readiness signal — cancel can't
326-
// no-op once we observe it.
323+
// Wait for a session's runner to enter a busy state. SessionStatus is flipped
324+
// inside Runner.startShell's serialized transition, so cancel can't no-op once
325+
// we observe it.
327326
const waitForBusy = (sessionID: SessionID, duration: Duration.Input = "2 seconds") =>
328327
pollWithTimeout(
329328
Effect.gen(function* () {

0 commit comments

Comments
 (0)