Skip to content

prevent nesting#1605

Merged
simo6529 merged 1 commit intomainfrom
nesting-bug
Nov 13, 2025
Merged

prevent nesting#1605
simo6529 merged 1 commit intomainfrom
nesting-bug

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Nov 13, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Drop markdown links now render correctly when targeting the current drop.
  • Tests

    • Added test coverage for drop markdown link handling when targeting the current drop.

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

coderabbitai Bot commented Nov 13, 2025

Walkthrough

The PR threads an optional currentDropId context prop through the link-rendering pipeline to prevent rendering drop-card links when targeting the current drop, enabling fallback to plain anchors instead.

Changes

Cohort / File(s) Summary
Test Coverage
__tests__/components/drops/view/part/dropPartMarkdown/linkHandlersRegistry.test.tsx
Adds test verifying fallback to simple anchor when link targets current drop with matching id
Component Props & Propagation
components/drops/view/part/DropPartMarkdown.tsx, components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
Adds optional currentDropId prop to DropPartMarkdownProps and threads through to createLinkRenderer; updates memoization equality check to include currentDropId
Link Handler Config
components/drops/view/part/dropPartMarkdown/linkHandlers.tsx
Extends LinkRendererConfig with currentDropId and destructures it to pass through to createSeizeHandlers
Seize Handler Logic
components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
Adds currentDropId field to CreateSeizeHandlersConfig; updates createSeizeDropHandler to guard against linking to current drop, throwing error if dropId === currentDropId
Consumer Components
components/waves/drops/WaveDropPartContentMarkdown.tsx, components/waves/drops/WaveDropQuote.tsx
Pass drop?.id as currentDropId prop to DropPartMarkdownWithPropLogger

Sequence Diagram

sequenceDiagram
    participant User
    participant WaveDropComponent
    participant DropPartMarkdown
    participant LinkHandler
    participant SeizeHandler

    User->>WaveDropComponent: Render wave drop
    WaveDropComponent->>DropPartMarkdown: Pass drop.id as currentDropId
    DropPartMarkdown->>LinkHandler: createLinkRenderer(currentDropId)
    User->>LinkHandler: Click link with href containing drop id
    
    alt Link targets current drop (href.drop === currentDropId)
        LinkHandler->>SeizeHandler: Handler invoked with currentDropId guard
        SeizeHandler->>SeizeHandler: Check: dropId === currentDropId?
        SeizeHandler-->>LinkHandler: Throw error (guard triggered)
        LinkHandler->>LinkHandler: Fallback to plain anchor
        LinkHandler->>User: Render simple anchor element
    else Link targets different drop
        LinkHandler->>SeizeHandler: Normal seize handler processing
        SeizeHandler->>User: Render drop-card
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Prop threading is repetitive and consistent across multiple files
  • Guard logic in seize.tsx is straightforward (single equality check with early throw)
  • Test coverage validates the new conditional path

Possibly related PRs

  • drop preview url fix #1556: Refactors URL parsing/normalization in seize link handlers that work alongside these currentDropId changes
  • quick test fix #1557: Updates test mocks for seize link machinery affected by handler signature changes in this PR

Suggested reviewers

  • ragnep

Poem

🐰 A drop links to itself? Oh no, not here!
We thread the context, crystal clear—
currentDropId guards the way,
Falls back graceful, come what may! 🌊

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
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.
Title check ❓ Inconclusive The title 'prevent nesting' is vague and generic, using a non-specific term that doesn't clearly convey what nesting prevention means or which components/features are affected. Consider a more descriptive title such as 'prevent linking to current drop in markdown' or 'guard against self-referential drop links' to clearly indicate the specific change being made.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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 nesting-bug

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 916562c and 023578e.

📒 Files selected for processing (7)
  • __tests__/components/drops/view/part/dropPartMarkdown/linkHandlersRegistry.test.tsx (1 hunks)
  • components/drops/view/part/DropPartMarkdown.tsx (4 hunks)
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx (1 hunks)
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx (2 hunks)
  • components/drops/view/part/dropPartMarkdown/linkHandlers.tsx (2 hunks)
  • components/waves/drops/WaveDropPartContentMarkdown.tsx (1 hunks)
  • components/waves/drops/WaveDropQuote.tsx (1 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:

  • components/drops/view/part/DropPartMarkdown.tsx
  • components/waves/drops/WaveDropQuote.tsx
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
  • components/waves/drops/WaveDropPartContentMarkdown.tsx
  • __tests__/components/drops/view/part/dropPartMarkdown/linkHandlersRegistry.test.tsx
  • components/drops/view/part/dropPartMarkdown/linkHandlers.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursorrules)

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

Files:

  • components/drops/view/part/DropPartMarkdown.tsx
  • components/waves/drops/WaveDropQuote.tsx
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
  • components/waves/drops/WaveDropPartContentMarkdown.tsx
  • __tests__/components/drops/view/part/dropPartMarkdown/linkHandlersRegistry.test.tsx
  • components/drops/view/part/dropPartMarkdown/linkHandlers.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/drops/view/part/dropPartMarkdown/linkHandlersRegistry.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/drops/view/part/dropPartMarkdown/linkHandlersRegistry.test.tsx
🧬 Code graph analysis (3)
components/drops/view/part/dropPartMarkdown/handlers/seize.tsx (2)
components/drops/view/part/dropPartMarkdown/linkTypes.ts (1)
  • LinkHandler (5-9)
components/waves/drops/DropItemChat.tsx (1)
  • DropItemChat (10-72)
__tests__/components/drops/view/part/dropPartMarkdown/linkHandlersRegistry.test.tsx (1)
components/drops/view/part/dropPartMarkdown/linkHandlers.tsx (1)
  • createLinkRenderer (57-197)
components/drops/view/part/dropPartMarkdown/linkHandlers.tsx (2)
components/drops/view/part/dropPartMarkdown/handlers/seize.tsx (1)
  • createSeizeHandlers (126-134)
components/drops/view/part/dropPartMarkdown/handlers/index.ts (1)
  • createSeizeHandlers (28-28)
⏰ 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 (10)
components/waves/drops/WaveDropPartContentMarkdown.tsx (1)

67-67: LGTM!

The currentDropId prop is correctly threaded through to prevent nested drop cards when rendering markdown content for the current drop.

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

224-238: LGTM!

The test correctly verifies that when a link targets the current drop (matching currentDropId), the renderer falls back to a simple anchor instead of rendering a drop card, preventing nesting.

components/waves/drops/WaveDropQuote.tsx (1)

159-159: LGTM!

The currentDropId prop is correctly propagated to prevent nested drop rendering in quoted content.

components/drops/view/part/DropPartMarkdownWithPropLogger.tsx (1)

25-25: LGTM!

Adding currentDropId to the props equality check ensures the memoized component re-renders appropriately when the current drop context changes.

components/drops/view/part/dropPartMarkdown/linkHandlers.tsx (1)

27-27: LGTM!

The currentDropId is correctly threaded through the link renderer configuration and passed to seize handlers, enabling guard logic against rendering cards for the current drop.

Also applies to: 59-61

components/drops/view/part/DropPartMarkdown.tsx (2)

218-218: LGTM!

The currentDropId prop is correctly added to the interface with the readonly modifier as required by coding guidelines.


227-227: LGTM!

The currentDropId is correctly integrated into the component:

  • Destructured from props
  • Passed to createLinkRenderer
  • Included in the useMemo dependency array for proper memoization

Also applies to: 245-247

components/drops/view/part/dropPartMarkdown/handlers/seize.tsx (3)

19-19: LGTM!

The currentDropId field is correctly added to the configuration interface with the readonly modifier as per coding guidelines.


113-124: LGTM!

The guard logic correctly prevents rendering a drop card when the link targets the current drop:

  • Checks if dropId === currentDropId
  • Throws an error to trigger fallback to a simple anchor
  • Error is caught by the error boundary in linkHandlers.tsx, resulting in the expected fallback behavior

This implementation effectively prevents the nesting issue described in the PR objectives.


126-134: LGTM!

The currentDropId is correctly propagated through createSeizeHandlers to the drop handler, completing the threading of the current drop context through the entire link rendering pipeline.


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.

@sonarqubecloud
Copy link
Copy Markdown

@simo6529 simo6529 merged commit 6e5ef8a into main Nov 13, 2025
8 checks passed
@simo6529 simo6529 deleted the nesting-bug branch November 13, 2025 09:53
This was referenced Nov 27, 2025
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