@devries-cameron20 / t3code Mirror · read-only / commits / dfc093ab9b
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 03:00 UTC

fix(web): ignore right-clicks in the flat Device viewport (#17020)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Sebastián Maluk committed Oct 19, 2026 at 01:59 UTC dfc093ab9b030aaeca891418e74c790c1beea603
2 files changed +53 -1
apps/web/src/components/device/DeviceStreamView.browser.test.tsx
+52 -1
@@ -110,6 +110,7 @@ afterEach(async () => {
110 });
111
112 async function setup(h264 = false) {
113 + const touches: unknown[] = [];
114 vi.useFakeTimers();
115 vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
116 let videoBody: ReadableStreamDefaultController<Uint8Array> | undefined;
@@ -168,7 +169,11 @@ async function setup(h264 = false) {
169 sockets.push(this);
170 }
171 onmessage?: (event: { data: ArrayBuffer }) => void;
171 - send() {}
172 + send(packet: Uint8Array) {
173 + if (packet[0] === 0x03) {
174 + touches.push(JSON.parse(new TextDecoder().decode(packet.subarray(1))));
175 + }
176 + }
177 close() {}
178 },
179 );
@@ -186,6 +191,7 @@ async function setup(h264 = false) {
191 return {
192 images,
193 view,
194 + touches,
195 configure() {
196 const json = new TextEncoder().encode(
197 JSON.stringify({ width: 400, height: 800, orientation: "portrait" }),
@@ -213,6 +219,51 @@ const reconnect = () =>
219 .click(),
220 );
221
222 +it.each([
223 + { name: "middle", button: 1, buttons: 4 },
224 + { name: "right", button: 2, buttons: 2 },
225 +])("ignores $name-button drags and forwards the next primary drag", async ({ button, buttons }) => {
226 + const { touches, configure } = await setup();
227 + await act(async () => configure());
228 + const viewport = container.querySelector("canvas")!.parentElement!;
229 + viewport.style.width = "400px";
230 + viewport.style.height = "800px";
231 + // Synthetic pointer events do not register an active browser pointer to capture.
232 + viewport.setPointerCapture = () => {};
233 + const rect = viewport.getBoundingClientRect();
234 + const pointer = (type: string, button: number, buttons: number, y: number) =>
235 + viewport.dispatchEvent(
236 + new PointerEvent(type, {
237 + bubbles: true,
238 + pointerId: 1,
239 + pointerType: "mouse",
240 + button,
241 + buttons,
242 + clientX: rect.left + 100,
243 + clientY: rect.top + y,
244 + }),
245 + );
246 +
247 + await act(async () => {
248 + pointer("pointerdown", button, buttons, 600);
249 + pointer("pointermove", -1, buttons, 200);
250 + pointer("pointerup", button, 0, 200);
251 + });
252 + expect(touches).toEqual([]);
253 +
254 + await act(async () => {
255 + pointer("pointerdown", 0, 1, 600);
256 + pointer("pointermove", -1, 1, 200);
257 + pointer("pointerup", 0, 0, 200);
258 + pointer("pointermove", -1, 0, 400);
259 + });
260 + expect(touches).toEqual([
261 + { type: "begin", x: 0.25, y: 0.75 },
262 + { type: "move", x: 0.25, y: 0.25 },
263 + { type: "end", x: 0.25, y: 0.25 },
264 + ]);
265 +});
266 +
267 it("removes MJPEG requests while hidden and reconnects when shown", async () => {
268 const { images, view } = await setup();
269 expect(images[0]!.src).toContain("stream.mjpeg");
apps/web/src/components/device/DeviceStreamView.tsx
+1
@@ -398,6 +398,7 @@ export function DeviceStreamView(props: {
398 className={cn("relative select-none", showPhone && "invisible pointer-events-none")}
399 style={{ width: frame.width, height: frame.height }}
400 onPointerDown={(event) => {
401 + if (event.button !== 0) return;
402 event.currentTarget.setPointerCapture(event.pointerId);
403 (event.currentTarget.parentElement as HTMLElement | null)?.focus();
404 pointerActive.current = true;