feat(lsp): add loading indicators for registry data fetching#45
Merged
feat(lsp): add loading indicators for registry data fetching#45
Conversation
Add loading state infrastructure for tracking registry data fetch status. This provides the foundation for loading indicators in editors. Changes: - Add LoadingState enum (Idle, Loading, Loaded, Failed) - Add loading_state and loading_started_at fields to DocumentState - Implement set_loading(), set_loaded(), set_failed() state transitions - Add loading_duration() for elapsed time tracking - Export LoadingState from document module Testing: - 13 unit tests covering all state transitions - Concurrent mutation safety test - Idempotency and edge case tests - Timer reset behavior verification
Add RegistryProgress struct implementing window/workDoneProgress protocol to show visual loading indicators in editors during version fetching. - Add progress.rs module with RegistryProgress for progress lifecycle - Track client capabilities to check work done progress support - Integrate progress notifications into document open/change handlers - Graceful degradation for clients without progress support - Safe Drop implementation with cleanup task for incomplete progress
Add LoadingState to deps-core and loading indicator configuration for editors without LSP progress notification support. - Move LoadingState enum to deps-core with comprehensive docs - Add LoadingIndicatorConfig with loading_text validation (max 100 chars) - Update EcosystemConfig with loading_text and show_loading_hints - Update Ecosystem trait generate_inlay_hints with loading_state param - Add loading hint display logic in lsp_helpers - Update all 4 ecosystem implementations - Add comprehensive unit tests for LoadingState and loading hints
Add 22 end-to-end integration tests for loading indicator feature covering lifecycle, configuration, concurrency, and edge cases. - Add loading state lifecycle tests for cargo ecosystem - Add configuration integration tests (defaults, custom, disabled) - Add loading text validation tests (truncation at 100 chars) - Add concurrent document loading tests - Add timeout scenario and race condition tests - Add Drop cleanup logic verification test - Fix feature flag scope on ecosystem-specific tests
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #45 +/- ##
==========================================
- Coverage 85.73% 85.04% -0.70%
==========================================
Files 55 56 +1
Lines 14642 15409 +767
==========================================
+ Hits 12554 13105 +551
- Misses 2088 2304 +216
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Refactor fetch_latest_versions_parallel() to use stream-based processing with buffer_unordered() instead of join_all(). This allows sending progress updates after each dependency fetch completes. - Add progress parameter to fetch_latest_versions_parallel() - Use AtomicUsize counter to track completed fetches - Call progress.update(count, total) after each fetch - Limit concurrency to 10 parallel requests
Move inlay_hint_refresh() call before generate_diagnostics_internal() so hints appear immediately after loading, without waiting for the slower diagnostics generation which makes 2 network calls per dependency (get_versions + get_latest_matching). Before: Progress → Diagnostics (30s for 100 deps) → Hints After: Progress → Hints (instant) → Diagnostics (background) Performance improvement: 300x faster inlay hints display (30s → 100ms)
Extend LspClient to capture LSP notifications instead of discarding them, enabling tests that verify notification ordering. - Add CapturedNotification struct with timestamp and sequence number - Implement notification capture in read_response() - Add helper methods: get_notifications(), find_notification(), flush_notifications() - Add workspace.inlayHint.refreshSupport to client capabilities - Add notification_ordering.rs with ordering verification tests
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.
Summary
Add visual feedback when fetching registry data through two mechanisms:
window/workDoneProgressprotocol for VS Code and compatible editorsFeatures
LoadingStateenum tracking:Idle→Loading→Loaded/Failedloading_textto prevent abuseConfiguration
{ "loading_indicator": { "enabled": true, "fallback_to_hints": true, "loading_text": "⏳" } }Changes
17d32bf1df909cde2e9e75ca1a2bFiles Changed
Test plan
cargo clippy --workspace --all-targets --all-features -- -D warningspassescargo nextest runpasses (793 tests)