fix(core): add LSP diagnostics caching and document refresh fallback#3034
Open
vadimLuzyanin wants to merge 2 commits intoQwenLM:mainfrom
Open
fix(core): add LSP diagnostics caching and document refresh fallback#3034vadimLuzyanin wants to merge 2 commits intoQwenLM:mainfrom
vadimLuzyanin wants to merge 2 commits intoQwenLM:mainfrom
Conversation
Add publishDiagnostics notification handler in LspServerManager that caches diagnostics and supports pending diagnostic promises. When textDocument/diagnostic pull fails in NativeLspService, fall back to force-refreshing the document (didClose + didOpen) and reading from the cached diagnostics. Also fix review findings: - Clear cache/pending maps on server restart in resetHandle() - Clean up pending diagnostics entries on timeout - Re-track URI in openedDocuments on refresh failure - Filter workspaceDiagnostics fallback by workspace root URI Fixes QwenLM#3029 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
wenshao
requested changes
Apr 9, 2026
4a09091 to
a6315cb
Compare
- Clear stale cache entry before refresh (not after) to prevent wiping fresh publishDiagnostics data that arrives during the delay - Re-add URI to openedDocuments after successful didOpen to keep local tracking in sync - Use continue instead of return to aggregate diagnostics from all servers in multi-server setups - Filter workspaceDiagnostics fallback by all workspace root URIs from WorkspaceContext for multi-root workspace support Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
7998f6f to
e6bd43d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Fixes missing LSP diagnostics by caching
textDocument/publishDiagnosticsnotifications and using them as a fallback whentextDocument/diagnosticpull requests fail. Also adds document refresh (didClose + didOpen) to trigger fresh analysis from the LSP server.Screenshots / Video Demo
N/A — internal change, verified end-to-end: the fixed build reports all TypeScript diagnostics while the original build returns none. Full flow confirmed in a single session: diagnose → fix → re-diagnose.
Dive Deeper
The LSP
textDocument/diagnosticpull request fails on some LSP servers (e.g.,typescript-language-serverin certain configurations), leaving users with no diagnostics. This change adds a push-based fallback:LspServerManagernow listens topublishDiagnosticsnotifications from the server and caches them. When the pull fails,NativeLspServiceforce-refreshes the document (didClose + didOpen) and reads from the cache, with a 5s timeout viaPromise.race. The same cache is also used as a fallback forworkspaceDiagnosticswhenworkspace/diagnosticfails, filtered by workspace root URI.Reviewer Test Plan
Create a TypeScript file with intentional type errors in a workspace with
.lsp.jsonconfigured fortypescript-language-server. Run with--experimental-lspand ask for diagnostics — should report all errors. Add another error to the file and ask again — should include the new error. Then ask the CLI to fix the errors and re-check diagnostics — should report zero remaining.Testing Matrix
Linked issues / bugs
Fixes #3029