Expand description
Embedded, version-matched web UI (WEBUI-PLAN P6).
Upstream’s serveUIEffect is embedded-first: the release binary embeds
the whole packages/app/dist and serves it at / + /assets/*, proxying
to app.opencode.ai only when embedding is disabled. ocserve historically
had only the proxy — so it served a newer Cloudflare UI against the
frozen server (version skew; the exact bug class the user hit). This module
restores upstream’s priority: serve the pinned 1.18.31 build first, fall
back to the proxy only under OCSERVE_DISABLE_EMBEDDED_WEB_UI=1 (mirroring
upstream’s OPENCODE_DISABLE_EMBEDDED_WEB_UI).
The pinned build is a single zstd pack (assets/webui/<tag>.pack.zst,
produced by scripts/extract-app.sh through the freeze’s PUBLIC HTTP
interface — not binary scraping). Pack format before zstd: OCAP1\n +
u32 count + (u16 pathlen, path, u64 datalen, data)*. Decompressed once at
boot into an in-memory map (bounded: the closure is ~10 MB raw).
Air-gapped property: an unknown asset under the embedded arm returns the
upstream JSON 404 {"error":"Not Found"} — it never falls through to the
network. That is exactly upstream’s embedded behavior.
Constants§
- APP_TAG
- The freeze tag the pack was built from — must match
FREEZE_VERSION.
Functions§
- available
- True when the embedded pack is present and parsed (non-empty).
- lookup
- Look up a request path in the embedded build. Mirrors upstream
serveEmbeddedUIEffect:/and unknown non-asset paths fall back toindex.html(SPA routing);/assets/*is exact (an unknown asset is a 404, neverindex.html). Returns(effective_path, bytes)so the caller uses the resolved file’s MIME (an SPA-fallback/routeis text/html). - mime_
for - MIME type by extension (small table; matches what freeze serves).