Skip to content

Conversation

@chmurson
Copy link
Collaborator

@chmurson chmurson commented Dec 30, 2025

Summary by CodeRabbit

  • Refactor
    • Improved internal caching logic to ensure metadata and notes are stored, read, and invalidated consistently for greater reliability.

Note: This change is internal only and does not alter any user-facing features or behaviors.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for graypaper-reader ready!

Name Link
🔨 Latest commit 08efe41
🔍 Latest deploy log https://app.netlify.com/projects/graypaper-reader/deploys/69551cd911e4f10008612269
😎 Deploy Preview https://deploy-preview-360--graypaper-reader.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Replaces simple note.key cache keys with composite keys derived from note.key, selectionStart, selectionEnd, and version throughout metadata caching operations. A new internal createNoteCacheKey() helper function builds these composite keys. No changes to public API or control flow.

Changes

Cohort / File(s) Summary
Cache key refactoring
src/components/NoteManager/useNoteManagerNotes.ts
Added createNoteCacheKey(note) helper that composes note.key, selectionStart, selectionEnd, and version. Replaced usages of note.key with the composite key for cache reads, writes, and invalidations in initialization, updateNote, and deleteNote.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I stitched keys from bits and thread,
version, start, and end combined,
no more clashes in the cache bed,
small change, clever and refined.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing the note cache key with a composite key that includes pdf version alongside note.key, selectionStart, selectionEnd, and version.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 680e791 and ac15a66.

📒 Files selected for processing (1)
  • src/components/NoteManager/useNoteManagerNotes.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/NoteManager/useNoteManagerNotes.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: visual-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

Visual Regression Test Report ✅ Passed

Github run id: 20619394019

🔗 Artifacts: Download

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 380ece8 and 680e791.

📒 Files selected for processing (1)
  • src/components/NoteManager/useNoteManagerNotes.ts
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.{ts,tsx}: Feature folders should keep components, hooks, and styles together in src/
Prefer hooks over Higher-Order Components (HOCs)
Colocate helper functions with their consumer components
Use PascalCase for component names
Favor semantic wrappers over long Tailwind utility class strings; complement Tailwind with @fluffylabs/shared-ui components

Files:

  • src/components/NoteManager/useNoteManagerNotes.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript as the primary language with functional React components
Use camelCase for function and variable names
Use SCREAMING_SNAKE_CASE for constants

Files:

  • src/components/NoteManager/useNoteManagerNotes.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use 2-space indentation

Files:

  • src/components/NoteManager/useNoteManagerNotes.ts
**/*.{js,jsx,ts,tsx}

⚙️ CodeRabbit configuration file

When reviewing Tailwind CSS classes, ensure they follow Tailwind 4.x conventions and suggest modern 4.x alternatives for deprecated patterns.

Files:

  • src/components/NoteManager/useNoteManagerNotes.ts
🧠 Learnings (2)
📚 Learning: 2025-12-28T21:10:33.529Z
Learnt from: chmurson
Repo: FluffyLabs/graypaper-reader PR: 357
File: src/components/NoteManager/NoteManager.tsx:52-58
Timestamp: 2025-12-28T21:10:33.529Z
Learning: In src/components/NoteManager/NoteManager.tsx, direct mutation of `note.original.content` before calling `updateNote` is intentional for optimistic UI updates. This pattern is documented with an explicit comment in the code.

Applied to files:

  • src/components/NoteManager/useNoteManagerNotes.ts
📚 Learning: 2025-12-28T21:10:04.074Z
Learnt from: chmurson
Repo: FluffyLabs/graypaper-reader PR: 357
File: src/components/NoteManager/NoteManager.tsx:52-58
Timestamp: 2025-12-28T21:10:04.074Z
Learning: In `src/components/NoteManager/NoteManager.tsx`, the direct mutation of `note.original.content` in `memoizedHandleUpdateNote` before calling `updateNote` is intentional and used for optimistic UI updates.

Applied to files:

  • src/components/NoteManager/useNoteManagerNotes.ts
🧬 Code graph analysis (1)
src/components/NoteManager/useNoteManagerNotes.ts (2)
src/components/NotesProvider/NotesProvider.tsx (1)
  • INotesContext (20-40)
src/components/NotesProvider/types/DecoratedNote.ts (1)
  • IDecoratedNote (4-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: visual-tests
🔇 Additional comments (3)
src/components/NoteManager/useNoteManagerNotes.ts (3)

39-45: Cache invalidation logic is correct.

The deletion of the old note's cache entry before the update ensures stale metadata is not retained. The implementation correctly uses the composite key helper for cache consistency.


46-52: Cache cleanup on deletion is correct.

The cache entry is properly removed when a note is deleted, preventing memory leaks and stale entries. The implementation correctly uses the composite key helper.


70-100: Cache read and write operations are properly synchronized.

The implementation correctly:

  • Checks for cached entries using the composite key (line 71)
  • Fetches fresh metadata for uncached notes (lines 75-83)
  • Stores computed metadata back to cache (line 99)

This ensures metadata caching respects both note position and PDF version, which aligns with the PR objective.

chmurson and others added 2 commits December 31, 2025 13:50
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@chmurson chmurson merged commit 97a3c23 into main Dec 31, 2025
4 of 5 checks passed
@chmurson chmurson deleted the improve-notes-metadata-cache-key-to-include-pdf-version branch December 31, 2025 12:53
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