Skip to content

feat(lsp): add loading indicators for registry data fetching#45

Merged
bug-ops merged 7 commits intomainfrom
feat/loading-indicator
Dec 26, 2025
Merged

feat(lsp): add loading indicators for registry data fetching#45
bug-ops merged 7 commits intomainfrom
feat/loading-indicator

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Dec 26, 2025

Summary

Add visual feedback when fetching registry data through two mechanisms:

  • LSP Progress Notifications - Standard window/workDoneProgress protocol for VS Code and compatible editors
  • Inlay Hints Fallback - Shows loading text (default: "⏳") for editors without progress support

Features

  • LoadingState enum tracking: IdleLoadingLoaded/Failed
  • Per-document loading state with duration tracking
  • Configurable loading indicator behavior
  • Security: 100 character limit on loading_text to prevent abuse
  • Graceful degradation for unsupported clients

Configuration

{
  "loading_indicator": {
    "enabled": true,
    "fallback_to_hints": true,
    "loading_text": ""
  }
}

Changes

Phase Commit Description
1 17d32bf LoadingState enum + DocumentState tracking
2 1df909c LSP progress notifications
3 de2e9e7 Inlay hints loading fallback
4 5ca1a2b E2E integration tests (22 tests)

Files Changed

  • 18 files modified
  • +1,824 lines added
  • 793 tests passing (36 new tests for this feature)

Test plan

  • Unit tests for LoadingState enum and state transitions
  • Unit tests for LoadingIndicatorConfig (defaults, validation, truncation)
  • Unit tests for RegistryProgress (lifecycle, Drop cleanup)
  • Integration tests for loading hint display logic
  • E2E tests for concurrent document loading
  • E2E tests for timeout and race condition scenarios
  • All ecosystems (Cargo, npm, PyPI, Go) updated and tested
  • cargo clippy --workspace --all-targets --all-features -- -D warnings passes
  • cargo nextest run passes (793 tests)

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
@github-actions github-actions bot added rust Rust code changes lsp Language Server Protocol parser Parser changes needs-review Needs review tests Test changes size: XXL >1000 lines changed labels Dec 26, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 26, 2025

Codecov Report

❌ Patch coverage is 70.28061% with 233 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/deps-lsp/src/progress.rs 35.76% 97 Missing ⚠️
crates/deps-core/src/lsp_helpers.rs 69.90% 65 Missing ⚠️
crates/deps-lsp/src/document/lifecycle.rs 0.00% 58 Missing ⚠️
crates/deps-lsp/src/server.rs 11.11% 8 Missing ⚠️
crates/deps-cargo/src/ecosystem.rs 95.83% 2 Missing ⚠️
crates/deps-lsp/src/config.rs 97.59% 2 Missing ⚠️
crates/deps-lsp/src/document/state.rs 99.41% 1 Missing ⚠️

Impacted file tree graph

@@            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     
Flag Coverage Δ
deps-cargo 79.75% <95.83%> (+0.43%) ⬆️
deps-core 90.00% <73.46%> (-0.99%) ⬇️
deps-go 85.04% <70.28%> (-0.70%) ⬇️
deps-lsp 77.97% <65.19%> (-1.57%) ⬇️
deps-npm 89.56% <100.00%> (+<0.01%) ⬆️
deps-pypi 86.70% <100.00%> (+<0.01%) ⬆️
overall 85.04% <70.28%> (-0.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
crates/deps-core/src/ecosystem.rs 63.07% <100.00%> (+2.42%) ⬆️
crates/deps-core/src/ecosystem_registry.rs 91.83% <ø> (ø)
crates/deps-core/src/parser.rs 94.11% <100.00%> (+1.90%) ⬆️
crates/deps-go/src/ecosystem.rs 83.40% <100.00%> (+0.43%) ⬆️
crates/deps-lsp/src/handlers/inlay_hints.rs 98.25% <100.00%> (+0.01%) ⬆️
crates/deps-lsp/src/lib.rs 100.00% <ø> (ø)
crates/deps-npm/src/ecosystem.rs 87.35% <100.00%> (+0.03%) ⬆️
crates/deps-pypi/src/ecosystem.rs 81.89% <100.00%> (+0.04%) ⬆️
crates/deps-lsp/src/document/state.rs 95.58% <99.41%> (+0.92%) ⬆️
crates/deps-cargo/src/ecosystem.rs 78.31% <95.83%> (+2.08%) ⬆️
... and 5 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@bug-ops bug-ops merged commit 1e7cb46 into main Dec 26, 2025
20 checks passed
@bug-ops bug-ops deleted the feat/loading-indicator branch December 26, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lsp Language Server Protocol needs-review Needs review parser Parser changes rust Rust code changes size: XXL >1000 lines changed tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants