Skip to content

Support matrix: URIs#40

Merged
SpiritCroc merged 1 commit into
mainfrom
matrix-uri-scheme
May 25, 2026
Merged

Support matrix: URIs#40
SpiritCroc merged 1 commit into
mainfrom
matrix-uri-scheme

Conversation

@SpiritCroc
Copy link
Copy Markdown
Contributor

@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: 9eba3a35-46c3-4a79-9c03-1340f08f679d

📥 Commits

Reviewing files that changed from the base of the PR and between 00c395d and c3fc7f3.

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

48-54: LGTM!

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

10-12: LGTM!


25-27: LGTM!


66-109: LGTM!


111-122: LGTM!


124-143: LGTM!

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

283-306: LGTM!


319-319: LGTM!


507-507: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added support for parsing Matrix URI format (matrix:) alongside existing matrix.to links to improve link recognition and compatibility across different link formats
    • Extended user mentions, room links, and message links with optional action field support for enhanced link interaction capabilities

Walkthrough

Added optional action field to MatrixToLink variants. Implemented matrix: URI parsing alongside existing matrix.to link support via new parseMatrixLink and parseMatrixUri functions. Integrated unified parser into MatrixHtmlParser to detect and annotate matrix-scheme URIs in plaintext and HTML.

Changes

Matrix URI and Action Field Enhancement

Layer / File(s) Summary
MatrixToLink schema extension
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixBodyAnnotations.kt
Added optional action: String? = null constructor parameter to UserMention, RoomLink, and MessageLink data classes, expanding their serialized representation.
Matrix URI parsing support
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixPatterns.kt
Introduced MATRIX_URI_SCHEME and MATRIX_URI_PATTERN for scheme recognition; implemented parseMatrixUri to extract and decode path/query components, validate segment counts, and reconstruct user/room/message identifiers with appropriate sigils; exposed parseMatrixLink as unified entry point that attempts matrix.to parsing first, then falls back to matrix: URI parsing.
HTML parser integration and plaintext auto-linkification
messageformat/src/commonMain/kotlin/com/beeper/android/messageformat/MatrixHtmlParser.kt
Replaced parseMatrixToUrl calls with parseMatrixLink in hyperlink and HTML <a> element handling; added plaintext auto-linkification pass to detect matrix: URI matches, skip overlapping ranges, parse into MatrixToLink, and create corresponding annotations.

Sequence Diagram(s)

sequenceDiagram
  participant Parser as MatrixHtmlParser
  participant LinkParser as MatrixPatterns.parseMatrixLink
  participant MatrixToParser as parseMatrixToUrl
  participant URIParser as parseMatrixUri
  participant Annotation as MatrixToLink
  Parser->>LinkParser: url, isAutoLink
  LinkParser->>MatrixToParser: url, isAutoLink
  alt matrix.to URL
    MatrixToParser-->>Annotation: UserMention | RoomLink | MessageLink
  else matrix: URI
    LinkParser->>URIParser: url, isAutoLink
    URIParser->>URIParser: validate scheme, extract/decode components
    URIParser->>URIParser: reconstruct identifiers with sigils
    URIParser-->>Annotation: UserMention | RoomLink | MessageLink
  end
  Annotation-->>LinkParser: result
  LinkParser-->>Parser: MatrixToLink or null
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • beeper/matrix-messageformat-compose#39: Both PRs update the matrix-link parsing/rendering pipeline by modifying MatrixHtmlParser to call into MatrixPatterns with link-context flags and updating MatrixBodyAnnotations.MatrixToLink variants with new optional fields.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Support matrix: URIs' directly describes the main purpose of the changeset, which adds support for parsing matrix: URI scheme alongside existing matrix.to links.
Description check ✅ Passed The description references the Matrix spec and recommended implementation algorithm, which are directly related to the changeset's goal of supporting the matrix: URI scheme.
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 matrix-uri-scheme

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

@SpiritCroc SpiritCroc merged commit 17e7a0c into main May 25, 2026
1 check passed
@SpiritCroc SpiritCroc deleted the matrix-uri-scheme branch May 25, 2026 14:55
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