mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +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
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { generateChangeWalkthrough, getChangeWalkthrough } from '@/api/changeWalkthroughs'
|
||||
import { cancelChangeWalkthrough, generateChangeWalkthrough, getChangeWalkthrough } from '@/api/changeWalkthroughs'
|
||||
import { walkthroughHunksIdentity, walkthroughSourceKey } from '@opencode-manager/shared/schemas'
|
||||
import type {
|
||||
ChangeWalkthrough,
|
||||
@@ -81,3 +81,23 @@ export function useGenerateChangeWalkthrough(sessionId: string | undefined, sour
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useCancelChangeWalkthrough(sessionId: string | undefined, source: WalkthroughSource) {
|
||||
const queryClient = useQueryClient()
|
||||
const sourceKey = walkthroughSourceKey(source)
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
const targetSessionId = sessionId!
|
||||
await cancelChangeWalkthrough(targetSessionId, source)
|
||||
return { sessionId: targetSessionId, sourceKey }
|
||||
},
|
||||
onSuccess: ({ sessionId: targetSessionId, sourceKey: targetSourceKey }) => {
|
||||
const queryKey = changeWalkthroughQueryKey(targetSessionId, targetSourceKey)
|
||||
queryClient.setQueryData<ChangeWalkthroughState>(queryKey, (cached) =>
|
||||
cached ? { ...cached, generating: false, error: null } : cached,
|
||||
)
|
||||
queryClient.invalidateQueries({ queryKey })
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user