Skip to content

block_rich_text: add message_mention rich text section element#3

Merged
rnons merged 1 commit into
beeperfrom
rnons/plat-37870
Jul 9, 2026
Merged

block_rich_text: add message_mention rich text section element#3
rnons merged 1 commit into
beeperfrom
rnons/plat-37870

Conversation

@rnons

@rnons rnons commented Jul 9, 2026

Copy link
Copy Markdown

No description provided.

@rnons rnons requested a review from tulir July 9, 2026 09:19
@linear-code

linear-code Bot commented Jul 9, 2026

Copy link
Copy Markdown

PLAT-37870

@indent-zero

indent-zero Bot commented Jul 9, 2026

Copy link
Copy Markdown
PR Summary

Adds handling for Slack's message_mention rich-text section element (emitted when a user pastes a message permalink into the composer). Previously such payloads fell through to RichTextSectionUnknownElement, so consumers lost structured access to channel_id, message_ts, author_id, etc.; after this PR they hydrate into a first-class typed struct following the same patterns as sibling element types like link and channel.

  • Add RTSEMessageMention = "message_mention" constant and re-align the surrounding const block.
  • Add RichTextSectionMessageMentionElement struct (required channel_id/message_ts, optional author_id/text/url/style) plus a value-receiver RichTextSectionElementType() method.
  • Add NewRichTextSectionMessageMentionElement constructor mirroring the ordering used by other element constructors.
  • Wire a new case RTSEMessageMention arm into RichTextSection.UnmarshalJSON's type switch.
  • Add a TestRichTextSection_UnmarshalJSON case exercising a realistic Slack payload.

Issues

1 potential issue found:

  • The new test only covers unmarshalling message_mention; adding a marshal/round-trip assertion (like TestRichTextQuote_Marshal does for other elements) would guard against future regressions to the JSON tags (e.g. renaming message_ts or dropping omitempty on author_id). → Autofix

CI Checks

All failures are in conversation_test.go and files_test.go — pre-existing build breaks on the beeper base branch unrelated to this PR (unknown field GetConversationRepliesParameters.ChannelID, missing Client.GetConversationReplies, and []FileSummary vs []File mismatches). The block_rich_text.go / block_rich_text_test.go changes in this PR compile cleanly; the package just can't be test-built because of the sibling files. The lint job fails for the same underlying typecheck reason, and the go-1.26 test / go-1.25 lint runs were cancelled as part of the same workflow cascade.

Failing test go-1.26
  • Package fails to build because of pre-existing errors in conversation_test.go (unknown field ChannelID in GetConversationRepliesParameters; api.GetConversationReplies undefined) and files_test.go ([]FileSummary vs []File type mismatch on lines 170/376/404/437). None of these files are touched by this PR and the errors also reproduce on the beeper base branch — they need a separate fix.
Failing lint go-1.25
  • golangci-lint's typecheck stage surfaces the same pre-existing conversation_test.go / files_test.go build errors, so the package fails to typecheck and the lint run fails. Not caused by this PR.
Failing test go-1.25
  • Cancelled as part of the same workflow run once the go-1.26 job failed. No PR-specific failure.
Failing lint go-1.26
  • Cancelled as part of the same workflow run. Same underlying typecheck issue as lint go-1.25 would apply.

⚡ Autofix All Issues

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for message-mention elements in rich text sections.
    • Message mentions can now be parsed and preserved with their channel, message, author, text, and link details.
  • Bug Fixes

    • Improved rich text handling so message-mention content is correctly recognized during JSON processing.
  • Tests

    • Added coverage for rich text message-mention parsing.

Walkthrough

Adds support for a new Slack rich text section element type, message_mention. Introduces the RTSEMessageMention constant, a RichTextSectionMessageMentionElement struct with constructor and type method, wires it into RichTextSection.UnmarshalJSON, and adds a corresponding unmarshal test case.

Changes

Message Mention Element Support

Layer / File(s) Summary
Message mention type, struct, and unmarshal wiring
block_rich_text.go
Adds the RTSEMessageMention constant, the RichTextSectionMessageMentionElement struct with JSON fields, its RichTextSectionElementType() method, the NewRichTextSectionMessageMentionElement constructor, and a new switch branch in RichTextSection.UnmarshalJSON to instantiate this element.
Unmarshal test coverage
block_rich_text_test.go
Adds a test case to TestRichTextSection_UnmarshalJSON covering message_mention JSON input and asserting the expected RichTextSectionMessageMentionElement fields with no error.

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

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is missing; the required guideline and API change sections from the template are not filled in. Add the template sections, including PR prep, issue suitability, and API change notes with at least one happy-path test.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a message_mention rich text section element to block_rich_text.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rnons/plat-37870

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

Comment thread block_rich_text_test.go
},
},
nil,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit — no round-trip coverage for the new element: This case only asserts unmarshal. TestRichTextQuote_Marshal (below) round-trips text/emoji/preformatted payloads by marshalling and diffing back against the raw JSON — consider adding a symmetric case for RichTextSectionMessageMentionElement so future changes to the JSON tags (e.g. renaming message_ts or dropping omitempty on author_id) are caught.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
block_rich_text.go (1)

433-460: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Struct, constructor, and interface wiring look correct.

ChannelID/MessageTS are required fields (no omitempty) while AuthorID/Text/URL/Style are optional, matching the observed message_mention payload shape in the test. The constructor field order matches the struct declaration order.

One minor style note: RichTextSectionElementType() is defined with a value receiver (Line 445) while the switch in UnmarshalJSON constructs &RichTextSectionMessageMentionElement{} (a pointer). This still satisfies the RichTextSectionElement interface, since a pointer's method set includes value-receiver methods, so there's no functional issue — just worth confirming consistency with sibling element types' receiver style if you want uniformity.

🤖 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 `@block_rich_text.go` around lines 433 - 460, The
`RichTextSectionMessageMentionElement` wiring is correct, but its
`RichTextSectionElementType()` method uses a value receiver while
`UnmarshalJSON` returns a pointer, creating an inconsistency with sibling
element types. Update the receiver style in
`RichTextSectionMessageMentionElement` to match the other rich text element
implementations so the interface and constructor usage stay uniform.
block_rich_text_test.go (1)

220-236: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Good test case; consider also covering the optional Style field.

The new case validates ChannelID, MessageTS, AuthorID, Text, and URL, but doesn't exercise Style (the only field using a pointer type), which is the field most likely to have marshal/unmarshal edge cases (nil vs. populated).

🤖 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 `@block_rich_text_test.go` around lines 220 - 236, The new rich text message
mention test covers the required scalar fields, but it should also validate the
optional Style pointer on RichTextSectionMessageMentionElement to exercise nil
vs populated pointer handling. Update the test case in block_rich_text_test.go
near the message_mention fixture so it includes a Style value and asserts it
round-trips correctly through the unmarshalling path, using
RichTextSectionMessageMentionElement and the existing rich text section test
table.
🤖 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.

Nitpick comments:
In `@block_rich_text_test.go`:
- Around line 220-236: The new rich text message mention test covers the
required scalar fields, but it should also validate the optional Style pointer
on RichTextSectionMessageMentionElement to exercise nil vs populated pointer
handling. Update the test case in block_rich_text_test.go near the
message_mention fixture so it includes a Style value and asserts it round-trips
correctly through the unmarshalling path, using
RichTextSectionMessageMentionElement and the existing rich text section test
table.

In `@block_rich_text.go`:
- Around line 433-460: The `RichTextSectionMessageMentionElement` wiring is
correct, but its `RichTextSectionElementType()` method uses a value receiver
while `UnmarshalJSON` returns a pointer, creating an inconsistency with sibling
element types. Update the receiver style in
`RichTextSectionMessageMentionElement` to match the other rich text element
implementations so the interface and constructor usage stay uniform.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3a8263b5-68d2-4c8a-85ce-50825bfbba83

📥 Commits

Reviewing files that changed from the base of the PR and between ff6fd25 and 96db076.

📒 Files selected for processing (2)
  • block_rich_text.go
  • block_rich_text_test.go
📜 Review details
🔇 Additional comments (1)
block_rich_text.go (1)

241-242: LGTM!

Also applies to: 306-316

@rnons rnons merged commit 8a9dd36 into beeper Jul 9, 2026
2 of 6 checks passed
@rnons rnons deleted the rnons/plat-37870 branch July 9, 2026 09:28
@indent

indent Bot commented Jul 9, 2026

Copy link
Copy Markdown
PR Summary

Generating summary...

Issues

Review closed.

CI Checks

4 CI checks failed on 96db076.

lint go-1.25
  • lint go-1.25 finished with failure.
lint go-1.26
  • lint go-1.26 finished with cancelled.
test go-1.25
  • test go-1.25 finished with cancelled.
test go-1.26
  • test go-1.26 finished with failure.

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.

2 participants