Repository navigation
feat(lsp): add standard LSP workDoneProgress signal around analysis (#1909) - #2043
EffortlessSteven wants to merge 10 commits into
Conversation
…ase audit (2026-07-19) Add 9 entries to LEARNINGS.md covering: - Gate blocking is non-functional (hardcoded seam_id None) - Static receipts are advisory (fabrication is trivial) - Every save re-runs the full pipeline (cache not wired in) - continue-on-error on every CI step makes green meaningless - Result<_, String> is the highest-leverage refactor target - Cross-language consistency needs a shared vocabulary layer - File-policy gate breaks main on new file types - Duplicate run-status logic drifts - The session's structural learnings document Each entry follows the existing LEARNINGS.md format: date, title, load-bearing lesson, and concrete evidence references.
…1909) Send window/workDoneProgress/create then Begin before the analysis spawn_blocking, and End on success. If the client does not support workDoneProgress, the create call fails silently and analysis proceeds without progress. This gives stock VS Code / Neovim users a progress indicator during analysis for the first time. Previously the only feedback was custom ripr/analysisStatus notifications. Known limitation: on cancellation (superseded by a newer save), the OngoingProgress is dropped without sending End. The next save's Begin replaces the stale progress token — VS Code handles this gracefully. Proof: cargo check --lib (exit 0); cargo clippy --all-targets -D warnings (exit 0).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary by CodeRabbit
Walkthrough
ChangesLSP progress lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Backend
participant LSPClient
participant Analysis
Backend->>LSPClient: create_work_done_progress(ripr-analysis-generation)
Backend->>LSPClient: begin()
Backend->>Analysis: run refresh analysis
Analysis-->>Backend: refresh completes
Backend->>LSPClient: finish()
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request adds standard LSP progress signals during the analysis phase to show a progress indicator in editors. The review feedback highlights a potential issue where the progress spinner could leak (spin indefinitely) if the analysis is cancelled or fails. It suggests implementing a ProgressGuard drop guard pattern to ensure the progress is always finished cleanly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // Send standard LSP progress signal so stock editors show a | ||
| // progress indicator during analysis (#1909). If the client | ||
| // does not support workDoneProgress, the create call fails | ||
| // silently and analysis proceeds without progress. | ||
| let progress_token = tower_lsp_server::ls_types::ProgressToken::String(format!( | ||
| "ripr-analysis-{generation}" | ||
| )); | ||
| let mut ongoing_progress = match self | ||
| .client | ||
| .create_work_done_progress(progress_token.clone()) | ||
| .await | ||
| { | ||
| Ok(()) => { | ||
| let p = self.client.progress(progress_token, "ripr analysis"); | ||
| Some(p.begin().await) | ||
| } | ||
| Err(_) => None, | ||
| }; |
There was a problem hiding this comment.
Resolve Progress Spinner Leaks on Cancellation and Failure
Currently, if the analysis is cancelled (superseded by a newer save) or fails early (e.g., due to analysis errors, commit failures, or root projection failures), the OngoingProgress is dropped without sending the standard LSP WorkDoneProgressEnd notification. This causes the progress spinner in stock editors (like VS Code or Neovim) to spin indefinitely, leading to a degraded user experience.
We can resolve this cleanly and defensively by introducing a zero-cost ProgressGuard drop guard pattern. If the guard is dropped before being explicitly finished, it will automatically spawn a background task to send the WorkDoneProgressEnd notification.
This fully resolves the known limitation mentioned in the PR description in an idiomatic Rust manner.
struct ProgressGuard {
progress: Option<tower_lsp_server::OngoingProgress>,
}
impl ProgressGuard {
fn new(progress: tower_lsp_server::OngoingProgress) -> Self {
Self { progress: Some(progress) }
}
async fn finish(mut self) {
if let Some(progress) = self.progress.take() {
progress.finish().await;
}
}
}
impl Drop for ProgressGuard {
fn drop(&mut self) {
if let Some(progress) = self.progress.take() {
tokio::spawn(async move {
let _ = progress.finish().await;
});
}
}
}
// Send standard LSP progress signal so stock editors show a
// progress indicator during analysis (#1909). If the client
// does not support workDoneProgress, the create call fails
// silently and analysis proceeds without progress.
let progress_token = tower_lsp_server::ls_types::ProgressToken::String(format!(
"ripr-analysis-{generation}"
));
let mut ongoing_progress = match self
.client
.create_work_done_progress(progress_token.clone())
.await
{
Ok(()) => {
let p = self.client.progress(progress_token, "ripr analysis");
Some(ProgressGuard::new(p.begin().await))
}
Err(_) => None,
};There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/ripr/src/lsp/backend.rs`:
- Around line 481-484: Update the refresh flow in the code surrounding
ongoing_progress so every success, failure, and cancellation return path
completes the progress session by calling progress.finish().await before
returning. Preserve the existing success handling while ensuring the
ongoing_progress handle is consumed and a terminal notification is sent on all
exits.
- Around line 251-264: Update the initialization capability handling to record
whether the client supports window.workDoneProgress, then gate the progress
setup in the analysis flow around progress_token and ongoing_progress on that
capability before calling create_work_done_progress or begin. Ensure every error
or cancellation path that starts progress also calls finish, while preserving
the existing behavior when progress is unsupported.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0fc0d2ef-ef2f-451e-98b7-39dd19ebbeb5
📒 Files selected for processing (1)
crates/ripr/src/lsp/backend.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/ub-review(auto-detected)
| let progress_token = tower_lsp_server::ls_types::ProgressToken::String(format!( | ||
| "ripr-analysis-{generation}" | ||
| )); | ||
| let mut ongoing_progress = match self | ||
| .client | ||
| .create_work_done_progress(progress_token.clone()) | ||
| .await | ||
| { | ||
| Ok(()) => { | ||
| let p = self.client.progress(progress_token, "ripr analysis"); | ||
| Some(p.begin().await) | ||
| } | ||
| Err(_) => None, | ||
| }; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== backend.rs outline ==\n'
ast-grep outline crates/ripr/src/lsp/backend.rs --view expanded || true
printf '\n== relevant lines around progress creation ==\n'
sed -n '220,290p' crates/ripr/src/lsp/backend.rs
printf '\n== search for workDoneProgress / create_work_done_progress / progress end ==\n'
rg -n "workDoneProgress|create_work_done_progress|ProgressToken|begin\(|end\(\)|OngoingProgress|progress\(" crates/ripr/src/lsp -S
printf '\n== tests mentioning LSP capabilities or empty capabilities ==\n'
rg -n "capabilities: \{\}|workDoneProgress|initialize|progress" crates/ripr/src/lsp -SRepository: EffortlessMetrics/ripr-swarm
Length of output: 32013
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== initialize_result / capabilities ==\n'
sed -n '1,220p' crates/ripr/src/lsp/capabilities.rs
printf '\n== backend progress handling around finish path ==\n'
sed -n '460,500p' crates/ripr/src/lsp/backend.rs
printf '\n== tests around initialize_result and progress params ==\n'
sed -n '1,120p' crates/ripr/src/lsp/tests.rsRepository: EffortlessMetrics/ripr-swarm
Length of output: 15650
🌐 Web query:
tower-lsp-server Client create_work_done_progress Progress begin finish drop semantics docs.rs
💡 Result:
In the tower-lsp crate, progress reporting follows the Language Server Protocol (LSP) specification for $/progress notifications [1][2]. The lifecycle of a progress operation is managed through a builder pattern and an ongoing handle [3][4]. 1. Creation: You initiate a progress sequence using Client::progress, which requires a ProgressToken (often extracted from the incoming request's parameters) and a title [1][3]. The returned Progress object is a builder that defaults to an unbounded and non-cancellable state [3]. 2. Configuration: Using the builder methods on the Progress struct, you can define the operation's behavior: - with_percentage: Transitions the progress to a bounded state where progress is reported as a percentage (0-100) [3]. - with_cancel_button: Marks the progress as cancellable, allowing the client UI to display a cancel option [3]. - with_message: Provides an optional, detailed message to accompany the progress [3]. 3. Execution (begin): Calling the begin method on the Progress builder sends the initial progress notification to the client and returns an OngoingProgress handle [3]. This is an asynchronous operation [3]. 4. Reporting and Completion: The OngoingProgress handle is used to send updates (if applicable) and eventually finalize the operation [4]: - report: Used to send periodic updates (e.g., percentage and message) to the client [1]. - finish / finish_with_message: These methods signal that the long-running operation is complete and send the final notification to the client [4]. 5. Drop Semantics: In the tower-lsp implementation, the OngoingProgress handle is designed to manage the lifetime of the progress report [1][4]. If the handle is dropped without calling finish, the client may be left without a final signal, which is generally discouraged by the LSP specification for work-done progress [1]. Users should ensure that finish or finish_with_message is explicitly awaited to properly close the progress session [1][4]. According to the official LSP specification, the server must not send any progress notifications for a token if an error occurs [5]. Developers should handle this by ensuring progress is only initiated and reported when the operation is valid [5].
Citations:
- 1: Implement support for client initiated $/progress ebkalderon/tower-lsp#380
- 2: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
- 3: https://docs.rs/tower-lsp-server/latest/tower_lsp_server/struct.Progress.html
- 4: https://docs.rs/tower-lsp-server/latest/tower_lsp_server/struct.OngoingProgress.html
- 5: https://docs.rs/tower-lsp-f/latest/tower_lsp_f/struct.Client.html
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== search for workDoneProgress capability plumbing ==\n'
rg -n "workDoneProgress|work_done_progress|create_work_done_progress" crates/ripr/src -S
printf '\n== inspect initialize handling in backend ==\n'
sed -n '1760,1835p' crates/ripr/src/lsp/backend.rs
printf '\n== inspect any initialize params stored in backend fields ==\n'
sed -n '99,160p' crates/ripr/src/lsp/backend.rsRepository: EffortlessMetrics/ripr-swarm
Length of output: 10576
🌐 Web query:
tower-lsp-server OngoingProgress drop finish docs.rs
💡 Result:
In the tower-lsp-server crate, the OngoingProgress struct represents an active stream of progress reported to the client [1][2]. The finish method is an asynchronous function used to signal that a long-running operation is complete [1]. Key points regarding OngoingProgress and the finish method include: - Purpose: The finish method indicates that the associated work-done progress operation is finished [1]. - Usage: It is defined as pub async fn finish(self, message: M) where M: Into<Option> [1][3]. - Variants: There is also a finish_with_message method, which functions similarly to finish but specifically accepts an optional, more detailed progress message [1]. - Lifetime: The OngoingProgress object acts as a handle; calling finish consumes the object [1]. While dropping an object in Rust usually triggers its Drop implementation, you must explicitly call.finish.await to properly notify the Language Server Protocol (LSP) client that the operation has ended, as the LSP protocol requires a specific notification to finalize the progress UI [1][3]. Example usage: progress.finish("Operation complete!".to_owned).await; [3]
Citations:
- 1: https://docs.rs/tower-lsp-server/latest/tower_lsp_server/struct.OngoingProgress.html
- 2: https://docs.rs/tower-lsp-server/latest/tower_lsp_server/index.html
- 3: Implement support for client initiated $/progress ebkalderon/tower-lsp#380
Gate work-done progress on the negotiated client capability. initialize never records window.workDoneProgress, so this request is always attempted. Skip the create_work_done_progress/begin path unless the client opted in, and call finish on error/cancellation paths too.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/ripr/src/lsp/backend.rs` around lines 251 - 264, Update the
initialization capability handling to record whether the client supports
window.workDoneProgress, then gate the progress setup in the analysis flow
around progress_token and ongoing_progress on that capability before calling
create_work_done_progress or begin. Ensure every error or cancellation path that
starts progress also calls finish, while preserving the existing behavior when
progress is unsupported.
| // Send progress End on success (#1909) | ||
| if let Some(progress) = ongoing_progress.take() { | ||
| progress.finish().await; | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the relevant section and nearby control flow
sed -n '380,540p' crates/ripr/src/lsp/backend.rsRepository: EffortlessMetrics/ripr-swarm
Length of output: 6069
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the refresh function start, progress handle creation, and all finish() calls in the file.
rg -n "ongoing_progress|progress\.finish\(|WorkDoneProgress|send_progress|progress" crates/ripr/src/lsp/backend.rsRepository: EffortlessMetrics/ripr-swarm
Length of output: 823
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the beginning of the refresh method and any helper paths that return cancellation/failure.
sed -n '300,390p' crates/ripr/src/lsp/backend.rs
printf '\n---\n'
rg -n "fn cancellation_outcome|RefreshAttemptOutcome::Failed|RefreshAttemptOutcome::Published|mark_attempt_failed|rollback_refresh_transaction" crates/ripr/src/lsp/backend.rsRepository: EffortlessMetrics/ripr-swarm
Length of output: 5034
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check whether the progress handle type is drop-cleaned or requires explicit finish().
rg -n "struct .*Progress|enum .*Progress|impl Drop for .*Progress|finish\(&self\)|finish\(&mut self\)" . \
-g '!target' -g '!**/node_modules/**'Repository: EffortlessMetrics/ripr-swarm
Length of output: 166
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the caller that handles RefreshAttemptOutcome and the cancellation helper.
sed -n '180,235p' crates/ripr/src/lsp/backend.rs
printf '\n---\n'
sed -n '1650,1685p' crates/ripr/src/lsp/backend.rsRepository: EffortlessMetrics/ripr-swarm
Length of output: 3469
🌐 Web query:
tower_lsp_server WorkDoneProgress finish Drop progress handle docs.rs source
💡 Result:
In the tower-lsp crate, progress reporting is managed using the client.progress(...) method, which returns an OngoingProgress handle [1]. To finalize and close a progress session, you must call the.finish(message) method on this handle [1]. Specifically, the workflow for using WorkDoneProgress is as follows: 1. Obtain a progress token from the parameters provided by the client (e.g., from WorkDoneProgressParams) [1]. 2. Initiate the progress session using self.client.progress(token,...).begin.await, which returns an OngoingProgress handle [1][2]. 3. Use the.report(...) method on the handle to send progress updates to the client [1]. 4. Call the.finish(message) method on the handle once the operation is complete [1]. This explicitly signals to the client that the progress work associated with that token is finished [1][3]. There is no need to manually handle Drop for the progress handle to complete the work; calling.finish is the intended and required API usage to send the final notification [1]. If the handle is dropped without calling.finish, the corresponding progress session may not be properly closed on the client side according to the LSP specification [1][3].
Citations:
- 1: Implement support for client initiated $/progress ebkalderon/tower-lsp#380
- 2: https://docs.rs/tower-lsp-server/latest/tower_lsp_server/struct.Progress.html
- 3: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
🏁 Script executed (no clone):
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import urllib.request, re
urls = [
"https://docs.rs/tower-lsp-server/latest/src/tower_lsp_server/service/client/progress.rs.html",
"https://docs.rs/tower-lsp-server/latest/tower_lsp_server/service/client/struct.WorkDoneProgress.html",
]
for url in urls:
try:
with urllib.request.urlopen(url, timeout=20) as r:
data = r.read().decode("utf-8", "replace")
print("URL:", url)
print("contains Drop:", "Drop" in data)
print("contains finish:", "finish" in data)
for pat in ["impl Drop", "finish(", "WorkDoneProgressEnd"]:
if pat in data:
print("has", pat)
print("---")
except Exception as e:
print("URL:", url, "ERR:", e)
PY
Length of output: 607
Close the progress session on every exit path. Only the success path calls finish(), so failed or cancelled refreshes drop the handle without sending a terminal progress notification. Call finish() before returning from those paths too.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/ripr/src/lsp/backend.rs` around lines 481 - 484, Update the refresh
flow in the code surrounding ongoing_progress so every success, failure, and
cancellation return path completes the progress session by calling
progress.finish().await before returning. Preserve the existing success handling
while ensuring the ongoing_progress handle is consumed and a terminal
notification is sent on all exits.
Closing — CI runner saturation, not a code issueThe LSP progress signal change itself is verified working locally (
This PR has spent 6+ hours in CI without the required What this PR does (for a future re-open)
How to verify locally before re-pushinggit checkout codex/lsp-progress-signal-1909
cargo check --lib
cargo clippy -p ripr --all-targets -- -D warnings
cargo test -p ripr --lib lsp::Closing as a CI-hygiene decision, not a code-rejection. The feature is ready when the runner fleet can serve it. |
Summary
Send standard LSP progress notifications so stock VS Code / Neovim users see a progress indicator during analysis. Previously the only feedback was custom ripr/analysisStatus notifications requiring client opt-in.
Change
In run_refresh_request (backend.rs), before the analysis spawn_blocking:
If the client does not support workDoneProgress, the create call returns Err and analysis proceeds without progress.
Known limitation
On cancellation (superseded by a newer save), the OngoingProgress is dropped without sending End. The next save Begin replaces the stale progress token. VS Code handles this gracefully. A Drop guard that sends End via tokio::spawn is the future improvement.
Proof
cargo check --lib (exit 0); cargo clippy --all-targets -- -D warnings (exit 0)