[PR #8562] feat(core): add server.enabled config option to restore HTTP server #12796

Open
opened 2026-02-16 18:17:41 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8562

State: open
Merged: No


Summary

Adds a server.enabled config option and --enable-server CLI flag that explicitly enable the HTTP server for the TUI, restoring the pre-982b71e behavior for users who need external connections (desktop app, SDK, etc).

Fixes #8561

Usage

Config (opencode.json):

{
  "server": {
    "enabled": true
  }
}

CLI:

opencode --enable-server

Both use the default port-0 fallback (try 4096, then random) on 127.0.0.1 — the same resilient behavior as before the server was disabled by default.

Changes

  • config.ts: Add enabled: z.boolean().optional() to Server schema
  • network.ts: Add --enable-server CLI option, resolve enabled from CLI flag or config, return in resolveNetworkOptions()
  • thread.ts: Add networkOpts.enabled || to shouldStartServer condition

Why

Since 982b71e ("disable server unless explicitly opted in"), users who need the HTTP server have no clean way to enable it:

  • port: 0 fails (schema rejects non-positive)
  • hostname: "127.0.0.1" doesn't trigger server (matches default)
  • mdns: true works but has unwanted side effects
  • There was no config-only path to start the server on default host/port

This provides a clear, self-documenting opt-in via both config and CLI with no side effects.

Testing

Tested locally — setting "server": { "enabled": true } in opencode.json or passing --enable-server correctly starts the HTTP server with the default port-0 fallback behavior.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8562 **State:** open **Merged:** No --- ## Summary Adds a `server.enabled` config option and `--enable-server` CLI flag that explicitly enable the HTTP server for the TUI, restoring the pre-982b71e behavior for users who need external connections (desktop app, SDK, etc). Fixes #8561 ## Usage Config (`opencode.json`): ```json { "server": { "enabled": true } } ``` CLI: ```bash opencode --enable-server ``` Both use the default port-0 fallback (try 4096, then random) on `127.0.0.1` — the same resilient behavior as before the server was disabled by default. ## Changes - **`config.ts`**: Add `enabled: z.boolean().optional()` to Server schema - **`network.ts`**: Add `--enable-server` CLI option, resolve `enabled` from CLI flag or config, return in `resolveNetworkOptions()` - **`thread.ts`**: Add `networkOpts.enabled ||` to `shouldStartServer` condition ## Why Since 982b71e ("disable server unless explicitly opted in"), users who need the HTTP server have no clean way to enable it: - `port: 0` fails (schema rejects non-positive) - `hostname: "127.0.0.1"` doesn't trigger server (matches default) - `mdns: true` works but has unwanted side effects - There was no config-only path to start the server on default host/port This provides a clear, self-documenting opt-in via both config and CLI with no side effects. ## Testing Tested locally — setting `"server": { "enabled": true }` in `opencode.json` or passing `--enable-server` correctly starts the HTTP server with the default port-0 fallback behavior.
yindo added the pull-request label 2026-02-16 18:17:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12796