File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @codesandbox/sdk" ,
3- "version" : " 2.0.0-rc.3 " ,
3+ "version" : " 2.0.0-rc.4 " ,
44 "description" : " The CodeSandbox SDK" ,
55 "author" : " CodeSandbox" ,
66 "license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -9,7 +9,12 @@ import { hostTokensCommand } from "./commands/hostTokens";
99import { Dashboard } from "./ui/Dashboard" ;
1010import React from "react" ;
1111import { SDKProvider } from "./ui/sdkContext" ;
12- import { QueryClient , QueryClientProvider } from "@tanstack/react-query" ;
12+ import {
13+ focusManager ,
14+ onlineManager ,
15+ QueryClient ,
16+ QueryClientProvider ,
17+ } from "@tanstack/react-query" ;
1318
1419if ( process . argv . length === 2 ) {
1520 // Clear the screen before rendering the dashboard
Original file line number Diff line number Diff line change @@ -25,14 +25,24 @@ export function Dashboard() {
2525 const runningVmsQuery = useQuery ( {
2626 queryKey : [ "runningVms" ] ,
2727 queryFn : getRunningVms ,
28- refetchInterval : 2000 , // Poll every 2 seconds
2928 } ) ;
3029
3130 const [ sandboxId , setSandboxId ] = useState ( "" ) ;
3231 const [ showSandbox , setShowSandbox ] = useState ( false ) ;
3332 const [ isFocused , setIsFocused ] = useState ( true ) ;
3433 const [ stdoutWidth , stdoutHeight ] = useTerminalSize ( ) ;
3534
35+ useEffect ( ( ) => {
36+ // have to manually do this because of environment
37+ const interval = setInterval ( ( ) => {
38+ runningVmsQuery . refetch ( ) ;
39+ } , 2000 ) ;
40+
41+ return ( ) => {
42+ clearInterval ( interval ) ;
43+ } ;
44+ } , [ ] ) ;
45+
3646 useInput ( ( input , key ) => {
3747 if ( ! showSandbox ) {
3848 if ( key . return ) {
@@ -49,7 +59,7 @@ export function Dashboard() {
4959 } ) ;
5060
5161 if ( showSandbox ) {
52- const state = runningVmsQuery . isFetching
62+ const state = runningVmsQuery . isLoading
5363 ? "PENDING"
5464 : runningVmsQuery . data ?. vms . find ( ( vm ) => vm . id === sandboxId )
5565 ? "RUNNING"
You can’t perform that action at this time.
0 commit comments