Skip to content

impl Support LSP $/progress messages #422#2591

Open
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721:422
Open

impl Support LSP $/progress messages #422#2591
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721:422

Conversation

@asukaminato0721
Copy link
Contributor

Summary

Fixes #422

Added an LSP progress subscriber that emits $/progress with window/workDoneProgress/create for recheck transactions, throttled to avoid spam.

Composed progress + streaming diagnostics via a new CompositeSubscriber so existing behavior remains unchanged while progress is reported.

Introduced progress token generation and client capability gating.

Test Plan

Added an LSP interaction test to verify window/workDoneProgress/create and $/progress begin notifications when a recheck is triggered.

@meta-cla meta-cla bot added the cla signed label Feb 28, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review February 28, 2026 18:31
Copilot AI review requested due to automatic review settings February 28, 2026 18:31
@asukaminato0721 asukaminato0721 marked this pull request as draft February 28, 2026 18:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements LSP work-done progress reporting (window/workDoneProgress/create + $/progress) during background recheck transactions, while preserving existing streaming diagnostics behavior.

Changes:

  • Added an LSP progress subscriber (throttled) and progress token generation with client capability gating.
  • Introduced CompositeSubscriber to fan out subscriber events to both diagnostics publishing and progress reporting.
  • Added an LSP interaction test to validate window/workDoneProgress/create and $/progress begin behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
pyrefly/lib/lsp/non_wasm/server.rs Adds progress token support and a progress subscriber, and composes it with existing diagnostics subscriber during rechecks.
pyrefly/lib/state/subscriber.rs Adds CompositeSubscriber to forward Subscriber events to multiple inner subscribers.
pyrefly/lib/test/lsp/lsp_interaction/progress.rs Adds an interaction test covering progress create + begin notifications.
pyrefly/lib/test/lsp/lsp_interaction/mod.rs Registers the new progress interaction test module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +212 to +215
assert!(
!subscribers.is_empty(),
"CompositeSubscriber requires at least one subscriber"
);
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompositeSubscriber::new is a public constructor that panics on an empty subscriber list. Since this is in a library module, it would be safer to avoid a hard panic (e.g., make the type/ctor pub(crate), return a Result<Self, ...>, or allow an empty list as a no-op subscriber) to prevent unexpected crashes if used elsewhere.

Suggested change
assert!(
!subscribers.is_empty(),
"CompositeSubscriber requires at least one subscriber"
);
// Allow an empty subscriber list; this results in a no-op composite subscriber.

Copilot uses AI. Check for mistakes.
Comment on lines +620 to +627
fn new(server: &'a Server, title: &'static str) -> Option<Self> {
if !server.supports_work_done_progress() {
return None;
}
let token = server.new_progress_token();
server.send_request::<WorkDoneProgressCreate>(WorkDoneProgressCreateParams {
token: token.clone(),
});
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window/workDoneProgress/create is sent, but the server may start emitting $/progress notifications immediately (on the first start_work) without waiting for the create request to be acknowledged. Per LSP, clients may ignore progress updates until the token is created. Consider tracking the create request/response (e.g., store the request id/token in Server, mark it ready on the matching response, and have LspProgressSubscriber suppress Begin/Report until ready) so Begin cannot be sent before the create response.

Copilot uses AI. Check for mistakes.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@github-actions
Copy link

No diffs to classify.

@asukaminato0721 asukaminato0721 marked this pull request as ready for review March 1, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support LSP $/progress messages

2 participants