Skip to content

Commit 26b0f5e

Browse files
fix(devices): keep healthy remote devices available in the picker
1 parent 181581f commit 26b0f5e

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

‎apps/web/src/components/device/DevicePanel.tsx‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ export function DevicePanel(props: {
130130
setOperationError(null);
131131
void close({
132132
environmentId,
133-
input: { threadId, deviceId: activeSession.deviceId, shutdown: powerOff },
133+
input: {
134+
threadId,
135+
hostId: activeSession.hostId,
136+
deviceId: activeSession.deviceId,
137+
shutdown: powerOff,
138+
},
134139
}).then((result) => {
135140
if (result._tag === "Failure") setOperationError(formatEnvironmentQueryError(result.cause));
136141
});
@@ -140,10 +145,16 @@ export function DevicePanel(props: {
140145

141146
const bootingDevices =
142147
state.bootingDevices?.filter((device) => device.threadId === threadId) ?? [];
143-
const hostReady = state.hostStatus === "ready";
144-
const hostBusy = state.hostStatus === "installing" || state.hostStatus === "starting";
148+
const hostReady = Object.values(state.hostStatuses).some((host) => host.status === "ready");
149+
const hostBusy =
150+
!hostReady &&
151+
Object.values(state.hostStatuses).some(
152+
(host) => host.status === "installing" || host.status === "starting",
153+
);
145154
const unavailablePlatforms = state.hosts.flatMap((host) =>
146-
host.platforms.filter((platform) => !platform.available),
155+
host.platforms
156+
.filter((platform) => !platform.available)
157+
.map((platform) => ({ ...platform, hostId: host.id, hostLabel: host.label })),
147158
);
148159

149160
if (loaded && (!state.onboardingCompleted || hostDisabled)) {
@@ -207,6 +218,7 @@ export function DevicePanel(props: {
207218
{device.booted ? device.name : `Start ${device.name}`}
208219
</span>
209220
<span className="ml-auto shrink-0 text-xs text-muted-foreground">
221+
{state.hosts.find((host) => host.id === device.hostId)?.label} ·{" "}
210222
{device.version}
211223
</span>
212224
</span>
@@ -381,7 +393,7 @@ export function DevicePanel(props: {
381393
</span>
382394
}
383395
title={device.name}
384-
description={`${device.version} · ${device.booted ? "Running" : "Stopped"}`}
396+
description={`${state.hosts.find((host) => host.id === device.hostId)?.label} · ${device.version} · ${device.booted ? "Running" : "Stopped"}`}
385397
disabled={pendingDeviceKey !== null}
386398
aria-label={`${device.booted ? "Open" : "Start"} ${device.name}`}
387399
onClick={() => void selectDevice(deviceKey(device))}
@@ -422,8 +434,9 @@ export function DevicePanel(props: {
422434
{unavailablePlatforms.length > 0 && hostReady ? (
423435
<ul className="max-w-sm space-y-1 text-xs opacity-70">
424436
{unavailablePlatforms.map((platform) => (
425-
<li key={platform.platform}>
426-
{platform.platform === "ios" ? "iOS" : "Android"}: {platform.reason}
437+
<li key={`${platform.hostId}:${platform.platform}`}>
438+
{platform.hostLabel} · {platform.platform === "ios" ? "iOS" : "Android"}:{" "}
439+
{platform.reason}
427440
</li>
428441
))}
429442
</ul>

0 commit comments

Comments
 (0)