Skip to content

feat: add offline mode support for air-gapped environments#8130

Closed
jamespapapa wants to merge 1 commit intoanomalyco:devfrom
jamespapapa:claude/offline-opencode-runtime-jhpYY
Closed

feat: add offline mode support for air-gapped environments#8130
jamespapapa wants to merge 1 commit intoanomalyco:devfrom
jamespapapa:claude/offline-opencode-runtime-jhpYY

Conversation

@jamespapapa
Copy link
Copy Markdown

Add comprehensive offline mode to enable OpenCode in closed networks:

  • Add OPENCODE_OFFLINE_MODE environment variable
  • Add timeouts (2-5s) to all external network requests
  • Auto-disable LSP downloads, auto-updates in offline mode
  • Skip share sync and remote config loading offline
  • Add fallbacks for models.dev API fetch failures
  • Add timeout to Installation.latest() version checks
  • Add timeout to remote config (.well-known/opencode)
  • Add timeout to session import from URLs

Modified files:

  • flag/flag.ts: Add OPENCODE_OFFLINE_MODE flag
  • installation/index.ts: Timeout for version checks
  • config/config.ts: Timeout for remote config
  • provider/models-macro.ts: Timeout for models API
  • share/share.ts: Skip in offline mode
  • share/share-next.ts: Skip in offline mode
  • cli/cmd/import.ts: Timeout for URL imports
  • OFFLINE_MODE.md: Complete offline setup guide

What does this PR do?

How did you verify your code works?

Add comprehensive offline mode to enable OpenCode in closed networks:

- Add OPENCODE_OFFLINE_MODE environment variable
- Add timeouts (2-5s) to all external network requests
- Auto-disable LSP downloads, auto-updates in offline mode
- Skip share sync and remote config loading offline
- Add fallbacks for models.dev API fetch failures
- Add timeout to Installation.latest() version checks
- Add timeout to remote config (.well-known/opencode)
- Add timeout to session import from URLs

Modified files:
- flag/flag.ts: Add OPENCODE_OFFLINE_MODE flag
- installation/index.ts: Timeout for version checks
- config/config.ts: Timeout for remote config
- provider/models-macro.ts: Timeout for models API
- share/share.ts: Skip in offline mode
- share/share-next.ts: Skip in offline mode
- cli/cmd/import.ts: Timeout for URL imports
- OFFLINE_MODE.md: Complete offline setup guide
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

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

No duplicate PRs found

@jakiechris
Copy link
Copy Markdown

期待解决:内网opencode serve,网页访问会报500

@jakiechris
Copy link
Copy Markdown

is there any differences between this pr and #9258 ?
OPENCODE_MODELS_URL

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants