Native fences were always three characters long, so a copied code block holding a Markdown example closed at its inner fence. The fence now outgrows the longest run of its character in the code. Code block copy uses the same writer and gets the same fix. Web quote copy read the diagram's incoming source while the preview still showed the previous streamed revision. It now copies the revision on screen. Co-authored-by: Pedro Vieira <pedro.vieira@dremio.com> Co-authored-by: Phieu Dinh <phieu@fiu.one>
13 KiB
Markdown rendering
Use MarkdownRenderer for chat replies, file previews, plans, pull requests and changelog content. It uses react-native-enriched-markdown on iOS, Android and web. Keep source adaptation and renderer configuration in components/markdown; consumers supply Markdown and, when needed, its file location.
Native selection belongs to the library's text view. Keep an assistant message in one row so selection can cross paragraphs, headings and lists. Code blocks and tables use the library's native views and their selection behavior. Web uses browser selection over semantic HTML. Once its WASM parser is initialized, the library parses synchronously for the first commit of each mounted row; an empty interim row would corrupt virtualized measurements and move the reader. Chat owns paced reveal, the web render cap, message identity and list measurement. Native renders completed messages together. While streaming, it keeps closed blocks in one head view and updates a separate tail, then reunites the text on completion. See native parsing cost for the boundary and pacing constraints.
Block spacing
Every block is separated by one gap, density.blockGap: 12 on compact layouts, 16 wider. Inside the library's text, every element style ends with that gap and the library drops it after the last block. Views stacked outside the library (Mermaid segments, streaming head and tail) use the same gap through MarkdownBlockStack. Do not give a block type its own margins; change the gap.
Links and images
Workspace file links use the shared file-link resolver. The workspace supplies its client, root and open-file action once; chat can supply the agent's more specific context. URLs use the same link press path. Recognized inline-code paths stay tappable. The library callback carries the tapped occurrence’s syntax context. Preserve it when opening files: explicit Markdown links decode URL escapes, while recognized inline-code paths preserve literal percent characters and use suffix lookup. Identical URL strings in different occurrences must stay distinct. Explicit absolute workspace links receive a relative hover title; existing authored titles remain intact. Inside a workspace, forge references such as #12 and owner/repo#12 are recognized in prose (not code) and open the workspace forge; the reference pattern comes before path recognition so group/project#12 is not read as a path. See forge providers.
Pass external for author-controlled Markdown from outside the host, such as a plugin README. It follows the registry's overview contract in packages/protocol/src/plugin-overview.ts, which the website also uses: only absolute https links and images work, and any other destination renders as its label or alt text. The parser still autolinks bare http://, www. and email text, so a link press checks the URL again and opens only https. None of the workspace recognition above applies, so Node.js is prose, not a file. The lines of a paragraph join, as they do on the README's forge.
Resolve workspace image paths over the existing session RPC, then give the library a cached native file URL or web blob URL. HTTP(S) images pass through unchanged. This preserves relay, SSH and local socket connections, which do not expose a daemon HTTP endpoint. Each mounted renderer owns its image acquisition identity, so a later reply reads a rewritten path again while the earlier mounted reply retains its snapshot. Image taps open the attachment lightbox. File previews resolve relative images against the Markdown file's directory. An image alone on its line becomes its own paragraph before the library sees it, so it renders as a block on every platform; the library only treats sole-child paragraph images as blocks, and with hard soft breaks every newline is a break node, which left own-line images inline on iOS and web. Images that share a line with text stay inline at line height and keep their aspect ratio. A linked image counts as an image, so review-bot badges such as [](url) Confidence stay inline on web; the library's web renderer only checked direct paragraph children, so it rendered them as full-width block images (fixed in the fork).
The fork
The library is a private workspace, packages/react-native-enriched-markdown. It is upstream enriched-markdown at npm 1.2.0-nightly-20261014-766fc0e67 (upstream commit 766fc0e67) plus Paseo's changes, which lived in a patch-package patch until the package moved into the repository. It is never published. Keep the name react-native-enriched-markdown: autolinking, the Gradle project :react-native-enriched-markdown, the CocoaPods spec and app imports all use it.
The package keeps the npm tarball's layout, including its build output:
- Metro, Vitest and TypeScript load
lib/, notsrc/. A JavaScript change editssrc/and the matchinglib/moduleandlib/typescriptfiles. android/generatedandios/generatedare checked-in codegen output (includesGeneratedCode). A change to a native component spec regenerates both;scripts/postinstall-patches.test.mjscompares them against the specs.src/web/wasm/md4c.jsandlib/module/web/wasm/md4c.jsare an Emscripten build ofcpp/md4c. A parser change rebuilds them with upstream'spackages/core/cpp/wasm/build.sh.- Upstream's Gradle, CMake and CocoaPods scripts detect upstream's own monorepo by the paths
packages/coreand a rootvendor/. Do not add either path to this repository. postinstall.mjsdownloads the tree-sitter grammars into the ignoredcpp/highlight/vendor/grammarsandvendor/tree-sitter. Theenriched-markdownblock inpackages/app/package.jsonchooses the languages.
CI does not build native code or run the fork's Robolectric suites. Run npm run test:android --workspace=@getpaseo/app for Android changes. Native changes require a client rebuild; JavaScript refresh cannot enable compiled grammars.
Some fork changes are backports. A sync past the upstream version drops them in favour of upstream's code:
| Fork change | Upstream | Released in |
|---|---|---|
| Android measurements survive parent clones | #924 | after 1.2.0-nightly-20261019-926ef06f0 |
| Android nested list items start their text after their own marker | #1015, #1023 (Android) | 1.2.0 |
Engine constraints
Math and video are disabled. Task lists and admonitions are enabled; task checkboxes are read-only. Source adaptation spaces adjacent empty GFM table delimiters before escaping prose spoiler delimiters and decodes entity text before the engine can discard it. Code spans and fences keep their literal source. Comment HTML is normalized to Markdown before parsing; details show their summary and body expanded.
Mermaid fences use the existing isolated diagram runtime and fullscreen viewer. Web dispatches them through the library’s code-block override. Native has no block-renderer hook, so the renderer extracts only Mermaid fences and places the existing WebView host between library-rendered segments. This is the only block exception; see native selection limitations for diagram grouping and leading inline images. Streaming keeps the last valid diagram visible while the next revision renders.
Code blocks and plain quotes have a copy control in their top trailing corner. Native code blocks use the library's compiled grammars. On native, the code block and quote container views share one control (HeaderCopyButton on Android, ENRMHeaderCopyButton on iOS). A quote reserves the code block's header band above its body, so the control never covers quote text at any font size. On web, code blocks use HighlightedCodeBlock through the library's renderers.codeBlock override, and quotes use WebBlockquote through renderers.blockquote. Both use BlockCopyButton. On compact layouts the control is always visible, so the web quote reserves a band above its body, as native does. On wide layouts the control appears on hover or focus, so the quote keeps a right gutter instead; a band there would leave an empty strip above every quote.
A quote copies its body without the > markers, with its nested Markdown, and reads the content at the time of the press, so a streaming quote copies what it shows. A nested quote or code block keeps its own control. Web quote copy uses the same two clipboard flavors as selection copy: text/plain is unescaped Markdown and text/html is rendered from escaped Markdown. A rendered Mermaid diagram copies as its fence because its wrapper carries the fence source. Native quote copy serializes the quote's parsed Markdown, so a workspace image copies as its cached file URL, as native selection copy does; native has no map back to the workspace path. A native Mermaid diagram in a quote renders outside it (see native selection limitations), so each quote fragment copies only its own text. Admonitions get no control: web renders them with a separate library renderer. Quotes inside list items get no control either, because they render as text spans in the item.
Selection copy has to tell links Paseo recognized in the text (paths, forge references, code spans) from links in the Markdown, so the web link renderer marks the recognized ones. Plain-text paste carries them as the text the reply showed, and rich paste keeps them as links only when they point to an http or https URL. Authored links and parser autolinks such as a bare www.example.com copy as links. The fork also keeps the library's block spacing around the web code block override, preserves web list numbering and link titles, marks pending parses with aria-busy so Find waits for rendered text, and carries link syntax through native and web tap events. Web inline code inside a link inherits only the link colour; its code font, size and background stay intact. Keep link variants colour-only: native pills replace text runs and prevent paths from wrapping; Android pills also use the surrounding block’s font size. Upstream PR #997 tracks these changes.
The fork also keeps overflowing native horizontal blocks in control of their drags: Android claims parent interception at touch-down and releases it for vertical drags so the chat list can scroll; iOS keeps its scroll recognizer active for outward drags at the leading edge. This prevents compact sidebar pans from taking block scrolling without changing sidebar swipes on prose or non-overflowing blocks. Native changes require a client rebuild.
On iOS a newly mounted Markdown view paints empty for a frame or more after it is laid out at its measured height: the library parses even a view's first content on a background queue and applies it in a later main-queue turn. Expanding a turn in chat therefore shows its rows in place with the text arriving a frame later (165 ms when the mount keeps the main thread busy). Android paints the text in the first frame. Rendering a view's first content synchronously fixes the frame but costs frame time when a fling mounts history rows, so the app keeps the library's behavior until enriched-markdown #1131 is resolved.
Android measurements use a size-only, 512-entry LRU across view unmounts, matching the library’s existing iOS cache. Scrolling back through history can reuse layout sizes without parsing those rows again. Content, layout props and width identify each entry; font-scale changes and native layout invalidation discard affected sizes. The cache retains no views or spans.
The library determines how incomplete Markdown appears during streaming. Completed text uses the same component and engine as history. Find and scroll-to-message address source message ids; selection-copy understands semantic HTML and the web code component's copy metadata.
Verification
Follow QA and mobile testing. Exercise chat, file preview, plan and PR content on all three platforms. Include cross-paragraph selection, progressive streaming, a file-link tap, code copy/highlighting, quote copy (nested quote, code block in a quote, admonition, large font on native), a table and a workspace image. On iPad, repeat preview selection after opening and closing Explorer and after rotation. Check web find, selection-copy and source-message navigation after DOM changes.