Skip to content

Make the composer's draft look like the message it sends, with less of our own Markdown handling - #4738

Merged
max-sixty merged 44 commits into
mainfrom
textbox-markdown-explore
Oct 31, 2026
Merged

max-sixty merged 44 commits into
mainfrom
textbox-markdown-explore

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

A browser exploration of the composer's live preview (seven agents, about 600 typed attempts, and 1,426 generated drafts compared line by line with the sent message) found the preview drawing many drafts differently from what was sent. Multi-line > quotes and ``` fences were the cases that surprised in use. This branch fixes those, makes Shift+Enter read the draft the same way the preview and the message do, and narrows the dialect where CommonMark only surprised.

What changes for a writer

  • Nested quotes, code in a quote, lists in a quote are drawn as the message nests them. Quotes and list items are now CodeMirror BlockWrapper boxes around their lines, as blockquote and li are in the message, rather than per-line classes that CodeMirror merged into one level.
  • An open fence draws the line being typed inside its code box, so it no longer jumps in on the first key.
  • Shift+Enter continues each quote's > and each item's indent from the preview's markdown-it reading, fences included. It leaves a list or quote on the second press on an empty line, outdents an empty nested item to the outer list, and continues task items as - [ ] . CodeMirror's own Markdown parser no longer runs in the composer.
  • Constructs the preview left as source are drawn: a --- rule, entities, a hidden trailing \, hidden leading spaces, and task checkboxes. Tabs are 8 wide in both draft and message. Up and Down reach every line, including the short blank lines in a gap of a draft edited in place, and keep their column through code.
  • A rule and a code fence take full lines in the draft, the sent message and page prose, so revealing their source under the caret moves nothing (browser/AGENTS.md, "Stability"); before, the composer jumped 20px at a rule and 12px at each fence line. A rule is one line tall with its stroke through the middle, at the same place as before; a code block has a code line above and below its code, which gives every code block 8px more room above its code. The caret-dependent shortening of those lines is deleted.
  • Every composer that holds lines shows the new-line key while focused and empty, for example Reply ⏎ · New line ⇧⏎, since Enter keeps sending. In a narrow box the label shortens first; the hint goes only when even a 4em label can't fit. An empty field now keeps its actions' room, so no placeholder runs under the mic or Send.
  • Setext headings and indented code blocks are off, in markdown.js and passages.py. A --- under a line is a rule, and leading spaces are text. Neither construct appears in the 2,579 messages and 17 drafts in local saved pages.
  • Fixes:
    • A bare URL right after a backtick, ~ or a CJK letter no longer crashes the preview for the rest of the draft.
    • In Firefox, typing over a selection that crosses formatting replaces it. Gecko left the selection in place inside a shadow root.
    • A * bullet no longer has its emphasis placed on it.
    • Words the parser kept verbatim are placed directly instead of aligned, about 330 → 190 ms per key on a pasted 3,000-line draft.

Where to look

  • browser/runtime/composing/field-editor.js holds the block boxes in decorate, continueBlocks for Shift+Enter, the arrow binding for skipped lines, and the exported DRAWN set.
  • browser/runtime/markdown.js changes the dialect, adds the verbatim fast path, and starts alignment past container markers. build/vendor.mjs records an item's content indent (meta.indent) and exports BlockWrapper.
  • tests/runtime/markdown-preview.test.mjs is a guard that fails when the renderer enables a rule the preview neither draws nor lists as kept as source (tables, reference definitions).
  • browser/styles/components/response.css keeps Experiment: give a draft's words Send's column under a mouse, with Send in the corner they leave free #4714's Send-in-the-corner rules to fields that hold lines. They also reached the one-line "Add another option" field and dropped its Add 16px below its key badge, which test_the_draft_binding_badge_and_send_press_share_the_row_end has caught on main since Experiment: give a draft's words Send's column under a mouse, with Send in the corner they leave free #4714.
  • browser/styles/floating-panel.css scopes the panel's separator style to its own .lf-fp-rule, so it no longer reaches a rule inside a message.

Testing

Each change was used cold in Chromium and Firefox by an independent reviewer before code review, over seven rounds; every finding is fixed with a test that failed before its fix. pnpm run test:runtime passes 703/703, and the focused browser tests in test_chrome_contracts.py, drafts/test_composer.py, drafts/test_draft_editing.py and test_render_floating_panel.py pass. The broad suite runs in this PR's checks.

Known and left open

  • The quote markers' reveal swaps a mark class, which CodeMirror applies as an unchanged child write. That predates this branch.
  • Right-to-left text and Tab indenting list items are unchanged.

This was written by Claude Code on behalf of max-sixty

…JK letter

Typing a URL straight after a backtick, `~`, `=`, `|`, `^`, `€` or a non-ASCII
letter (`` `https://… ``, `参见https://…`) threw in the source-position wrapper,
and CodeMirror disabled the composer's preview for the rest of the draft, even
after the field was cleared. The wrapper found the link's start by matching the
words again with linkify-it, whose search won't start a link after those
characters, though markdown-it's inline rule does. The start now comes from the
words the rule itself left pending.
In Firefox, typing over a selection that crossed a preview decoration's element
(bold, inline code, a quote or heading marker) inserted the words beside the
selection and kept the selected words: `aa **bold** zz`, select all, type X gave
`Xaa **bold** zz`. Gecko leaves the DOM unchanged under such a selection inside
a shadow root, and CodeMirror reads its edit from that DOM. The field now
handles insertText over a non-empty selection itself, as a transaction, in
every engine that sends beforeinput for it.
… nests them

The composer's preview put a class on every line of a quote, which CodeMirror
merged, so a quote inside a quote drew one rule at one inset and a lazy line
looked back at the first level; a code block in a quote replaced the quote's
rule and inset with its own frame. Quotes and list items are now CodeMirror
block wrappers around their lines, as the message's blockquote and li are, so
each level draws its own rule and inset and code stands inside its quote. An
item's inset is its box's margin, so the platform's bullet stands outside a
quote the item holds. This reverses the recorded per-line approach; the
rejected alternatives are now recorded at `box` in field-editor.js.

The source markers that open a line (`>`, `-`, `1.`) stand in one run that
takes no room, each as wide as its container's rule and inset, so a revealed
`>` stands in its own level's inset and revealing moves no word. A field that
edits in place now gives every quote level its display's inset, through the
`--quote-inset` token, rather than the outermost only.

Indented code in a quote hides its four spaces after the quote's markers, not
from the line start. A fence its container ends, with no closing line, takes
the code's bottom padding on its last line, so sending no longer raises the
next block by 8px. An unclosed fence outside any container takes the draft's
empty last line, so a new line typed into an open fence is drawn in its code
box from the start instead of jumping in on the first key.

The CodeMirror bundle now exports BlockWrapper.
…lists in quotes

A blank last line, where the next words will be typed, is now read with a word on
it, so it stands in whichever block those words will join. The preview had drawn
it from the reading of the draft alone, which stops short of it: in a fence that
a list item held, the caret's line stood below the code's frame and outside the
item, then jumped in on the first key. This replaces `codeEnd`, which covered
only an unclosed fence outside any container. A blank line a quote or list item
would continue lazily now stands in that container, and the trailing-gap rule
for drafts edited in place, which the reading now covers, is removed.

Code counts its lines from its reading's own breaks, so the last line of a fence
the draft's end ends hides its item's indent too, as the message drops it.

A list inside a quote now draws its bullets or numbers, as the message does. Its
items are boxes inside the quote's box with their markers in the line's marker
run; the special case that kept their source markers, whose reason was that the
platform's marker could not stand on a quoted line, is gone. Each container's
indent on an item's later line is hidden after the markers of the containers
outside it.

A container a line stands in without a marker, as a quote's lazy line and an
item's later line do, keeps its inset in the marker run, so a revealed `>` on a
lazy line stands in its own quote's inset rather than on the inner quote's rule.

In a field that edits in place, a quote's own trailing `>` lines are its lines,
so its bottom padding lands on its last line, not one line early.
a13e9d3 counted a quote's trailing `>` lines as its own, so the in-place
editor's last quote line took the quote's bottom padding. The sent message draws
nothing for such a line, so in a draft edited in place the editor grew the quote
by a line and everything below it moved ~27px on opening. The line stands in the
gap again; the draft-faces test now holds a quote ending in `>`.
# Conflicts:
#	dist/kernel/kernel.json
# Conflicts:
#	dist/kernel/kernel.json
A `---` or `===` line under text turned it into a heading (it flashed while
typing a list's `-` under a line), and four leading spaces turned a line into
code. The preview could only reproduce those surprises. Neither construct
appears in the 2,579 messages and 17 drafts in the saved pages. Both renderers,
markdown.js and passages.py, now disable `lheading` and `code`: `---` under a line
is a rule, leading spaces are text, and a fence is the one way to write code.
The preview's Setext rule line and indented-code branches go with them.

Tests: the dialect test now expects a rule after `Heading`; the block-marker test
drops its Setext case; the preloaded-body test keeps its leading spaces in a
fence; the draft-faces fixture uses an ATX heading; the nesting test drops
indented code in a quote. test_a_draft_draws_a_list_as_the_message_will reads an
item's marker from its box, which 1a74647 moved there, and puts the caret at
the line's start with Home, since ArrowDown now lands after the markers. The
write watch drops its exemption for list-item lines, which no longer exist.
Shift+Enter in a composer now reads the containers around the caret from the
markdown-it tokens the live preview already holds, so a new line continues
exactly the quotes and list items the sent message will hold. CodeMirror's
Markdown language and its insertNewlineContinueMarkup leave the field.

Behavior changes:
- A line in a fence inside a quote or item keeps its `> ` or indent, so the
  code no longer falls out and the closing fence no longer opens a new fence.
- A second Shift+Enter on an empty item or `>` line leaves the innermost
  container (`- a` ⇧⏎ ⇧⏎ `b` gives `- a\n\nb`); it took three presses, the
  second only making the list loose.
- Splitting an item mid-words keeps the space before the caret on the first
  line; the old command trimmed it. The message reads the same.
- Items after a new numbered one keep their typed numbers, as the message
  numbers a list from its first.

markdown-it's list rule now records each item's content indent past its
container's (`meta.indent`), which later lines carry.

Per key on a pasted 3,000-line draft (Chromium, loaded host, 3 interleaved
rounds of 10 keys): keydown 112 ms -> 72 ms median; the Lezer parse that took
~42 ms of each is gone. The vendored CodeMirror bundle drops 4,125 bytes
(1,507 gzip); the file editor still imports markdownLanguage, so
@codemirror/lang-markdown and @lezer/markdown stay.
…h the editor

Shift+Enter on an empty item directly inside another item now turns its line
into the next item of the outer list (`- a\n  - b\n  - ` gives
`- a\n  - b\n- `), as Google Docs, Notion and Obsidian do. Leaving the
outermost list or a quote is unchanged.

The field's editor now waits for markdown-it beside CodeMirror. The preview
started loading the renderer only once the editor built, so a Shift+Enter
pressed as a field first opened found no reading and inserted a plain line;
the browser test hit it in Chromium on a loaded host.
The composer's preview drew only the constructs `decorate` had a branch for, so
five that the sent message renders stayed as source in the draft:

- A thematic break (`---`, `***`, `- - -`) is now drawn as the message's rule:
  the line collapses to a 1px stroke while the caret is away from it, and shows
  its dimmed source at full line height while the caret is on it.
  `placedMarkdownTokens` now places every block leaf (`hr` as well as `fence`),
  and `FACE_PROBE` includes `<hr>`, so a field that edits in place spaces a rule
  as its display does.
- An entity (`&amp;`, `&copy;`, `&#123;`) is drawn as the character it names.
  Placed tokens now carry `spelled` spans (`[from, to, shown]`) in place of
  `escapes`. One loop in `decorate` handles escapes, entities and a break's
  backslash.
- A backslash hard break hides its backslash.
- The spaces at the start of a paragraph or heading line, and before a quote's
  `>`, are hidden, because the message drops them. Like an item's continuation
  indent, they are never revealed, so the words don't jump as the caret
  arrives.
- A task item's `[ ]` or `[x]` is drawn as the message's disabled checkbox. The
  plugin's checkbox token now gets the brackets' source span.

`DRAWN` in field-editor.js is the list of token types the preview draws.
`decorate` skips every other type, so the list is the one place that says what
is drawn. tests/runtime/markdown-preview.test.mjs checks every rule that
`makeMarkdown` enables (core, block, inline and inline2) against that list. A
rule passes if the preview draws every token type it emits, or if the test
lists it as kept as typed with a reason: tables, reference definitions, and the
html and typographer rules, which are off. The test fails on an enabled rule
neither list names, such as Setext headings turned back on, and on an entry for
a rule that isn't enabled.

In the floating panel, the separator rule for the panel's own menus also matched
an `hr` inside a sent message, which gave the message's rule 4px margins it has
nowhere else. The rule now skips message bodies, so a rule in a message reads
the same in the panel as in any thread.

The body-text runtime test now checks `spelled` spans and the task box's
source in place of `escapes`. The new browser test checks that the draft shows
the same words as the sent message, with each word at the same position.
After leaving a list inside a quote, Shift+Enter on the bare `> ` line did
nothing: markdown-it counts the blank lines after a list item as the item's,
so the line read as still inside it, and leaving the item rewrote the line as
it stood. Three changes fix it at the reading:

- The preview reads a last line holding nothing past its `>` markers with a
  word on it, as it already did a whitespace-only one, so the line stands in
  the quote the next words join. This also stops the caret line drawing inside
  the item and jumping left on the first key.
- Shift+Enter takes an item to end at its last block, or its last nested
  item's marker line, so a bare line mid-quote after a list is not the item's.
- Leaving a container whose parting blank line is already above turns that
  line into the outer containers' blank too: `> - a` ⇧⏎ ⇧⏎ ⇧⏎ `x` gives
  `> - a\n\nx`. A press that would leave the line as it stands inserts a
  plain line instead, so Shift+Enter always changes the draft.

Task items continue as open tasks again (`- [ ] a` ⇧⏎ gives `- [ ] `, and so
does `- [x] a`), read from the task-list-item class markdown-it-task-lists
puts on the item. An item holding only that checkbox counts as empty, so a
second press leaves the list.
Review fixes for the draft's preview of rules, tabs and task boxes:

- Up and Down now step onto a rule's line. While the caret is away, the line is
  1px tall, and the 1px is its border. CodeMirror's vertical motion aims half a
  line of text past the caret's line, so it passed over the rule in Chromium
  and Firefox. The preview binds Up and Down (with and without Shift) at high
  precedence. When CodeMirror's own step leaves the caret's line and the line
  beside it is shorter than a line of text, the caret goes to that line at its
  column instead, and the line then shows at full height. All other moves are
  CodeMirror's own.
- A rule inside a list item is 1px tall, as in the message. The item's hidden
  indent on the rule's line was a replaced range, which held the line at a
  line's height (15px). A rule the caret is away from now leaves its leading
  spaces unseen with the rest of its source.
- A tab is 8 columns wide in the draft, as it is in the sent message
  (CodeMirror's default is 4), so code with tabs no longer sits 24 to 32px off.
- A press on a task's box now puts the caret in its brackets, which then show.
  In Chromium the disabled box took the press and nothing happened. The box
  now takes no pointer events.
- The panel's own `<hr>`s carry `lf-fp-rule`, and the panel's separator style
  targets that class. Previously it targeted every `hr` except one inside a
  message body.

The draft-versus-message browser test now also covers a rule inside a list
item, a tab in fenced code, and a press on a task's box. A new test,
parametrized over both engines, checks that the arrows step onto a rule with
and without blank lines around it.
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-disclosure.js
# Conflicts:
#	dist/kernel/kernel.json
The editor's reading aligned every inline token's text against its block's source,
about 300 ms per key on a pasted 3,000-line draft. When a block ends with its words
exactly as typed, each word now sits where it was typed, and only blocks whose words
the parser rewrote (container prefixes on later lines, table cells) are aligned:
~190 ms on the same draft, and the same placement on 3,100 test and harness drafts
except one the old alignment got wrong.

Alignment now also starts past the quote and list markers on the words' first line.
It matched a `*` bullet to the emphasis after it, so `* *e*` placed the emphasis on
the bullet and the preview hid or dimmed the bullet with its marks.
The Up/Down binding stepped in whenever CodeMirror's step left the caret's line
for a line shorter than a line of text. It then placed the caret by the
character column it carried. Code lines (20px against 21px for prose) passed
that height test by accident, and a blank line resets the character column to
0. So Up through a fence and its code dropped the caret to column 0 on every
fence and code line, in Chromium and Firefox.

The binding now steps in only when CodeMirror's own step passed over the line
beside the caret's: the step lands outside both the caret's line and that
neighbouring line. In that case it places the caret on the neighbouring line
at the goal column CodeMirror aimed for. It finds that position with
`posAtCoords` at the middle of the line in CodeMirror's height map, so a rule's
1px line is found even though that pixel is its border. Every other step is
CodeMirror's own, so the goal column carries through code, tabs included.

A new browser test runs Up through a fence and its code from column 0 and
column 14 of the last line, in both engines. It checks that every line is
visited and that, on each line long enough, the caret stays within a
character of the starting x. The column-14 case failed on the previous
binding (code line at x 11 against a goal of 87). The task-box press in the
draft test now waits for the box to hold still and checks the field is under
the pointer: under load the press could land while the panel was still
settling, outside the field, and put the reply away.
# Conflicts:
#	dist/kernel/kernel.json
# Conflicts:
#	browser/runtime/floating-panel.js
#	dist/kernel/kernel.json
#	dist/kernel/leaf.js
# Conflicts:
#	browser/runtime/floating-panel.js
#	dist/kernel/kernel.json
#	dist/kernel/leaf.js

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule preview introduces a layout shift on caret movement that needs resolving before approval. Although the description acknowledges it, browser/AGENTS.md, Stability, requires that “A reveal on hover, focus or a key never changes the size or position of its ancestors or siblings.” This is an ordinary editing path, with no text change to explain the reflow.

# Conflicts:
#	dist/kernel/kernel.json
Return sends a comment, and only Send's tooltip said that Shift+Return
breaks a line, so writers sent half a comment, such as an opened fence,
on their first Return. Every focused, empty box that holds lines now
reads its label, its send key, then "· New line ⇧⏎" in a key badge,
with the same words in its placeholder attribute; Send's tooltip reads
"Send (⏎) · New line (⇧⏎)" from the same constant. A one-line field,
such as Add another option, and any box under a finger keep their hint
unchanged, since Return there never makes a line.

The panel's field, focused, used to show only where the words go and no
key. It now shows the send key and the new-line key like every other
box, dim as before; its other readings still hide keys.

Where the box is too narrow, the new-line hint drops whole before the
label shortens: it takes only the room the label and send key leave,
and wraps onto a line the placeholder doesn't show, so a narrow box
reads as it did before. The panel's turn rule and two tests named the
label by position; they name it by class now.

stills gains the panel reply, a message rewrite and the one-line option
field, empty and focused.
… actions

A narrow composer now follows one rule: its label shortens first, down to
4em, and the send key and "· New line ⇧⏎" stay; only where even that
shortened label can't stand beside them does the hint go, whole, and the
label takes its room back. Before, the hint went first, so at 320 px the
panel's page comment dropped it while the passage composer kept it. Now
the page comment reads "Comment on … ⏎ · New line ⇧⏎" there; the panel's
thread reply and a seat's box at 320 px still leave too little room and
show their label and send key.

Under a mouse an empty composer whose actions stand in its corner, such
as a seat's or a margin card's reply, ran its placeholder the whole line
under them, so at 320 px a seat's send key stood on Dictate (Send in
Firefox). Its empty field now keeps its actions' room, as the passage
composer's does for Other responses; the first word takes it back.

The previous commit folded test_markdown_decoration_keeps_source_editable
into the new hint test by dropping its def line; it stands on its own
again. The hint test now also reads what the placeholder shows part by
part, and a new test at 320 px checks the panel's page comment shortens
its label and keeps both keys and that neither it nor a seat's box puts a
shown part on an action.
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
# Conflicts:
#	dist/kernel/kernel.json
@max-sixty
max-sixty merged commit 3002a52 into main Oct 31, 2026
1 check passed
@max-sixty
max-sixty deleted the textbox-markdown-explore branch October 31, 2026 22:58
max-sixty added a commit that referenced this pull request Oct 31, 2026
…ab (#4871)

In a composer, Tab now nests the list item the caret is in under the
item above, and ⇧Tab takes it out a level. Today Tab leaves the field,
so a nested item has to be typed as spaces. The maintainer chose this on
the composer exploration page, after #4738.

### Behaviour

- `- one` ⇧⏎ ⇥ `two` gives `- one\n - two`. The nested marker stands
where the words of the item above start: 2 columns under `- `, 3 under
`1. `. The preview draws the nested bullet as soon as Tab is pressed.
- ⇧Tab moves the item to its parent's column, with the parent list's
next marker. Items after it in its old list stay where they are, so they
are now nested under it, as in Google Docs.
- Numbered items: one that starts a new nested list becomes `1.`; one
that joins an existing nested list takes that list's next number. Task
items keep their `[ ]`. Lines in a quote keep their `>`. An item's later
lines and nested items move with it, and a selection spanning items
moves them together. One press is one undo step.
- Outside a list item, Tab and ⇧Tab move focus as before. Tab from the
panel's field still opens Other responses.
- At the edges: Tab on the first item of a list does nothing and keeps
focus, as in Docs and Notion. ⇧Tab on a top-level item moves focus back,
so a draft that is all list can still be left by keyboard.
- Touch has no Tab. Typing the spaces still nests an item.

### Where to look

- `browser/runtime/composing/field-editor.js`: `nestItems` reads the
list from the same markdown-it reading (`placedMarkdownTokens`) the
preview and Shift+Enter use, so there is no second list parser.
`itemEnd` is now shared with `continueBlocks`. The draft's reading also
treats a last line holding only list markers as holding a word.
Otherwise a new empty nested item would read, as CommonMark has it, as
words of the paragraph above, and the preview would show a literal `-`
until words were typed.
- `tests/words_watch.js`: a Tab the page prevents now counts as a
command key, as Shift+Enter does. Before this, a nest made right after
typing was reported as words vanishing.
- `browser/runtime/keyboard/AGENTS.md` and `text-field.js` say what Tab
does in a field.

### Testing

`tests/runtime/list-nesting.test.mjs` covers the source transformation.
`test_tab_nests_a_list_item_and_shift_tab_takes_it_out`, in Chromium and
Firefox, covers nest, un-nest, a quoted list, a numbered item, the first
item, undo, the nested bullet with and without words, and focus leaving
outside a list. Both new tests fail without the change. `pnpm run
test:runtime` passes 720/720, and the focused Shift+Enter, list-bullet,
fence and Return tests pass.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 2, 2026
…nMark does

`renderMarkdown(text, false)`, `lf-text-document`'s preview and every Markdown body
(`x-text-format: markdown`, such as `lf-draft`) read text as a Markdown file, yet a
block indented four spaces rendered as a paragraph in the body face and `Title` over
`=====` as the words "Title =====". #4738 turned off markdown-it's `code` and
`lheading` rules so that a person typing a message wouldn't get code from a leading
indent or a heading from a `---` under a line. That reason holds for a message, and
`makeMarkdown` applied it to both readings.

The reading now decides the grammar as well as the soft breaks. `makeMarkdown`'s
boolean, renamed `message` from `breaks`, turns the two rules off only for a message;
a file keeps CommonMark's. `renderMarkdown` records why, restoring the reason a
type-checking pass dropped from `makeMarkdown`. Every reader of a file follows:

- Python's mirror (`passages.markdown_dialect`) takes the same flag, so a body's
  passages and its server prepaint read the same blocks as the browser, and the
  reply door's media check (`text_media_errors`) reads a message as a message.
- The field that edits a Markdown body in place tokenizes with the file reading, as
  does `markdownSourceOffset`, so a click in a body's code opens the editor at that
  character and Return in indented code writes the code's next line.
- The field draws an indented block as it draws a fence's code, with the pre's
  padding on its first and last lines (`lf-md-code-pad-start`), since no fence line
  stands for it.

A setext heading's underline line keeps its own line in the editor, so opening a
draft that holds one moves the words below it down a line. Drafts rarely hold one:
none of the 36 distinct `lf-draft` bodies in pages on this Mac changes structure
under the new reading.

Evidence: the issue's reply in an `lf-draft` rendered `p p p p p` before and
`h1 p p pre p` after (`leaf-dev probe --base`); `test_a_draft_edits_where_it_reads`
now includes an indented block and fails if the field reads it as a message.
`test_live_revision_drafts_wait_for_the_complete_controller_publication` indented
its draft bodies only as Python layout, so they lose the indent and stay prose.

Closes #5016.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 2, 2026
…nMark does (#5029)

A Markdown file now reads indented code and setext headings the way
CommonMark does. That covers `renderMarkdown(text, false)`,
`lf-text-document`'s Markdown preview and every Markdown body
(`x-text-format: markdown`, such as `lf-draft`). A message reads as
before.

Before this change, a block indented four spaces after a blank line
rendered as a paragraph in the body face, so the issue's `sed` command
lost its code font and its quotes and regex read as prose. `Title` over
`=====` rendered as the words "Title =====", and a line over `---` as a
paragraph followed by a rule.

### Why it happened

#4738 turned off markdown-it's `code` and `lheading` rules so that a
person typing a message wouldn't get code from a leading indent, or a
heading from a `---` under a line. That reason holds for a message, but
`makeMarkdown` applied it to both readings, and the comment recording it
was later dropped in a type-checking pass (#4873).

### What changes

The reading now decides the grammar as well as the soft breaks.
`makeMarkdown`'s boolean is renamed from `breaks` to `message`, and it
turns the two rules off only for a message. The comment on
`renderMarkdown` says what each reading does and why. Every reader of a
Markdown file moves together:

- **Python's mirror.** `passages.markdown_dialect(message)` replaces
`block_markdown()`. A body's passages and its server prepaint read the
same blocks as the browser. The reply door's media check
(`text_media_errors`) reads a message as a message, so an indented
`![shot](/media/…)` in a reply is still checked, since the message
renders it as a picture.
- **The field that edits a Markdown body in place.** Its configuration
names its reading `message()`, the name markdown.js uses (it was
`joined()`, facet `joinsLines`). In a body it tokenizes with the file
reading, and so does `markdownSourceOffset`. A click in a draft's
indented code opens the editor at that character, and Return at the end
of an indented code line writes the code's next line. The field draws an
indented block the way it draws a fence's code. No fence line stands for
the pre's padding, so the block's first and last lines carry it
(`lf-md-code-pad-start`, beside the existing `pad-end`).
- **A draft's answer.** `markdownWords` takes the same reading argument
as `renderMarkdown`. `lf-draft.answerWords` passes the file reading, so
the On me row for a draft whose body shows a heading over `=====` says
"Answered: Title Body" rather than "Title ===== Body".
- **Contract text.** `module-reading.md` describes both readings, and
text-field.js's header names a setext heading's underline among the
constructs that keep their source lines.

The message reading keeps both rules off. A widget showing a model's
reply can already ask for CommonMark with `renderMarkdown(text, false)`,
but in that reading a single line break becomes a space. Neither reading
keeps message line breaks and also reads indented code. No caller in
this tree needs both, so this PR adds no third reading.

### Known limit

In the field that edits a body in place, a setext heading's underline
keeps a line of its own. Opening a draft that holds one moves the words
below the heading down by that line (probed). Before this change, the
same draft showed the heading as a paragraph in both views. Drafts
rarely hold setext headings: none of the 36 distinct `lf-draft` bodies
in pages on the author's machine changes structure under the new
reading, and neither does any string in the examples' data files.

### Evidence

- The issue's reply in an `lf-draft` renders as the blocks `p p p p p`
on main and `h1 p p pre p` on this branch (`leaf-dev probe --base`, a
page holding the issue's text under a setext heading).
- `tests/markdown_body_cases.json` now records each case's top-level
`blocks`, and both runtimes are held to them. The new indented-code and
setext cases, and the existing `<div>\nHeading\n---` case, failed on
main in both the browser (`body-text.test.mjs`) and Python
(`test_markdown_body_file_words_match_the_shared_browser_dialect`).
- A runtime test holds `lf-draft.answerWords` to the words its painted
body shows. It fails with the message reading.
- `markdown-preview.test.mjs` now checks both readings: the field must
draw every rule either reading's renderer enables.
`field-editor.test.mjs` checks that Return continues indented code in a
field editing a body. Both failed on main.
- `test_a_draft_edits_where_it_reads` now includes an indented block. It
fails if the field reads that block as a message, and it fails if the
block's top padding is dropped.
-
`test_live_revision_drafts_wait_for_the_complete_controller_publication`
indented its draft bodies only as Python layout, so the indent is
removed and they stay prose.

### Checks run

`pnpm run test:runtime` (739 passed), `pnpm run check:browser`, and the
model tests for passages, anchors, revision delivery, media and authored
markup (406 passed). Focused browser tests: draft editing (faces,
wrapping, arrow keys, exact source, continuation clicks, Enter, format
comparison), composer Markdown decoration and Return, the chrome
contracts for draft faces, nesting, drawn source, fences and bullets,
and the live-revision drafts test.
`test_on_panel.py::test_an_answered_obligations_words_are_its_widgets_semantic_state`
fails the same way with this branch's source and with the merge base's:
its playground output never shows the posted `strip` choice, before the
test reaches the draft's answer.

The open editor over an indented block draws the same in Firefox as in
Chromium (probed). Not checked: WebKit, and the broad suite, which runs
in this PR's checks.

Closes #5016

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 2, 2026
…ace test (#5105)

The Markdown state race test held the module before navigation, then
waited for full readiness before reaching the code that releases it. The
editor's after-presentation preload participates in readiness, so the
fixture deadlocked at startup instead of testing whether an older state
can overwrite a newer comment.

Open only through presentation while Markdown is held, using the
existing readiness stage, and let the editor's preload start the import
instead of explicitly starting it again. The held older poll, newer
comment response and final assertions remain in place. The shared parser
preparation added in #4738 makes Markdown part of the editor preload;
this preserves that behavior and the deferred editor loading introduced
by #3897. No product behavior changes.

Validation: the focused test reproduces the startup timeout before the
change and passes after it (4.81 seconds); Ruff and `git diff --check`
pass.

Closes #5088 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 3, 2026
#4738 deliberately gave every page code block a code line above and
below its code (`padding: var(--code-line) …` in
`browser/styles/components/reading.css`, 20px at the top), so a fence's
source revealed under the composer's caret moves nothing. Its
description says this "gives every code block 8px more room above its
code". The nightly journey
`test_code_copy_keeps_source_and_stays_beside_scrolling_and_revised_blocks`
still pinned the old 12px for every block, so it has failed since that
merge.

The test now expects 20px for the page blocks, both on desktop and for
the plain block on a phone. The numbered `lf-code` widget keeps its own
12px inset (`--lf-code-inset-block` in
`packages/default/styles/code.css`), which #4738 didn't touch. The
assertion still protects what #1541 added it for: Copy overlays the
block and takes no room from it. No product code changes.

The journey failed on current main with the same `'20px' == '12px'`
assertion as the nightly run, and passes with this change (`uv run
pytest
tests/journeys/test_render_anchors.py::test_code_copy_keeps_source_and_stays_beside_scrolling_and_revised_blocks
--run-nightly`).

Closes #5175 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 14, 2026
…ne quiet ink (#5842)

A focused comment box says `Comment… ⏎ · New line ⇧⏎`. Since #4738 the
label was the part that gave way: it shrank toward a 4em floor to keep
both keys, so the margin comment box at roughly 270–290px read `Comm…`
beside a full set of keys, while the same box at 240px showed `Comment…`
whole. Now the label keeps its full width when the flex line breaks, so
the new-line hint drops whole first, then the send key, and the label
shortens only where it can't stand alone.

The hint was also too prominent. Every empty box's words and keys now
wear the floating panel's dimmer ink (ink at 62%), which moves from the
panel's stylesheet into the theme as `--quiet`. Leaf-text boxes,
`.lf-ui` and Web Awesome inputs, and the file editor read it in place of
`--muted`, and the panel's own override goes, so Leaf has one
placeholder ink where it had two and adds no token. It reads 4.8:1 on
paper against `--muted`'s 5.8:1, the dimmest WCAG AA allows; the lowest
measured on any surface a box sits on is 4.72:1, on the panel's ground.

Worth weighing: boxes with a single key (`Add another option… ⏎`) keep
the old order, shortening the label to keep the key. Extending the new
order to them dropped the key even where the label is cut regardless, as
in a 250px option list.

Asked for by max-sixty, who chose one size for the whole hint and the
panel's ink on the review page. The rewritten
`test_a_narrow_box_keeps_its_label_whole_and_drops_its_new_line_key`
fails on the old CSS and passes here; the focused placeholder, panel and
anchor tests pass.

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants