feat: add offline mode to disable non-essential outbound connections#18235
Open
dgruzd wants to merge 1 commit intoanomalyco:devfrom
Open
feat: add offline mode to disable non-essential outbound connections#18235dgruzd wants to merge 1 commit intoanomalyco:devfrom
dgruzd wants to merge 1 commit intoanomalyco:devfrom
Conversation
Introduces OPENCODE_OFFLINE=true env var, offline: true config option, and --offline CLI flag that act as a single kill switch for non-essential outbound connections: - opencode.ai/install auto-update check - opncd.ai session sharing (also forces share: "disabled" so the TUI hides the /share command) - app.opencode.ai web UI proxy Exa search (mcp.exa.ai) is intentionally excluded — it is user-initiated and already gated by a permission prompt. models.dev is excluded as it provides essential model metadata. Existing granular env vars (OPENCODE_DISABLE_AUTOUPDATE, OPENCODE_DISABLE_SHARE, OPENCODE_DISABLE_APP_PROXY) still work independently. OPENCODE_OFFLINE is a superset that enables all of them. The offline flags use Object.defineProperty getters rather than plain constants because flag.ts is imported before the CLI handler or config loading sets process.env.OPENCODE_OFFLINE. Docs: added Offline mode section to config.mdx.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
nice!! this is what I want, offline mode;) |
Collaborator
|
We ofc need to ship something with this shape, internally we talked about some approaches briefly, ill need to sync back w/ them to see what they think is best next week |
This was referenced Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #18233
Type of change
What does this PR do?
Adds a single "kill switch" for non-essential outbound connections, useful in privacy-sensitive or restricted-network environments.
Three equivalent ways to enable it:
OPENCODE_OFFLINE=true opencode opencode --offline opencode run --offline "fix the tests" opencode serve --offlineWhen enabled, the following are disabled:
opencode.ai/installauto-update checkopncd.aisession sharing/sharecommand hidden in TUIapp.opencode.aiweb UI proxyIntentionally not affected:
models.dev(essential model metadata) and Exa search (user-initiated, already gated by a permission prompt).The existing granular flags (
OPENCODE_DISABLE_AUTOUPDATE,OPENCODE_DISABLE_SHARE,OPENCODE_DISABLE_APP_PROXY) continue to work independently —OPENCODE_OFFLINEis a superset that implies all of them.Implementation note: offline flags are implemented as
Object.definePropertygetters rather than plain constants, becauseflag.tsis imported before the CLI handler or config loading has a chance to setOPENCODE_OFFLINEin the environment.Inspired by the rolandcode fork, which patches these out entirely — this PR adds a first-class opt-in instead.
How did you verify your code works?
test/flag/offline.test.ts— 5 tests covering: env var activation, granular flag independence,OPENCODE_OFFLINEas superset, and dynamic runtime behavior (getters pick up env changes after module load)test/cli/tui/thread.test.tsto includeoffline: falsein the expected args shapebun test— all tests passbun typecheck— no errorsScreenshots / recordings
Not applicable — no UI changes (the
/sharecommand disappearing from the TUI when offline is the only visual effect, and it's a removal rather than something screenshot-worthy).Checklist