Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-6542 fix(mobile): stabilize recycled markdown layout (#7499)
iiwish5bc021c369ca
diff --git a/apps/mobile/docs/markdown-rendering-adr.md b/apps/mobile/docs/markdown-rendering-adr.mdindex f988a76bb1..e9f6c20297 100644--- a/apps/mobile/docs/markdown-rendering-adr.md+++ b/apps/mobile/docs/markdown-rendering-adr.md@@ -30,7 +30,7 @@ not a Multica problem.| Library | Path | Last release | Verdict for Multica ||---|---|---|---|-| [`react-native-enriched-markdown`](https://github.com/software-mansion-labs/react-native-enriched-markdown) | A | v0.5.0 (Apr 2026) | **Selected for prose.** Expo officially recommends it in [Edit rich text](https://docs.expo.dev/guides/editing-richtext/) — A-tier endorsement. Software Mansion (same team as Reanimated / Gesture Handler) |+| [`react-native-enriched-markdown`](https://github.com/software-mansion/enriched-markdown) | A | v0.6.0 (May 2026) | **Selected for prose.** Expo officially recommends it in [Edit rich text](https://docs.expo.dev/guides/editing-richtext/) — A-tier endorsement. Software Mansion (same team as Reanimated / Gesture Handler) || [`react-native-streamdown`](https://github.com/software-mansion-labs/react-native-streamdown) | A + worklets | active 2026 | Not adopted. Built on enriched-markdown, optimised for AI streaming. Web/desktop don't use a streaming-specific renderer either, mobile streaming isn't currently a top product pain || [`react-native-marked`](https://github.com/gmsgowtham/react-native-marked) | B | v8.1.0 (2026-05-14) | Not adopted. v7 removed `CustomToken`, v8 added "React component embedding" but no token-level customisation. Pure `<Text>` tree → would trigger nested-text bugs || [`amilmohd155/react-native-markdown`](https://github.com/amilmohd155/react-native-markdown) | B | v0.8.5 (Jan 2026) | Not adopted. Same nested-`<Text>` constraint as `react-native-marked`. 14 ⭐, single maintainer, not production-validated |@@ -106,9 +106,10 @@ enriched-markdown's `normalizeMarkdownStyle.js` carries a frozen table of~30 hardcoded **light-mode** color defaults. Fields not explicitlyoverridden in `useMarkdownStyle()` use those hardcoded values anddisappear (or render garishly) in dark mode. Every color field must be-explicitly mapped to a `THEME[scheme]` token. **When upgrading-enriched-markdown (v0.6+), re-audit `normalizeMarkdownStyle.js` for-newly-added color fields** — they will also ship light-mode defaults.+explicitly mapped to a `THEME[scheme]` token. Version 0.6.0 adds a transparent+link background plus link-variant, superscript, and subscript defaults; none+introduce a new opaque color. Re-audit `normalizeMarkdownStyle.js` on every+upgrade because newly-added color fields may ship light-mode defaults.---diff --git a/apps/mobile/lib/markdown/code-block.tsx b/apps/mobile/lib/markdown/code-block.tsxindex b23c449294..fa9c3879e8 100644--- a/apps/mobile/lib/markdown/code-block.tsx+++ b/apps/mobile/lib/markdown/code-block.tsx@@ -69,16 +69,26 @@ export function CodeBlock({ code, lang, selectable = true }: Props) {const { isDarkColorScheme } = useColorScheme();const theme = isDarkColorScheme ? SHIKI_THEME_DARK : SHIKI_THEME_LIGHT;const resolvedLang = resolveLang(lang);- const [lines, setLines] = useState<HighlightedLine[] | null>(null);+ const [highlighted, setHighlighted] = useState<{+ code: string;+ lang: string;+ theme: string;+ lines: HighlightedLine[];+ } | null>(null);+ const lines =+ highlighted?.code === code &&+ highlighted.lang === resolvedLang &&+ highlighted.theme === theme+ ? highlighted.lines+ : null;useEffect(() => {- if (!resolvedLang) {- setLines(null);- return;- }+ if (!resolvedLang) return;let cancelled = false;void highlight(code, resolvedLang, theme).then((result) => {- if (!cancelled) setLines(result);+ if (!cancelled && result) {+ setHighlighted({ code, lang: resolvedLang, theme, lines: result });+ }});return () => {cancelled = true;@@ -88,7 +98,14 @@ export function CodeBlock({ code, lang, selectable = true }: Props) {return (<View className={CODE_BLOCK_CONTAINER_CLASS}><CodeBlockHeader code={code} lang={lang} />- <ScrollView horizontal showsHorizontalScrollIndicator={false}>+ {/* RN's horizontal ScrollView defaults to flexGrow: 1. In a recycled,+ self-sized chat bubble that lets the child outgrow the FlashList+ cell instead of sizing to its code. */}+ <ScrollView+ horizontal+ showsHorizontalScrollIndicator={false}+ style={{ flexGrow: 0 }}+ >{lines ? (<HighlightedCode lines={lines} selectable={selectable} />) : (diff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex 6069603ceb..7b8494ecc6 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -63,7 +63,7 @@"react": "19.2.0","react-dom": "19.2.0","react-native": "0.83.6",- "react-native-enriched-markdown": "^0.5.0",+ "react-native-enriched-markdown": "^0.6.0","react-native-gesture-handler": "~2.30.1","react-native-image-viewing": "^0.2.2","react-native-keyboard-controller": "1.20.7",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 4e71f0cd4a..a00be3e12c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -462,8 +462,8 @@ importers:specifier: 0.83.6react-native-enriched-markdown:- specifier: ^0.5.0- version: 0.5.0(@expo/[email protected])([email protected])([email protected](@babel/[email protected])(@types/[email protected])([email protected]))([email protected])+ specifier: ^0.6.0+ version: 0.6.0(@expo/[email protected])([email protected])([email protected](@babel/[email protected])(@types/[email protected])([email protected]))([email protected])react-native-gesture-handler:specifier: ~2.30.1version: 2.30.1([email protected](@babel/[email protected])(@types/[email protected])([email protected]))([email protected])@@ -9275,8 +9275,8 @@ packages:react-native-svg:optional: true- resolution: {integrity: sha512-CYihNlcg8IjsrVbmypDjFHsDF6Z6vYO0yraw6CkR30SDsg99J6fcBrOkyWOItO8PIDD21jw8yD1eYP/0LBOCdA==}+ resolution: {integrity: sha512-/ZkKZv9jGPAuc/oXevkf3MpVfcrG3pjHoVMyKzpJhGsmIXxeTRr2dlsIqo66k+Pa4JrChBg+HB6ImQ44Fg3wJw==}peerDependencies:'@expo/config-plugins': '>=50.0.0'katex: '>=0.16.0'@@ -20908,7 +20908,7 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@expo/[email protected])([email protected])([email protected](@babel/[email protected])(@types/[email protected])([email protected]))([email protected]):+ [email protected](@expo/[email protected])([email protected])([email protected](@babel/[email protected])(@types/[email protected])([email protected]))([email protected]):dependencies:react: 19.2.0