mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
fix: web search references missing caused by early reset (#9328)
This commit is contained in:
parent
cdca8c0ed7
commit
f8120c2ebb
@ -40,7 +40,6 @@ export const createCitationCallbacks = (deps: CitationCallbacksDependencies) =>
|
|||||||
status: MessageBlockStatus.SUCCESS
|
status: MessageBlockStatus.SUCCESS
|
||||||
}
|
}
|
||||||
blockManager.smartBlockUpdate(citationBlockId, changes, MessageBlockType.CITATION, true)
|
blockManager.smartBlockUpdate(citationBlockId, changes, MessageBlockType.CITATION, true)
|
||||||
citationBlockId = null
|
|
||||||
} else {
|
} else {
|
||||||
logger.error('[onExternalToolComplete] citationBlockId is null. Cannot update.')
|
logger.error('[onExternalToolComplete] citationBlockId is null. Cannot update.')
|
||||||
}
|
}
|
||||||
@ -121,6 +120,9 @@ export const createCitationCallbacks = (deps: CitationCallbacksDependencies) =>
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 暴露给外部的方法,用于textCallbacks中获取citationBlockId
|
// 暴露给外部的方法,用于textCallbacks中获取citationBlockId
|
||||||
getCitationBlockId: () => citationBlockId
|
getCitationBlockId: () => citationBlockId,
|
||||||
|
setCitationBlockId: (id: string | null) => {
|
||||||
|
citationBlockId = id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,8 @@ export const createCallbacks = (deps: CallbacksDependencies) => {
|
|||||||
blockManager,
|
blockManager,
|
||||||
getState,
|
getState,
|
||||||
assistantMsgId,
|
assistantMsgId,
|
||||||
getCitationBlockId: citationCallbacks.getCitationBlockId
|
getCitationBlockId: citationCallbacks.getCitationBlockId,
|
||||||
|
setCitationBlockId: citationCallbacks.setCitationBlockId
|
||||||
})
|
})
|
||||||
|
|
||||||
// 组合所有回调
|
// 组合所有回调
|
||||||
|
|||||||
@ -12,10 +12,11 @@ interface TextCallbacksDependencies {
|
|||||||
getState: any
|
getState: any
|
||||||
assistantMsgId: string
|
assistantMsgId: string
|
||||||
getCitationBlockId: () => string | null
|
getCitationBlockId: () => string | null
|
||||||
|
setCitationBlockId: (id: string | null) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTextCallbacks = (deps: TextCallbacksDependencies) => {
|
export const createTextCallbacks = (deps: TextCallbacksDependencies) => {
|
||||||
const { blockManager, getState, assistantMsgId, getCitationBlockId } = deps
|
const { blockManager, getState, assistantMsgId, getCitationBlockId, setCitationBlockId } = deps
|
||||||
|
|
||||||
// 内部维护的状态
|
// 内部维护的状态
|
||||||
let mainTextBlockId: string | null = null
|
let mainTextBlockId: string | null = null
|
||||||
@ -62,6 +63,7 @@ export const createTextCallbacks = (deps: TextCallbacksDependencies) => {
|
|||||||
}
|
}
|
||||||
blockManager.smartBlockUpdate(mainTextBlockId, changes, MessageBlockType.MAIN_TEXT, true)
|
blockManager.smartBlockUpdate(mainTextBlockId, changes, MessageBlockType.MAIN_TEXT, true)
|
||||||
mainTextBlockId = null
|
mainTextBlockId = null
|
||||||
|
setCitationBlockId(null)
|
||||||
} else {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[onTextComplete] Received text.complete but last block was not MAIN_TEXT (was ${blockManager.lastBlockType}) or lastBlockId is null.`
|
`[onTextComplete] Received text.complete but last block was not MAIN_TEXT (was ${blockManager.lastBlockType}) or lastBlockId is null.`
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user