From ca69d025bd91d812d8f5b71aebaff0fa448b9a1c Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 16 May 2025 14:33:30 +0530 Subject: [PATCH] (fix:agents) adhere to new MessageInput --- frontend/src/agents/AgentPreview.tsx | 26 ++++++-------------------- frontend/src/agents/SharedAgent.tsx | 18 ++++++------------ 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/frontend/src/agents/AgentPreview.tsx b/frontend/src/agents/AgentPreview.tsx index 621ac477..cd4fdc18 100644 --- a/frontend/src/agents/AgentPreview.tsx +++ b/frontend/src/agents/AgentPreview.tsx @@ -65,22 +65,18 @@ export default function AgentPreview() { ); const handleQuestionSubmission = ( - updatedQuestion?: string, + question?: string, updated?: boolean, indx?: number, ) => { - if ( - updated === true && - updatedQuestion !== undefined && - indx !== undefined - ) { + if (updated === true && question !== undefined && indx !== undefined) { handleQuestion({ - question: updatedQuestion, + question, index: indx, isRetry: false, }); - } else if (input.trim() && status !== 'loading') { - const currentInput = input.trim(); + } else if (question && status !== 'loading') { + const currentInput = question.trim(); if (lastQueryReturnedErr && queries.length > 0) { const lastQueryIndex = queries.length - 1; handleQuestion({ @@ -95,14 +91,6 @@ export default function AgentPreview() { index: undefined, }); } - setInput(''); - } - }; - - const handleKeyDown = (event: React.KeyboardEvent) => { - if (event.key === 'Enter' && !event.shiftKey) { - event.preventDefault(); - handleQuestionSubmission(); } }; @@ -135,9 +123,7 @@ export default function AgentPreview() {
setInput(e.target.value)} - onSubmit={() => handleQuestionSubmission()} + onSubmit={(text) => handleQuestionSubmission(text)} loading={status === 'loading'} showSourceButton={selectedAgent ? false : true} showToolButton={selectedAgent ? false : true} diff --git a/frontend/src/agents/SharedAgent.tsx b/frontend/src/agents/SharedAgent.tsx index 3fa5f608..631a050b 100644 --- a/frontend/src/agents/SharedAgent.tsx +++ b/frontend/src/agents/SharedAgent.tsx @@ -91,22 +91,18 @@ export default function SharedAgent() { ); const handleQuestionSubmission = ( - updatedQuestion?: string, + question?: string, updated?: boolean, indx?: number, ) => { - if ( - updated === true && - updatedQuestion !== undefined && - indx !== undefined - ) { + if (updated === true && question !== undefined && indx !== undefined) { handleQuestion({ - question: updatedQuestion, + question, index: indx, isRetry: false, }); - } else if (input.trim() && status !== 'loading') { - const currentInput = input.trim(); + } else if (question && status !== 'loading') { + const currentInput = question.trim(); if (lastQueryReturnedErr && queries.length > 0) { const lastQueryIndex = queries.length - 1; handleQuestion({ @@ -183,9 +179,7 @@ export default function SharedAgent() {
setInput(e.target.value)} - onSubmit={() => handleQuestionSubmission()} + onSubmit={(text) => handleQuestionSubmission(text)} loading={status === 'loading'} showSourceButton={sharedAgent ? false : true} showToolButton={sharedAgent ? false : true}