Repository navigation
Convert pasted plain-text Markdown into document blocks - #360
Conversation
|
Hold — please don't merge yet. This adds a paste path through the restricted dialect parser; a security-focused review is in progress. I'll post the verdict here. 🤖 Generated with Claude Code |
|
Review: Changes needed The feature works in a real browser. Headings, lists, code, tables, quotes and tasks land as blocks and sync to the second client. Component tags, 1. A paste can trigger
|
|
Addressed in da4f20e. CI is green.
|
|
Review: Changes needed I re-reviewed da4f20e in a real browser on a fake-GitHub server, with two clients watching the socket for Verified (no
|
| Paste | Markdown | Literal (⇧⌘V) |
|---|---|---|
"**a".repeat(2000) (6 KB) |
1.5 s | 55 ms |
"**a".repeat(4000) (12 KB) |
10.9 s | 170 ms |
"**a".repeat(8000) (24 KB) |
85 s | 0.6 s |
The 128 KB case from your perf test never finished: the tab hung for more than 10 minutes. That test only times looksLikeMarkdown, not the full paste. parse() also slows down quadratically on runs of *: 32 KB of ## h\n plus *a repeated takes 1.3 s on its own. Only the person pasting is affected, but their tab hangs and the paste never reaches the room.
Fix: after parsing, fall back to a plain-text paste when any parent holds more than about 200 phrasing children, or the tree has more than a few thousand nodes. Optionally also cap conversion at about 64 KB so parse() stays well under a second. Add a test that times $pasteMarkdown end to end on "**a".repeat(4000).
Not this PR (for the record)
- A plain-text paste that takes the document past the open-question expiry reserve (
fitsExpiry,source-too-large) is still refused by the server. It behaves the same onmain. - A 128 KB literal paste of
a|repeated took 7.7 s in Lexical. On my fake server the resulting batch was rejected and the server then lost its writer lease and shut down. Both behave the same asmain, but are worth a separate issue.
|
Fixed in 7c97950. CI is green.
|
|
Review: Changes needed I checked 7c97950 in a real browser (fake-GitHub server) and in headless Lexical. The pathological pastes no longer freeze the tab. But the new 2,000-node cap is now too tight for ordinary documents, which defeats the purpose of the feature. Both fixes are small. Fixed
1. Ordinary documents of about 12 KB now paste as raw Markdown (blocking)
A long Claude answer or a README is exactly what this PR is for, and it now comes in as raw 2.
|
|
Fixed in c932cc1. CI is green.
|
|
Hold lifted. Security review passed (no paste can trigger a server batch rejection; projections stay literal), and the final perf items are addressed in c932cc1 (20k node cap, pre-parse emphasis guard, looser timing bounds). CI fully green. 🤖 Generated with Claude Code |
A plain-text paste with clear Markdown syntax is parsed by the dialect with components and single-dollar math turned off, validated, and inserted as blocks. Prose, code, math and table cells, and Shift+Mod+V stay literal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the server's introduced-URL checks, the byte limit, and the document's image and depth limits before converting; keep numbered lists that do not start at one as lines; end lists at unindented prose; make detection linear and skip it above the source limit; recognise Shift+Mod+V on any layout and with Option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lexical inserts inline runs in quadratic time, so a paste over 64K characters, over 2,000 nodes, or with more than 200 children in one block stays literal. Checked on the parsed tree before anything is inserted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Raise the node bound to 20,000; the per-block cap is what prevents the freeze. Take the literal path before parsing when a paste holds more than 4,000 emphasis characters, since the parser is quadratic on lone runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c932cc1 to
3d4855c
Compare
Why
Plain-text Markdown pasted from a terminal or writing tool stayed as literal markers such as
##,**, and fences. Structured HTML paste already converted.What changed
Verification
17 focused paste tests,
bun run types,bun run ci, andbun run buildpass on the restacked branch. GitHub's browser suite will run the Markdown paste scenarios on the final published head.Visuals