Skip to content

Conversation

@JackNorris
Copy link
Contributor

Summary

Add restartServer operation to the LSP tool

Problem

When installing new packages (e.g., adding pyav to pyproject.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.

Related: #5899, #2156

@rekram1-node
Copy link
Collaborator

Is this something we should do automatically? We do have a file watcher...

@rekram1-node
Copy link
Collaborator

Tho I will say I do like the ability of the user to restart lsp servers too

@JackNorris
Copy link
Contributor Author

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.

@rekram1-node
Copy link
Collaborator

Gotcha, hm do u think the best spot for this is for the agent? Ig it makes some sense...

There are the 3 cases:

  • automatic (file watcher << if necessary, this may just be misconfigured lsp tbh)
  • user invoked (maybe they wanna force a restart, i do this in my ide daily)
  • agent invoked

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

@rekram1-node
Copy link
Collaborator

Have you been using the experimental lsp tool? (or ig has ur agent?)

@rekram1-node
Copy link
Collaborator

Screenshot 2025-12-26 at 10 32 37 PM

Lol so a more intelligent model like opus here would probably leverage ur option here actually.

@rekram1-node
Copy link
Collaborator

I literally just ran into this so, interesting

@JackNorris
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants