diff --git a/backend/app/controller/chat_controller.py b/backend/app/controller/chat_controller.py index dd28fe3e4..be7fe2e0d 100644 --- a/backend/app/controller/chat_controller.py +++ b/backend/app/controller/chat_controller.py @@ -61,6 +61,9 @@ async def post(data: Chat, request: Request): if data.is_cloud(): os.environ["cloud_api_key"] = data.api_key + # Put initial action in queue to start processing + await task_lock.put_queue(ActionImproveData(data=data.question)) + chat_logger.info(f"Chat session initialized, starting streaming response for project_id: {data.project_id}") return StreamingResponse(step_solve(data, request, task_lock), media_type="text/event-stream") diff --git a/src/components/ChatBox/index.tsx b/src/components/ChatBox/index.tsx index ccbe9c157..661444bc3 100644 --- a/src/components/ChatBox/index.tsx +++ b/src/components/ChatBox/index.tsx @@ -213,7 +213,9 @@ export default function ChatBox(): JSX.Element { ); // Only start a new task if: pending, no messages processed yet - if (chatStore.tasks[_taskId as string].status === "pending" && !hasSimpleResponse && !hasComplexTask && !isFinished) { + // OR while or after replaying a project + if ((chatStore.tasks[_taskId as string].status === "pending" && !hasSimpleResponse && !hasComplexTask && !isFinished) + || chatStore.tasks[_taskId].type === "replay") { setMessage(""); // Pass the message content to startTask instead of adding it to current chatStore const attachesToSend = JSON.parse(JSON.stringify(chatStore.tasks[_taskId]?.attaches)) || []; diff --git a/src/store/chatStore.ts b/src/store/chatStore.ts index 7886082d1..47b8b5003 100644 --- a/src/store/chatStore.ts +++ b/src/store/chatStore.ts @@ -429,6 +429,9 @@ const chatStore = (initial?: Partial) => createStore()( targetChatStore.getState().setIsPending(newTaskId, false); + targetChatStore.getState().setDelayTime(newTaskId, delayTime as number); + targetChatStore.getState().setType(newTaskId, "replay"); + //From handleSend if message is given // Add the message to the new chatStore if provided if (question) {