fix: filter LSP diagnostics by client root#16365
fix: filter LSP diagnostics by client root#16365dotuananh0712 wants to merge 2 commits intoanomalyco:devfrom
Conversation
Fixes issue anomalyco#16353 where diagnostics from external projects leak into tool results and context window. Only include diagnostics for files within each LSP client's workspace root.
|
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. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Potential related PR found:
However, this appears to be an older related PR addressing different issues rather than a true duplicate. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes #16353
Type of change
What does this PR do?
Fixes issue #16353 where LSP diagnostics from external projects leak into tool results and context window.
In
packages/opencode/src/lsp/index.ts, thediagnostics()function now filters diagnostics to only include files within each LSP client's workspace root (client.root).This prevents:
write.ts(which appends up to 5 "other files" diagnostics)metadata.diagnosticspollution inwrite,edit, andapply_patchtoolsThe original code aggregated diagnostics from ALL active LSP clients without filtering by workspace path. When TypeScript language server follows imports across project boundaries, diagnostics from external projects would leak into the current project's results.
How did you verify my code works?
Checklist