Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

Diffs frequently displayed "Processing..." even for previously-viewed content, causing visual flicker when scrolling through messages.

Root Cause

  1. useHighlightedDiff initialized state as null - even cached content required async operations
  2. The existing cache in highlightWorkerClient was async (required hash lookup via getCacheKey)

Solution

  • Add module-level LRU cache (highlightedDiffCache) storing full HighlightedChunk[] results
  • Synchronous cache lookup during render: cachedResult ?? chunks returns immediately
  • Remove redundant async cache from highlightWorkerClient (caching now at higher level)
  • Preserve hasRealHighlightRef to prevent downgrade when enableHighlighting toggles off (viewport optimization)

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

The diff renderer was showing 'Processing...' frequently because:
- useState initialized as null even when the same diff was already highlighted
- The existing cache in highlightWorkerClient was async (required hash lookup)

Fix:
- Add module-level LRU cache (highlightedDiffCache) storing full HighlightedChunk[]
- Synchronous cache lookup during render via 'cachedResult ?? chunks'
- Remove redundant async cache from highlightWorkerClient (now handled at higher level)
- Preserve hasRealHighlightRef to prevent downgrade when enableHighlighting toggles off
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@ammario ammario merged commit 020a17b into main Dec 14, 2025
20 checks passed
@ammario ammario deleted the fix-diff-cache-processing-flash branch December 14, 2025 18:39
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.

2 participants