-
Notifications
You must be signed in to change notification settings - Fork 32
π€ feat: configurable API server bind host experiment #1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
βΉοΈ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. βΉοΈ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with π. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Change-Id: Ie1b6293b5a41c8f7dbba3589e64357736d1ee3ee Signed-off-by: Thomas Kosiewski <[email protected]>
Change-Id: I9f29384286bd75aa25000758c887f608df99d607 Signed-off-by: Thomas Kosiewski <[email protected]>
9c50205 to
ecf123c
Compare
Change-Id: I85049e30b2aa89f81782681cc0bba1154080594b Signed-off-by: Thomas Kosiewski <[email protected]>
Change-Id: If5babd087a2ccd55402daf74c4128dc64107cd9b Signed-off-by: Thomas Kosiewski <[email protected]>
Change-Id: I5436c9b73c6c4d46c4eb4584cc694fd25bc96fad Signed-off-by: Thomas Kosiewski <[email protected]>
Change-Id: I6d189db020bdd8901aaedc21f1998fad40f1ceac Signed-off-by: Thomas Kosiewski <[email protected]>
Adds an opt-in Settings β Experiments feature to expose mux's API server on LAN/VPN.
~/.mux/config.json(apiServerBindHost,apiServerPort).networkBaseUrlsfor copy/paste (LAN/VPN IPs) + auth token.Validation:
make static-checkbun test src/node/services/serverService.test.ts src/node/services/serverLockfile.test.ts src/node/config.test.tsπ Implementation Plan
Configurable bind URL for the local API server (Experiment)
Answer (current behavior)
127.0.0.1(src/node/services/serverService.ts).MUX_SERVER_PORT(port; default is random)MUX_SERVER_AUTH_TOKEN(auth token)MUX_NO_API_SERVER=1(disable the server)--host, but the desktop app does not expose a bind-host setting today.Consequence: if mux only listens on loopback, your phone (LAN) and VPN clients (e.g., Tailscale) canβt connect.
Goal
Add an opt-in experiment that lets users configure the bind host/interface (and ideally a stable port) for the desktop appβs HTTP/WS API server, with UI text that clearly explains:
Recommended approach (config-backed experiment + connection info)
Net estimate: ~350β500 LoC product code.
What the experiment does (user-facing)
When enabled, mux can bind its local API server to a non-loopback interface (e.g.
0.0.0.0or a specific IP), making it reachable from:It should also surface copy/paste connection info:
/api+/orpcSecurity/UX requirements
Implementation plan
1) Add a new experiment entry (UI discoverability)
Files:
src/common/constants/experiments.tsSteps:
EXPERIMENT_IDS.CONFIGURABLE_BIND_URL = "configurable-bind-url"."Expose API server on LAN/VPN""Allow mux to listen on a non-localhost address so other devices on your LAN/VPN can connect. Anyone on your network with the auth token can access your mux API. HTTP only; use only on trusted networks (Tailscale recommended)."enabledByDefault: falseuserOverridable: trueshowInSettings: true2) Persist API server bind settings in
~/.mux/config.jsonWhy: main process needs this at app launch; localStorage isnβt available.
Files:
src/common/types/project.ts(extendProjectsConfig)src/node/config.ts(load/save)Add config fields (proposal):
apiServerBindHost?: string(default: unset β127.0.0.1)apiServerPort?: number(default: unset β current behavior; env var still overrides)Notes:
MUX_SERVER_PORTas highest-precedence override (useful for CI / power users).3) Update server startup to respect the configured bind host
Files:
src/node/services/serverService.tssrc/desktop/main.tsSteps:
Extend
StartServerOptionsto accepthost?: string.Pass
hostthrough tocreateOrpcServer({ host, port, ... }).In
src/desktop/main.ts, decide host/port in this precedence order:MUX_SERVER_PORTenv var (existing)apiServerPort0(random)and for host:
apiServerBindHost127.0.0.14) Make connection URLs discoverable (LAN/Tailscale)
Today
createOrpcServerrewrites wildcard bind hosts (0.0.0.0/::) to127.0.0.1forbaseUrl, which is fine for the desktop app + CLI discovery.To support phones/remote clients, add additional URLs rather than changing
baseUrl:Files:
src/node/services/serverLockfile.tssrc/node/services/serverService.tssrc/node/orpc/server.ts(only if we want server.ts to return more metadata)Steps:
ServerLockDataSchemato include optional fields, e.g.:bindHost?: stringport?: numbernetworkBaseUrls?: string[](derived fromos.networkInterfaces(), filtered to non-internal addresses)ServerLockfile.acquire(...)to accept and persist these optional fields.ServerService.startServer, after the server is listening (we knowactualPort), compute:networkBaseUrlsfor each relevant interface IP:http://<ip>:<port>ws://<ip>:<port>/orpc/wsas well if needed later5) Add backend RPC for viewing/updating bind settings (+ restarting server)
We want the experiment UI to be able to:
Files:
src/common/orpc/schemas/api.ts(add schemas underserver)src/node/orpc/router.ts(implement handlers)Proposed API surface:
server.getApiServerStatusβ returns current:running: booleanbaseUrl(loopback)networkBaseUrls(if any)token(so user can copy it for phone usage)bindHost,portserver.setApiServerSettingsβ persists config and restarts the HTTP server.Restart semantics:
ServerService.stopServer()+startServer()); this should not break the Electron renderer since it uses MessagePort.6) Update Settings β Experiments UI to include controls + warnings
Files:
src/browser/components/Settings/sections/ExperimentsSection.tsxApproach:
127.0.0.1(localhost only)0.0.0.0(all interfaces: LAN + VPN)networkBaseUrls+ a βCopyβ buttonSuggested warning copy (UI):
Validation
ServerLockDataSchemabackward compatibility (old lock files still parse)0.0.0.0and fixed port, confirm phone can loadhttp://<LAN-IP>:<port>/api/docs./api/*requests require the auth token.Alternatives considered
A) Environment variable only (
MUX_SERVER_HOST)Net estimate: ~20β40 LoC.
MUX_SERVER_HOSTenv var read insrc/desktop/main.tsand pass intoServerService.startServer.Pros: trivial.
Cons: doesnβt satisfy βExperiments tabβ UX + doesnβt help discoverability.
B) Make the existing experiments system config-backed
Net estimate: ~250β400 LoC in addition to the feature.
~/.mux/config.jsonand expose them to both main + renderer.Pros: more consistent long-term.
Cons: larger cross-cutting refactor than necessary for a single setting.
Generated with
muxβ’ Model:openai:gpt-5.2β’ Thinking:xhigh