@@ -36,6 +36,21 @@ export function Terminal({
3636 userScrolledUp . current = ! atBottom ;
3737 } , [ ] ) ;
3838
39+ const status = run ?. status ;
40+ const isRunning = status === "EXECUTING" ;
41+ const isQueued = status === "PENDING_VERSION" || status === "DELAYED" || ! status ;
42+ const isFailed = status === "FAILED" || status === "CRASHED" || status === "SYSTEM_FAILURE" ;
43+ const isComplete = status === "COMPLETED" ;
44+
45+ // Notify parent when run finishes
46+ const notified = useRef ( false ) ;
47+ useEffect ( ( ) => {
48+ if ( ( isComplete || isFailed ) && ! notified . current ) {
49+ notified . current = true ;
50+ onComplete ?.( ) ;
51+ }
52+ } , [ isComplete , isFailed , onComplete ] ) ;
53+
3954 // Auto-scroll when new events arrive (unless user scrolled up)
4055 useEffect ( ( ) => {
4156 if ( events . length > 0 && ! userScrolledUp . current ) {
@@ -53,21 +68,6 @@ export function Terminal({
5368 ) ;
5469 }
5570
56- const status = run ?. status ;
57- const isRunning = status === "EXECUTING" ;
58- const isQueued = status === "PENDING_VERSION" || status === "DELAYED" || ! status ;
59- const isFailed = status === "FAILED" || status === "CRASHED" || status === "SYSTEM_FAILURE" ;
60- const isComplete = status === "COMPLETED" ;
61-
62- // Notify parent when run finishes
63- const notified = useRef ( false ) ;
64- useEffect ( ( ) => {
65- if ( ( isComplete || isFailed ) && ! notified . current ) {
66- notified . current = true ;
67- onComplete ?.( ) ;
68- }
69- } , [ isComplete , isFailed , onComplete ] ) ;
70-
7171 return (
7272 < div
7373 ref = { scrollRef }
0 commit comments