Building a phone remote for a desktop app that has no API
Описание и применение
Создано приложение Relaymote, позволяющее управлять сессиями Claude Code с телефона, читая данные из файлов и выполняя действия через Chrome DevTools Protocol, при этом обеспечивая безопасность и сериализацию UI‑операций.
Задача
The author needed to view and answer Claude Code sessions from a phone, but the desktop app had no public API.
Результат
Relaymote allows phone users to list, view, and control Claude Code sessions without a public API, while keeping the UI interactions safe and secure.
Рабочий процесс
- Read session metadata and transcripts from JSON files, starting from the end for fast load.
- For actions, attach to the app’s main‑process debugger via CDP on 127.0.0.1.
- If the app exposes an internal method for the action, call it; otherwise drive the UI via CDP.
- Serialize all UI interactions through a single lane and gate them on human idleness to avoid race conditions.
- Secure the control port by binding to loopback, requiring an access key on every request, and verifying Cloudflare Access JWTs if used.
- Implement auto‑resume by recording reset times for usage limits and sending a “continue” request when the limit resets.
- Poll the sidebar every 30 seconds to update status dots and unread state without opening sessions.
Доказательства
Claude Desktop writes a small JSON file per Code session (title, folder, model, archived), and Claude Code writes each conversation as a .jsonl transcript.
Relaymote reads those directly, and reads transcripts from the end, so a long session opens fast.
Acting goes through the app’s main-process debugger (Chrome DevTools Protocol on 127.0.0.1).
Every UI action goes through one serialised lane and waits for an idle gate: no keyboard or mouse input for a short while.
The control port binds to loopback only.
The app port requires an access key on every request. Pairing is a QR link whose key is exchanged once for an HttpOnly cookie.
- Дата записи: 2026-10-06T22:40:59.770Z