Skip to content

Commit 6c9b2c3

Browse files
committed
core: allow starting new sessions after errors by fixing stuck session status
1 parent 3ab41d5 commit 6c9b2c3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/opencode/src/session/processor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ export namespace SessionProcessor {
368368
sessionID: input.assistantMessage.sessionID,
369369
error: input.assistantMessage.error,
370370
})
371+
SessionStatus.set(input.sessionID, { type: "idle" })
371372
}
372373
if (snapshot) {
373374
const patch = await Snapshot.patch(snapshot)

packages/opencode/src/session/prompt.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export namespace SessionPrompt {
6262
abort: AbortController
6363
callbacks: {
6464
resolve(input: MessageV2.WithParts): void
65-
reject(): void
65+
reject(reason?: any): void
6666
}[]
6767
}
6868
> = {}
@@ -72,7 +72,7 @@ export namespace SessionPrompt {
7272
for (const item of Object.values(current)) {
7373
item.abort.abort()
7474
for (const callback of item.callbacks) {
75-
callback.reject()
75+
callback.reject(new DOMException("Aborted", "AbortError"))
7676
}
7777
}
7878
},
@@ -251,10 +251,13 @@ export namespace SessionPrompt {
251251
log.info("cancel", { sessionID })
252252
const s = state()
253253
const match = s[sessionID]
254-
if (!match) return
254+
if (!match) {
255+
SessionStatus.set(sessionID, { type: "idle" })
256+
return
257+
}
255258
match.abort.abort()
256259
for (const item of match.callbacks) {
257-
item.reject()
260+
item.reject(new DOMException("Aborted", "AbortError"))
258261
}
259262
delete s[sessionID]
260263
SessionStatus.set(sessionID, { type: "idle" })

0 commit comments

Comments
 (0)