Skip to content

feat(message-parser): block fallback for unsupported renderers#41110

Merged
ggazzo merged 8 commits into
developfrom
feat/message-parser-block-fallback
Jul 1, 2026
Merged

feat(message-parser): block fallback for unsupported renderers#41110
ggazzo merged 8 commits into
developfrom
feat/message-parser-block-fallback

Conversation

@ggazzo

@ggazzo ggazzo commented Jun 30, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Degrades block AST nodes that a renderer doesn't implement to their raw markup, instead of dropping them.

Problem

Renderers switch on block.type with default: return null. Any block type a given renderer doesn't implement is silently dropped — the content vanishes.

Approach

A block may carry a fallback: a [start, end] offset span into the original message source (see the table / horizontal-rule PRs that populate it). Markup and PreviewMarkup now take an optional source prop (the original message.msg) and, in their default branch, slice source[start..end] and render that text instead of returning null.

Using offsets rather than a copy of the text keeps the AST from being bloated in the persisted/transmitted payload — the source is already available next to the AST in the message. Both web and mobile (React Native) are JS, so the UTF-16 offsets slice identically on both.

Issue(s)

Consumes the fallback offsets produced by the table and horizontal-rule PRs.

Steps to test or reproduce

yarn turbo run build --filter=@rocket.chat/gazzodown then typecheck. Render a Markup with a block carrying a fallback offset span and a source, and confirm the raw markup is shown.

Further comments

Callers that render messages should pass source={message.msg} to Markup/PreviewMarkup so unsupported blocks degrade to text. Mobile should adopt the same default.

Summary by CodeRabbit

  • New Features

    • Unsupported message blocks now remain visible by falling back to their original markup instead of disappearing.
    • Message rendering now preserves the original source text so fallback content can be shown more accurately.
  • Bug Fixes

    • Timestamp content now renders consistently using source-position fallbacks, improving display for parsed messages.
    • Translation and formatted message content now keeps the expected raw text available during rendering.

@dionisio-bot

dionisio-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds fallback rendering for message blocks lacking dedicated renderers. The message-parser package introduces a SourceRange type and normalizes Timestamp.fallback to [start, end] offsets. Gazzodown's Markup and PreviewMarkup accept an optional source prop to slice and render fallback text. Meteor components propagate the original message source (mdSource) through MessageContentBody to enable this fallback path.

Changes

Fallback Rendering Feature

Layer / File(s) Summary
SourceRange type and Timestamp fallback offsets
packages/message-parser/src/definitions.ts, packages/message-parser/src/grammar.pegjs, packages/message-parser/src/utils.ts, packages/message-parser/tests/timestamp.test.ts, .changeset/timestamp-fallback-offsets.md
Adds a SourceRange tuple type, changes Timestamp.fallback to accept offset spans (retaining legacy Plain for compatibility), updates grammar rules and the timestamp utility to pass/consume source ranges, and updates tests accordingly.
Markup and PreviewMarkup fallback rendering
packages/gazzodown/src/Markup.tsx, packages/gazzodown/src/PreviewMarkup.tsx, .changeset/block-fallback-rendering.md
Adds an optional source prop; unhandled block types now slice source using the block's fallback offset span and render the raw text instead of returning null.
Wiring message source through meteor components
apps/meteor/client/components/message/MessageContentBody.tsx, .../variants/room/RoomMessageContent.tsx, .../variants/thread/ThreadMessageContent.tsx, apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts, apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts, .changeset/message-content-body-source.md
Adds mdSource to the parsed message type/value, adds a msg prop to MessageContentBody that is forwarded as source to Markup, and passes mdSource from RoomMessageContent/ThreadMessageContent; updates test fixtures.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Parser as parseMessageTextToAstMarkdown
  participant Content as RoomMessageContent / ThreadMessageContent
  participant Body as MessageContentBody
  participant Markup as Markup / PreviewMarkup

  Parser->>Content: normalizedMessage.mdSource
  Content->>Body: msg = mdSource
  Body->>Markup: source = msg
  Markup->>Markup: default case - check block.fallback [start, end]
  Markup->>Markup: slice source and render raw text
Loading

Suggested labels: type: feature

Suggested reviewers: KevLehman, MartinSchoeler, tassoevan

🚥 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: unsupported blocks now fall back instead of being dropped.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • UTF-16: Request failed with status code 401

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.

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 50302fb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@rocket.chat/gazzodown Major
@rocket.chat/meteor Patch
@rocket.chat/message-parser Minor
@rocket.chat/core-services Patch
@rocket.chat/core-typings Patch
@rocket.chat/livechat Patch
@rocket.chat/rest-typings Patch
rocketchat-services Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.04%. Comparing base (b6e0d3b) to head (50302fb).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41110      +/-   ##
===========================================
+ Coverage    69.14%   70.04%   +0.90%     
===========================================
  Files         3433     3369      -64     
  Lines       132323   130321    -2002     
  Branches     23091    22650     -441     
===========================================
- Hits         91489    91288     -201     
+ Misses       37472    35709    -1763     
+ Partials      3362     3324      -38     
Flag Coverage Δ
unit 69.99% <90.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

When a block has no dedicated renderer, render its optional `fallback`
plain-text node as a paragraph instead of returning null, mirroring the
existing inline fallback handling. Lets unsupported blocks degrade to their
original markup rather than being dropped.
@ggazzo ggazzo force-pushed the feat/message-parser-block-fallback branch from 99021b1 to 8f5920b Compare June 30, 2026 12:49
@ggazzo ggazzo changed the base branch from feat/message-parser-markdown-gaps to develop June 30, 2026 12:49
ggazzo added 6 commits June 30, 2026 17:01
Block fallback is now a [start, end] offset span instead of inline text.
Markup/PreviewMarkup take an optional `source` prop (the original message
text) and slice it to render the raw markup for blocks without a dedicated
renderer.
Thread the original message text (msg) into MessageContentBody and on to
gazzodown's Markup as `source`, so blocks without a dedicated renderer can
slice the source to show their raw markup via the parser fallback offsets.
Expose mdSource (the translation/E2EE-aware text that md was parsed from) from
parseMessageTextToAstMarkdown and pass it as the Markup source, so fallback
offsets slice against the right string for translated messages too.
Type the block fallback as the union of the new offset span and the original
form, and narrow with Array.isArray before slicing the source. The non-array
(original) form is intentionally ignored.
Emit the Timestamp `fallback` as a [start, end] source-offset span (via the
grammar's range()), matching the other blocks. The field type keeps the
previous `Plain` form so already-persisted data still type-checks and is
ignored at render time.
The function now returns mdSource; update the full-object toStrictEqual
assertions for translated messages to include it.
@ggazzo ggazzo force-pushed the feat/message-parser-block-fallback branch from 362f3db to a2f2866 Compare July 1, 2026 03:21
@ggazzo ggazzo added this to the 8.7.0 milestone Jul 1, 2026
@ggazzo ggazzo marked this pull request as ready for review July 1, 2026 04:48
@ggazzo ggazzo requested a review from a team as a code owner July 1, 2026 04:48
@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label Jul 1, 2026

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

🧹 Nitpick comments (2)
packages/gazzodown/src/Markup.tsx (1)

68-78: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract shared fallback-resolution logic.

This fallback extraction/slicing logic (type-cast, Array.isArray check, slice into a PLAIN_TEXT inline) is duplicated verbatim in PreviewMarkup.tsx (lines 89-98). Consider extracting a small shared helper (e.g. resolveFallbackText(block, source) returning the sliced string or undefined) so both components stay in sync as the fallback contract evolves.

♻️ Proposed shared helper
// packages/gazzodown/src/getBlockFallbackText.ts
import type * as MessageParser from '`@rocket.chat/message-parser`';

export const getBlockFallbackText = (block: unknown, source?: string): string | undefined => {
	const { fallback } = block as { fallback?: [number, number] | MessageParser.Plain };
	if (Array.isArray(fallback) && source !== undefined) {
		return source.slice(fallback[0], fallback[1]);
	}
	return undefined;
};
+import { getBlockFallbackText } from './getBlockFallbackText';
...
-				default: {
-					// Graceful degradation: blocks may carry a `fallback`. The current form is a
-					// `[start, end]` offset span into the source (sliced to render the raw markup);
-					// the union keeps the original form too, which we intentionally ignore.
-					const { fallback } = block as { fallback?: [number, number] | MessageParser.Plain };
-					if (Array.isArray(fallback) && source !== undefined) {
-						const inlines: MessageParser.Inlines[] = [{ type: 'PLAIN_TEXT', value: source.slice(fallback[0], fallback[1]) }];
-						return <ParagraphBlock key={index}>{inlines}</ParagraphBlock>;
-					}
-					return null;
-				}
+				default: {
+					const text = getBlockFallbackText(block, source);
+					if (text === undefined) return null;
+					return <ParagraphBlock key={index}>{[{ type: 'PLAIN_TEXT', value: text }]}</ParagraphBlock>;
+				}
🤖 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 `@packages/gazzodown/src/Markup.tsx` around lines 68 - 78, The fallback
extraction logic in Markup.tsx is duplicated in PreviewMarkup.tsx, so extract
the shared `fallback` resolution into a small helper and reuse it from both
render paths. Move the type-cast plus `Array.isArray(fallback)` and source
slicing behavior into a helper such as `getBlockFallbackText` or
`resolveFallbackText`, then have the `Markup` default block branch and the
matching `PreviewMarkup` branch call that helper and handle the returned
text/undefined consistently.
apps/meteor/client/components/message/MessageContentBody.tsx (1)

10-16: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor naming mismatch: mdSource becomes msg.

MessageWithMdEnforced.mdSource is renamed to msg in MessageContentBodyProps, and then forwarded as source to Markup. Functionally correct, but the three different names (mdSourcemsgsource) for the same concept across layers adds cognitive overhead when tracing the data flow.

🤖 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 `@apps/meteor/client/components/message/MessageContentBody.tsx` around lines 10
- 16, The `MessageContentBody` props use three different names for the same
value (`mdSource` on `MessageWithMdEnforced`, `msg` in
`MessageContentBodyProps`, and `source` in `Markup`), which makes the data flow
harder to follow. Update `MessageContentBody` and its props to use one
consistent name across the component boundary and forwarding path, and make sure
the symbol names in `MessageContentBodyProps` and `Markup` match the chosen
convention.
🤖 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 `@apps/meteor/client/components/message/MessageContentBody.tsx`:
- Around line 10-16: The `MessageContentBody` props use three different names
for the same value (`mdSource` on `MessageWithMdEnforced`, `msg` in
`MessageContentBodyProps`, and `source` in `Markup`), which makes the data flow
harder to follow. Update `MessageContentBody` and its props to use one
consistent name across the component boundary and forwarding path, and make sure
the symbol names in `MessageContentBodyProps` and `Markup` match the chosen
convention.

In `@packages/gazzodown/src/Markup.tsx`:
- Around line 68-78: The fallback extraction logic in Markup.tsx is duplicated
in PreviewMarkup.tsx, so extract the shared `fallback` resolution into a small
helper and reuse it from both render paths. Move the type-cast plus
`Array.isArray(fallback)` and source slicing behavior into a helper such as
`getBlockFallbackText` or `resolveFallbackText`, then have the `Markup` default
block branch and the matching `PreviewMarkup` branch call that helper and handle
the returned text/undefined consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7b48352-6278-4a7a-b1b2-92320a2e810c

📥 Commits

Reviewing files that changed from the base of the PR and between b6e0d3b and 50302fb.

📒 Files selected for processing (14)
  • .changeset/block-fallback-rendering.md
  • .changeset/message-content-body-source.md
  • .changeset/timestamp-fallback-offsets.md
  • apps/meteor/client/components/message/MessageContentBody.tsx
  • apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx
  • apps/meteor/client/components/message/variants/thread/ThreadMessageContent.tsx
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • packages/gazzodown/src/Markup.tsx
  • packages/gazzodown/src/PreviewMarkup.tsx
  • packages/message-parser/src/definitions.ts
  • packages/message-parser/src/grammar.pegjs
  • packages/message-parser/src/utils.ts
  • packages/message-parser/tests/timestamp.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 📦 Meteor Build (coverage)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx
  • apps/meteor/client/components/message/variants/thread/ThreadMessageContent.tsx
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • packages/message-parser/src/definitions.ts
  • apps/meteor/client/components/message/MessageContentBody.tsx
  • packages/gazzodown/src/PreviewMarkup.tsx
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
  • packages/message-parser/tests/timestamp.test.ts
  • packages/gazzodown/src/Markup.tsx
  • packages/message-parser/src/utils.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
🧠 Learnings (9)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/timestamp-fallback-offsets.md
  • .changeset/block-fallback-rendering.md
  • .changeset/message-content-body-source.md
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx
  • apps/meteor/client/components/message/variants/thread/ThreadMessageContent.tsx
  • apps/meteor/client/components/message/MessageContentBody.tsx
  • packages/gazzodown/src/PreviewMarkup.tsx
  • packages/gazzodown/src/Markup.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx
  • apps/meteor/client/components/message/variants/thread/ThreadMessageContent.tsx
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • packages/message-parser/src/definitions.ts
  • apps/meteor/client/components/message/MessageContentBody.tsx
  • packages/gazzodown/src/PreviewMarkup.tsx
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
  • packages/message-parser/tests/timestamp.test.ts
  • packages/gazzodown/src/Markup.tsx
  • packages/message-parser/src/utils.ts
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • packages/message-parser/src/definitions.ts
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
  • packages/message-parser/tests/timestamp.test.ts
  • packages/message-parser/src/utils.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
  • packages/message-parser/src/definitions.ts
  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
  • packages/message-parser/tests/timestamp.test.ts
  • packages/message-parser/src/utils.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts
🔇 Additional comments (15)
packages/gazzodown/src/PreviewMarkup.tsx (2)

89-98: Same fallback-extraction logic duplicated from Markup.tsx.

See the extraction suggestion on Markup.tsx's default case (lines 68-78); the same helper could be reused here.


15-19: LGTM!

packages/message-parser/src/definitions.ts (1)

121-125: LGTM!

Also applies to: 172-181

packages/message-parser/src/grammar.pegjs (1)

112-112: LGTM!

packages/message-parser/src/utils.ts (1)

20-20: LGTM!

Also applies to: 291-299

packages/message-parser/tests/timestamp.test.ts (1)

11-33: LGTM!

Also applies to: 44-58, 72-78

.changeset/timestamp-fallback-offsets.md (1)

1-6: LGTM!

packages/gazzodown/src/Markup.tsx (1)

19-23: LGTM!

.changeset/block-fallback-rendering.md (1)

1-6: LGTM!

apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts (1)

20-24: LGTM: mdSource wiring is straightforward and matches the fallback contract.

The unconditional mdSource: text assignment correctly captures the translation/E2EE-aware source string that Markup's source prop expects for fallback slicing, consistent with packages/gazzodown/src/Markup.tsx's source.slice(fallback[0], fallback[1]) behavior.

Also applies to: 49-58

apps/meteor/client/components/message/MessageContentBody.tsx (1)

19-27: LGTM!

apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx (1)

65-72: LGTM!

apps/meteor/client/components/message/variants/thread/ThreadMessageContent.tsx (1)

59-64: LGTM!

.changeset/message-content-body-source.md (1)

1-6: LGTM!

apps/meteor/client/lib/parseMessageTextToAstMarkdown.spec.ts (1)

195-195: 🎯 Functional Correctness

No additional mdSource fixture updates needed
The remaining assertions only compare .md, and the full-object expectations already include mdSource.

			> Likely an incorrect or invalid review comment.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 14 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/gazzodown/src/PreviewMarkup.tsx">

<violation number="1" location="packages/gazzodown/src/PreviewMarkup.tsx:89">
P2: Fallback extraction and rendering logic is duplicated from `Markup.tsx`. Extract a shared helper for converting `(fallback, source)` to a `MessageParser.Inlines[]` array so that fixes to the fallback contract or rendering behavior are applied consistently in both full and preview renderers.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

);

default:
default: {

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.

P2: Fallback extraction and rendering logic is duplicated from Markup.tsx. Extract a shared helper for converting (fallback, source) to a MessageParser.Inlines[] array so that fixes to the fallback contract or rendering behavior are applied consistently in both full and preview renderers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/gazzodown/src/PreviewMarkup.tsx, line 89:

<comment>Fallback extraction and rendering logic is duplicated from `Markup.tsx`. Extract a shared helper for converting `(fallback, source)` to a `MessageParser.Inlines[]` array so that fixes to the fallback contract or rendering behavior are applied consistently in both full and preview renderers.</comment>

<file context>
@@ -84,8 +86,16 @@ const PreviewMarkup = ({ tokens }: PreviewMarkupProps) => {
 			);
 
-		default:
+		default: {
+			// Only the `[start, end]` offset form is rendered (sliced from source); the union
+			// keeps the original fallback form too, which we intentionally ignore.
</file context>

@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Jul 1, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 1, 2026
@ggazzo ggazzo merged commit 70c0ff0 into develop Jul 1, 2026
44 of 48 checks passed
@ggazzo ggazzo deleted the feat/message-parser-block-fallback branch July 1, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants