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

main
ts 19 lines 806 Bytes
Raw
1 import type { MouseEvent as ReactMouseEvent } from "react";
2
3 const isThumbButton = (event: ReactMouseEvent) => event.button === 3 || event.button === 4;
4
5 // A thumb press would otherwise focus the URL bar, which then stops tracking the page.
6 export function preventThumbButtonFocus(event: ReactMouseEvent) {
7 if (isThumbButton(event)) event.preventDefault();
8 }
9
10 // Chromium runs app-router history on a thumb-button mouseup unless it is cancelled.
11 // Page content that already stepped its own history cancels it first.
12 export function takeThumbButtonNavigation(
13 event: ReactMouseEvent,
14 navigate: ((direction: "back" | "forward") => void) | undefined,
15 ) {
16 if (!isThumbButton(event) || event.defaultPrevented) return;
17 event.preventDefault();
18 navigate?.(event.button === 3 ? "back" : "forward");
19 }