diff --git a/web/src/hooks/useChat.ts b/web/src/hooks/useChat.ts index 28f3496..69f5614 100644 --- a/web/src/hooks/useChat.ts +++ b/web/src/hooks/useChat.ts @@ -445,20 +445,30 @@ export function useChat(): UseChatReturn { case 'task_started': { const msg = message as TaskStarted + console.log('[useChat] task_started received:', { task_id: msg.task_id, topic_id: msg.topic_id, parent_task_id: msg.parent_task_id, selectedTopic: selectedTopicRef.current }) // 只 backfill 当前话题的 task tool_call,避免跨话题串扰 - if (msg.topic_id && msg.topic_id !== selectedTopicRef.current) break + if (msg.topic_id && msg.topic_id !== selectedTopicRef.current) { + console.log('[useChat] task_started filtered by topic_id') + break + } // 孙智能体的 TaskStarted 不应 backfill 到主视图 - if (msg.parent_task_id) break + if (msg.parent_task_id) { + console.log('[useChat] task_started filtered by parent_task_id') + break + } // 设置 navigateToTaskId,让用户可以点击查看实时进度 setMessages((prev) => { + console.log('[useChat] task_started searching messages for task tool_call, total messages:', prev.length) for (let i = prev.length - 1; i >= 0; i--) { if (prev[i].type === 'tool_call' && prev[i].toolName === 'task' && !prev[i].navigateToTaskId) { + console.log('[useChat] task_started SET navigateToTaskId at index', i, 'task_id:', msg.task_id) const updated = [...prev] updated[i] = { ...updated[i], navigateToTaskId: msg.task_id } return updated } } + console.log('[useChat] task_started NO matching task tool_call found in messages') return prev }) break