Skip to content

fix(chat): preserve text before links in reply message preview - #25268

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v4.0.x-developfrom
imdt-claudiop:fix-chat-reply-preview-first-line
Jun 16, 2026
Merged

ramonlsouza merged 1 commit into
bigbluebutton:v4.0.x-developfrom
imdt-claudiop:fix-chat-reply-preview-first-line

Conversation

@Tainan404

Copy link
Copy Markdown
Member

What does this PR do?

Fixes the chat reply preview dropping text that comes before a link.

When you reply to a message like Hello https://example.com, both previews — the "replying to" banner above the input and the quote inside the sent reply — showed only https://example.com, silently dropping the Hello.

The culprit is getFirstVisibleLineHtml (bigbluebutton-html5/.../chat/chat-graphql/service.ts), which extracts the first line of the original message. It walked the message's nodes in reverse and treated the inline tags <a> and <code> as block-level, so it kept the last block (the link) and removed everything before it. This also affected text before inline code, text on both sides of a link, and lists (showed the last item instead of the first).

The fix rewrites the extraction to walk the DOM in document order and truncate at the first real line break (a \n in a text node, a <br>, or the end of the first block element), keeping all inline content of the first line intact.

Closes Issue(s)

Closes #25251

How to test

  1. Send a public chat message: Hello https://example.com
  2. Hover the message and click Reply
  3. Check the "replying to" preview above the input → should show the full Hello https://example.com, not just the link
  4. Send the reply, then check the quote inside the sent reply → should also show the full Hello https://example.com

Automated: npx playwright test chat/chat.spec.ts --grep "Reply to a message with text followed by a link" (new scenario covering both previews).

The reply intention preview and the quote inside sent replies extract
the first visible line of the original message with
getFirstVisibleLineHtml. The function treated the inline tags <a> and
<code> as block-level, walked the root children in reverse order and
removed every node that precedes the last "block" found - so a message
like "Hello https://example.com" was previewed as just the link.

Rewrite the extraction to walk the DOM in document order and truncate
at the first visual line break (newline in a non-whitespace-only text
node, <br>, or the end of the first nested block element), keeping
inline content of the first line intact. Lists now preview their first
item instead of the last one.

Add an e2e scenario covering both previews when replying to a message
with text followed by a link.

Co-authored-by: Tainan Felipe <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: abe11d7c-a496-4433-b9e0-f1da2245e3e0

📥 Commits

Reviewing files that changed from the base of the PR and between 7361050 and 039c8ea.

📒 Files selected for processing (4)
  • bigbluebutton-html5/imports/ui/components/chat/chat-graphql/service.ts
  • bigbluebutton-tests/playwright/chat/chat.spec.ts
  • bigbluebutton-tests/playwright/chat/messageActions.ts
  • bigbluebutton-tests/playwright/core/elements.ts

Walkthrough

The PR fixes a bug where the chat reply preview omits text appearing before a link in a message. The getFirstVisibleLineHtml function in service.ts is rewritten: a new lineBreakingTags set and a recursive truncateAtFirstLineBreak helper are introduced to mutate the parsed DOM, stopping at the first text-node newline, <br> element, or block-level tag and removing all subsequent siblings. getFirstVisibleLineHtml now calls this helper and returns root.outerHTML. A Playwright test is added that sends a "text + link" message, triggers a reply, and asserts that both the reply preview and the quoted reply display the complete first line.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • ramonlsouza
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: fixing the chat reply preview to preserve text before links.
Description check ✅ Passed The description is clearly related to the changeset, explaining the bug, root cause, solution, and testing approach.
Linked Issues check ✅ Passed The PR addresses the linked issue #25251 by fixing the getFirstVisibleLineHtml function to preserve text before links in reply previews, with both unit and end-to-end test coverage.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the reply preview bug: service logic fix, new test helper, new test case, and test selector constant.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@antobinary antobinary added this to the Release 4.0 milestone Jun 15, 2026
@github-actions

Copy link
Copy Markdown

🚨 Automated tests failed

@ramonlsouza ramonlsouza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tested locally and it looks good! the failing tests are unrelated to the changes made in this pull request

@ramonlsouza
ramonlsouza merged commit 64b3e59 into bigbluebutton:v4.0.x-develop Jun 16, 2026
60 of 64 checks passed
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.

4 participants