Skip to content

Drop recursion fix#1618

Merged
ragnep merged 1 commit intomainfrom
submission-preview-quoted-drop-fix
Nov 27, 2025
Merged

Drop recursion fix#1618
ragnep merged 1 commit intomainfrom
submission-preview-quoted-drop-fix

Conversation

@ragnep
Copy link
Copy Markdown
Contributor

@ragnep ragnep commented Nov 27, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced content reference validation to prevent circular references where content could quote itself. The application now properly detects and prevents recursive self-referencing scenarios that could cause rendering issues.

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

Signed-off-by: ragnep <ragneinfo@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 27, 2025

Walkthrough

The pull request threads a new optional currentSerialNo prop through the DropPartMarkdown component tree and its link/seize handlers, establishing a data pathway from top-level components down to the seize quote handler. A self-reference guard is added to prevent recursive citations when the serialized number matches the current context.

Changes

Cohort / File(s) Summary
DropPartMarkdown prop threading
components/drops/view/part/DropPartMarkdown.tsx, components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
Added optional currentSerialNo?: number prop to DropPartMarkdownProps interface and component; prop forwarded to createLinkRenderer and added to memoization dependency array; updated areEqual check in prop logger to include currentSerialNo in comparison.
Link renderer configuration
components/drops/view/part/dropPartMarkdown/linkHandlers.tsx
Extended LinkRendererConfig with optional currentSerialNo?: number field; passed currentSerialNo from config to createSeizeHandlers call during link renderer initialization.
Seize handler self-reference guard
components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
Added optional currentSerialNo?: number parameter to CreateSeizeHandlersConfig and createSeizeQuoteHandler; implemented guard logic that extracts quoteInfo from href and throws error if currentSerialNo matches the quoted drop's serialNo to prevent recursive self-reference.
Wave component prop propagation
components/waves/drops/WaveDropPartContentMarkdown.tsx, components/waves/drops/WaveDropQuote.tsx
Added currentSerialNo prop binding to DropPartMarkdownWithPropLogger, sourced from drop?.serial_no in both components.

Sequence Diagram

sequenceDiagram
    participant Wave as WaveDropQuote
    participant DP as DropPartMarkdown
    participant LR as LinkRenderer
    participant SH as SeizeHandler
    participant QI as QuoteInfo

    Wave->>DP: render(currentSerialNo=drop.serial_no)
    DP->>LR: createLinkRenderer({currentSerialNo})
    LR->>SH: createSeizeHandlers({currentSerialNo})
    
    Note over Wave,SH: User clicks seized link
    SH->>QI: parse quoteInfo from href
    alt currentSerialNo === quoteInfo.serialNo
        SH->>SH: ❌ throw error (recursive self-reference)
    else
        SH->>SH: ✓ render quote content
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Attention areas:
    • Verify the self-reference guard in seize.tsx: confirm that the href parsing correctly extracts serialNo and that the equality check prevents unintended recursion without breaking valid cross-references.
    • Confirm memoization dependency arrays are correctly updated in DropPartMarkdownWithPropLogger.tsx to avoid stale closures.
    • Check that drop?.serial_no is consistently available in WaveDropPartContentMarkdown and WaveDropQuote components and matches the expected number type.

Possibly related PRs

  • drop preview url fix #1556: Modifies seize URL normalization and parsing in the same handler files; the current PR's quoteInfo extraction may depend on or interact with those URL changes.
  • prevent nesting #1605: Implements a similar contextual identifier threading pattern (currentDropId guard) for preventing self-references; provides a reference implementation for the currentSerialNo approach used here.

Suggested reviewers

  • simo6529
  • prxt6529

Poem

🐰 A thread runs deep through drops and waves,
Passing serial whispers through the saves,
When a drop would quote itself—alas!
The guard steps in, "Not this, dearlass!"
Safe and sound, no loops we crave,
Our citations flow like a brave, recursive-free wave! 🌊

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 'Drop recursion fix' directly reflects the main change: preventing recursive self-references when rendering quoted drops by adding currentSerialNo checks.
✨ 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 submission-preview-quoted-drop-fix

📜 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 b092d96 and 735ce98.

📒 Files selected for processing (6)
  • components/drops/view/part/DropPartMarkdown.tsx (3 hunks)
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx (1 hunks)
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx (3 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 (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Do not include any comments in the code; it should be self-explanatory
Write correct, up-to-date, bug-free, fully componentized, secure, and efficient code
Include all required imports and ensure proper naming of key components
Use NextJS features that match the current version

**/*.{ts,tsx,js,jsx}: Enforce ≥ 80% line coverage for files changed since main via npm run test
All code must pass ESLint (Next's Core Web Vitals + React Hooks rules) via npm run lint
Use <Link> from Next.js for internal navigation instead of <a> tags or HTML anchors
Use <Image> from next/image instead of HTML <img> elements

Files:

  • components/drops/view/part/dropPartMarkdown/linkHandlers.tsx
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
  • components/waves/drops/WaveDropQuote.tsx
  • components/drops/view/part/DropPartMarkdown.tsx
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
  • components/waves/drops/WaveDropPartContentMarkdown.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{tsx,jsx}: Use FontAwesome for icons in React components
Use TailwindCSS for styling in React components
Use react-query for data fetching
Always add readonly before props in React components

Files:

  • components/drops/view/part/dropPartMarkdown/linkHandlers.tsx
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
  • components/waves/drops/WaveDropQuote.tsx
  • components/drops/view/part/DropPartMarkdown.tsx
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
  • components/waves/drops/WaveDropPartContentMarkdown.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: All code must pass TypeScript type checking via npm run type-check (tsc --noEmit)
Use 'use cache' directive at the top of Server Components or functions to explicitly opt-in to caching in Next.js 16

Files:

  • components/drops/view/part/dropPartMarkdown/linkHandlers.tsx
  • components/drops/view/part/DropPartMarkdownWithPropLogger.tsx
  • components/waves/drops/WaveDropQuote.tsx
  • components/drops/view/part/DropPartMarkdown.tsx
  • components/drops/view/part/dropPartMarkdown/handlers/seize.tsx
  • components/waves/drops/WaveDropPartContentMarkdown.tsx
🧬 Code graph analysis (1)
components/drops/view/part/dropPartMarkdown/linkHandlers.tsx (2)
components/drops/view/part/dropPartMarkdown/handlers/seize.tsx (1)
  • createSeizeHandlers (135-144)
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 (6)
components/drops/view/part/DropPartMarkdownWithPropLogger.tsx (1)

16-27: Including currentSerialNo in memo comparison looks correct

Adding currentSerialNo to propsToCheck keeps React.memo behavior consistent with other props and ensures re-renders when the serial changes. No issues spotted.

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

153-161: Prop wiring for currentSerialNo is consistent

Passing currentSerialNo={drop?.serial_no} alongside currentDropId={drop?.id} cleanly threads serial context into the markdown logger path. This aligns with the new DropPartMarkdown props and the seize/link handling changes.

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

62-69: Serial context forwarding matches the rest of the tree

Forwarding currentSerialNo={drop?.serial_no} here keeps the Wave content path consistent with the quote path and ensures seize/link logic always has the correct serial context when available.

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

25-29: Serial number plumbed cleanly into seize link handling

Extending LinkRendererConfig with currentSerialNo?: number and passing it through createLinkRenderer into createSeizeHandlers is type-consistent and keeps seize-specific logic encapsulated in the handlers while leaving external link behavior unchanged.

Also applies to: 58-64

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

212-220: DropPartMarkdown now exposes currentSerialNo correctly to link rendering

Adding currentSerialNo?: number to DropPartMarkdownProps, threading it into createLinkRenderer, and including it in the useMemo dependency array keeps the link/seize handlers in sync with the current drop context. The change is minimal, type-safe, and localized to link handling.

Also applies to: 222-230, 243-251

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

17-21: Config and handler wiring for currentSerialNo are consistent

Adding currentSerialNo?: number to CreateSeizeHandlersConfig and passing it through from createSeizeHandlers into createSeizeQuoteHandler matches the link renderer config and keeps the serial context localized to seize handling. No issues here.

Also applies to: 135-141

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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

@ragnep ragnep merged commit be55f86 into main Nov 27, 2025
8 checks passed
@ragnep ragnep deleted the submission-preview-quoted-drop-fix branch November 27, 2025 09:32
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