How I built phone continuity for my desktop AI companion: 2-minute pairing codes, a 4-file browser, and 0 native-app installs
Ankita AI is a desktop AI assistant by Krish Verma, and its work lives on the desktop — which is fine until you walk away from the desk. The obvious fix is a phone app. I built the other thing instead: the phone's browser becomes a window into the desktop, with no app to install, no second account, and a pairing code that dies after two minutes. The project is open source at https://github.com/akyourowngames/A.N.K.I.T.A, and the site is https://ankita-sable.vercel.app.
The decision: a browser, not an app
Desktop Settings → Phone → Create pairing code now defaults to a phone-browser QR/link. The selector still offers the native app's QR/link and v1 request, but the default is the browser. That choice does most of the security work for me: a browser tab has no background life of its own, no stored credentials beyond the tab, and nothing to update. The phone holds its token only in that tab's sessionStorage and in-memory state. Disconnect revokes it on the desktop; Forget clears local access. And a stale response cannot restore a forgotten connection — the client carries a connection-generation guard, added after a delayed successful pairing response reconnected a forgotten tab in testing.
Four files, and nothing else
The same HTTPS listener serves a fixed allowlist at /v1/ankita-companion/phone: index.html, app.mjs, style.css, and the shared contract module. Four files, mapped in code — no request path ever becomes a filesystem path. The responses carry a strict content policy (default-src 'none', no framing, no inline or remote scripts, no camera, microphone, or geolocation), and the browser DOM renders untrusted messages with textContent, never HTML.
Pairing itself is guarded at the network layer before any asset or auth operation runs. phone-pairing.mjs validates the Host header against discovered addresses and names, the leaf certificate's SANs, and the actual bound port. A Browser Origin, when present, must exactly match the served HTTPS origin. Arbitrary or null origins, rebinding names, wrong ports, and cross-site fetch metadata all fail first. There is no wildcard CORS and no cookie auth. The invitation code lives for 120 seconds — long enough to scan, short enough to limit guessing — and a pending approval waits the same 120 seconds on the desktop owner before it expires.
What the phone actually sees
After the desktop owner approves, the phone shows recent assigned-conversation messages and saved work: the checklist, bounded receipts, and selected context excerpts. Hidden and tool chat entries are excluded, and arbitrary owner or thread selectors are refused — the server never accepts a caller-selected owner. A missing assignment is an actionable error, not an empty screen.
The numbers are the boundary. A task's goal is excerpted at 8,000 characters, run events are capped at 128 with 2,400 characters of detail each, and selected context for review is named and bounded: a 120-character title, 4,000 characters of text, a redacted server preview, and a visible review checkbox. The server issues an expiring preview identity bound to the device, the owner, and the task — consumed by exactly one accepted request. Editing or removing the selection invalidates the preview, and the preview itself expires after two minutes without a send, so reviewed context cannot sit around waiting to be replayed.
Review and continue, inside the same custody
Continuing from the phone does not create a second assistant. Review and continue route through assistant.resume inside the normal phone run owner, so engine event and turn custody, tool approval, timeout, cancellation, and revocation all stay active. New requests without context create no new saved references; existing task context follows the original task on continuation.
Reassignment is where the old behaviour broke. The first version returned old run events after a device was reassigned — a 200 where a 404 belonged. Now reassignment cancels and removes old runs, approvals, and previews before changing authority, and both old events and old approvals return 404. That regression has its own test, alongside the endpoint tests that first failed with 401 !== 200 on the phone page and 404 !== 200 on history, and the surface-propagation fix that stopped phone tasks being marked as desktop.
The honest limits
The phone browser is a window, not a second desktop. The desktop must approve the phone first, and the pairing code expires in two minutes, so a slow scan means generating a new code. You install and trust the desktop's saved public certificate on the phone and compare the desktop fingerprint — do not bypass a browser warning. Production TLS verification was not disabled, and the desktop still exports only its public CA and fingerprint. And the two-minute preview expiry cuts both ways: reviewed context that is not sent promptly has to be reviewed again.
Tell me I'm wrong: is a 2-minute expiring preview identity the right line, or should the phone be allowed to hold reviewed context longer — and where would a longer-lived token first get abused?
— Krish Verma, creator of Ankita AI
Top comments (0)