@@ -14,7 +14,7 @@ import { useUIState } from "./context/ui-state"
1414import { AgentTimeline } from "./components/timeline"
1515import { OutputWindow , TelemetryBar , StatusFooter } from "./components/output"
1616import { formatRuntime } from "./state/formatters"
17- import { CheckpointModal , LogViewer , HistoryView , StopModal } from "./components/modals"
17+ import { CheckpointModal , LogViewer , HistoryView , StopModal , ErrorModal } from "./components/modals"
1818import { OpenTUIAdapter } from "./adapters/opentui"
1919import { useLogStream } from "./hooks/useLogStream"
2020import { useSubAgentSync } from "./hooks/useSubAgentSync"
@@ -90,7 +90,21 @@ export function WorkflowShell(props: WorkflowShellProps) {
9090 ui . actions . setWorkflowStatus ( "stopped" )
9191 }
9292
93+ // Error modal state
94+ const [ errorMessage , setErrorMessage ] = createSignal < string | null > ( null )
95+ const isErrorModalActive = ( ) => errorMessage ( ) !== null
96+
97+ const handleWorkflowError = ( data : { reason : string } ) => {
98+ setErrorMessage ( data . reason )
99+ ui . actions . setWorkflowStatus ( "error" )
100+ }
101+
102+ const handleErrorModalClose = ( ) => {
103+ setErrorMessage ( null )
104+ }
105+
93106 onMount ( ( ) => {
107+ ; ( process as NodeJS . EventEmitter ) . on ( 'workflow:error' , handleWorkflowError )
94108 ; ( process as NodeJS . EventEmitter ) . on ( 'workflow:stopping' , handleStopping )
95109 ; ( process as NodeJS . EventEmitter ) . on ( 'workflow:user-stop' , handleUserStop )
96110 if ( props . eventBus ) {
@@ -102,6 +116,7 @@ export function WorkflowShell(props: WorkflowShellProps) {
102116 } )
103117
104118 onCleanup ( ( ) => {
119+ ; ( process as NodeJS . EventEmitter ) . off ( 'workflow:error' , handleWorkflowError )
105120 ; ( process as NodeJS . EventEmitter ) . off ( 'workflow:stopping' , handleStopping )
106121 ; ( process as NodeJS . EventEmitter ) . off ( 'workflow:user-stop' , handleUserStop )
107122 if ( adapter ) {
@@ -275,7 +290,7 @@ export function WorkflowShell(props: WorkflowShellProps) {
275290 getState : state ,
276291 actions : ui . actions ,
277292 calculateVisibleItems : getVisibleItems ,
278- isModalBlocking : ( ) => isCheckpointActive ( ) || modals . isLogViewerActive ( ) || modals . isHistoryActive ( ) || modals . isHistoryLogViewerActive ( ) || showStopModal ( ) ,
293+ isModalBlocking : ( ) => isCheckpointActive ( ) || modals . isLogViewerActive ( ) || modals . isHistoryActive ( ) || modals . isHistoryLogViewerActive ( ) || showStopModal ( ) || isErrorModalActive ( ) ,
279294 isPromptBoxFocused : ( ) => isPromptBoxFocused ( ) ,
280295 isWaitingForInput,
281296 hasQueuedPrompts,
@@ -360,6 +375,12 @@ export function WorkflowShell(props: WorkflowShellProps) {
360375 < StopModal onConfirm = { handleStopConfirm } onCancel = { handleStopCancel } />
361376 </ box >
362377 </ Show >
378+
379+ < Show when = { isErrorModalActive ( ) } >
380+ < box position = "absolute" left = { 0 } top = { 0 } width = "100%" height = "100%" zIndex = { 2000 } >
381+ < ErrorModal message = { errorMessage ( ) ! } onClose = { handleErrorModalClose } />
382+ </ box >
383+ </ Show >
363384 </ box >
364385 )
365386}
0 commit comments