镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

feat(mobile): render messages with gpt_markdown 1.3.4 plusparse - #8945

Draft
brow wants to merge 3 commits into
mainfrom
gpt-markdown-1.3.4
Draft

brow wants to merge 3 commits into
mainfrom
gpt-markdown-1.3.4

Conversation

@brow

@brow brow commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Message Markdown on mobile moves from gpt_markdown 1.2.1's legacy regex pipeline to the CommonMark parser that 1.3 added ("plusparse"). Before this, passing inlineComponents (now deprecated, removed in 2.0.0) kept every message on the legacy pipeline.

What changes for users

Rendering moves closer to desktop (react-markdown + remark-gfm):

  • _italic_ and __bold__ work, backslash escapes and HTML entities decode, and [a [b] c](url) labels are correct.
  • Inline code follows CommonMark pairing: "```npm install```" in a sentence is inline code, and four-backtick fences work.
  • Setext headings, reference links, footnotes, ~~~ fences, 1) lists and CommonMark list/quote continuation render.
  • HTML comments are hidden, as on desktop.
  • \[, \], \( and \) stay literal, as on desktop. Plusparse hard-codes them as LaTeX delimiters, so they're written as entities before rendering.
  • Side effect: an unfenced __init__ now renders as bold "init", and a line over --- becomes a heading, same as desktop.

Device benchmark (iPhone SE, profile build, 600 synthetic messages, 3 launches per build): scrolling spends 9% less time building, and frames with more than 8 ms of build drop from 63 to 22. Jumping onto unbuilt messages is 11% cheaper, and raster time is unchanged.

App size: the release app grows about 4.6 MB uncompressed (80.6 to 85.2 MB), mostly Dart code from the new math and highlighting packages.

Before and after

Synthetic messages that reproduce differences found in real channel history, rendered through MessageContent on main and on this branch:

01-escaped-brackets-in-code

02-inline-triple-backticks

03-four-backtick-fence

04-entities

05-stars-and-underscores

06-ordered-list-paren

07-setext-heading

08-dunder

How

  • Mentions, custom emoji and #channel tokens are InlinePatterns. Links go through inlineLinkBuilder into the existing _buildLink, so chips, media links and taps are unchanged.

  • Removed workarounds the parser makes unnecessary:

    Plain-text previews and gallery helpers keep their own escape handling. normalizeBareLinks stays because attachment and gallery detection depend on its output. Bubble segmentation unescapes a link destination itself before its imeta lookup, since content no longer arrives shielded.

  • Kept desktop parity where plusparse differs from GFM:

    • a table typed directly under a caption line gets a blank line inserted before it, since plusparse can't start a table mid-paragraph
    • > [!NOTE] quotes render as quotes (alertBuilder returns asBlockQuote()), since desktop has no alerts
  • mapMarkdownProse now ends an unclosed backtick run at its paragraph. Before, it could pair with a run in a later block and flip code and prose for the rest of the message.

  • Synthesized autolink labels escape backslashes instead of using \, which the parser leaves undecoded in a URL-shaped label.

  • Repo/PR/issue chips keep their own semantics node.

  • Forum card previews clip at their 120 px cap instead of overflowing: blocks now lay out as a column.

  • Pinned to exactly 1.3.4. 1.4.0 renders HTML by default and themes through the separate material_ui package, which would need a theme bridge.

Validation

  • Full mobile suite passes and analyze is clean at 78b9c1a.
  • All of fix(mobile): render Markdown backslash escapes #8925's and fix(mobile): split escaped voice-note links into their own segment #8940's backslash-escape cases pass on the new parser, including the strike-across-lines case that used to be a known limitation.
  • Real-message diff: 2,259 recent messages from 13 busy channels, rendered through MessageContent on main and on this branch. 29 differed in text or styling. On inline and fenced code, the branch matched desktop's parser (remark-gfm) in 23 of them and main in 7. The review found the three parity gaps above, now fixed. The rest are CommonMark behavior that desktop shares.
  • Added tests, each confirmed to fail without its fix:
    • a leading #channel renders as a link, not a heading
    • a table under its caption renders as a table
    • an alert-marker quote stays a quote
    • an unclosed backtick run doesn't flip later code
    • the transcript tests detect a rendered link by its style; the old LinkButton check passed even with autolink on
  • Automated simulator run (iPhone 17 Pro, iOS 27, debug build, signed in to a Builderlab community): channel list, two channels with history scrolled back several pages (mentions, link previews, thread summaries, images), an agent Solo chat with long agent messages, and the inbox. No rendering errors or layout breaks; the Solo chat screen also matched main's build side by side.

Before merge

  • Merge at a risk-appropriate time in the mobile release cycle, agreed with Tom.

🤖 Generated with Claude Code

@brow

brow commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T22:02:05.390637Z 45f75bf Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6394cd2a1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

textAlign: textAlign,
maxLines: maxLines,
inlineComponents: inlineComponents,
inlinePatterns: inlinePatterns,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle reference-style images in attachment preprocessing

When a bubbled message uses newly supported reference-style media such as ![shot][1]\n\n[1]: https://example.com/shot.png, this plusparse path resolves it and invokes imageBuilder, but messageBubbleSegments() and extractTrailingImageGallery() still recognize only inline ![...](...) syntax. The image therefore remains inside the text bubble instead of receiving attachment corners, and multiple trailing reference images do not form a gallery; resolve reference definitions before classifying attachments or extend both preprocessors to understand this syntax.

Useful? React with 👍 / 👎.

@brow
brow force-pushed the gpt-markdown-1.3.4 branch from 6394cd2 to 78b9c1a Compare November 2, 2026 19:36
brow pushed a commit that referenced this pull request Nov 2, 2026
@brow

brow commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78b9c1a6d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

square-tomb and others added 3 commits November 4, 2026 13:50
Move message Markdown off the legacy regex pipeline, which the deprecated
inlineComponents API forced, onto the CommonMark parser that 1.3 added.
Mentions, custom emoji and #channel tokens become InlinePatterns; links go
through inlineLinkBuilder into the existing _buildLink.

Drop workarounds the new parser makes unnecessary: the escape shielding in
the render path and the _MarkdownEscapeMd, _MarkdownLabelEntityMd and
_MessageLinkMd components, plus the zero-width prefix before a leading
handling.

Keep \[ \] \( \) literal, as on desktop: plusparse hard-codes them as LaTeX
delimiters, so they are written as entities before rendering. Synthesized
autolink labels escape backslashes instead of using an entity, which the
parser leaves undecoded in a URL-shaped label.

Keep non-interactive repo/PR/issue chips as their own semantics node, and
clip forum card previews instead of overflowing now that blocks lay out as
a column.

Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
A real-message diff against desktop's parser found three differences:

- A table typed directly under a caption line showed raw pipes. GFM lets
  a table interrupt a paragraph; plusparse doesn't, so a blank line is
  inserted before such a table.
- `> [!NOTE]` quotes became alerts. Desktop has no alerts, so they stay
  quotes.
- An unclosed backtick run paired with a run in a later block, flipping
  later code and prose, so math-delimiter escapes leaked into code as
  entities. A code span now ends with its paragraph.

Bubble segmentation now unescapes a link destination itself before the
imeta lookup, since content no longer arrives shielded (#8940 relied on
that). Also pins gpt_markdown to exactly 1.3.4.

Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
A block quote interrupts a paragraph, so an unmatched backtick must not
pair with one inside a quote that follows it. Otherwise the quoted bare
URL skipped normalization and rendered as non-clickable text. Quoted code
spans that continue on the next line at the same depth are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
@brow
brow force-pushed the gpt-markdown-1.3.4 branch from 78b9c1a to 45f75bf Compare November 4, 2026 21:57
@brow

brow commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 45f75bf51c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// stand-ins that _MarkdownEscapeMd and the link builders restore.
final markdownContent = useMemoized(
() => shieldMarkdownProseEscapes(galleryText),
() => separateMarkdownTables(escapeMarkdownMathDelimiters(galleryText)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve reference-definition destinations before plusparse

When a newly supported reference link has a normal HTTP definition such as [docs][1]\n\n[1]: https://example.com/docs, the earlier normalizeBareLinks(content) call rewrites the definition destination into [https://example.com/docs](https://example.com/docs) before this plusparse pipeline receives it. The reference consequently resolves to that synthetic Markdown string rather than the HTTP URL, so _buildLink does not open it; exclude reference-definition destinations from bare-link normalization before enabling reference-style parsing.

Useful? React with 👍 / 👎.

Comment on lines +220 to +222
final _paragraphBreak = RegExp(
r'[ \t]*(?:$|[-*+][ \t]|\d{1,9}[.)][ \t]|#{1,6}(?:[ \t]|$)|`{3}|~{3})',
multiLine: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize setext underlines as paragraph boundaries

When an unmatched backtick precedes a setext underline, this expression does not treat --- or === as the end of the paragraph. For example, title \n---\nhttps://example.com code`` pairs the title's backtick with the one in the later paragraph, causing normalizeBareLinksto skip that URL; plusparse then renders the heading and later paragraph separately, andautolink: false` leaves the URL non-clickable. Add setext/thematic-break lines to the paragraph terminators.

Useful? React with 👍 / 👎.

@brow brow added the parked Not being shepherded toward review or merge; sweeps skip it label Nov 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parked Not being shepherded toward review or merge; sweeps skip it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants