diff --git a/frontend/app/components/Kai/KaiService.ts b/frontend/app/components/Kai/KaiService.ts index 1843af9cd..48ab8eafc 100644 --- a/frontend/app/components/Kai/KaiService.ts +++ b/frontend/app/components/Kai/KaiService.ts @@ -126,8 +126,10 @@ export default class KaiService extends AiService { getPromptSuggestions = async ( projectId: string, + threadId?: string | null, ): Promise => { - const r = await this.client.get(`/kai/${projectId}/prompt-suggestions`); + const endpoint = (threadId) ? `/kai/${projectId}/chats/${threadId}/prompt-suggestions` : `/kai/${projectId}/prompt-suggestions`; + const r = await this.client.get(endpoint); if (!r.ok) { throw new Error('Failed to fetch prompt suggestions'); } diff --git a/frontend/app/components/Kai/components/ChatLog.tsx b/frontend/app/components/Kai/components/ChatLog.tsx index ecb4405b4..5c3dca6c5 100644 --- a/frontend/app/components/Kai/components/ChatLog.tsx +++ b/frontend/app/components/Kai/components/ChatLog.tsx @@ -1,6 +1,7 @@ import React from 'react'; import ChatInput from './ChatInput'; import ChatMsg, { ChatNotice } from './ChatMsg'; +import Ideas from "./Ideas"; import { Loader } from 'UI'; import { kaiStore } from '../KaiStore'; import { observer } from 'mobx-react-lite'; @@ -81,6 +82,7 @@ function ChatLog({ duration={processingStage.duration} /> ) : null} + {(!processingStage && lastHumanMsgInd && messages.length == lastHumanMsgInd + 2) ? onSubmit(query)} projectId={projectId} threadId={threadId}/> : null}
diff --git a/frontend/app/components/Kai/components/Ideas.tsx b/frontend/app/components/Kai/components/Ideas.tsx index 2cca2d444..f1104756e 100644 --- a/frontend/app/components/Kai/components/Ideas.tsx +++ b/frontend/app/components/Kai/components/Ideas.tsx @@ -4,14 +4,14 @@ import { useQuery } from '@tanstack/react-query'; import { kaiService } from 'App/services'; import { useTranslation } from 'react-i18next'; -function Ideas({ onClick, projectId }: { onClick: (query: string) => void, projectId: string }) { +function Ideas({ onClick, projectId, threadId = null }: { onClick: (query: string) => void, projectId: string, threadId?: string | null }) { const { t } = useTranslation(); const { data: suggestedPromptIdeas = [], isPending, } = useQuery({ - queryKey: ['kai', 'prompt-suggestions', projectId], - queryFn: () => kaiService.getPromptSuggestions(projectId), + queryKey: ['kai', projectId, 'chats', threadId, 'prompt-suggestions'], + queryFn: () => kaiService.getPromptSuggestions(projectId, threadId), staleTime: 1000 * 60, }); const ideas = React.useMemo(() => {