From fb33e2ebe0fa3b1d155a22078b381a5fe611960d Mon Sep 17 00:00:00 2001 From: Gemini AI Date: Wed, 24 Dec 2025 22:54:20 +0400 Subject: [PATCH] Fix initialization order: Define filteredMessageIds before lastAssistantIndex Fixed 'Cannot access filteredMessageIds before initialization' error by reordering the declarations. Since lastAssistantIndex depends on filteredMessageIds, it must be defined after it. --- .../src/components/chat/multi-task-chat.tsx | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/ui/src/components/chat/multi-task-chat.tsx b/packages/ui/src/components/chat/multi-task-chat.tsx index e235361..8c15a74 100644 --- a/packages/ui/src/components/chat/multi-task-chat.tsx +++ b/packages/ui/src/components/chat/multi-task-chat.tsx @@ -97,6 +97,22 @@ export default function MultiTaskChat(props: MultiTaskChatProps) { // Message store integration const messageStore = () => messageStoreBus.getOrCreate(props.instanceId); + // Filter messages based on selected task - use store's session messages for the task session + // Must be defined before lastAssistantIndex which depends on it + const filteredMessageIds = createMemo(() => { + const task = selectedTask(); + if (!task) return []; // Show no messages in Pipeline view + + // If task has a dedicated session, get messages from the store for that session + if (task.taskSessionId) { + const store = messageStore(); + return store.getSessionMessageIds(task.taskSessionId); + } + + // Fallback to task.messageIds for backward compatibility + return task.messageIds || []; + }); + // Memoized to prevent recalculation on every render const lastAssistantIndex = createMemo(() => { const ids = filteredMessageIds(); @@ -117,21 +133,6 @@ export default function MultiTaskChat(props: MultiTaskChatProps) { return -1; }); - // Filter messages based on selected task - use store's session messages for the task session - const filteredMessageIds = createMemo(() => { - const task = selectedTask(); - if (!task) return []; // Show no messages in Pipeline view - - // If task has a dedicated session, get messages from the store for that session - if (task.taskSessionId) { - const store = messageStore(); - return store.getSessionMessageIds(task.taskSessionId); - } - - // Fallback to task.messageIds for backward compatibility - return task.messageIds || []; - }); - // Note: Auto-scroll is handled in two places: // 1. After sending a message (in handleSendMessage) // 2. During streaming (in the isAgentThinking effect below)