Did you check the docs?
Is your feature request related to a problem? Please describe.
Most of us run opencode (which dual-launches the server and TUI) locally, for which the plugin works great. However its remote-server uses are growing and opencode.nvim can't connect to those because we hard-code localhost.
Describe the solution you'd like
Expose server.host configuration (maybe server.hostname to match opencode's CLI flags?). Default to localhost. Use it in Server:curl.
The user has likely configured the remote server with basic auth, so we should support that too via server.username and server.password.
Questions:
- Do we need to expose
server.protocol too? Is it reliable to use http for localhost, and https otherwise? Can we self-reference in the defaults like that? Or has to be inline, and not configurable? What about edge case locals like 127.0.0.1 and 0.0.0.0, or Docker internal URLs that are "remote" but SSL-less?
- Can we always default the username and password to the env vars (which may or may not be set)? Will a server with no auth set care if the request still includes it?
- Because we leverage TUI commands, I believe we still need an
attached TUI ultimately? If so, perhaps we change the server command to opencode attach when we detect a remote host? Maybe we pass an args list to server.start for the user to concat to their opencode cmd, conditionally including attach and/or --port <opts.server.port>. Lower maintenance and more straightforward than the previous opts.server.cmd.
Describe alternatives you've considered
No alternatives afaik. opencode attach <remote server> locally doesn't work because we must make requests to the server, not the attached TUI.
We could expose server.url instead of the separate host and port (and protocol?) fields. It's nicer for remote config - just copy/paste the entire URL. But it adds noise (and breaks backwards-compat) for the most common localhost case, has worse intellisense, and requires internal parsing. With just host and port, remote configuration is NBD. If we need protocol, it gets a bit annoying. But still the lesser evil.
Note that whatever URL configuration we choose above, we'll also use in an eventual configurable server discovery process.
Additional context
Related:
Did you check the docs?
Is your feature request related to a problem? Please describe.
Most of us run
opencode(which dual-launches the server and TUI) locally, for which the plugin works great. However its remote-server uses are growing andopencode.nvimcan't connect to those because we hard-codelocalhost.Describe the solution you'd like
Expose
server.hostconfiguration (maybeserver.hostnameto matchopencode's CLI flags?). Default tolocalhost. Use it inServer:curl.The user has likely configured the remote server with basic auth, so we should support that too via
server.usernameandserver.password.Questions:
server.protocoltoo? Is it reliable to usehttpforlocalhost, andhttpsotherwise? Can we self-reference in the defaults like that? Or has to be inline, and not configurable? What about edge case locals like 127.0.0.1 and 0.0.0.0, or Docker internal URLs that are "remote" but SSL-less?attached TUI ultimately? If so, perhaps we change theservercommand toopencode attachwhen we detect a remote host? Maybe we pass anargslist toserver.startfor the user to concat to their opencode cmd, conditionally includingattachand/or--port <opts.server.port>. Lower maintenance and more straightforward than the previousopts.server.cmd.Describe alternatives you've considered
No alternatives afaik.
opencode attach <remote server>locally doesn't work because we must make requests to the server, not theattached TUI.We could expose
server.urlinstead of the separatehostandport(andprotocol?) fields. It's nicer for remote config - just copy/paste the entire URL. But it adds noise (and breaks backwards-compat) for the most commonlocalhostcase, has worse intellisense, and requires internal parsing. With justhostandport, remote configuration is NBD. If we needprotocol, it gets a bit annoying. But still the lesser evil.Note that whatever URL configuration we choose above, we'll also use in an eventual configurable server discovery process.
Additional context
Related:
opencodeserver without TUI #190