From df6ed871f7f844f4b38cdb7b27f55257f681b4bd Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 10 Jun 2025 04:46:50 +0100 Subject: [PATCH] Handle chat submission --- .../FrameRenderer/RoadmapFloatingChat.tsx | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/components/FrameRenderer/RoadmapFloatingChat.tsx b/src/components/FrameRenderer/RoadmapFloatingChat.tsx index 7b52169e6..96a379e60 100644 --- a/src/components/FrameRenderer/RoadmapFloatingChat.tsx +++ b/src/components/FrameRenderer/RoadmapFloatingChat.tsx @@ -157,26 +157,20 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) { setIsOpen(false); }); + function textToJSON(text: string): JSONContent { + return { + type: 'doc', + content: [{ type: 'paragraph', content: [{ type: 'text', text }] }], + }; + } + const submitInput = () => { const trimmed = inputValue.trim(); if (!trimmed) { return; } - const json: JSONContent = { - type: 'doc', - content: [ - { - type: 'paragraph', - content: [ - { - type: 'text', - text: trimmed, - }, - ], - }, - ], - }; + const json: JSONContent = textToJSON(trimmed); setInputValue(''); handleChatSubmit(json, isRoadmapDetailLoading); @@ -266,8 +260,10 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) { key={`default-question-${index}`} className="flex h-full self-start rounded-md bg-yellow-500/10 px-3 py-2 text-left text-sm text-black hover:bg-yellow-500/20" onClick={() => { - setInputValue(question); - inputRef.current?.focus(); + handleChatSubmit( + textToJSON(question), + isRoadmapDetailLoading, + ); }} > {question}