mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix(walkthrough): address review of agent-opened walkthrough
- Wait for the model catalog once per walkthrough generation instead of before every model call - Report open_walkthrough as requested, not opened, and drop its unused metadata - Share the ocm tool and action names through @opencode-manager/shared - Remove the unused source-request nonce and duplicate session check - Scan only new messages when auto-opening the walkthrough - Assert the request action cannot reach the internal change-walkthroughs route
This commit is contained in:
1 parent
aa1da8d608
commit
c497df5161
14 files changed
+146
-122
No files matched your search
@@ -27,6 +27,7 @@ export function useAutoOpenWalkthrough({
|
||||
}: UseAutoOpenWalkthroughOptions): void {
|
||||
const seenRef = useRef<Set<string> | null>(null)
|
||||
const frontierRef = useRef<string | null>(null)
|
||||
const lastScannedRef = useRef<string | null>(null)
|
||||
const sessionRef = useRef<string | undefined>(undefined)
|
||||
const onOpenRef = useRef(onOpen)
|
||||
onOpenRef.current = onOpen
|
||||
@@ -36,16 +37,33 @@ export function useAutoOpenWalkthrough({
|
||||
sessionRef.current = sessionId
|
||||
seenRef.current = null
|
||||
frontierRef.current = null
|
||||
lastScannedRef.current = null
|
||||
}
|
||||
if (loading) return
|
||||
if (seenRef.current === null) {
|
||||
seenRef.current = new Set(collectOpenWalkthroughCalls(messages).map((call) => call.id))
|
||||
frontierRef.current = messages[0]?.id ?? null
|
||||
lastScannedRef.current = messages[messages.length - 1]?.id ?? null
|
||||
return
|
||||
}
|
||||
const frontier = frontierRef.current
|
||||
const liveMessages =
|
||||
frontier === null ? messages : messages.filter((message) => message.id >= frontier)
|
||||
const lastScannedId = lastScannedRef.current
|
||||
let scanFrom = -1
|
||||
if (lastScannedId !== null) {
|
||||
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
||||
if (messages[index]?.id === lastScannedId) {
|
||||
scanFrom = index
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
let liveMessages: SessionMessageInfo[]
|
||||
if (scanFrom >= 0) {
|
||||
liveMessages = messages.slice(scanFrom)
|
||||
} else {
|
||||
const frontier = frontierRef.current
|
||||
liveMessages = frontier === null ? messages : messages.filter((message) => message.id >= frontier)
|
||||
}
|
||||
lastScannedRef.current = messages[messages.length - 1]?.id ?? null
|
||||
let opened = false
|
||||
for (const call of collectOpenWalkthroughCalls(liveMessages)) {
|
||||
if (seenRef.current.has(call.id)) continue
|
||||
|
||||
Reference in new issue
Block a user