Skip to content

fix: katex array breaking the app#6963

Merged
OtavioStasiak merged 11 commits intodevelopfrom
fix.katex-array-breaking-the-app
Feb 5, 2026
Merged

fix: katex array breaking the app#6963
OtavioStasiak merged 11 commits intodevelopfrom
fix.katex-array-breaking-the-app

Conversation

@OtavioStasiak
Copy link
Contributor

@OtavioStasiak OtavioStasiak commented Feb 3, 2026

Proposed changes

KaTeX arrays should be rendered using our KaTeX component, not MathView.
Usually, this kind of KaTeX should go to renderError and then be rendered using the KaTeX component. However, MathView is not treating it as an error and is also unable to render it correctly. Because of that, I added a validation to detect arrayKaTeX and render it using the correct component.

Issue(s)

https://rocketchat.atlassian.net/browse/SUP-990

How to test or reproduce

  • send a katex message like this and open the room:
 \\begin{array}{|c|c|c|c|c|c|} \\hline \\text{testing} & \\text{testingII} & \\text{testing III} & \\text{testing IV} & \\text{testV} & \\text{testVI} \\\\ \\hline \\text{TEST} & \\text{TEST} & \\text{TEST} & \\text{TEST} & \\text{TEST} & \\text{TEST} \\\\ \\hline\\text{TEST} & \\text{✅} & \\text{test} & \\text{test} & \\text{test} & \\text{✅} \\\\ \\hline \\end{array} 

Screenshots

Before After
Simulator Screenshot - iPhone 16 - 2026-02-03 at 18 33 00 Simulator Screenshot - iPhone 16 - 2026-02-03 at 18 32 47

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • Improved rendering of block mathematical environments (arrays, matrices) with proper display formatting and error handling.
  • Tests

    • Added test stories for array-based mathematical formula rendering scenarios.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

Walkthrough

These changes address KaTeX array rendering by introducing block environment detection in the KaTeX component, which short-circuits rendering in display mode instead of delegating through MathView. New story exports are added to demonstrate KaTeX array rendering behavior.

Changes

Cohort / File(s) Summary
KaTeX Block Environment Detection
app/containers/markdown/components/Katex.tsx
Added BLOCK_ENV_PATTERN regex to identify block environments (array, matrix, pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix) and modified rendering logic to short-circuit display mode for detected blocks, bypassing MathView. Updated renderError to display block KaTeX in display mode consistently.
Story Exports
app/containers/message/Message.stories.tsx
Introduced KatexArray and KatexArrayLargeFont story exports with corresponding katexArray payload structure to demonstrate array-based KaTeX rendering.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • fix: katex breaking the app #6710: Both PRs modify KaTeX-related message stories in app/containers/message/Message.stories.tsx by adding new KaTeX story exports for testing different KaTeX rendering scenarios.

Suggested reviewers

  • diegolmello

Poem

🐰✨ A hop through matrices and arrays so fine,
Block patterns gleaming in display design,
No black squares now—just beauty in sight,
KaTeX arrays rendering perfectly right! 📐

🚥 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 accurately identifies the main fix: routing KaTeX array rendering to the correct component to prevent app breakage.
Linked Issues check ✅ Passed The PR implements the required fix for SUP-990 by detecting array-style KaTeX and routing it to the KaTeX component, preventing rendering failures and app breakage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the KaTeX array rendering issue: pattern detection, component routing, and story examples demonstrating the fix.
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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix.katex-array-breaking-the-app

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.

@OtavioStasiak OtavioStasiak marked this pull request as ready for review February 4, 2026 19:47
@Rohit3523
Copy link
Contributor

LGTM

@OtavioStasiak OtavioStasiak temporarily deployed to approve_e2e_testing February 5, 2026 16:26 — with GitHub Actions Inactive
@OtavioStasiak OtavioStasiak requested a deployment to official_android_build February 5, 2026 16:28 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak requested a deployment to experimental_ios_build February 5, 2026 16:28 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak requested a deployment to experimental_android_build February 5, 2026 16:28 — with GitHub Actions Waiting
@OtavioStasiak OtavioStasiak merged commit bfe97f5 into develop Feb 5, 2026
19 of 37 checks passed
@OtavioStasiak OtavioStasiak deleted the fix.katex-array-breaking-the-app branch February 5, 2026 20:06
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.

2 participants