@devries-cameron20 / t3code-1 / commits / 43b56b1790
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(device): forward numeric keypad keys to iOS simulators (#23339)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>

Victor Vogel committed Oct 31, 2026 at 03:44 UTC 43b56b17903085efe7907d0eff372b98cc5fd235
2 files changed +107
packages/client-runtime/src/device/stream.test.ts
+90
@@ -156,6 +156,96 @@ describe("native device stream transport", () => {
156 );
157 });
158
159 +describe("iOS keypad protocol", () => {
160 + afterEach(() => vi.unstubAllGlobals());
161 +
162 + it("encodes keypad presses and releases as HID key packets", async () => {
163 + const packets: Uint8Array[] = [];
164 + let opened!: (socket: Socket) => void;
165 + const connected = new Promise<Socket>((resolve) => {
166 + opened = resolve;
167 + });
168 + class Socket {
169 + static OPEN = 1;
170 + readyState = 1;
171 + binaryType = "";
172 + onmessage: ((event: { data: ArrayBuffer }) => void) | null = null;
173 + constructor() {
174 + opened(this);
175 + }
176 + send(packet: Uint8Array) {
177 + packets.push(packet);
178 + }
179 + close() {}
180 + }
181 + vi.stubGlobal("WebSocket", Socket);
182 + vi.stubGlobal("fetch", async () => new Response("frame"));
183 + const client = createDeviceStreamClient(
184 + {
185 + platform: "ios",
186 + deviceId: "keypad-device",
187 + preferMjpeg: true,
188 + access: {
189 + httpBase: "https://device.test",
190 + wsBase: "wss://device.test",
191 + credentials: false,
192 + query: {},
193 + },
194 + },
195 + { getContext: () => null } as unknown as HTMLCanvasElement,
196 + {
197 + onStatus() {},
198 + onScreen() {},
199 + onUnauthorized() {},
200 + onMjpegFallback() {},
201 + onInputConnected() {},
202 + },
203 + );
204 + try {
205 + client.start();
206 + const socket = await connected;
207 + socket.onmessage?.({ data: Uint8Array.of(0x83).buffer });
208 + const keys = [
209 + ["NumpadDivide", 0x54],
210 + ["NumpadMultiply", 0x55],
211 + ["NumpadSubtract", 0x56],
212 + ["NumpadAdd", 0x57],
213 + ["NumpadEnter", 0x58],
214 + ["Numpad1", 0x59],
215 + ["Numpad2", 0x5a],
216 + ["Numpad3", 0x5b],
217 + ["Numpad4", 0x5c],
218 + ["Numpad5", 0x5d],
219 + ["Numpad6", 0x5e],
220 + ["Numpad7", 0x5f],
221 + ["Numpad8", 0x60],
222 + ["Numpad9", 0x61],
223 + ["Numpad0", 0x62],
224 + ["NumpadDecimal", 0x63],
225 + ["NumpadEqual", 0x67],
226 + ["Digit1", 0x1e],
227 + ["Enter", 0x28],
228 + ] as const;
229 + for (const [code] of keys) {
230 + for (const phase of ["down", "up"] as const) {
231 + client.sendKey({ code } as KeyboardEvent, phase);
232 + }
233 + }
234 + const decoder = new TextDecoder();
235 + expect(
236 + packets.map((packet) => [packet[0], JSON.parse(decoder.decode(packet.subarray(1)))]),
237 + ).toEqual(
238 + keys.flatMap(([, usage]) => [
239 + [0x06, { type: "down", usage }],
240 + [0x06, { type: "up", usage }],
241 + ]),
242 + );
243 + } finally {
244 + client.stop();
245 + }
246 + });
247 +});
248 +
249 describe("serve-emu frames", () => {
250 it("strips the SEMU header and reads the keyframe flag and timestamp", () => {
251 const buffer = new ArrayBuffer(16 + 3);
packages/client-runtime/src/device/stream.ts
+17
@@ -344,6 +344,23 @@ const HID_USAGE_BY_CODE: Readonly<Record<string, number>> = {
344 ArrowLeft: 0x50,
345 ArrowDown: 0x51,
346 ArrowUp: 0x52,
347 + NumpadDivide: 0x54,
348 + NumpadMultiply: 0x55,
349 + NumpadSubtract: 0x56,
350 + NumpadAdd: 0x57,
351 + NumpadEnter: 0x58,
352 + Numpad1: 0x59,
353 + Numpad2: 0x5a,
354 + Numpad3: 0x5b,
355 + Numpad4: 0x5c,
356 + Numpad5: 0x5d,
357 + Numpad6: 0x5e,
358 + Numpad7: 0x5f,
359 + Numpad8: 0x60,
360 + Numpad9: 0x61,
361 + Numpad0: 0x62,
362 + NumpadDecimal: 0x63,
363 + NumpadEqual: 0x67,
364 ControlLeft: 0xe0,
365 ShiftLeft: 0xe1,
366 AltLeft: 0xe2,