feat(ios): render inline LaTeX math in completed chat prose#101388
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 1:40 AM ET / 05:40 UTC. Summary PR surface: Other +735. Total +735 across 7 files. Reproducibility: not applicable. this is a feature PR, not a bug report with a failing reproduction. Source inspection shows current main leaves inline math as prose, while the PR adds the completed-prose rendering path and focused regression tests. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land a scoped shared iOS/macOS chat renderer change that renders completed inline math, keeps streaming cheap, preserves Markdown/code/currency literals, bounds SwiftMath parsing/rendering, and carries focused renderer proof. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature PR, not a bug report with a failing reproduction. Source inspection shows current main leaves inline math as prose, while the PR adds the completed-prose rendering path and focused regression tests. Is this the best way to solve the issue? Yes: the PR is an appropriate owner-boundary solution because it extends the shared chat renderer after block segmentation, reuses display-math parse guards, avoids the streaming reveal path, and keeps single-dollar currency text untouched. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cc085da581fa. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Other +735. Total +735 across 7 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Related: #100699
What Problem This Solves
Inline LaTeX (
\(...\)) in assistant responses still rendered as raw TeX after #100829 shipped display math — inline was the declared follow-up because SwiftUI Text runs cannot embed views.Why This Change Was Made
Inline math now renders in completed iOS/macOS chat prose via SwiftMath-rendered images interpolated into
Text(theText(Image(...))concatenation path), with baseline alignment driven by SwiftMath's own display-list descent (MTMathImage/MTMathListDisplay.descent, verified against the dependency source). Delimiters are strictly\(...\)— single-dollar spans stay text (currency). A code-aware scanner (confirmed backtick-run pairing, escape handling) splits prose outside inline code; unclosed or newline-containing spans stay literal, spans are capped (16 per block, 200 bytes each), and every span passes the same parse guards as display math via the shared cache (ASCII-only, nesting/command bounds, unsafe color commands) — anything rejected renders as literal text, never dropped. The streaming boundary is enforced at construction: only completed prose builds inline content, so the streaming reveal pipeline and per-delta costs are untouched. Rendered images are cached (bounded, keyed by latex/size/color) and Dynamic-Type-sized via ScaledMetric.User Impact
Inline formulas in finished messages render as proper math on iOS and macOS; streaming text, code spans, currency amounts, and malformed spans are unaffected.
Evidence
xcodebuild build-for-testinggreen; inline-math transcript case added to the render smoke suite; SwiftMath image/baseline APIs cited from the checked-out dependency source.swiftformat --lintclean on touched files; i18n inventory unchanged; structured review (codex) clean.