Building a phone remote for a desktop app that has no API
说明与用途
Relaymote 通过读取会话文件并使用 Chrome DevTools Protocol 执行操作,实现了从手机控制 Claude Code 会话,同时提供安全性和 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