Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a627472
docs(devices): design and contracts for the Device panel
badcuban Nov 20, 2026
2c48361
feat(client-runtime): device hub transport and stream client over the…
badcuban Nov 20, 2026
31335c7
feat(server): devices: hub, service, channel and agent tools endpoint
badcuban Nov 20, 2026
b4b8a2e
feat(server): device tools reach every provider
badcuban Nov 20, 2026
20ae62f
fix(server): preview tunnel refuses device tool ports
badcuban Nov 20, 2026
f0ada33
docs(devices): what the server build settled
badcuban Nov 20, 2026
27c9c01
feat(web): device RPCs on the client and a devices capability
badcuban Nov 20, 2026
f48125c
feat(web): a Device tab with a live simulator or emulator
badcuban Nov 20, 2026
db9b10f
feat(web): Settings > Devices, the app guide and Open device
badcuban Nov 20, 2026
c26834c
docs(devices): record where the web half differs from the plan
badcuban Nov 20, 2026
07a086d
Merge branch 'feat/device-panel' into feat/ios-simulator-setup
badcuban Nov 20, 2026
2b53b81
fix(server): devices report their capability, and channel credit coun…
badcuban Nov 20, 2026
dc6ce0a
fix(server): list iOS simulators that were never booted
badcuban Nov 20, 2026
4b2b90a
fix(web): the Tools drawer shows the iOS app in front
badcuban Nov 20, 2026
9bd97b3
fix(devices): close the gaps the diff review found
badcuban Nov 20, 2026
a32e361
test(web): the RPC client fake carries the device group
badcuban Nov 20, 2026
e86b417
fix(devices): outside work can't reach devices, and the viewer caps f…
badcuban Nov 20, 2026
d08d041
fix(server): device tools use the credential scope's own outside limit
badcuban Nov 20, 2026
9b4dd5e
docs(devices): round 2 plan: model frames, iPhone Duo, foldables, ove…
badcuban Nov 20, 2026
023c067
docs(devices): round 2 plan after review
badcuban Nov 20, 2026
8398136
feat(devices): devices report their hardware model
badcuban Nov 20, 2026
5c5122c
feat(devices): stream client speaks iPhone Duo, Android fold and the …
badcuban Nov 20, 2026
dadac9e
feat(client-runtime): device event log and accessibility tree over th…
badcuban Nov 20, 2026
f09c981
feat(web): iOS event log in the device Tools drawer
badcuban Nov 20, 2026
986a1df
feat(web): record a device flow into the thread's draft
badcuban Nov 20, 2026
4a85bab
feat(web): device chips, floating device over the chat, record button
badcuban Nov 20, 2026
45fce9a
fix(web): a new floating device lands over the chat column
badcuban Nov 20, 2026
5a4b03a
fix(web): device recordings keep their screenshots and fit 3 minutes
badcuban Nov 20, 2026
20c0f4e
fix(web): an attachment too big for local storage no longer stops the…
badcuban Nov 20, 2026
54c848a
docs(devices): what the round 2 chips, float and recording build settled
badcuban Nov 20, 2026
f154d1b
feat(web): device frames drawn per model, iPhone Duo and foldable con…
badcuban Nov 20, 2026
2e0c892
docs(devices): record how frames, the Duo, folds and the overlay were…
badcuban Nov 20, 2026
f734105
fix(web): device recordings are never lost after a failed hand-off
badcuban Nov 20, 2026
0aebc3d
fix(web): chip order, a float in a short window, the event log when t…
badcuban Nov 20, 2026
398732a
fix(web): accessibility and fold reads stop while the device is off s…
badcuban Nov 20, 2026
524c5b7
Merge branch 'feat/device-panel-recording' into feat/ios-simulator-setup
badcuban Nov 20, 2026
17e9924
fix(server): the device hub keeps starting when the tab that asked cl…
badcuban Nov 20, 2026
26cbc6e
fix(server): the device model cache outlives hub restarts
badcuban Nov 20, 2026
091eecc
fix(devices): a Duo panel feed that never paints falls back instead o…
badcuban Nov 20, 2026
ce22d12
fix(web): Duo drags stop at the screen in front, unknown emulators ke…
badcuban Nov 20, 2026
57b88d2
fix(devices): find Java for the Android tools, and say when it's missing
badcuban Nov 20, 2026
f2119f2
fix(web): the device toolbar leaves the name to the chips, and record…
badcuban Nov 20, 2026
cfa9e9c
Merge branch 'feat/ios-simulator-setup' into feat/device-model-frames
badcuban Nov 20, 2026
9cbef3f
refactor(server): hosts make hub operations through one factory that …
badcuban Nov 20, 2026
bec323e
fix(devices): a held Duo touch never ends on the display that took over
badcuban Nov 20, 2026
1b1d12d
fix(web): a draft never loses an attachment it had saved
badcuban Nov 20, 2026
9e51d7f
fix(web): a device recording is saved even after its thread was left
badcuban Nov 20, 2026
848d399
fix(web): recordings stop capturing at once, and follow the iPhone Du…
badcuban Nov 20, 2026
b0a90e3
docs(devices): how recordings save, stop, and record an iPhone Duo
badcuban Nov 20, 2026
e69860f
Merge branch 'feat/device-panel-recording' into feat/ios-simulator-setup
badcuban Nov 20, 2026
9b41d78
fix(devices): the hub reads ready together with its first device list
badcuban Nov 20, 2026
4999853
fix(web): a draft save never writes a list older than the draft's
badcuban Nov 20, 2026
c3e10d0
fix(web): every unsaved file of a device recording is kept for download
badcuban Nov 20, 2026
2a24db5
Merge remote-tracking branch 'origin/main' into feat/ios-simulator-setup
badcuban Nov 20, 2026
87a043d
Merge remote-tracking branch 'origin/main' into feat/ios-simulator-setup
badcuban Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions apps/server/src/device/AgentDeviceShim.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// @effect-diagnostics nodeBuiltinImport:off - runs the generated launcher as a real subprocess.
import * as NodeChildProcess from "node:child_process";
import * as NodeNet from "node:net";
import * as NodeUtil from "node:util";

import * as NodeServices from "@effect/platform-node/NodeServices";
import { describe, expect, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";

import {
agentDeviceLauncherKey,
agentDeviceLaunchersDir,
bindAgentDeviceLauncher,
pruneAgentDeviceLaunchers,
} from "./AgentDeviceShim.ts";
import { agentDeviceConfigPath, writeAgentDeviceConfig } from "./AgentDeviceTarget.ts";

const exec = NodeUtil.promisify(NodeChildProcess.execFile);

/** A loopback port that accepts connections until the scope closes, like the agent-device daemon. */
const listeningPort = Effect.acquireRelease(
Effect.promise(
() =>
new Promise<NodeNet.Server>((resolve) => {
const server = NodeNet.createServer((socket) => socket.destroy());
server.listen(0, "127.0.0.1", () => resolve(server));
}),
),
(server) => Effect.promise(() => new Promise<void>((resolve) => server.close(() => resolve()))),
).pipe(Effect.map((server) => (server.address() as NodeNet.AddressInfo).port));

describe.skipIf(process.platform === "win32")("agent-device launcher", () => {
it.live("binds one device's flags, lets the agent's own flags win, and leaves help alone", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "tl-device-launcher-" });
const port = yield* listeningPort;
const entryPath = path.join(dir, "cli.mjs");
yield* fs.writeFileString(entryPath, "console.log(JSON.stringify(process.argv.slice(2)));");
const config = agentDeviceConfigPath(path, dir);
yield* writeAgentDeviceConfig(config, { baseUrl: `http://127.0.0.1:${port}`, token: "t" });
const target = [
"--platform",
"ios",
"--udid",
"UDID-1",
"--config",
config,
"--session",
"tl-a",
];
const command = yield* bindAgentDeviceLauncher({
stateDir: dir,
threadId: "thread-1",
deviceId: "UDID-1",
node: process.execPath,
entryPath,
targetArgs: target,
});
expect(command).toBe(
path.join(agentDeviceLaunchersDir(path, dir), "thread-1", "UDID-1", "agent-device"),
);
const launch = (args: ReadonlyArray<string>) =>
exec(command, [...args]).then((result) => JSON.parse(result.stdout));

expect(yield* Effect.promise(() => launch(["snapshot", "-i"]))).toEqual([
"snapshot",
"-i",
...target,
]);
expect(yield* Effect.promise(() => launch(["open", "--session", "mine"]))).toEqual([
"open",
"--session",
"mine",
...target.slice(0, 6),
]);
// After `--` everything is text, and bound flags go before it.
expect(yield* Effect.promise(() => launch(["fill", "@e5", "--", "--help"]))).toEqual([
"fill",
"@e5",
...target,
"--",
"--help",
]);
for (const args of [["help", "gesture"], ["open", "--help"], []]) {
expect(yield* Effect.promise(() => launch(args))).toEqual(args);
}
// Commands that would replace Threadlines' connection are refused.
yield* Effect.promise(() =>
expect(launch(["daemon", "stop"])).rejects.toThrow("Threadlines manages this command"),
);
// A runtime that moved since device_open names the fix.
yield* fs.remove(entryPath);
yield* Effect.promise(() =>
expect(launch(["snapshot"])).rejects.toThrow("Call device_open again"),
);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

it.live("says the device connection is down before running agent-device", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "tl-device-launcher-" });
const entryPath = path.join(dir, "cli.mjs");
yield* fs.writeFileString(entryPath, "process.exit(3);");
const port = yield* Effect.scoped(listeningPort);
const config = agentDeviceConfigPath(path, dir);
yield* writeAgentDeviceConfig(config, { baseUrl: `http://127.0.0.1:${port}`, token: "t" });
const command = yield* bindAgentDeviceLauncher({
stateDir: dir,
threadId: "thread-1",
deviceId: "UDID-1",
node: process.execPath,
entryPath,
targetArgs: ["--config", config, "--session", "tl-a"],
});
yield* Effect.promise(() =>
expect(exec(command, ["snapshot"])).rejects.toThrow("is not reachable from this shell"),
);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);

it.effect("removes the launchers of sessions that ended", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "tl-device-launcher-" });
for (const [threadId, deviceId] of [
["thread-1", "UDID-1"],
["thread-1", "Pixel 9"],
["thread-2", "UDID-1"],
] as const) {
yield* bindAgentDeviceLauncher({
stateDir: dir,
threadId,
deviceId,
node: process.execPath,
entryPath: "/missing.mjs",
targetArgs: [],
});
}
yield* pruneAgentDeviceLaunchers({
stateDir: dir,
live: new Set([agentDeviceLauncherKey("thread-1", "Pixel 9")]),
});
const root = agentDeviceLaunchersDir(path, dir);
expect(yield* fs.readDirectory(root)).toEqual(["thread-1"]);
expect(yield* fs.readDirectory(path.join(root, "thread-1"))).toEqual([
agentDeviceLauncherKey("thread-1", "Pixel 9").split("/")[1],
]);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
});
Loading
Loading