Skip to content

Conversation

@kbrilla
Copy link
Contributor

@kbrilla kbrilla commented Feb 8, 2026

PR: feat(language-service): integrate progressive init with pull-based diagnostics

Description

Integrates Progressive Project Initialization (#66966) with Pull-Based Diagnostics (#66700) so they work optimally together.

When pull-based diagnostics (LSP 3.17) is active, progressive project initialization now sends a single workspace/diagnostic/refresh notification instead of computing and pushing diagnostics for each open file. This eliminates wasted computation since the pull-based client would discard pushed diagnostics anyway.

Falls back to the chunked push-based approach when pull diagnostics is not supported by the client.

Problem

Without this integration, when both features are active:

  1. Progressive init computes diagnostics for each open file (getSemanticDiagnostics) and pushes them via connection.sendDiagnostics()
  2. The pull-based client ignores these pushed diagnostics (it uses textDocument/diagnostic to request them on-demand)
  3. The diagnostic computation in step 1 is entirely wasted

Solution

private async initializeProjectProgressively(project: ts.server.Project): Promise<void> {
    // ...
    if (this.usePullDiagnostics) {
        // Just notify the client to re-pull — no computation needed
        this.connection.languages.diagnostics.refresh();
        return;
    }
    // Fall back to chunked push-based approach
    // ...
}

When usePullDiagnostics is true, the method:

  1. Sends workspace/diagnostic/refresh to the client
  2. Returns immediately — no file-by-file diagnostic computation

The client then pulls diagnostics on its own schedule, using the pull diagnostics handler which has its own caching via resultId.

Changes

File Change
vscode-ng-language-service/server/src/session.ts Check usePullDiagnostics in initializeProjectProgressively(), send refresh notification instead of computing diagnostics

Dependencies

This PR must be merged AFTER both base PRs:

Testing

  • All language service tests pass (modern + legacy)
  • All LSP integration tests pass (including pull diagnostics tests)
  • All server unit tests pass

Breaking Changes

None


AI Disclosure

This PR was developed using Claude Opus 4 AI assistant under human orchestration and review by @kbrilla.

Implement support for LSP 3.17 Pull-Based Diagnostics, which allows
clients to request diagnostics on-demand rather than receiving them
pushed from the server.

Key changes:
- Add new diagnostics.ts handler with onDocumentDiagnostic and
  onWorkspaceDiagnostic implementations
- Register diagnosticProvider capability in server initialization
- Detect client support for pull diagnostics and workspace refresh
- Implement result caching with resultId to return unchanged reports
  when documents haven't been modified
- Support fallback to push-based diagnostics when client doesn't
  support pull diagnostics
- Add integration tests for pull-based diagnostics

Benefits:
- Client controls when diagnostics are computed
- Reduced unnecessary diagnostic computations via caching
- Better integration with VS Code's diagnostic system
- Supports inter-file dependencies for Angular projects
Replace project.refreshDiagnostics() with progressive background processing
during project initialization. Open files are now processed in configurable
chunks (default: 10) with event loop yields between chunks, keeping the IDE
responsive during Angular project startup.

Progressive initialization provides:
- Immediate feedback: diagnostics appear file-by-file
- Responsiveness: event loop not blocked between chunks
- Cancellation: stops if project closes or user starts typing
Use promisify(setImmediate) instead of a custom yieldToEventLoop() function
for consistency with the existing pattern in session.ts.
…agnostics

When pull-based diagnostics (LSP 3.17) is active, progressive project init
now sends a workspace/diagnostic/refresh notification instead of computing
and pushing diagnostics for each open file. This avoids wasted computation
since the pull-based client would discard pushed diagnostics anyway.

Falls back to the chunked push-based approach when pull diagnostics is not
supported by the client.

Depends on:
- PR angular#66700 (Pull-Based Diagnostics)
- PR angular#66966 (Progressive Project Initialization)
@pullapprove pullapprove bot requested a review from atscott February 8, 2026 20:01
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: performance Issues related to performance area: language-service Issues related to Angular's VS Code language service labels Feb 8, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: language-service Issues related to Angular's VS Code language service area: performance Issues related to performance detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant