From a69b7ee5a7e36346e83b3a5d494e011773f2aab1 Mon Sep 17 00:00:00 2001 From: adamrturman Date: Wed, 15 Jan 2025 12:33:32 -0600 Subject: [PATCH] fix: clean up two explicit errors handled elsewhere --- src/App.tsx | 7 +------ src/ChatView.tsx | 12 ++---------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 63058c5a..37912f5f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -151,18 +151,13 @@ export const App = () => { messageStore, ) .catch((error) => { - let errorMessage = + const errorMessage = typeof error === 'object' && error !== null && 'message' in error ? (error as { message: string }).message : 'An error occurred - please try again'; - // Errors can be thrown when recursive call is cancelled - if (errorMessage.includes('JSON')) { - errorMessage = 'You clicked cancel - please try again'; - } - setErrorText(errorMessage); }) .finally(() => { diff --git a/src/ChatView.tsx b/src/ChatView.tsx index 8caece80..bad8226a 100644 --- a/src/ChatView.tsx +++ b/src/ChatView.tsx @@ -62,15 +62,7 @@ export const ChatView = ({ ); const handleButtonClick = useCallback(() => { - const lastMessage = messages[messages.length - 1]; - const lastMessageRole = lastMessage.role; - - // if a user has initiated a wallet-based tool call, but not confirmed or denied it - // we don't want to add more messages to the history - const userRequestInProgress = - messages.length > 1 && lastMessageRole === 'user'; - - if (isRequesting || userRequestInProgress) { + if (isRequesting) { onCancel(); return; } @@ -90,7 +82,7 @@ export const ChatView = ({ onSubmit(output); setInputValue(''); - }, [messages, isRequesting, inputValue, onSubmit, onCancel]); + }, [isRequesting, inputValue, onSubmit, onCancel]); const buttonRef = useRef(null); const handleKeyDown = (event: React.KeyboardEvent) => {