Skip to content

Commit 023ffcf

Browse files
fix(web): device setup lets you through with only a remote device host
The setup wizard waited for the local hub to be ready, so a machine without simulator tooling stayed stuck even when a remote host was ready and listing devices. Readiness and platform support now consider every device host. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 727b4e7 commit 023ffcf

4 files changed

Lines changed: 92 additions & 29 deletions

File tree

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { deviceEnvironment, useDeviceState } from "~/state/device";
2020
import { formatEnvironmentQueryError } from "~/state/query";
2121
import { useAtomCommand } from "~/state/use-atom-command";
2222
import { DeviceLoadingView } from "./DeviceLoadingView";
23-
import { DeviceSetup } from "./DeviceSetup";
23+
import { DeviceSetup, deviceHubReadiness } from "./DeviceSetup";
2424
import { DeviceWorkspace } from "./DeviceWorkspace";
2525
import { PreviewPanelShell, type PreviewPanelMode } from "../preview/PreviewPanelShell";
2626

@@ -138,12 +138,7 @@ export function DevicePanel(props: {
138138

139139
const bootingDevices =
140140
state.bootingDevices?.filter((device) => device.threadId === threadId) ?? [];
141-
const hostReady = Object.values(state.hostStatuses).some((host) => host.status === "ready");
142-
const hostBusy =
143-
!hostReady &&
144-
Object.values(state.hostStatuses).some(
145-
(host) => host.status === "installing" || host.status === "starting",
146-
);
141+
const { ready: hostReady, busy: hostBusy } = deviceHubReadiness(state);
147142
const unavailablePlatforms = state.hosts.flatMap((host) =>
148143
host.platforms
149144
.filter((platform) => !platform.available)

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

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,42 @@ export const deviceHubDescription =
2323
export 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+
2641
export 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 (

‎apps/web/src/components/settings/IntegrationsSettings.test.tsx‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ vi.mock("./SettingsScopeContext", () => ({
6868
}));
6969

7070
import { IntegrationsSettingsPanel } from "./IntegrationsSettings";
71-
import { platformSetupStatus } from "../device/DeviceSetup";
71+
import { deviceHubReadiness, platformSetupStatus } from "../device/DeviceSetup";
7272

7373
let renderer: ReactTestRenderer | undefined;
7474

@@ -163,4 +163,48 @@ describe("device setup guidance", () => {
163163
});
164164
expect(platformSetupStatus(state, "android").message).toBe("Android Emulator is missing.");
165165
});
166+
167+
it("counts a remote device host when this machine has no simulator tooling", () => {
168+
const state = deviceState({
169+
hostStatus: "idle",
170+
hostStatuses: { macmini: { status: "ready" } },
171+
hosts: [
172+
{
173+
...deviceState().hosts[0]!,
174+
platforms: [
175+
{ platform: "ios", available: false, reason: "Xcode was not found." },
176+
{ platform: "android", available: false, reason: "Android SDK was not found." },
177+
],
178+
},
179+
{
180+
id: "macmini",
181+
kind: "ssh",
182+
label: "Mac Mini",
183+
hubInstalled: true,
184+
agentDeviceInstalled: true,
185+
platforms: [
186+
{ platform: "ios", available: true },
187+
{ platform: "android", available: false, reason: "Android SDK was not found." },
188+
],
189+
},
190+
],
191+
devices: [
192+
{
193+
hostId: "macmini",
194+
id: "iphone",
195+
platform: "ios",
196+
name: "iPhone 16 Pro",
197+
version: "iOS 27.0",
198+
booted: true,
199+
physical: false,
200+
},
201+
],
202+
});
203+
expect(deviceHubReadiness(state).ready).toBe(true);
204+
expect(platformSetupStatus(state, "ios")).toEqual({
205+
ready: true,
206+
message: "Xcode and iOS Simulator are available on Mac Mini.",
207+
});
208+
expect(platformSetupStatus(state, "android").ready).toBe(false);
209+
});
166210
});

‎apps/web/src/components/settings/IntegrationsSettings.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"
5858
import {
5959
AgentDeviceSetupStatus,
6060
DeviceHubSetupStatus,
61+
deviceHubReadiness,
6162
PlatformStatus,
6263
platformSetupStatus,
6364
deviceHubDescription,
@@ -691,7 +692,7 @@ function DeviceIntegrationControls({
691692
const [pending, setPending] = useState<
692693
"hub" | "check" | "agent" | "update-hub" | "update-agent" | null
693694
>(null);
694-
const busy = state.hostStatus === "installing" || state.hostStatus === "starting";
695+
const { ready: hubReady, busy } = deviceHubReadiness(state);
695696
const localPlatformsUnavailable = state.hosts.some(
696697
(host) => host.kind === "local" && !host.platforms.some((platform) => platform.available),
697698
);
@@ -701,7 +702,7 @@ function DeviceIntegrationControls({
701702
if (
702703
enabled &&
703704
!platformsRevealed &&
704-
(state.hostStatus === "ready" || localPlatformsUnavailable) &&
705+
(hubReady || localPlatformsUnavailable) &&
705706
pending !== "hub"
706707
) {
707708
setPlatformsRevealed(true);

0 commit comments

Comments
 (0)