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.
This commit is contained in:
Gemini AI
2025-12-24 22:54:20 +04:00
Unverified
parent 6c63bb7d7d
commit fb33e2ebe0

View File

@@ -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)