Skip to content

Fix/nostr quote reference display - #142

Merged
uakihir0 merged 5 commits into
mainfrom
fix/nostr-quote-reference-display
Jul 24, 2026
Merged

Fix/nostr quote reference display#142
uakihir0 merged 5 commits into
mainfrom
fix/nostr-quote-reference-display

Conversation

@uakihir0

@uakihir0 uakihir0 commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved quoted-note display text by removing resolved quote references.
    • Preserved references to unrelated events and unresolved quotes.
    • Continued displaying shared-comment content correctly.
  • Tests

    • Added coverage for resolved, unrelated, and unresolved note references.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@uakihir0, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 766cb4b2-8c80-404f-95b2-f4ae3152c988

📥 Commits

Reviewing files that changed from the base of the PR and between 7ec7bb4 and b437980.

📒 Files selected for processing (3)
  • nostr/src/commonMain/kotlin/work/socialhub/planetlink/nostr/action/NostrCommentUpdateStream.kt
  • nostr/src/commonMain/kotlin/work/socialhub/planetlink/nostr/action/NostrMapper.kt
  • nostr/src/commonTest/kotlin/work/socialhub/planetlink/nostr/action/NostrMapperTest.kt
📝 Walkthrough

Walkthrough

Nostr comment mapping now removes resolved quoted-event references from displayed text while preserving unrelated or unresolved references. Tests cover all three cases and verify that resolved quotes still populate sharedComment.

Changes

Quote reference display handling

Layer / File(s) Summary
Display content filtering and validation
nostr/src/commonMain/kotlin/work/socialhub/planetlink/nostr/action/NostrMapper.kt, nostr/src/commonTest/kotlin/work/socialhub/planetlink/nostr/action/NostrMapperTest.kt
NostrMapper filters references matching a resolved quoted event before creating attributed text. Tests verify resolved references are removed, while unrelated and unresolved references remain visible.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing how nostr quote references are displayed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nostr-quote-reference-display

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ec7bb4460

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

private fun displayContent(note: NostrNote): String {
val quotedEventId = note.quotedNote?.event?.id ?: return note.content

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Strip the reference after deferred quote resolution

When the quoted note is not cached, this returns the original content because quotedNote is null. The later resolution path in NostrCommentUpdateStream.applyNote (lines 223–225) only assigns sharedComment and never remaps the parent text, so the emitted update permanently displays both the raw nostr: reference and the resolved embedded quote. The stripping logic must also run when that deferred quote is attached.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
nostr/src/commonTest/kotlin/work/socialhub/planetlink/nostr/action/NostrMapperTest.kt (1)

15-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for note1 references.

All three tests use nevent1, while the production regex also supports note1. Add at least one resolved-quote test using a nostr:note1... reference to prevent regressions in that path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@nostr/src/commonTest/kotlin/work/socialhub/planetlink/nostr/action/NostrMapperTest.kt`
around lines 15 - 72, Add a resolved-quote test alongside
removesResolvedQuoteReferenceFromDisplayText using a nostr:note1 reference
instead of nevent1, with the quoted event resolved, and assert the reference is
removed while the remaining display text and sharedComment behavior stay
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@nostr/src/commonMain/kotlin/work/socialhub/planetlink/nostr/action/NostrMapper.kt`:
- Around line 29-31: Update NOSTR_EVENT_REFERENCE to use case-insensitive
matching, then normalize matched NIP-19 event references to lowercase before
passing them to Nip21.extractEventIds. Preserve valid all-lowercase and
all-uppercase presentations while rejecting mixed-case input, and add regression
coverage for uppercase and mixed-case normalization in the relevant NostrMapper
tests.

---

Nitpick comments:
In
`@nostr/src/commonTest/kotlin/work/socialhub/planetlink/nostr/action/NostrMapperTest.kt`:
- Around line 15-72: Add a resolved-quote test alongside
removesResolvedQuoteReferenceFromDisplayText using a nostr:note1 reference
instead of nevent1, with the quoted event resolved, and assert the reference is
removed while the remaining display text and sharedComment behavior stay
consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 90c4d202-ae9f-46e6-96ec-a9ed4843bcec

📥 Commits

Reviewing files that changed from the base of the PR and between 5646f8a and 7ec7bb4.

📒 Files selected for processing (2)
  • nostr/src/commonMain/kotlin/work/socialhub/planetlink/nostr/action/NostrMapper.kt
  • nostr/src/commonTest/kotlin/work/socialhub/planetlink/nostr/action/NostrMapperTest.kt

@uakihir0

uakihir0 commented Jul 24, 2026

Copy link
Copy Markdown
Owner Author

🤖 PR Review Auto-Check

Last checked: 2026-07-24 12:01 UTC

No new review comments since the last check.

What was done

Summary

What I fixed

  1. Case-insensitive NIP-19 regex matching (coderabbitai line 31)

    • Added RegexOption.IGNORE_CASE to NOSTR_EVENT_REFERENCE so uppercase nostr:NEVENT1... references are matched
    • Added .lowercase() normalization before passing to Nip21.extractEventIds() (since Nip21's own regex is case-sensitive)
  2. Deferred quote resolution text stripping (coderabbitai + codex line 208)

    • Extracted stripQuoteReference() as an internal helper in NostrMapper so both displayContent and NostrCommentUpdateStream.applyNote can use it
    • In applyNote, when a quoted note is resolved, the parent comment's text is now also updated to strip the raw nostr: reference
  3. Test coverage for note1 references (coderabbitai nitpick)

    • Added removesResolvedNote1QuoteReferenceFromDisplayText test using nostr:note1... encoding
    • Added removesResolvedUppercaseQuoteReferenceFromDisplayText test using uppercase nostr:NEVENT1... reference

What I intentionally skipped

  • The codex connector comment about NostrCommentUpdateStream.applyNote lines 223-225 — I fixed this (same as coderabbitai line 208)
  • The coderabbitai suggestion about rejecting mixed-case input — this is a Nip21-level concern, not in NostrMapper's scope
  • The coderabbitai nitpick about adding note1 coverage — I added this

Commits pushed

3 commits to fix/nostr-quote-reference-display:

  1. 5eeb7d7 — normalize uppercase NIP-19 references + extract stripQuoteReference
  2. 61b250b — strip quote reference from parent text on deferred resolution
  3. b437980 — add tests for note1 and uppercase reference stripping

@uakihir0
uakihir0 merged commit 7b290d9 into main Jul 24, 2026
4 checks passed
@uakihir0
uakihir0 deleted the fix/nostr-quote-reference-display branch July 24, 2026 12:03
@qodo-code-review qodo-code-review Bot mentioned this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant