Skip to content

fix: avoid redundant direction writes in large previews - #197

Merged
mattenarle10 merged 1 commit into
mainfrom
fix/195-preview-direction
Nov 10, 2026
Merged

mattenarle10 merged 1 commit into
mainfrom
fix/195-preview-direction

Conversation

@mattenarle10

Copy link
Copy Markdown
Owner

Large chat exports stall while the preview writes dir on every top-level block. Let LTR-only blocks inherit automatic direction when safe, while retaining native per-block detection for RTL text, explicit direction settings, and detached PDF exports.

Fixes #195. Thanks to @zenbao for the detailed report and measurements.

Validation:

  • bun test: 113 tests pass.
  • bun run build: TypeScript and production build pass.
  • 121 comparisons in each of WKWebView and Chrome match the original directions, element bounds, and text positions, including mixed scripts, direction changes, technical content, and detached export.
  • On a synthetic 4.7 MB / 10,200-block document, median DOM insertion through layout improved from 1,145 ms to 64 ms in WKWebView and 487 ms to 222 ms in Chrome. These timings exclude Markdown parsing and the rest of the app.

The separate full-document rerendering cost remains outside this fix.

Let LTR prose inherit automatic direction when safe, while retaining native per-block detection for RTL text and detached PDF export. Cover mixed scripts, direction changes, technical content, and large-document attribute writes.

Fixes #195.
@mattenarle10
mattenarle10 merged commit 73ebad9 into main Nov 10, 2026
2 checks passed
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.

Preview blocks the main thread ~600 ms on a 4 MB markdown file (dir written on every block)

1 participant