Skip to content

Conversation

@chmurson
Copy link
Collaborator

@chmurson chmurson commented Dec 31, 2025

Summary by CodeRabbit

  • Refactor
    • Improved performance in label filtering logic by optimizing early-return conditions when no labels are present.

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

@netlify
Copy link

netlify bot commented Dec 31, 2025

Deploy Preview for graypaper-reader ready!

Name Link
🔨 Latest commit d6917dc
🔍 Latest deploy log https://app.netlify.com/projects/graypaper-reader/deploys/69552fb77f851b000819a7db
😎 Deploy Preview https://deploy-preview-361--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 31, 2025

📝 Walkthrough

Walkthrough

A guard clause is added to the isVisibleByActiveLabelsLatest function that returns true immediately when there are no labels, bypassing filtering logic. Existing label-based filtering behavior remains unchanged when labels are present.

Changes

Cohort / File(s) Summary
Early-return guard in label visibility logic
src/components/NotesProvider/hooks/useLabels.ts
Added early-return guard: when labels array is empty, function returns true without evaluating filter conditions. Preserves existing filtering logic when labels exist.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A guardian arrives at the gate,
When labels vanish, it won't wait—
Return true, skip the filter dance,
The function takes the rabbit's prance! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title mentions fixing an alert when adding the first note, which aligns with the technical change of adding an early-return guard for when there are no labels, preventing incorrect filtering behavior during initial note creation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 97a3c23 and d6917dc.

📒 Files selected for processing (1)
  • src/components/NotesProvider/hooks/useLabels.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/NotesProvider/hooks/useLabels.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/NotesProvider/hooks/useLabels.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use 2-space indentation

Files:

  • src/components/NotesProvider/hooks/useLabels.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/NotesProvider/hooks/useLabels.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
🔇 Additional comments (1)
src/components/NotesProvider/hooks/useLabels.ts (1)

242-244: Guard clause correctly fixes the first-note visibility issue.

The early return when labels.length === 0 appropriately handles the case where no labels exist yet in the system. When adding the first note, this ensures isVisibleByActiveLabelsLatest returns true instead of falling through to getFilteredNotes([note], []), which would incorrectly return an empty array and hide the note.

The distinction between "no labels exist" (labels.length === 0) and "all labels are inactive" (activeLabels.length === 0) is intentional and correct. When users deactivate all labels, notes should remain hidden—only when the label system doesn't exist yet should new notes be visible by default.


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

Visual Regression Test Report ✅ Passed

Github run id: 20620750507

🔗 Artifacts: Download

@chmurson chmurson merged commit c365c69 into main Dec 31, 2025
9 checks passed
@chmurson chmurson deleted the fix-note-alert-when-adding-first-note branch December 31, 2025 14:22
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