feat: webapp support change inputs after conversation started (#16901)

This commit is contained in:
KVOJJJin
2025-03-27 11:58:16 +08:00
committed by GitHub
parent 0722beeb0b
commit c23135c9e8
15 changed files with 76 additions and 36 deletions

View File

@@ -263,6 +263,17 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
return conversationItem
}, [conversationList, currentConversationId, pinnedConversationList])
const currentConversationLatestInputs = useMemo(() => {
if (!currentConversationId || !appChatListData?.data.length)
return {}
return appChatListData.data.slice().pop().inputs || {}
}, [appChatListData, currentConversationId])
const [currentConversationInputs, setCurrentConversationInputs] = useState<Record<string, any>>(currentConversationLatestInputs || {})
useEffect(() => {
if (currentConversationItem)
setCurrentConversationInputs(currentConversationLatestInputs || {})
}, [currentConversationItem, currentConversationLatestInputs])
const { notify } = useToastContext()
const checkInputsRequired = useCallback((silent?: boolean) => {
let hasEmptyInput = ''
@@ -464,5 +475,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
setClearChatList,
isResponding,
setIsResponding,
currentConversationInputs,
setCurrentConversationInputs,
}
}