PocketAGY v7.2 Architecture & Pairing

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:

  1. Full innerHTML repaints blinked on every step and snapped <details> tool-trace accordions shut unless carefully tracked.
  2. Optimistic messages vanished for 1–2 seconds whenever a poll landed before the desktop process flushed the new JSONL line to disk.
  3. Reading multi-megabyte .jsonl transcripts (4.9 MB+) from byte 0 on every poll burned CPU and stalled responses.
  4. Reverse proxies (Tailscale Funnel / Cloudflare Tunnel) buffered small SSE frames, making real-time updates feel choppy on 5G.

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.

1. Tail-Seek JSONL Reader + (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.

2. Proxy-Busting 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.

3. Pure-Stdlib QR Pairing & Offline ECDSA P-256 Licensing

  • Zero-Dependency QR Pairing: 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.
  • Anti-Tamper Pro Separation: Following great feedback from @tabzipsa on an earlier post, the Free Open Beta physically excludes pro_runtime.py, Pro certificates are signed with NIST P-256 (secp256r1) ECDSA bound to machine fingerprint, and privileged cloud calls are verified server-side on a stateless Cloudflare Worker.

PocketAGY Mobile IDE Tabs

Roast My Setup (Open Beta Feedback -> Free Pro Keys)

I'd love genuine code/UX critiques from folks building dev tools, mobile PWAs, or local-first bridges:

  1. Click around the Zero-Install Live Sandbox on your phone or desktop.
  2. Or run the Free Wi-Fi Open Beta (v7.0.0-beta) if you use Google Antigravity.
  3. Drop your bluntest critique in the comments (or GitHub Issues) — what breaks on iOS Safari / Android WebView, where does the FNV-1a slot reconciler fall short, or what security/UX edge case did I miss?

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