@@ -10,6 +10,8 @@ import { getDevboxUrl } from "../utils/url.js";
1010import { colors } from "../utils/theme.js" ;
1111import { useViewportHeight } from "../hooks/useViewportHeight.js" ;
1212import { useExitOnCtrlC } from "../hooks/useExitOnCtrlC.js" ;
13+ import { useNavigation , type ScreenName , type RouteParams } from "../store/navigationStore.js" ;
14+ import { getDevbox } from "../services/devboxService.js" ;
1315
1416interface DevboxDetailPageProps {
1517 devbox : any ;
@@ -52,11 +54,38 @@ export const DevboxDetailPage = ({
5254 } ;
5355 } , [ ] ) ;
5456
57+ // Local state for devbox data (updated by polling)
58+ const [ currentDevbox , setCurrentDevbox ] = React . useState ( initialDevbox ) ;
59+
5560 const [ showDetailedInfo , setShowDetailedInfo ] = React . useState ( false ) ;
5661 const [ detailScroll , setDetailScroll ] = React . useState ( 0 ) ;
5762 const [ showActions , setShowActions ] = React . useState ( false ) ;
5863 const [ selectedOperation , setSelectedOperation ] = React . useState ( 0 ) ;
5964
65+ // Background polling for devbox details
66+ React . useEffect ( ( ) => {
67+ // Skip polling if showing actions, detailed info, or not mounted
68+ if ( showActions || showDetailedInfo ) return ;
69+
70+ const interval = setInterval ( async ( ) => {
71+ // Only poll when not in actions/detail mode and component is mounted
72+ if ( ! showActions && ! showDetailedInfo && isMounted . current ) {
73+ try {
74+ const updatedDevbox = await getDevbox ( initialDevbox . id ) ;
75+
76+ // Only update if still mounted
77+ if ( isMounted . current ) {
78+ setCurrentDevbox ( updatedDevbox ) ;
79+ }
80+ } catch ( err ) {
81+ // Silently ignore polling errors to avoid disrupting user experience
82+ }
83+ }
84+ } , 3000 ) ; // Poll every 3 seconds
85+
86+ return ( ) => clearInterval ( interval ) ;
87+ } , [ initialDevbox . id , showActions , showDetailedInfo ] ) ;
88+
6089 // Calculate viewport for detailed info view:
6190 // - Breadcrumb (3 lines + marginBottom): 4 lines
6291 // - Header (title + underline + marginBottom): 3 lines
@@ -67,7 +96,7 @@ export const DevboxDetailPage = ({
6796 // Total: 18 lines
6897 const detailViewport = useViewportHeight ( { overhead : 18 , minHeight : 10 } ) ;
6998
70- const selectedDevbox = initialDevbox ;
99+ const selectedDevbox = currentDevbox ;
71100
72101 const allOperations = [
73102 {
0 commit comments