-
Notifications
You must be signed in to change notification settings - Fork 26
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
|
Seems like this will also have the benefit of correctly attaching new sessions to the CWD if that changes within the Neovim instance (e.g. using the |
Move health check logic from OpencodeServer.try_existing_server to a new static OpencodeApiClient.check_health method using promises.
|
I have modified the code based on the comment, I think now maybe it is ok? |
Theoretically yes, but I'm wondering if anyone would actually change the CWD with |
|
Oh, I found a problem, sometime plugin will create more than one opencode, I will figure out the reason |
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