cd /news/ai-agents/building-a-60fps-self-hosted-mobile-… · home › topics › ai-agents › article
[ARTICLE · art-182789] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Building a 60fps Self-Hosted Mobile IDE in Pure Python + Vanilla JS (2.8ms Delta Sync — Roast My Architecture)

A developer built PocketAGY, a self-hosted mobile IDE (iOS PWA plus a universal Android WebView APK) that controls AI coding agents running on a desktop over Wi-Fi and 5G, using only the Python standard library and framework-free Vanilla JS. The stack keys conversation segments by (file_size, st_mtime_ns) and reads only the last 680 KB of JSONL transcripts, returning unchanged delta checks in 2.8ms and under 60 bytes on the wire, while a 250ms SSE stream with a 1 KB comment preamble defeats proxy buffering and dual feed/outbox containers reconciled by 32-bit FNV-1a hashes keep chat flicker-free at 60fps. The project also includes a pure-Python QR pairing module with Reed-Solomon ECC and is in a free open beta.

recommendation

Tail-read large JSONL agent transcripts by byte offset and cache segments on (size, mtime_ns), and reconcile DOM slots by content hash instead of repainting the whole feed.

more in playbook: Designing agent systems
by read3 min views8 publishedDec 6, 2026

When building PocketAGY — a self-hosted Mobile IDE (iOS PWA + Universal Android WebView APK) to control AI coding agents running on my desktop over Wi-Fi and 5G — my early prototype felt noticeably clunky on a real phone over cellular:

innerHTML repaints blinked on every step<details> tool-trace accordions shut unless carefully tracked..jsonl transcripts (4.9 MB+) from byte 0 Here is how I re-engineered the stack in pure Python stdlib + zero-framework Vanilla JS (v7.2) to hit 2.8ms delta checks and 60fps flicker-free chat — plus a Live Sandbox & Free Open Beta if you want to poke holes in it.

v7.2): v7.0.0-beta``(size, mtime_ns) Segment Cache (2.8ms Delta) Long agent sessions easily exceed 5 MB of JSONL logs (2,300+ tool calls and thoughts). Parsing the whole file on every 250ms stream check is wasteful.

Instead, each conversation segment is keyed by (file_size, st_mtime_ns) in RAM, and active transcripts seek straight to the last 680 KB window:

@staticmethod
def _read_jsonl_tail(tpath: Path, max_lines: int = 340, max_bytes: int = 680_000):
    size = tpath.stat().st_size
    if size <= 0:
        return [], 0
    with tpath.open("rb") as f:
        if size > max_bytes:
            f.seek(size - max_bytes)
            raw_chunk = f.read()
            nl = raw_chunk.find(b"\n")
            if nl != -1:
                raw_chunk = raw_chunk[nl + 1:]
            lines = raw_chunk.decode("utf-8", errors="replace").splitlines()
            return lines[-max_lines:], max(len(lines), size // 900)
        lines = f.read().decode("utf-8", errors="replace").splitlines()
        return lines[-max_lines:], len(lines)

Pairing this with ?since=<composite_sig> means unchanged delta checks return {"unchanged": true} in 2.8ms locally and <60 bytes on the wire.

250ms SSE + Dual-Container Optimistic Outbox Over 5G reverse proxies, small initial text/event-stream headers often sit in an edge buffer until ~1 KB accumulates. Sending a single 1 KB comment preamble on stream open flushes the tunnel immediately:

self.send_header("Cache-Control", "no-cache, no-transform")
self.send_header("X-Accel-Buffering", "no")
self.end_headers()
self.wfile.write((": stream-open " + (" " * 1024) + "\n\n").encode("utf-8"))
self.wfile.flush()

On the frontend, instead of shipping React/Preact, I split the feed into two sibling containers (#feedSlots for server-confirmed turns and #outboxSlots for in-flight mobile prompts) and reconcile each slot via 32-bit FNV-1a hashes (data-hash):

function reconcileSlots(container, htmlItems) {
  const children = container.children;
  for (let i = 0; i < htmlItems.length; i++) {
    const html = htmlItems[i];
    const h = fastHash(html);
    if (i < children.length) {
      if (children[i].getAttribute('data-hash') !== h) {
        children[i].setAttribute('data-hash', h);
        children[i].innerHTML = html;
      }
    } else {
      const slot = document.createElement('div');
      slot.className = 'turn-slot';
      slot.setAttribute('data-hash', h);
      slot.innerHTML = html;
      container.appendChild(slot);
    }
  }
  while (container.children.length > htmlItems.length) {
    container.removeChild(container.lastChild);
  }
}

Historical bubbles stay 100% untouched in the DOM (text selection and open <details> tool logs never reset), while #outboxSlots keeps the user's message pinned until the exact turn appears in #feedSlots in the same frame.

qr_svg.py implements GF(256) Reed-Solomon ECC + ISO/IEC 18004 Byte-mode matrix masking in ~170 lines of pure Python so http://127.0.0.1:8787/pair works without pillow or qrcode C-wheels.@tabzipsa on an earlier post, the Free Open Beta physically excludes pro_runtime.py, Pro certificates are signed with secp256r1) ECDSA I'd love genuine code/UX critiques from folks building dev tools, mobile PWAs, or local-first bridges:

I'm giving free lifetime Pro licenses (Gumroad link for reference) to the sharpest technical critiques and bug reports!

── more in #ai-agents 4 stories · sorted by recency
── more on @pocketagy 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-a-60fps-sel…] indexed:0 read:3min 2026-12-06 · —