Refactor entries list with clean service architecture#2147
Refactor entries list with clean service architecture#2147
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
📝 WalkthroughWalkthroughThe changes introduce a modular, hook-based architecture for entry management in the browse view. Three new utility modules— Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 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 |
UI unit Tests 1 files 50 suites 23s ⏱️ Results for commit 9f7fe15. ♻️ This comment has been updated with latest results. |
C# Unit Tests146 tests 146 ✅ 20s ⏱️ Results for commit 9f7fe15. ♻️ This comment has been updated with latest results. |
f2c3d64 to
a2d69e2
Compare
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Use watch() to handle cleanup of previous entryLoader instance instead of referencing entryLoader inside its own $derived. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Restructured the on-demand entry loader with cleaner architecture: 1. Extracted EntryCache class - Encapsulates all cache state (#entries, #idToIndex, #pending, #loaded) - Single responsibility: cache operations only - Clear API: getByIndex, storeBatch, isBatchLoaded, etc. 2. Extracted ViewportBatchTracker class - Tracks which batches the UI is currently viewing - Simplified from confusing #recentBatchNumbers object - Clear semantics: markAccessed(), getRelevantBatches() 3. Extracted QuietResetDebouncer class - Handles the coalescing of rapid quiet reset requests - Encapsulates the debounce/inflight promise logic - Configurable DEBOUNCE_MS constant 4. Simplified main EntryLoaderService - Now orchestrates the extracted components - Generation checks are localized and consistent - Better method organization by concern All 74 tests pass - functionality fully preserved. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
Replace separate quiet/full reset paths with a single priority-based ResetQueue that coalesces reset requests: - FILTER priority: User filter changes (show loading, 300ms debounce) - EVENT priority: Entry events (no loading, 600ms debounce) Key improvements: - Higher priority resets override pending lower priority ones - Single #executeReset method handles both reset types - Cleaner generation tracking in finally blocks - Removed QuietResetDebouncer in favor of unified queue https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
Remove ugly polling loop (checking every 50ms) and replace with proper promise-based debounce resolution: - #debounceResolvers array collects promises waiting for debounce - #resolveDebounce() resolves all waiters when timer fires - #waitForDebounce() returns immediately if no timer, else waits This is cleaner and more efficient than polling. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
- Add lodash.debounce dependency for robust debouncing - Create reusable Debouncer class that wraps lodash.debounce with promise tracking for async workflows - Refactor EntryLoaderService to use dual Debouncer pattern: - filterDebouncer (300ms) for search/sort/filter changes - eventDebouncer (600ms) for entry update/delete events - Filter resets cancel pending event resets (priority override) - Remove loadInitialCount method (was only used for tests) - Update tests to use reset() directly for race condition testing The new architecture is cleaner: - No custom ResetQueue class needed - Standard lodash.debounce handles timing edge cases - Debouncer utility is reusable elsewhere in the codebase https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
Replace the custom Debouncer utility with runed's built-in useDebounce, which provides the same promise-based debouncing functionality. This removes the lodash.debounce dependency and the custom wrapper class. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
- Remove premature generation bump and cache clear from reset() - Generation now only bumped atomically AFTER data is fetched - Add #filterResetInFlight to track executing filter resets - quietReset() now waits for in-flight filter reset instead of starting an independent reset that could race This restores the atomic swap behavior where totalCount and cache are updated together, preventing skeleton count mismatches. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
Events that occur while a filter reset is in-flight would be lost because we waited for the filter reset (which fetched data before the event occurred). Now we track these events with a flag and trigger a follow-up quiet reset after the filter reset completes. This ensures entry updates/deletes are never silently dropped. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
- Add ASCII diagram documenting the reset flow and event queuing - Initial load now calls #executeReset directly, skipping the 300ms debounce. Only subsequent filter changes are debounced. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
ASCII diagram replaced with Mermaid flowchart in ENTRY_LOADER_SERVICE.md for better readability in GitHub/IDE markdown viewers. https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN
61ecdb1 to
98a95fa
Compare
Extracts entry data management from EntriesList.svelte into dedicated
services with two implementation options:
Option 1 (Class-based): entries-service.svelte.ts + EntriesList.svelte
Option 2 (Functional): use-entries.svelte.ts + EntriesList.functional.svelte
Key improvements:
https://claude.ai/code/session_01BcA6nLuRLkkaqaqNyYqnuN