Skip to content

notifications prevent freeze#1588

Merged
simo6529 merged 4 commits intomainfrom
app-freezes
Oct 31, 2025
Merged

notifications prevent freeze#1588
simo6529 merged 4 commits intomainfrom
app-freezes

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Oct 31, 2025

Summary by CodeRabbit

  • Tests

    • Updated emoji context mocks and unified test helpers to cover custom emoji lookup and richer emoji data across suites.
  • Refactor

    • Added fast custom-emoji lookup and caching for quicker emoji resolution.
    • Replaced mutation-observer auto-scroll with a periodic polling approach.
    • Improved layout height calculations to avoid redundant re-renders.
    • Made notification prefetch page count configurable (adjusted defaults).

Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 31, 2025

Walkthrough

Expanded EmojiContext to expose a direct custom-emoji lookup and native emoji caching; tests updated to mock the richer API. Emoji consumers switched from traversing emojiMap to findCustomEmoji. Notifications auto-scroll switched from MutationObserver to 250ms polling; prefetch pages became configurable; layout state updates deduplicated.

Changes

Cohort / File(s) Change Summary
Test mock expansions
__tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx, __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx, __tests__/components/drops/view/part/DropPartMarkdown.test.tsx, __tests__/components/waves/CreateDropEmojiPicker.test.tsx, __tests__/components/waves/drops/WaveDropActions.test.tsx, __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx, __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx, __tests__/components/waves/drops/WaveDropReactions.test.tsx, __tests__/integration/EditDropFlow.test.tsx, __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx, __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
Expanded mocked useEmoji return values to include loading, categories, categoryIcons, findNativeEmoji, and findCustomEmoji; introduced shared factory/mocks in some tests and adjusted expectations for prefetch arguments.
EmojiContext API expansion
contexts/EmojiContext.tsx
Added public `findCustomEmoji(emojiId: string) => Emoji
Emoji lookup refactors
components/drops/create/lexical/nodes/EmojiNode.tsx, components/brain/notifications/drop-reacted/NotificationDropReacted.tsx
Replaced emojiMap traversal with direct findCustomEmoji(emojiId) calls; native fallback still via findNativeEmoji.
Notifications scroll modification
components/brain/notifications/hooks/useNotificationsScroll.ts
Replaced MutationObserver with a 250ms interval poll; added lastMeasuredScrollHeightRef; schedule/cleanup updated to use interval and requestAnimationFrame for scroll-to-bottom.
Prefetch parameter additions
hooks/useNotificationsQuery.tsx, components/brain/notifications/NotificationsCauseFilter.tsx
Made prefetch page count configurable by adding optional pages?: number (default 3) and updated calls to pass pages: 1 where used.
Layout optimization
components/brain/my-stream/layout/LayoutContext.tsx
Added spacesAreEqual comparator and calculateHeightStyle; LayoutProvider now computes nextSpaces and only updates state when changed to avoid redundant re-renders.

Sequence Diagram(s)

sequenceDiagram
    participant Component as Component
    participant EmojiContext as EmojiContext
    participant CustomIdx as customEmojiIndex
    participant NativeCache as nativeEmojiCache
    participant Data as data.emojis

    Component->>EmojiContext: findCustomEmoji(emojiId)
    EmojiContext->>CustomIdx: Map.get(emojiId)
    alt Custom emoji found
        CustomIdx-->>EmojiContext: Emoji
        EmojiContext-->>Component: Emoji
    else Custom emoji not found
        EmojiContext->>EmojiContext: findNativeEmoji(emojiId)
        EmojiContext->>NativeCache: check cache
        alt Cache hit
            NativeCache-->>EmojiContext: NativeEmoji | null
        else Cache miss
            EmojiContext->>Data: normalized lookup (data.emojis[normalizedId])
            Data-->>EmojiContext: NativeEmoji | null
            EmojiContext->>NativeCache: store result
        end
        EmojiContext-->>Component: NativeEmoji | null
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring extra attention:
    • components/brain/notifications/hooks/useNotificationsScroll.ts — behavioral change from MutationObserver to polling and interval cleanup.
    • contexts/EmojiContext.tsx — correctness of memoization, cache lifecycle, normalization, and dependency lists.
    • Tests that were centralized with factories (WaveDropReactions tests) — ensure mocks match production API and cover custom/native paths.
    • Prefetch signature change — confirm callers expecting previous behavior are updated appropriately.

Possibly related PRs

Suggested reviewers

  • ragnep
  • prxt6529

"🐇 I hop through indexed maps with glee,
No slow flat searches bothering me.
I poll the scroll and cache the smiles,
Layouts stay steady across the miles.
Prefetch hops in measured piles ✨"

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 "notifications prevent freeze" is partially related to the changeset and captures a real and important aspect of the changes. The most significant technical contribution addressing the freeze issue is the refactoring of useNotificationsScroll.ts, which replaces MutationObserver-based auto-scrolling logic with a lightweight 250ms interval polling mechanism—a direct solution to prevent performance degradation. While the PR also includes substantial emoji refactoring work (adding findCustomEmoji functionality and caching optimizations across multiple components and tests), the title accurately reflects the primary objective reflected in the branch name ("app-freezes") and the key change that addresses the core performance issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch app-freezes

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.

Copy link
Copy Markdown

@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: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac2e2f8 and 2550629.

📒 Files selected for processing (16)
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx (2 hunks)
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx (1 hunks)
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx (1 hunks)
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx (1 hunks)
  • __tests__/components/waves/drops/WaveDropActions.test.tsx (1 hunks)
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx (1 hunks)
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx (1 hunks)
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx (5 hunks)
  • __tests__/integration/EditDropFlow.test.tsx (1 hunks)
  • components/brain/my-stream/layout/LayoutContext.tsx (3 hunks)
  • components/brain/notifications/NotificationsCauseFilter.tsx (1 hunks)
  • components/brain/notifications/drop-reacted/NotificationDropReacted.tsx (3 hunks)
  • components/brain/notifications/hooks/useNotificationsScroll.ts (2 hunks)
  • components/drops/create/lexical/nodes/EmojiNode.tsx (1 hunks)
  • contexts/EmojiContext.tsx (2 hunks)
  • hooks/useNotificationsQuery.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Do not include any comments in the code
Use react-query for data fetching
Always add readonly before props

Files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • components/brain/notifications/drop-reacted/NotificationDropReacted.tsx
  • components/drops/create/lexical/nodes/EmojiNode.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • components/brain/notifications/NotificationsCauseFilter.tsx
  • components/brain/notifications/hooks/useNotificationsScroll.ts
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • contexts/EmojiContext.tsx
  • hooks/useNotificationsQuery.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
  • components/brain/my-stream/layout/LayoutContext.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursorrules)

**/*.tsx: Use FontAwesome for icons
Use TailwindCSS for styling

Files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • components/brain/notifications/drop-reacted/NotificationDropReacted.tsx
  • components/drops/create/lexical/nodes/EmojiNode.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • components/brain/notifications/NotificationsCauseFilter.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • contexts/EmojiContext.tsx
  • hooks/useNotificationsQuery.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
  • components/brain/my-stream/layout/LayoutContext.tsx
__tests__/**

📄 CodeRabbit inference engine (tests/AGENTS.md)

Place Jest test suites under the __tests__ directory mirroring source folders (e.g., components, contexts, hooks, utils)

Files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
__tests__/components/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (tests/AGENTS.md)

Use @testing-library/react and @testing-library/user-event for React component tests

Files:

  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Keep mocks up to date with the real implementations they represent
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Document non-obvious expected behaviour directly in the mock file

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Keep mocks up to date with the real implementations they represent

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Keep mock implementations minimal—only what’s necessary for the test scenarios

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Mock only external dependencies or heavy functionality; avoid over-mocking internal logic

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Review mocks periodically and remove unused mock modules

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Organise mocks to mirror the real module structure so import paths remain consistent

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropMobileMenu.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:30.950Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:30.950Z
Learning: Applies to __tests__/components/**/*.{ts,tsx,js,jsx} : Use `testing-library/react` and `testing-library/user-event` for React component tests

Applied to files:

  • __tests__/integration/EditDropFlow.test.tsx
  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/CreateDropEmojiPicker.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/*.{test,spec}.{js,jsx,ts,tsx} : In tests, use jest.mock('module') with a bare module specifier to load the corresponding manual mock

Applied to files:

  • __tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx
  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Use Jest’s built-in mocking for module replacement; keep manual mocks simple and lightweight

Applied to files:

  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Name mock files to mirror the real module names so jest.mock('module') can pick them up automatically

Applied to files:

  • __tests__/components/drops/view/part/DropPartMarkdown.test.tsx
  • __tests__/components/waves/drops/WaveDropReactions.test.tsx
  • __tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx
  • __tests__/components/waves/drops/WaveDropActions.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Place manual mock modules under a __mocks__ directory so Jest can auto-resolve them

Applied to files:

  • __tests__/components/waves/drops/WaveDropActions.test.tsx
🧬 Code graph analysis (4)
__tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx (1)
contexts/EmojiContext.tsx (1)
  • useEmoji (156-162)
components/brain/notifications/drop-reacted/NotificationDropReacted.tsx (1)
contexts/EmojiContext.tsx (1)
  • useEmoji (156-162)
components/drops/create/lexical/nodes/EmojiNode.tsx (1)
contexts/EmojiContext.tsx (1)
  • useEmoji (156-162)
__tests__/components/waves/drops/WaveDropReactions.test.tsx (1)
contexts/EmojiContext.tsx (1)
  • useEmoji (156-162)
⏰ 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: Analyze (javascript-typescript)
🔇 Additional comments (17)
components/brain/notifications/NotificationsCauseFilter.tsx (1)

54-61: LGTM! Efficient prefetch on hover.

Limiting prefetch to 1 page on hover is a sensible optimization that reduces speculative data fetching while still warming the cache for likely navigation.

components/brain/notifications/drop-reacted/NotificationDropReacted.tsx (1)

49-118: LGTM! Cleaner emoji resolution.

The refactored emoji lookup using dedicated findCustomEmoji and findNativeEmoji helpers is more maintainable and efficient than the previous emojiMap traversal approach.

components/brain/my-stream/layout/LayoutContext.tsx (2)

53-61: LGTM! Deduplication helper.

The spacesAreEqual function correctly compares all fields to enable state deduplication.


312-325: LGTM! State deduplication prevents unnecessary re-renders.

The deduplication check using spacesAreEqual ensures state updates only occur when measurements actually change, improving performance.

hooks/useNotificationsQuery.tsx (2)

84-96: LGTM! Optimized initial prefetch.

Reducing initial prefetch to 1 page improves initial load performance while still warming the cache.


150-186: LGTM! Configurable prefetch with sensible default.

The addition of the pages parameter with a default of 3 maintains backward compatibility while enabling callers to optimize prefetch behavior.

__tests__/components/waves/drops/WaveDropMobileMenu.test.tsx (1)

45-55: LGTM! Mock updated to match API surface.

The EmojiContext mock correctly includes the new findCustomEmoji function, keeping the test mock aligned with the real implementation. Based on learnings.

__tests__/integration/EditDropFlow.test.tsx (1)

52-62: LGTM! Mock synchronized with API.

The EmojiContext mock correctly includes findCustomEmoji, maintaining consistency with the expanded context API. Based on learnings.

__tests__/components/waves/CreateDropEmojiPicker.test.tsx (1)

67-74: LGTM! Complete mock with all context fields.

The EmojiContext mock includes all necessary fields (loading, findNativeEmoji, findCustomEmoji) while remaining minimal. Based on learnings.

__tests__/components/waves/drops/WaveDropActions.test.tsx (1)

20-22: LGTM! Inline mock updated correctly.

The EmojiContext mock includes findCustomEmoji along with all other required fields, maintaining consistency across the test suite. Based on learnings.

__tests__/components/drops/view/part/DropPartMarkdown.test.tsx (1)

67-74: EmojiContext mock matches expanded API

Thanks for syncing this mock with the new context surface—having both findNativeEmoji and findCustomEmoji here will keep the markdown tests exercising the same contract the components rely on.

components/drops/create/lexical/nodes/EmojiNode.tsx (1)

73-76: findCustomEmoji lookup keeps decorator lean

Good call switching to the dedicated finder—this keeps the node logic tidy while benefiting from the provider’s indexed lookup.

__tests__/components/waves/drops/WaveDropActionsAddReaction.test.tsx (1)

60-63: WaveDropActions emoji mock stays in sync

Appreciate the fuller mock surface—this keeps the reaction flow exercising both native and custom resolution just like production.

__tests__/components/drops/create/lexical/nodes/EmojiNode.test.tsx (1)

30-55: EmojiNode tests cover both lookup paths

Nice refresh—by routing through findCustomEmoji and stubbing native fallback you’ve kept these specs aligned with the runtime behavior.

__tests__/components/waves/drops/WaveDropReactions.test.tsx (1)

28-206: Helper centralizes emoji context setup

The shared factory + mock make these cases easier to follow while mirroring the provider’s API—great cleanup.

contexts/EmojiContext.tsx (1)

100-140: Caching + index tighten lookup costs

Indexing custom emojis and memoizing native lookups should eliminate repeated scans while keeping the colon normalization intact—looks solid.

__tests__/components/drops/create/lexical/plugins/emoji/EmojiPlugin.test.tsx (1)

61-76: Mock updates correctly reflect the expanded EmojiContext API and component requirements.

The mock setup is complete and accurate. The emojiMap field is actively used by the EmojiPlugin component to extract custom emoji IDs (see EmojiPlugin.ts lines 135-140), so it must remain in the mock. The additions of loading, categories, categoryIcons, and the findCustomEmoji implementation correctly support the expanded API surface. The mock remains minimal and focused on test requirements.

Comment thread components/brain/notifications/hooks/useNotificationsScroll.ts Outdated
@simo6529
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 31, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Signed-off-by: Simo <simo@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
__tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx (1)

4-4: Comments present in test file may violate coding guidelines.

The coding guidelines specify "Do not include any comments in the code" for **/*.{ts,tsx} files. While explanatory comments are common and helpful in test files, the guideline applies to all TypeScript files including tests. Consider whether these comments are essential or if the code can be self-documenting.

As per coding guidelines

Also applies to: 11-11, 16-16, 24-24

🧹 Nitpick comments (2)
__tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx (2)

106-106: Update test description to reflect the new API.

The test description mentions "emojiMap" but the implementation now uses findCustomEmoji for direct emoji lookup. Update the description to accurately reflect the new behavior.

Apply this diff:

-  it("renders <img> when emoji found in emojiMap", () => {
+  it("renders <img> when findCustomEmoji returns a custom emoji", () => {

113-137: Add verification that findCustomEmoji is called correctly.

The test creates a mock for findCustomEmoji but doesn't assert it was invoked with the expected argument. Add an expectation to ensure the component uses the new API correctly.

Apply this diff after line 136:

     expect(img).toHaveAttribute("src", fakeEmoji.skins[0].src);
     expect(img).toHaveAttribute("alt", "heart");
     expect(img).toHaveClass("emoji-node");
+    expect(findCustomEmoji).toHaveBeenCalledWith("heart");
   });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e180a7b and 020329a.

📒 Files selected for processing (2)
  • __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx (2 hunks)
  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Do not include any comments in the code
Use react-query for data fetching
Always add readonly before props

Files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursorrules)

**/*.tsx: Use FontAwesome for icons
Use TailwindCSS for styling

Files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx
__tests__/**

📄 CodeRabbit inference engine (tests/AGENTS.md)

Place Jest test suites under the __tests__ directory mirroring source folders (e.g., components, contexts, hooks, utils)

Files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx
__tests__/components/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (tests/AGENTS.md)

Use @testing-library/react and @testing-library/user-event for React component tests

Files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx
🧠 Learnings (7)
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Document non-obvious expected behaviour directly in the mock file

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Keep mocks up to date with the real implementations they represent

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Keep mock implementations minimal—only what’s necessary for the test scenarios

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
📚 Learning: 2025-09-28T12:33:30.950Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:30.950Z
Learning: Applies to __tests__/components/**/*.{ts,tsx,js,jsx} : Use `testing-library/react` and `testing-library/user-event` for React component tests

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
  • __tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Mock only external dependencies or heavy functionality; avoid over-mocking internal logic

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Review mocks periodically and remove unused mock modules

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
📚 Learning: 2025-09-28T12:33:07.561Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __mocks__/AGENTS.md:0-0
Timestamp: 2025-09-28T12:33:07.561Z
Learning: Applies to __mocks__/**/__mocks__/**/*.{js,jsx,ts,tsx} : Organise mocks to mirror the real module structure so import paths remain consistent

Applied to files:

  • __tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx
⏰ 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: Analyze (javascript-typescript)
🔇 Additional comments (5)
__tests__/components/brain/notifications/NotificationsCauseFilter.test.tsx (2)

5-5: LGTM!

The import is necessary for the enum references in the updated test assertion.


29-36: The cause array is correct; verification confirms buttons[1] maps to [IdentityMentioned, DropQuoted].

The hardcoded causes match the component's filter definitions. Index 1 in the NotificationFilters array is the "Mentions" filter with exactly [ApiNotificationCause.IdentityMentioned, ApiNotificationCause.DropQuoted]. The pages: 1 addition is also correct per the PR's configurable prefetch changes.

Optional: Consider using getByRole('button', { name: /mentions/i }) instead of buttons[1] for better test resilience, though the current approach is functionally correct.

__tests__/components/waves/drops/create/lexical/nodes/EmojiNode.test.tsx (3)

147-154: Verify whether emojiMap is still required in the mocked context.

Similar to the first test, if emojiMap is no longer consumed by the component implementation, it can be removed from this mock as well.

Based on learnings


168-168: Verify whether emojiMap is still required in the mocked context.

Same consideration as the previous tests—if emojiMap is not used by the component, it can be omitted.

Based on learnings


117-124: The emojiMap must remain in the mocked context.

The EmojiContextType interface requires emojiMap as a mandatory property. Additionally, multiple components throughout the codebase actively consume it (WaveDropReactions, WaveDropActionsAddReaction, CreateDropEmojiPicker, DropPartMarkdown, EmojiPlugin). The fact that EmojiNode uses findCustomEmoji for lookups does not mean emojiMap can be removed from the mock—the mock must satisfy the complete type definition that all consumers depend on.

Likely an incorrect or invalid review comment.

@simo6529 simo6529 merged commit 0a626fc into main Oct 31, 2025
9 checks passed
@simo6529 simo6529 deleted the app-freezes branch October 31, 2025 12:41
@coderabbitai coderabbitai Bot mentioned this pull request Jan 9, 2026
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