feat(lsp): add restartServer operation#6233
Conversation
|
Is this something we should do automatically? We do have a file watcher... |
|
Tho I will say I do like the ability of the user to restart lsp servers too |
|
Automatic restart would be a nice QoL feature I for sure. I didn't want to make the changes too aggressive though since the LSP tool is still tagged experimental so I thought it best to keep it simple. I know pyright would benefit from automatic restarts when adding dependencies to a project. Rust might be more challenging as I think it goes out of sync over time but I've less experience with this one. Happy to to take a look though unless it's something you want to handle. |
|
Gotcha, hm do u think the best spot for this is for the agent? Ig it makes some sense... There are the 3 cases:
Trying to think which one is highest priority, because the agent invoked one seems like it could lead to the worst outcomes if the agent confuses itself but ur changes prolly wouldn't cause that |
|
Have you been using the experimental lsp tool? (or ig has ur agent?) |
|
I literally just ran into this so, interesting |
|
I've been using it a fair bit yeah, really nice addition! In the case of pyright it's a long standing issue that the LSP needs restarting on environment changes, there's no config options available to my knowledge. They (and pylance) have several open issues regarding it. Perhaps that needs addressing directly with them and we leave the ability open for the user/agent to trigger a restart? I'm trying to think what the dangers would be if the agent did get confused. Opus and Sonnet both seem leverage the restart feature well for what it's worth. |
3c02d0f to
62088e8
Compare
62088e8 to
ad5b0a7
Compare
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
|
Would love this. Running into a bunch of stale LSP errors on a daily basis. Not sure if it's something we're doing wrong |
|
It's a common occurence for me too, running my own fork right now but would rather not. Even Claude Code can do this now. @rekram1-node - Is this something you are interested in adding or not? I can create an issue if needed. |
ad5b0a7 to
94ba405
Compare
|
This is a daily occurance for me too, using typescript and svelte. The agent confuses itself all the time. Does edits, sees errors. Has to reassure itself that the errors are because of stale lsp. It even resorts to running external |
|
Linked it with an issue. Not sure if anyone is going to actually pick up on this though. |
|
+1 This would be great! I'm using basedpyright and frequently run into stale LSP in two scenarios:
Looking forward to this being merged. Thanks! |

Summary
Add
restartServeroperation to the LSP toolProblem
When installing new packages (e.g., adding
pyavtopyproject.toml), pyright doesn't pick up the changes automatically. It continues throwing diagnostic errors on every edit until opencode is restarted. Also affects rust-analyzer.Solution
Allow opencode to restart the LSP server by file extension without requiring a full opencode restart.
Fixes #5899
Related: #2156