Skip to content

Fix PR status display: deduplicate concurrent requests and simplify cache logic - #38

Merged
AmethystLiang merged 1 commit into
mainfrom
AmethystLiang/fixPrStatusDisplay
Mar 22, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
AmethystLiang/fixPrStatusDisplay

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Problem

PR status wasn't updating properly when switching between worktrees because:

  1. The ref-based debouncing in WorktreeCard prevented cache updates from triggering re-fetches
  2. Concurrent requests for the same PR/issue could create duplicate API calls, leading to race conditions

Solution

  1. Removed unnecessary debouncing: Replaced the prFetchedRef guard with simplified effect logic that relies on the store's isFresh() cache TTL check to prevent redundant API calls
  2. Added request deduplication: Implemented inflight request tracking using Maps to ensure that multiple concurrent requests for the same data return the same promise, eliminating duplicate API calls
  3. Simplified dependency tracking: The PR fetch effect now only depends on cache key and repo changes, not PR data itself, allowing the cache logic to control fetch timing

Changes

  • src/renderer/src/store/slices/github.ts: Added inflightPRRequests and inflightIssueRequests Maps to deduplicate concurrent requests
  • src/renderer/src/components/sidebar/WorktreeCard.tsx: Simplified PR fetch effect to use cache TTL instead of ref-based debouncing

…ache logic

- Add inflight request tracking in github.ts to prevent duplicate concurrent API calls
- Simplify PR fetch effect in WorktreeCard by relying on store's isFresh() cache check
- Remove unnecessary ref-based debouncing that was preventing cache updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant