fix: web search references missing caused by early reset (#9328)

This commit is contained in:
one 2025-08-20 13:25:22 +08:00 committed by GitHub
parent cdca8c0ed7
commit f8120c2ebb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -40,7 +40,6 @@ export const createCitationCallbacks = (deps: CitationCallbacksDependencies) =>
status: MessageBlockStatus.SUCCESS
}
blockManager.smartBlockUpdate(citationBlockId, changes, MessageBlockType.CITATION, true)
citationBlockId = null
} else {
logger.error('[onExternalToolComplete] citationBlockId is null. Cannot update.')
}
@ -121,6 +120,9 @@ export const createCitationCallbacks = (deps: CitationCallbacksDependencies) =>
},
// 暴露给外部的方法用于textCallbacks中获取citationBlockId
getCitationBlockId: () => citationBlockId
getCitationBlockId: () => citationBlockId,
setCitationBlockId: (id: string | null) => {
citationBlockId = id
}
}
}

View File

@ -59,7 +59,8 @@ export const createCallbacks = (deps: CallbacksDependencies) => {
blockManager,
getState,
assistantMsgId,
getCitationBlockId: citationCallbacks.getCitationBlockId
getCitationBlockId: citationCallbacks.getCitationBlockId,
setCitationBlockId: citationCallbacks.setCitationBlockId
})
// 组合所有回调

View File

@ -12,10 +12,11 @@ interface TextCallbacksDependencies {
getState: any
assistantMsgId: string
getCitationBlockId: () => string | null
setCitationBlockId: (id: string | null) => void
}
export const createTextCallbacks = (deps: TextCallbacksDependencies) => {
const { blockManager, getState, assistantMsgId, getCitationBlockId } = deps
const { blockManager, getState, assistantMsgId, getCitationBlockId, setCitationBlockId } = deps
// 内部维护的状态
let mainTextBlockId: string | null = null
@ -62,6 +63,7 @@ export const createTextCallbacks = (deps: TextCallbacksDependencies) => {
}
blockManager.smartBlockUpdate(mainTextBlockId, changes, MessageBlockType.MAIN_TEXT, true)
mainTextBlockId = null
setCitationBlockId(null)
} else {
logger.warn(
`[onTextComplete] Received text.complete but last block was not MAIN_TEXT (was ${blockManager.lastBlockType}) or lastBlockId is null.`