Skip to content

feat(server): embed web UI assets in binary and serve locally - #15700

Closed
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:embed-web-ui-assets
Closed

feat(server): embed web UI assets in binary and serve locally#15700
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:embed-web-ui-assets

Conversation

@BYK

@BYKBYK commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Embeds the web UI into the compiled binary at build time so opencode serve works offline without proxying to the CDN.

What

  • build.ts generates src/server/app-manifest.ts at compile time, mapping URL paths to embedded $bunfs asset paths. A Bun plugin with loader: "file" ensures non-JS assets (images, fonts, etc.) are embedded as opaque blobs rather than parsed as modules.
  • server.ts gains two serving functions: serveStaticFile() (exact-match only, runs as middleware before Instance.provide() to avoid triggering DB migrations on asset requests) and serveLocal() (exact match + SPA fallback for extensionless page routes, used in the catch-all after all API routes).
  • Asset resolution order: embedded $bunfsOPENCODE_APP_DIR env var → auto-detect packages/app/dist → CDN proxy fallback.
  • Optional Nerd Fonts excluded from embedding (83 files, ~27 MB). Core fonts (Inter, IBM Plex Mono) stay embedded. Optional fonts are transparently proxied from app.opencode.ai on first use and browser-cached thereafter. font-display: swap ensures immediate text rendering with fallback.

Size impact

Size
Before (v1.2.15, CDN proxy only)~159 MB
With all fonts embedded~201 MB
With optional fonts externalized~174 MB

@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Found a related PR:

PR #12829: feat(app): embed web ui in binary
#12829

This appears to be a previous attempt at the same feature - embedding the web UI in the binary. This PR (#15700) may be a revived or refactored version of that earlier work, or it could be addressing the same goal with a different implementation approach.

Build the web UI into the binary at compile time via a generated
app-manifest. The server serves embedded assets directly instead of
proxying everything to the CDN, with a CDN fallback for when no local
assets are present.
- build.ts generates src/server/app-manifest.ts mapping URL paths to
embedded $bunfs asset paths; uses a Bun plugin with loader:"file" so
non-JS assets are embedded as opaque blobs rather than parsed
- Optional Nerd Font woff2/woff/ttf files (83 files, ~27MB) are
excluded from the manifest and transparently proxied from CDN on
demand; core fonts (Inter, IBM Plex Mono) remain embedded
- server.ts gains serveStaticFile() for exact-match serving (used in
pre-bootstrap middleware to avoid DB migration on asset requests) and
serveLocal() with SPA fallback (used in catch-all after API routes)
- Asset resolution order: embedded $bunfs → OPENCODE_APP_DIR env →
auto-detect packages/app/dist → CDN proxy
- SPA fallback skips paths with file extensions so unmatched assets
fall through to CDN proxy instead of returning index.html
- Binary size: ~159MB (v1.2.15) + 42MB embedded assets = ~201MB raw,
174MB after excluding optional fonts
@BYK
BYKforce-pushed the embed-web-ui-assets branch from ebf523a to 6cd356eCompareMarch 2, 2026 12:06
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 2, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@BYK