diff --git a/src/components/ChatBox/index.tsx b/src/components/ChatBox/index.tsx index 7e3f8af3f..9da848c99 100644 --- a/src/components/ChatBox/index.tsx +++ b/src/components/ChatBox/index.tsx @@ -102,7 +102,6 @@ export default function ChatBox(): JSX.Element { const task = chatStore.tasks[_taskId]; const isTaskBusy = ( // running or paused counts as busy - // TODO: Bug where when replay end hasMessages = false & status = running (task.status === 'running' && !task.hasMessages) || task.status === 'pause' || // splitting phase: has to_sub_tasks not confirmed OR skeleton computing task.messages.some(m => m.step === 'to_sub_tasks' && !m.isConfirm) || @@ -111,6 +110,10 @@ export default function ChatBox(): JSX.Element { (!!task.messages.find(m => m.step === 'to_sub_tasks' && !m.isConfirm) && task.status === 'pending') ); + //Fixes bug where doesn't matter the SSE order or final state of the chatStore + const isReplayChatStore = chatStore.tasks[_taskId as string]?.type === "replay"; + const queueTask = isTaskBusy && !isReplayChatStore; + console.log(`Current task is ${isTaskBusy} with ${task}`); if (textareaRef.current) textareaRef.current.style.height = "60px"; @@ -152,7 +155,7 @@ export default function ChatBox(): JSX.Element { } } else { // If current task is busy (splitting/confirm/running), queue the new message instead of sending immediately - if (isTaskBusy) { + if (queueTask) { const project_id = projectStore.activeProjectId; // Queue the message locally; do not send to backend yet. const currentAttaches = JSON.parse(JSON.stringify(task.attaches)) || []; diff --git a/src/store/projectStore.ts b/src/store/projectStore.ts index 40cdcf4dc..6fcdb22ab 100644 --- a/src/store/projectStore.ts +++ b/src/store/projectStore.ts @@ -196,7 +196,8 @@ const projectStore = create()((set, get) => ({ queuedMessages: [], // Initialize empty queued messages array metadata: { status: 'active', - historyId: historyId + historyId: historyId, + tags: type === ProjectType.REPLAY ? ["replay"] : [] } };