Skip to content

perf(mobile): incrementally render Markdown and isolate streaming controls - #574

Merged
huichen merged 3 commits into
mainfrom
claude/mobile-stream-render
Sep 12, 2026
Merged

huichen merged 3 commits into
mainfrom
claude/mobile-stream-render

Conversation

@huichen

@huichen huichen commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a shared streaming Markdown parser that reuses stable top-level nodes and completed GFM table rows, with conservative full-parse fallback for bracket/reference context, replacement, unsupported checkpoints and deep nesting. Finalization always uses the canonical parser.
  • Keep transient fragments out of the settled-document LRU; memoize Mobile Markdown blocks and rows.
  • Separate control/navigation state from transcript updates while preserving useRemote compatibility. Stabilize composer callbacks and avoid redraws for unchanged approval items.

Validation

  • Mobile typecheck + ESLint; 51 suites / 720 tests passed.
  • Desktop typecheck + ESLint + Stylelint; 107 files / 943 tests passed after syncing origin/main. Shared Markdown package typecheck passed.
  • Android and iOS production Expo exports succeeded, including Hermes bytecode generation.
  • 21 Markdown fixtures match canonical parsing at every character prefix; tests cover cache isolation, stable node/row identities, replacements, definitions, finalization and nesting fallback.
  • React tests: 100 text commits do not rerender controls; streaming start/end still do. Composer tests preserve callback updates while suppressing redundant approval-array redraws.

Reproducible workload (not phone FPS)

Initial document plus 100 appends, isolated Windows Node/Vitest run:

  • Prose: canonical input 721,544 chars / 2,337 ms; incremental 12,544 chars / 49 ms.
  • Table: canonical input 516,367 chars / 3,081 ms; incremental 10,598 chars / 74 ms.
    The test gates deterministic parser-work reduction and correctness, not noisy wall-clock ratios. Both paths bypass settled caching. Large single mutable blocks and bracket-bearing documents may still require full parsing. No device/emulator performance or native build claim.

Details: docs/mobile-latency-diagnosis.md. No user services, credentials or model calls were touched.

@huichen
huichen enabled auto-merge (squash) September 12, 2026 08:06
@huichen
huichen merged commit a4c54d4 into main Sep 12, 2026
12 checks passed
@huichen
huichen deleted the claude/mobile-stream-render branch September 12, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant