- React and TypeScript
- The interface. Each control shares one hold-to-confirm hook, so the contract cannot drift between buttons.
- MediaPipe hand landmarks
- Finds the index fingertip. The hand only covers the middle of the camera frame comfortably, so that middle area is stretched to fill the screen.
- Direct DOM writes for the cursor
- The dot is moved by writing its transform inside the tracking loop, not through React state. State renders a frame behind the hit test, so the dot you see and the button being pressed disagreed by tens of pixels.
- Electron shell
- Exists only so the camera permission sticks. It loads the deployed site so Spotify’s sign-in returns to the right address.
- Spotify Connect with PKCE
- Controls the Spotify app already running, with no server of my own.
A cursor landing a couple of centimetres off was not a tracking problem. An ancestor with a CSS transform becomes the containing block for anything fixed inside it, so the dot was laid out in the scaled frame while the hit test read the real viewport. Rendering it outside that frame fixed it. Most tracking problems I met were coordinate problems.
The worst bug froze the whole Mac. After sleep the camera track ends, and a silent catch around detection retried every frame forever. It now counts failures and stops, checks whether the track has ended, and releases the camera before the Mac sleeps.