Skip to content

Tell apart matrix.to user links from formatted message mentions#39

Merged
SpiritCroc merged 2 commits into
mainfrom
auto-linkified-mentions
May 24, 2026
Merged

Tell apart matrix.to user links from formatted message mentions#39
SpiritCroc merged 2 commits into
mainfrom
auto-linkified-mentions

Conversation

@SpiritCroc
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eafbaf54-bfe7-493a-8374-4bc4cabcda69

📥 Commits

Reviewing files that changed from the base of the PR and between 4c589f3 and b1929d4.

📒 Files selected for processing (1)
  • messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyStyledFormatter.kt
📜 Recent review details
🔇 Additional comments (1)
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyStyledFormatter.kt (1)

427-427: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Auto-detected (auto-linked) user mentions are now distinguished from explicit mentions and rendered as clickable links.
  • Bug Fixes

    • Auto-linked mentions now use link styling and no longer receive the inline mention highlight reserved for explicit mentions.
  • Documentation / Examples

    • Example message updated to include an auto-linked user URL for demonstration.

Walkthrough

Adds an isAutoLink Boolean to MatrixToLink.UserMention, threads it through parseMatrixToUrl, sets the flag during HTML/plaintext parsing, and conditions formatter/playground rendering on that flag to treat auto-linked mentions as clickable URLs.

Changes

Auto-link distinction for user mentions

Layer / File(s) Summary
Data model and parser API contract
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyAnnotations.kt, messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixPatterns.kt
UserMention gains an isAutoLink: Boolean field. The parseMatrixToUrl function signature is updated to accept an isAutoLink parameter.
Parser implementation
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixPatterns.kt, messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixHtmlParser.kt
MatrixPatterns constructs UserMention with the flag value, and MatrixHtmlParser calls parseMatrixToUrl with isAutoLink=true for plaintext auto-linkified URLs and isAutoLink=false for explicit href attributes.
Rendering and display
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyStyledFormatter.kt, playground/src/jvmMain/kotlin/com/beeper/android/messageformat/desktop/MessageRenderPlaygroundMain.kt, playground/src/jvmMain/kotlin/com/beeper/android/messageformat/desktop/ExampleMessage.kt
formatUserMention returns a clickable LinkAnnotation.Url for auto-linked mentions or the existing bold white styling for regular mentions. The playground's drawBehindUserMention skips background rendering for auto-linked mentions, and an example message demonstrates the feature.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess whether any provided description relates to the changeset. Add a pull request description explaining the motivation and impact of distinguishing auto-linkified mentions from formatted mentions.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: distinguishing between auto-linkified matrix.to user URLs and formatted message mentions using the new isAutoLink flag.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch auto-linkified-mentions

Comment @coderabbitai help to get the list of available commands and usage tips.

@SpiritCroc SpiritCroc force-pushed the auto-linkified-mentions branch from 2018e3a to 4c589f3 Compare May 24, 2026 07:19
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

🤖 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
`@messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyStyledFormatter.kt`:
- Around line 424-432: formatUserMention currently returns a LinkAnnotation.Url
without an onClick, bypassing the spoiler-intercept and click handling in
formatWebLink; update formatUserMention to attach the same onClick behavior as
formatWebLink (or delegate to formatWebLink) so that auto-linked mentions call
interceptLinkClicks(context) and then handleWebLinkClick(url) before navigation,
ensuring you still pass urlStyle when constructing the LinkAnnotation.Url.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72412c91-f667-4271-ad53-d8c14af58336

📥 Commits

Reviewing files that changed from the base of the PR and between 73c9f02 and 2018e3a.

📒 Files selected for processing (6)
  • messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyAnnotations.kt
  • messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyStyledFormatter.kt
  • messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixHtmlParser.kt
  • messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixPatterns.kt
  • playground/src/jvmMain/kotlin/com/beeper/android/messageformat/desktop/ExampleMessage.kt
  • playground/src/jvmMain/kotlin/com/beeper/android/messageformat/desktop/MessageRenderPlaygroundMain.kt
📜 Review details
🔇 Additional comments (5)
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyAnnotations.kt (1)

48-48: LGTM!

messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixPatterns.kt (1)

20-20: LGTM!

Also applies to: 40-40

messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixHtmlParser.kt (1)

266-266: LGTM!

Also applies to: 457-457

playground/src/jvmMain/kotlin/com/beeper/android/messageformat/desktop/MessageRenderPlaygroundMain.kt (1)

188-191: LGTM!

playground/src/jvmMain/kotlin/com/beeper/android/messageformat/desktop/ExampleMessage.kt (1)

32-33: LGTM!

@SpiritCroc SpiritCroc merged commit 00c395d into main May 24, 2026
1 check passed
@SpiritCroc SpiritCroc deleted the auto-linkified-mentions branch May 24, 2026 07:27
@coderabbitai coderabbitai Bot mentioned this pull request May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant