@@ -28,6 +28,7 @@ import {
28
28
submitTextToCadMultiFileIterationRequest ,
29
29
constructMultiFileIterationRequestWithPromptHelpers ,
30
30
} from '@src/lib/promptToEdit'
31
+ import toast from 'react-hot-toast'
31
32
32
33
const MLEPHANT_POLL_STATUSES_MS = 5000
33
34
@@ -182,6 +183,18 @@ export const mlEphantManagerMachine = setup({
182
183
context : { } as MlEphantManagerContext ,
183
184
events : { } as MlEphantManagerEvents ,
184
185
} ,
186
+ actions : {
187
+ toastError : ( { event } ) => {
188
+ console . error ( event )
189
+ if ( 'output' in event && event . output instanceof Error ) {
190
+ toast . error ( event . output . message )
191
+ } else if ( 'data' in event && event . data instanceof Error ) {
192
+ toast . error ( event . data . message )
193
+ } else if ( 'error' in event && event . error instanceof Error ) {
194
+ toast . error ( event . error . message )
195
+ }
196
+ } ,
197
+ } ,
185
198
actors : {
186
199
[ MlEphantManagerTransitions . GetConversationsThatCreatedProjects ] :
187
200
fromPromise ( async function ( args : {
@@ -553,7 +566,7 @@ export const mlEphantManagerMachine = setup({
553
566
// On failure we need correct dependencies still.
554
567
onError : {
555
568
target : MlEphantManagerStates . NeedDependencies ,
556
- actions : console . error ,
569
+ actions : 'toastError' ,
557
570
} ,
558
571
} ,
559
572
} ,
@@ -582,7 +595,7 @@ export const mlEphantManagerMachine = setup({
582
595
target : S . Await ,
583
596
actions : assign ( ( { event } ) => event . output ) ,
584
597
} ,
585
- onError : { target : S . Await , actions : console . error } ,
598
+ onError : { target : S . Await , actions : 'toastError' } ,
586
599
} ,
587
600
} ,
588
601
} ,
@@ -625,7 +638,7 @@ export const mlEphantManagerMachine = setup({
625
638
target : S . Await ,
626
639
actions : assign ( ( { event } ) => event . output ) ,
627
640
} ,
628
- onError : { target : S . Await , actions : console . error } ,
641
+ onError : { target : S . Await , actions : 'toastError' } ,
629
642
} ,
630
643
} ,
631
644
[ MlEphantManagerTransitions . GetPromptsBelongingToConversation ] : {
@@ -640,7 +653,7 @@ export const mlEphantManagerMachine = setup({
640
653
target : S . Await ,
641
654
actions : assign ( ( { event } ) => event . output ) ,
642
655
} ,
643
- onError : { target : S . Await , actions : console . error } ,
656
+ onError : { target : S . Await , actions : 'toastError' } ,
644
657
} ,
645
658
} ,
646
659
[ MlEphantManagerTransitions . GetReasoningForPrompt ] : {
@@ -670,7 +683,7 @@ export const mlEphantManagerMachine = setup({
670
683
target : S . Await ,
671
684
actions : assign ( ( { event } ) => event . output ) ,
672
685
} ,
673
- onError : { target : S . Await , actions : console . error } ,
686
+ onError : { target : S . Await , actions : 'toastError' } ,
674
687
} ,
675
688
} ,
676
689
[ MlEphantManagerTransitions . PromptCreateModel ] : {
@@ -685,7 +698,7 @@ export const mlEphantManagerMachine = setup({
685
698
target : MlEphantManagerTransitions . GetReasoningForPrompt ,
686
699
actions : assign ( ( { event } ) => event . output ) ,
687
700
} ,
688
- onError : { target : S . Await , actions : console . error } ,
701
+ onError : { target : S . Await , actions : 'toastError' } ,
689
702
} ,
690
703
} ,
691
704
[ MlEphantManagerTransitions . PromptEditModel ] : {
@@ -700,7 +713,7 @@ export const mlEphantManagerMachine = setup({
700
713
target : MlEphantManagerTransitions . GetReasoningForPrompt ,
701
714
actions : assign ( ( { event } ) => event . output ) ,
702
715
} ,
703
- onError : { target : S . Await , actions : console . error } ,
716
+ onError : { target : S . Await , actions : 'toastError' } ,
704
717
} ,
705
718
} ,
706
719
[ MlEphantManagerTransitions . PromptFeedback ] : {
@@ -715,7 +728,7 @@ export const mlEphantManagerMachine = setup({
715
728
target : S . Await ,
716
729
actions : assign ( ( { event } ) => event . output ) ,
717
730
} ,
718
- onError : { target : S . Await , actions : console . error } ,
731
+ onError : { target : S . Await , actions : 'toastError' } ,
719
732
} ,
720
733
} ,
721
734
[ MlEphantManagerTransitions . AppendThoughtForPrompt ] : {
0 commit comments