opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Add `server.enabled` config option to explicitly enable HTTP server

Open rmk40 opened this issue 1 day ago • 1 comments

Problem

Since v1.1.10 (commit 982b71e86), the TUI no longer starts an HTTP server by default. While this is a reasonable security improvement, it breaks workflows that depend on the HTTP server:

  • Desktop app connecting to the TUI backend
  • SDK integrations that communicate via HTTP
  • Remote access scenarios (e.g., driving OpenCode from a mobile app)

Current Workarounds Don't Work Well

  1. port: 0 - Fails because the schema uses .positive() which rejects 0
  2. hostname: "127.0.0.1" - Doesn't trigger server because it matches the default
  3. mdns: true - Works but enables mDNS discovery which may not be desired

Users need a clear, explicit way to opt into the HTTP server without side effects.

Proposed Solution

Add a server.enabled config option:

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

This provides a clear opt-in mechanism that:

  • Is self-documenting (the intent is obvious)
  • Has no side effects (unlike mdns: true)
  • Restores pre-982b71e behavior for users who need it

Implementation

Minimal 3-file change:

  1. Add enabled: z.boolean().optional() to Server schema
  2. Return enabled from resolveNetworkOptions()
  3. Add networkOpts.enabled || to shouldStartServer condition

I have a PR ready with this implementation.

References

  • Commit that disabled server by default: 982b71e861e538c33382ae34049f312f46f37cd2
  • Related PR: #7529

rmk40 avatar Jan 14 '26 23:01 rmk40