From 1e82083a3c8b27e61cbabe95c1df923cfab68703 Mon Sep 17 00:00:00 2001 From: MananTank Date: Fri, 2 May 2025 14:56:24 +0000 Subject: [PATCH] [NEB-229] Nebula: follow-up prompt improvements, preserve reasoning UI on error (#6925) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on enhancing the `ChatPageContent` and `Chats` components by managing message handling and improving the logic for sending prompts based on the presence of subsequent messages. ### Detailed summary - Removed logic to delete the last message if it is of type `presence` in `ChatPageContent.tsx`. - Added `nextMessage` prop to `RenderMessage` in `Chats.tsx`. - Updated `onTxSettled` to prevent sending prompts if the `nextMessage` is of type `action`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../(app)/components/ChatPageContent.tsx | 4 ---- .../app/nebula-app/(app)/components/Chats.tsx | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx index 6003ae1e1f4..9d154254531 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx @@ -375,10 +375,6 @@ export function ChatPageContent(props: { chatAbortController?.abort(); setChatAbortController(undefined); setIsChatStreaming(false); - // if last message is presence, remove it - if (messages[messages.length - 1]?.type === "presence") { - setMessages((prev) => prev.slice(0, -1)); - } }} context={contextFilters} setContext={(v) => { diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx index 82cceeb5d1e..cadaefa4c30 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx @@ -173,6 +173,7 @@ export function Chats(props: { isMessagePending={isMessagePending} client={props.client} sendMessage={props.sendMessage} + nextMessage={props.messages[index + 1]} /> @@ -207,8 +208,9 @@ function RenderMessage(props: { isMessagePending: boolean; client: ThirdwebClient; sendMessage: (message: string) => void; + nextMessage: ChatMessage | undefined; }) { - const { message, isMessagePending, client, sendMessage } = props; + const { message, isMessagePending, client, sendMessage, nextMessage } = props; switch (message.type) { case "assistant": @@ -237,6 +239,11 @@ function RenderMessage(props: { txData={message.data} client={client} onTxSettled={(txHash) => { + // do not send automatic prompt if there is another transaction after this one + if (nextMessage?.type === "action") { + return; + } + sendMessage(getTransactionSettledPrompt(txHash)); }} /> @@ -254,8 +261,13 @@ function RenderMessage(props: { { - // no op + onTxSettled={(txHash) => { + // do not send automatic prompt if there is another transaction after this one + if (nextMessage?.type === "action") { + return; + } + + sendMessage(getTransactionSettledPrompt(txHash)); }} /> );