The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { resolveDesktopAppControlAddress } from "./desktopAppControl.ts"; |
| 4 | |
| 5 | describe("resolveDesktopAppControlAddress", () => { |
| 6 | it.each([ |
| 7 | ["linux", "/tmp", "/tmp/t3code-1000", 107], |
| 8 | ["linux", "/var/tmp/custom", "/var/tmp/custom/t3code-1000", 107], |
| 9 | ["linux", `/tmp/${"x".repeat(120)}`, "/tmp/t3code-1000", 107], |
| 10 | ["darwin", `/tmp/${"é".repeat(30)}`, "/tmp/t3code-1000", 103], |
| 11 | ["darwin", `/tmp/${"x".repeat(56)}`, `/tmp/${"x".repeat(56)}/t3code-1000`, 103], |
| 12 | ] as const)("keeps %s sockets short under %s", (platform, tempDir, directory, maxBytes) => { |
| 13 | const first = resolveDesktopAppControlAddress({ |
| 14 | stateDir: `/home/user/${"long/".repeat(40)}userdata`, |
| 15 | platform, |
| 16 | tempDir, |
| 17 | userId: 1000, |
| 18 | joinPath: (...segments) => segments.join("/"), |
| 19 | }); |
| 20 | const second = resolveDesktopAppControlAddress({ |
| 21 | stateDir: "/home/user/.t3/other/userdata", |
| 22 | platform, |
| 23 | tempDir, |
| 24 | userId: 1000, |
| 25 | joinPath: (...segments) => segments.join("/"), |
| 26 | }); |
| 27 | |
| 28 | expect(new TextEncoder().encode(first.address).byteLength).toBeLessThanOrEqual(maxBytes); |
| 29 | expect(first.directory).toBe(directory); |
| 30 | expect(first.address).not.toBe(second.address); |
| 31 | }); |
| 32 | |
| 33 | it("uses a Windows named pipe", () => { |
| 34 | const result = resolveDesktopAppControlAddress({ |
| 35 | stateDir: "C:\\Users\\user\\.t3\\userdata", |
| 36 | platform: "win32", |
| 37 | tempDir: "C:\\Temp", |
| 38 | userId: undefined, |
| 39 | joinPath: (...segments) => segments.join("\\"), |
| 40 | }); |
| 41 | |
| 42 | expect(result.directory).toBeNull(); |
| 43 | expect(result.address).toMatch(/^\\\\\.\\pipe\\t3code-app-[a-f0-9]{24}$/); |
| 44 | }); |
| 45 | }); |