mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(walkthrough): stop an in-flight change walkthrough generation
Add DELETE /api/change-walkthroughs/:sessionId to cancel the generation for a session and source. The service removes the in-flight entry, persists the partial walkthrough, and aborts a per-generation signal threaded through model resolution and every model call. Cancellation is not recorded as a failure and leaves the remaining stops pending. A Stop button in the walkthrough chrome calls the new endpoint.
This commit is contained in:
1 parent
2d134d9de7
commit
0752ebf360
12 files changed
+334
-21
No files matched your search
@@ -14,9 +14,18 @@ export async function generateTextWithTimeout(
|
||||
client: OpenCodeClient,
|
||||
input: { prompt: string; model?: ModelRef },
|
||||
timeoutMs: number,
|
||||
signal?: AbortSignal,
|
||||
): Promise<string> {
|
||||
const controller = new AbortController()
|
||||
let timer: ReturnType<typeof setTimeout> | undefined
|
||||
const abortFromSignal = () => controller.abort(signal?.reason)
|
||||
if (signal) {
|
||||
if (signal.aborted) {
|
||||
controller.abort(signal.reason)
|
||||
} else {
|
||||
signal.addEventListener('abort', abortFromSignal, { once: true })
|
||||
}
|
||||
}
|
||||
const timeout = new Promise<never>((_resolve, reject) => {
|
||||
timer = setTimeout(() => {
|
||||
controller.abort()
|
||||
@@ -29,6 +38,7 @@ export async function generateTextWithTimeout(
|
||||
return text
|
||||
} finally {
|
||||
if (timer) clearTimeout(timer)
|
||||
signal?.removeEventListener('abort', abortFromSignal)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user