fix(app): stop markdown lines joining

Custom line-break rules dropped the resolved full-width break style, allowing adjacent native text spans to collapse onto one line. Preserve the break styles in both chat and shared Markdown renderers.
This commit is contained in:
Mohamed Boudra
2026-07-21 23:29:20 +02:00
parent 9603397aed
commit 97cfcf8306
2 changed files with 43 additions and 6 deletions

View File

@@ -569,8 +569,26 @@ export function createSharedMarkdownRules(): RenderRules {
{children}
</MarkdownInheritedText>
),
hardbreak: (node: ASTNode) => <MarkdownTextSpan key={node.key}>{"\n"}</MarkdownTextSpan>,
softbreak: (node: ASTNode) => <MarkdownTextSpan key={node.key}>{"\n"}</MarkdownTextSpan>,
hardbreak: (
node: ASTNode,
_children: ReactNode[],
_parent: ASTNode[],
styles: MarkdownStyles,
) => (
<MarkdownTextSpan key={node.key} style={styles.hardbreak}>
{"\n"}
</MarkdownTextSpan>
),
softbreak: (
node: ASTNode,
_children: ReactNode[],
_parent: ASTNode[],
styles: MarkdownStyles,
) => (
<MarkdownTextSpan key={node.key} style={styles.softbreak}>
{"\n"}
</MarkdownTextSpan>
),
code_block: (
node: ASTNode,
_children: ReactNode[],

View File

@@ -1689,10 +1689,29 @@ export const AssistantMessage = memo(function AssistantMessage({
// plain <Text> is not hoisted into a UITextViewChild and is dropped (same
// root cause as strong/em/s) — so on iOS a hard line break vanished, and
// a softbreak between words jammed them together ("one\ntwo" -> "onetwo").
// Emit the break through MarkdownTextSpan so it composes on iOS; web and
// Android keep the same "\n" they rendered before.
hardbreak: (node: ASTNode) => <MarkdownTextSpan key={node.key}>{"\n"}</MarkdownTextSpan>,
softbreak: (node: ASTNode) => <MarkdownTextSpan key={node.key}>{"\n"}</MarkdownTextSpan>,
// Emit the break through MarkdownTextSpan so it composes on iOS. Keep
// the resolved break styles: hardbreak is a full-width flex-row child on
// Android, and dropping that width joins the surrounding text spans.
hardbreak: (
node: ASTNode,
_children: ReactNode[],
_parent: ASTNode[],
styles: MarkdownStyles,
) => (
<MarkdownTextSpan key={node.key} style={styles.hardbreak}>
{"\n"}
</MarkdownTextSpan>
),
softbreak: (
node: ASTNode,
_children: ReactNode[],
_parent: ASTNode[],
styles: MarkdownStyles,
) => (
<MarkdownTextSpan key={node.key} style={styles.softbreak}>
{"\n"}
</MarkdownTextSpan>
),
code_block: (
node: ASTNode,
_children: ReactNode[],