Improve progress bar - #43
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe LSP progress handling was refactored from static module methods to an instance-based architecture. The autocmd now delegates to a singleton progress bar object, which internally tracks tasks, schedules renders via timers, coalesces updates, and manages state to suppress redundant UI sends. Changes
Sequence Diagram(s)sequenceDiagram
participant LSP as LSP Server
participant Autocmd
participant ProgressBar as Progress Bar<br/>(Singleton)
participant Timer as Timer
participant VimAPI as Vim API
LSP->>Autocmd: progress event (on_lsp_progress)
Autocmd->>ProgressBar: on_lsp_progress(args)
alt value.kind == "end"
ProgressBar->>ProgressBar: remove task<br/>(clear state)
else value.percentage
ProgressBar->>ProgressBar: update task state<br/>(aggregate %)<br/>(track last_state)
end
ProgressBar->>ProgressBar: schedule render<br/>(coalesce updates)
alt render_timer not active
ProgressBar->>Timer: set_timeout(render_callback)
end
Timer->>ProgressBar: render_callback()
ProgressBar->>ProgressBar: build OSC string<br/>(check last_percent<br/>suppress if no change)
alt no tasks after delay
ProgressBar->>ProgressBar: send clear signal
else tasks exist
ProgressBar->>VimAPI: nvim_ui_send(osc_string)
VimAPI-->>ProgressBar: success or fail
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This pull request refactors the LSP progress bar implementation to make it more robust, modular, and better suited for handling multiple concurrent tasks. The changes introduce a new
ProgressBarclass with improved state management and timer-based rendering, and update the autocmd setup to use the new interface.Major improvements to progress bar architecture:
ProgressBarclass with internal state, task tracking, and timer-based rendering, replacing the previous stateless function-based approach. This allows for better handling of multiple LSP progress tasks and more reliable updates.on_lsp_progressmethod to handle LSP progress events, replacing the inline logic in the autocmd callback. The autocmd now delegates directly to this method for better separation of concerns. [1] [2]Enhancements to environment compatibility and cleanup:
vim.env.TMUXand updated the OSC sequence construction for better compatibility.destroymethod and updating theVimLeavePreautocmd to call it.These changes collectively make the progress bar more reliable, extensible, and maintainable, especially when handling multiple simultaneous LSP tasks.