Repository navigation
Description
The draft editor's bugs reach us one at a time, from the user's own captures and from reviews, though a generated draft and a few keys reproduce each of them. A seeded fuzzer would find them before the user does: it generates Markdown drafts and key sequences, runs them against the real field, and reports any step that breaks a property the editor promises.
Why now. In one afternoon on #7076, which shows every blank line in a draft's editor, three sources found editor bugs that the hand-written tests missed:
- The user's capture: Return on the blank line under a paragraph joined the next paragraph, and each later Return wrote a hard break, so the saved draft held
o\and three lines of\. - Three Codex reviews of that PR: saving deleted a link's definition between two paragraphs, so the link became literal text; Return before a bold first word put a hard break inside the
**; Return in an empty link looped until the stack overflowed. Two it found are still open: Return before the first visible character of a code span padded with spaces (` Alpha `) or of an escaped character (**\*Hello**) breaks the line inside the markup, and in a row such as| \| | \| |a click on the second cell can place the caret in the first. - A seeded property test the PR added (1,500 generated drafts,
tests/runtime/field-editor.test.mjs), which found two more in its first run: an empty list item followed by two blank lines ends its list, so saving one blank line in their place joined two lists; and the editor's reading threw on any table after a quote or list item (>\n| a |\n| - |).
An agent that used the editor for twenty minutes, looking for surprises, found eight more, none of them new in #7076. Each reproduces in Chromium and Firefox:
- Return then Backspace inside a paragraph leaves a stray
\(Alpha\one two.). - Typing on the one blank line between two paragraphs joins all three into one paragraph.
- Backspace at the start of a code block's first line moves that line into the fence's language name.
- Double-clicking the first word of
**bold words**selects the**, and typing over it leaves a literal**. - Home on a heading goes before its hidden
#, so typed words turn the heading into a paragraph. - Return at the start of a heading's words moves them out of the heading.
- Backspace or Delete at a block's edge turns its marker into shown text:
#Title,-second item,Before quote.> Quoted. - Pasting two paragraphs at the end of a quote leaves the second outside it, and pasting two lines at the end of a list item joins the first to the item.
Most of these share one cause: a key acts on the hidden source characters (\, # , - , > , a fence line) as plain text, while the user sees only the construct they draw. Fixing that cause is a design question for its own issue; this one is about finding such cases.
Oracles. Each is a property that needs no expected output written by hand:
- No exception from the editor's reading or a command.
- Undo after each step restores the value before it, exactly.
- What saving writes renders as the editor's value renders, and saving it again changes nothing.
- One typed character changes the shown text of one block, by that character.
- A key never turns a marker the display hides into words it shows, unless the key typed that character.
- Opening a saved draft moves no word from where the display drew it (browser only).
Where it runs. The Node harness in tests/runtime/field-editor.test.mjs (draftField) drives the field's own commands with no layout, in milliseconds per case, which covers the first five oracles. Layout and the browser's own editing (double-click, paste, Home) need Playwright in Chromium and Firefox, slower and best run nightly with a fixed budget. A failing seed prints its draft and keys, shrunk to the fewest lines and keys that still fail.
Precedent. #4738 compared 1,426 generated drafts, line by line, with the messages they sent, and found the composer's preview drawing many of them differently. It ran once, so nothing catches the next such difference.
Unconfirmed. Nobody has measured how often the fourth and fifth oracles report a case that is fine, such as a key that rightly joins two blocks. Start with the first three, which have no such cases, and add the others once a run shows what they report.
This was written by Claude Code on behalf of max-sixty
Activity
Have keys at a draft's markup act on the blocks it shows, and fuzz th…