-
Notifications
You must be signed in to change notification settings - Fork 25
feat(server): share process across multiple instances #159
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
base: main
Are you sure you want to change the base?
feat(server): share process across multiple instances #159
Conversation
Add a lock file mechanism to coordinate a single server process among multiple Neovim clients. Track ownership and active clients in opencode-server.lock to ensure the process persists until the last instance closes. Additionally, implement URI encoding for API queries.
|
This PR is generated by AI with I think this code is ok |
Add logic to tests/unit/util_spec.lua to handle year transitions in date formatting. The assertions now check the year of the timestamp to determine if the year should be present in the output string.
Replace the `owner` field in the lock file with `server_pid` to explicitly track the background process. Update `unregister_client` to return this PID and remove client promotion logic.
nvim returns non-zero exit codes when error messages are printed, even for expected errors in error handling tests. Changed test runner to check for actual '[31mFail.*||' patterns in output instead.
568d1a6 to
f948664
Compare
|
Thanks for the PR this looks interesting, I will play with it a little bit |
|
If you need to modify code, feel free to contact me! |
|
This repository is great |
sudo-tee
left a comment
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.
This is a really great feature for the plugin, and it looks stable from the tests I did.
I did add some little nitpicking , but otherwise this looks good
| local result_received = false | ||
| local is_healthy = false | ||
|
|
||
| curl.request({ |
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.
It would be cleaner to use the api-client.lua and add this route to it.
The api-client is already creating promises for the curl calls, so you can avoid using the vim.wait there
| server.url = url | ||
| server.is_owner = false | ||
| register_client() | ||
| server.spawn_promise:resolve(server --[[@as any]]) |
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.
should cast it to OpencodeServer
Title
feat(server): share opencode server process across multiple Neovim instances
Summary
This PR implements a shared server mechanism that allows multiple Neovim instances to share a single
opencode serveprocess, reducing resource usage and improving startup time for subsequent instances.Problem
Previously, each Neovim instance spawned its own
opencode serveprocess. When working with multiple projects simultaneously, this resulted in:Solution
Implement a lock file mechanism at
~/.cache/nvim/opencode-server.lockthat tracks:Key features:
Lock File Format
Testing