@@ -23,20 +23,42 @@ export const deviceHubDescription =
2323export const agentDeviceDescription =
2424 "Allow new agent sessions in this environment to start and control local and remote devices, with required tools set up automatically." ;
2525
26+ /**
27+ * `hostStatus` only tracks this machine. A machine without simulator tooling never
28+ * starts its own hub, so setup and the panel must also count remote device hosts.
29+ */
30+ export function deviceHubReadiness ( state : DeviceServiceState ) {
31+ const statuses = Object . values ( state . hostStatuses ) . map ( ( host ) => host . status ) ;
32+ const ready = state . hostStatus === "ready" || statuses . includes ( "ready" ) ;
33+ const busy =
34+ ! ready &&
35+ [ state . hostStatus , ...statuses ] . some (
36+ ( status ) => status === "installing" || status === "starting" ,
37+ ) ;
38+ return { ready, busy } ;
39+ }
40+
2641export function platformSetupStatus ( state : DeviceServiceState , platform : DevicePlatform ) {
27- const availability = state . hosts
28- . flatMap ( ( host ) => host . platforms )
29- . find ( ( candidate ) => candidate . platform === platform ) ;
30- if ( ! availability ?. available ) {
42+ const availabilities = state . hosts . flatMap ( ( host ) =>
43+ host . platforms
44+ . filter ( ( candidate ) => candidate . platform === platform )
45+ . map ( ( candidate ) => ( { ...candidate , host } ) ) ,
46+ ) ;
47+ const supportingHosts = availabilities
48+ . filter ( ( candidate ) => candidate . available )
49+ . map ( ( candidate ) => candidate . host ) ;
50+ if ( supportingHosts . length === 0 ) {
3151 return {
3252 ready : false ,
33- message : availability ?. reason ?? `${ platformName ( platform ) } support was not detected.` ,
53+ message : availabilities [ 0 ] ?. reason ?? `${ platformName ( platform ) } support was not detected.` ,
3454 } ;
3555 }
36- if (
37- state . hostStatus === "ready" &&
38- ! state . devices . some ( ( device ) => device . platform === platform )
39- ) {
56+ const readyHosts = supportingHosts . filter (
57+ ( host ) =>
58+ state . hostStatuses [ host . id ] ?. status === "ready" ||
59+ ( host . kind === "local" && state . hostStatus === "ready" ) ,
60+ ) ;
61+ if ( readyHosts . length > 0 && ! state . devices . some ( ( device ) => device . platform === platform ) ) {
4062 return {
4163 ready : false ,
4264 message :
@@ -45,12 +67,16 @@ export function platformSetupStatus(state: DeviceServiceState, platform: DeviceP
4567 : "The Android SDK is installed, but no virtual device exists. Create one in Android Studio → Device Manager." ,
4668 } ;
4769 }
70+ const remoteHost = supportingHosts . every ( ( host ) => host . kind !== "local" )
71+ ? supportingHosts [ 0 ]
72+ : undefined ;
73+ const location = remoteHost ? ` on ${ remoteHost . label } ` : "" ;
4874 return {
4975 ready : true ,
5076 message :
5177 platform === "ios"
52- ? " Xcode and iOS Simulator are available."
53- : " The Android SDK and Emulator are available." ,
78+ ? ` Xcode and iOS Simulator are available${ location } .`
79+ : ` The Android SDK and Emulator are available${ location } .` ,
5480 } ;
5581}
5682
@@ -65,7 +91,7 @@ export function DeviceSetup(props: {
6591 const [ pending , setPending ] = useState < "hub" | "check" | "agent" | "complete" | null > ( null ) ;
6692 const [ step , setStep ] = useState ( 0 ) ;
6793 const enabled = props . state . hostStatus !== "disabled" ;
68- const busy = props . state . hostStatus === "installing" || props . state . hostStatus === "starting" ;
94+ const { ready , busy } = deviceHubReadiness ( props . state ) ;
6995 const localPlatformsUnavailable = props . state . hosts . some (
7096 ( host ) => host . kind === "local" && ! host . platforms . some ( ( platform ) => platform . available ) ,
7197 ) ;
@@ -181,15 +207,12 @@ export function DeviceSetup(props: {
181207 </ Button >
182208 ) }
183209 { step < 2 ? (
184- < Button
185- disabled = { props . state . hostStatus !== "ready" || pending !== null }
186- onClick = { ( ) => setStep ( step + 1 ) }
187- >
210+ < Button disabled = { ! ready || pending !== null } onClick = { ( ) => setStep ( step + 1 ) } >
188211 Continue
189212 </ Button >
190213 ) : (
191214 < Button
192- disabled = { ! canConfigure || props . state . hostStatus !== " ready" || pending !== null }
215+ disabled = { ! canConfigure || ! ready || pending !== null }
193216 onClick = { ( ) => void update ( "complete" , { onboardingCompleted : true } ) }
194217 >
195218 { pending === "complete" ? "Saving…" : "Done" }
@@ -209,7 +232,7 @@ export function DeviceHubSetupStatus({
209232 readonly pending : boolean ;
210233 readonly compact ?: boolean ;
211234} ) {
212- if ( ! pending && state . hostStatus !== " ready" ) return null ;
235+ if ( ! pending && ! deviceHubReadiness ( state ) . ready ) return null ;
213236 return (
214237 < p role = "status" className = "flex items-center gap-2 text-xs text-muted-foreground" >
215238 { pending ? < Spinner size = "xs" /> : < Check className = "size-3 text-success" /> }
@@ -278,7 +301,7 @@ export function AgentDeviceSetupStatus(props: {
278301 }
279302 if (
280303 props . state . agentAccessEnabled &&
281- props . state . hostStatus === " ready" &&
304+ deviceHubReadiness ( props . state ) . ready &&
282305 props . state . hosts . some ( ( host ) => host . agentDeviceInstalled )
283306 ) {
284307 return (
0 commit comments