Skip to content

feature: connect to remote servers #240

@nickjvandyke

Description

@nickjvandyke

Did you check the docs?

  • I am using the latest plugin version
  • I read the plugin docs
  • I read the opencode 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?
    • Edit: Yup! Works fine.
  • 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions