|
|
|
|
@ -33,22 +33,27 @@ export const useLogs = () => {
|
|
|
|
|
setIterationResultDurationMap(iterDurationMap)
|
|
|
|
|
}, [setShowIteratingDetailTrue, setIterationResultList, setIterationResultDurationMap])
|
|
|
|
|
|
|
|
|
|
const [agentOrToolLogIdStack, setAgentOrToolLogIdStack] = useState<string[]>([])
|
|
|
|
|
const agentOrToolLogIdStackRef = useRef(agentOrToolLogIdStack)
|
|
|
|
|
const [agentOrToolLogItemStack, setAgentOrToolLogItemStack] = useState<{ id: string; label: string }[]>([])
|
|
|
|
|
const agentOrToolLogItemStackRef = useRef(agentOrToolLogItemStack)
|
|
|
|
|
const [agentOrToolLogListMap, setAgentOrToolLogListMap] = useState<Record<string, AgentLogItemWithChildren[]>>({})
|
|
|
|
|
const agentOrToolLogListMapRef = useRef(agentOrToolLogListMap)
|
|
|
|
|
const handleShowAgentOrToolLog = useCallback((detail: AgentLogItemWithChildren) => {
|
|
|
|
|
const { id, children } = detail
|
|
|
|
|
let currentAgentOrToolLogIdStack = agentOrToolLogIdStackRef.current.slice()
|
|
|
|
|
const index = currentAgentOrToolLogIdStack.findIndex(logId => logId === id)
|
|
|
|
|
const handleShowAgentOrToolLog = useCallback((detail?: AgentLogItemWithChildren) => {
|
|
|
|
|
if (!detail) {
|
|
|
|
|
setAgentOrToolLogItemStack([])
|
|
|
|
|
agentOrToolLogItemStackRef.current = []
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const { id, label, children } = detail
|
|
|
|
|
let currentAgentOrToolLogItemStack = agentOrToolLogItemStackRef.current.slice()
|
|
|
|
|
const index = currentAgentOrToolLogItemStack.findIndex(logItem => logItem.id === id)
|
|
|
|
|
|
|
|
|
|
if (index > -1)
|
|
|
|
|
currentAgentOrToolLogIdStack = currentAgentOrToolLogIdStack.slice(0, index + 1)
|
|
|
|
|
currentAgentOrToolLogItemStack = currentAgentOrToolLogItemStack.slice(0, index + 1)
|
|
|
|
|
else
|
|
|
|
|
currentAgentOrToolLogIdStack = [...currentAgentOrToolLogIdStack.slice(), id]
|
|
|
|
|
currentAgentOrToolLogItemStack = [...currentAgentOrToolLogItemStack.slice(), { id, label }]
|
|
|
|
|
|
|
|
|
|
setAgentOrToolLogIdStack(currentAgentOrToolLogIdStack)
|
|
|
|
|
agentOrToolLogIdStackRef.current = currentAgentOrToolLogIdStack
|
|
|
|
|
setAgentOrToolLogItemStack(currentAgentOrToolLogItemStack)
|
|
|
|
|
agentOrToolLogItemStackRef.current = currentAgentOrToolLogItemStack
|
|
|
|
|
|
|
|
|
|
if (children) {
|
|
|
|
|
setAgentOrToolLogListMap({
|
|
|
|
|
@ -56,10 +61,10 @@ export const useLogs = () => {
|
|
|
|
|
[id]: children,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, [setAgentOrToolLogIdStack, setAgentOrToolLogListMap])
|
|
|
|
|
}, [setAgentOrToolLogItemStack, setAgentOrToolLogListMap])
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
showSpecialResultPanel: showRetryDetail || showIteratingDetail || !!agentOrToolLogIdStack.length,
|
|
|
|
|
showSpecialResultPanel: showRetryDetail || showIteratingDetail || !!agentOrToolLogItemStack.length,
|
|
|
|
|
showRetryDetail,
|
|
|
|
|
setShowRetryDetailTrue,
|
|
|
|
|
setShowRetryDetailFalse,
|
|
|
|
|
@ -76,7 +81,7 @@ export const useLogs = () => {
|
|
|
|
|
setIterationResultDurationMap,
|
|
|
|
|
handleShowIterationResultList,
|
|
|
|
|
|
|
|
|
|
agentOrToolLogIdStack,
|
|
|
|
|
agentOrToolLogItemStack,
|
|
|
|
|
agentOrToolLogListMap,
|
|
|
|
|
handleShowAgentOrToolLog,
|
|
|
|
|
}
|
|
|
|
|
|