Skip to content

Commit f984155

Browse files
fix(devices): Simlock emulators open without ffmpeg and stay view-only when floated
Hosts that route their own streams never encode with serve-emu, so the ffmpeg check no longer blocks their Android emulators. The floating device preview now passes the Simlock view-only state too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1b192b2 commit f984155

3 files changed

Lines changed: 35 additions & 4 deletions

File tree

‎apps/server/src/device/DeviceService.test.ts‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const fixture = Effect.fn("fixture")(function* (
4949
| DeviceHost.AgentDeviceStartError,
5050
inspectError = false,
5151
installTool?: Parameters<typeof DeviceService.makeWithHosts>[3],
52-
options: { readonly endsDevices?: boolean } = {},
52+
options: { readonly endsDevices?: boolean; readonly routesStreams?: boolean } = {},
5353
) {
5454
const settings = yield* Ref.make(DEFAULT_SERVER_SETTINGS);
5555
const starts: string[] = [];
@@ -133,6 +133,7 @@ const fixture = Effect.fn("fixture")(function* (
133133
},
134134
helpers: { serveSimAxSettings: null, serveSimCli: null },
135135
run,
136+
...(options.routesStreams ? { upstream: () => Effect.succeed(null) } : {}),
136137
};
137138
const host: DeviceHost.DeviceHost["Service"] = {
138139
...(inspectError
@@ -396,6 +397,29 @@ describe("device setup consent", () => {
396397
}).pipe(Effect.scoped),
397398
);
398399

400+
it.effect("opens emulators on hosts that route their own streams without ffmpeg", () =>
401+
Effect.gen(function* () {
402+
const { service, requests, encoderResult } = yield* fixture(
403+
Effect.void,
404+
undefined,
405+
false,
406+
undefined,
407+
false,
408+
undefined,
409+
{ routesStreams: true },
410+
);
411+
yield* Ref.set(encoderResult, { code: 127, stdout: "", stderr: "host commands unavailable" });
412+
yield* service.configure({ enabled: true });
413+
const session = yield* service.open({
414+
threadId: ThreadId.make("pool-emulator"),
415+
deviceId: "Pixel_API_35",
416+
platform: "android",
417+
});
418+
expect(session.deviceId).toBe("emulator-5554");
419+
expect(requests.filter((url) => url.endsWith("/boot"))).toHaveLength(1);
420+
}).pipe(Effect.scoped),
421+
);
422+
399423
it.effect("installs agent support only after the separate agent permission", () =>
400424
Effect.gen(function* () {
401425
const { service, agentStarts, agentStops, settings } = yield* fixture();

‎apps/server/src/device/DeviceService.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function*
600600
if (!device) {
601601
return yield* new DeviceNotFoundError({ hostId: host.id, deviceId: input.deviceId });
602602
}
603-
if (device.platform === "android" && !device.physical) {
603+
// Hosts that route their own streams never encode emulator video with serve-emu's ffmpeg.
604+
if (device.platform === "android" && !device.physical && !ready.upstream) {
604605
// Resolve the override on the device host the way its hub does.
605606
const encoders = yield* ready.run(ready.nodePath, [
606607
"-e",

‎apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ function DeviceMiniPlayer({
271271
const device = deviceState.devices.find(
272272
(entry) => entry.hostId === source.hostId && entry.id === source.deviceId,
273273
);
274-
const hostLabel =
275-
deviceState.hosts.find((host) => host.id === source.hostId)?.label ?? "Device host";
274+
const host = deviceState.hosts.find((entry) => entry.id === source.hostId);
275+
const hostLabel = host?.label ?? "Device host";
276276
const cornerRadius = (player: PreviewMiniPlayerSize) =>
277277
resolveDeviceMiniPlayerCornerRadius(source.platform, player);
278278

@@ -309,6 +309,12 @@ function DeviceMiniPlayer({
309309
deviceDescription={`${hostLabel} · ${device?.version ?? source.platform}`}
310310
visible
311311
onScreen={setScreen}
312+
{...(host?.kind === "simlock"
313+
? {
314+
viewOnly: true,
315+
...(host.streamUnavailable ? { unavailableReason: host.streamUnavailable } : {}),
316+
}
317+
: {})}
312318
/>
313319
</div>
314320
)}

0 commit comments

Comments
 (0)