@@ -3,9 +3,8 @@ import { useChatStore } from '../../state/chat-store'
33import { processBashContext } from '../../utils/bash-context-processor'
44import {
55 createErrorMessage ,
6- createPaymentErrorMessage ,
76 isOutOfCreditsError ,
8- isPaymentRequiredError ,
7+ OUT_OF_CREDITS_MESSAGE ,
98} from '../../utils/error-handling'
109import { formatElapsedTime } from '../../utils/format-elapsed-time'
1110import { processImagesForMessage } from '../../utils/image-processor'
@@ -215,23 +214,11 @@ export const handleRunCompletion = (params: {
215214 return
216215 }
217216
218- if ( isOutOfCreditsError ( output ) ) {
219- const { message, showUsageBanner } = createPaymentErrorMessage ( output )
220- updater . setError ( message )
221-
222- if ( showUsageBanner ) {
223- useChatStore . getState ( ) . setInputMode ( 'usage' )
224- queryClient . invalidateQueries ( {
225- queryKey : usageQueryKeys . current ( ) ,
226- } )
227- }
228- } else {
229- const partial = createErrorMessage (
230- output . message ?? 'No output from agent run' ,
231- aiMessageId ,
232- )
233- updater . setError ( partial . content ?? '' )
234- }
217+ const partial = createErrorMessage (
218+ output . message ?? 'No output from agent run' ,
219+ aiMessageId ,
220+ )
221+ updater . setError ( partial . content ?? '' )
235222
236223 finalizeAfterError ( )
237224 return
@@ -302,10 +289,8 @@ export const handleRunError = (params: {
302289 updateChainInProgress ( false )
303290 timerController . stop ( 'error' )
304291
305- if ( isPaymentRequiredError ( error ) ) {
306- const { message } = createPaymentErrorMessage ( error )
307-
308- updater . setError ( message )
292+ if ( isOutOfCreditsError ( error ) ) {
293+ updater . setError ( OUT_OF_CREDITS_MESSAGE )
309294 useChatStore . getState ( ) . setInputMode ( 'usage' )
310295 queryClient . invalidateQueries ( { queryKey : usageQueryKeys . current ( ) } )
311296 return
0 commit comments