Skip to content

Feat/offline web static serve#18508

Closed
DroganC wants to merge 4 commits intoanomalyco:devfrom
DroganC:feat/offline-web-static-serve
Closed

Feat/offline web static serve#18508
DroganC wants to merge 4 commits intoanomalyco:devfrom
DroganC:feat/offline-web-static-serve

Conversation

@DroganC
Copy link

@DroganC DroganC commented Mar 21, 2026

Issue for this PR

Closes #ISSUE_NUMBER

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Problem: opencode web serves the browser UI by proxying to https://app.opencode.ai when no API route matches. On machines without outbound access to that host, the UI never loads.

Changes:

  1. packages/opencode/src/server/server.ts — If packages/app/dist/index.html exists (or OPENCODE_APP_DIST points at a directory that contains it), serve files from that directory with the same SPA fallback as before (unknown paths → index.html). Otherwise keep the existing proxy behavior.
  2. Flag.OPENCODE_APP_DIST in packages/opencode/src/flag/flag.ts — Documents and centralizes the env var used for the absolute path override.
  3. One log line when local dist is used (serving web UI from local dist with root) so operators can confirm the proxy is not in use.
  4. packages/app — Changelog fetch uses /changelog.json (from public/ after build); notification and project avatar use same-origin favicon paths instead of https://opencode.ai/..., so those requests stay on the server.
  5. docs/OFFLINE_WEB.md (English) — How to build packages/app, which env vars matter, and troubleshooting. CONTRIBUTING.md — Short subsection linking to that doc.

Why it works: The Vite production bundle is static files. Serving them from the same process that hosts the API avoids any dependency on app.opencode.ai for HTML/JS/CSS. The API routes are unchanged and still registered before the catch-all.

How did you verify your code works?

  • bun run build in packages/app so dist/index.html exists.
  • OPENCODE_APP_DIST set to that dist path (or rely on default path from packages/opencode), then bun run --conditions=browser ./src/index.ts web from packages/opencode.
  • Confirmed the browser loads the app from http://127.0.0.1:4096 and the server logs serving web UI from local dist once.
  • With dist removed or renamed, confirmed fallback still proxies (when network allows) so default behavior is preserved.

Screenshots / recordings

Optional: browser showing the app loaded from localhost while offline (no change to core UI layout intended).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

chenlong added 4 commits March 21, 2026 17:24
- Add OPENCODE_APP_DIST and fallback to packages/app/dist when index.html exists
- Fall back to app.opencode.ai proxy when no local build
- Use same-origin changelog and favicon assets in the app
- Document env vars and workflow in docs/OFFLINE_WEB.md
- Ignore offline/ for local models-api.json mirrors

Made-with: Cursor
- Document OPENCODE_APP_DIST in Flag; log once when serving local dist
- Rewrite OFFLINE_WEB.md in English; note issue-first policy for PRs
- Link air-gapped web flow from CONTRIBUTING.md

Made-with: Cursor
Fixes @opencode-ai/app typecheck for dialog-connect-provider and dialog-custom-provider.

Add docs/PR_BODY_offline_web.md as PR description draft for offline web PR.

Made-with: Cursor
@DroganC DroganC requested a review from adamdotdevin as a code owner March 21, 2026 09:33
@github-actions
Copy link
Contributor

Hey! Your PR title Feat/offline web static serve doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:title labels Mar 21, 2026
@github-actions
Copy link
Contributor

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

What needs to be fixed:

  • No issue referenced. Please add Closes #<number> linking to the relevant issue.

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
Contributor

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

Based on my search, I found 2 potentially related PRs that address similar functionality:

Potential Duplicates:

  1. PR feat(server): embed web UI assets in binary and serve locally #15721 - "feat(server): embed web UI assets in binary and serve locally"

  2. PR feat(server): support OPENCODE_WEB_URL for local frontend serving #17104 - "feat(server): support OPENCODE_WEB_URL for local frontend serving"

These PRs should be reviewed to ensure PR #18508 doesn't duplicate work or conflicts with existing approaches.

@DroganC DroganC closed this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours. needs:title

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant