Skip to content

Line a draft up with the message it sends: real list markers, and blocks spaced by blank lines - #3486

Merged
leaf-agent merged 10 commits into
mainfrom
textbox-bullets
Oct 21, 2026
Merged

leaf-agent merged 10 commits into
mainfrom
textbox-bullets

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A draft in the comment field now lines up with the message it sends, line for line. Before, the field swapped a list's - for a small • glyph at its left edge, while the message indents the list 24px under the browser's disc; and the message added margins the draft never showed, such as a gap between a line and the list typed under it.

The draft (runtime/composing/text-field.js): a list item's line is a real list item in the browser's layout (display: list-item), so it wears the message's own disc, circle, square or number, at the message's inset, one --list-inset per level. The typed marker stands unseen in that inset and shows, muted, while the caret touches it, so revealing it moves no word; a quote's > does the same in the quote's inset. A continued paragraph line's whole indent is hidden as the message drops it, and a line of code hides the indent beyond what the parser's reading of it keeps. A code fence's lines keep their room, unseen while the caret is outside the block; an indented block, with no fence lines, takes the message's 8px end padding. Items inside a quote keep their source marker, since the quote's rule stands where the browser's marker would.

The message (runtime/markdown.js, styles/components/reading.css): the renderer counts the blank lines the source left before each block (data-lf-gap), and a Markdown message stands its blocks a line apart per blank line and touching otherwise. Code keeps a code line of room above and below, where the draft shows its fences. Agent-authored markup carries no counts and keeps its spacing. Visible on sent messages: a list typed under a line stays under it, and headings and lists lose their fixed margins.

The panel's field (styles/floating-panel.css) takes --msg-font, the face the theme says a message and its field share: 21px lines rather than 22px.

test_a_draft_draws_a_list_as_the_message_will compares each item's position, marker and the whole height of draft and message. write_watch.js excuses CodeMirror restating a list line's style, which its setAttrs assigns on every sync.

Still different, all rare: tables (the draft shows pipes), setext headings, a list inside a quote, and - - x.

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

# Conflicts:
#	skills/leaf/kernel/kernel.json
The renderer marks each block with the blank lines its source left before it
(`data-lf-gap`), and a Markdown message stands its blocks a line apart per blank
line and touching otherwise, so a list typed under a line no longer gains a gap
when sent. The floating panel's field takes the message's face (21px lines, not
22px), a code fence's lines keep their room unseen while the caret is away, with
the message's code padded a code line to match, and a quote's `>` stands unseen
in its inset. Agent-authored markup carries no counts and keeps its spacing.

The draft-list test now also compares item heights and the message's total
height with the draft's.
# Conflicts:
#	skills/leaf/kernel/kernel.json
# Conflicts:
#	skills/leaf/kernel/kernel.json

@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.

A continued list line can still shift when sent. The new continuation handling caps the hidden indent at the marker's width, although Markdown can strip more leading spaces from that line.

A list item's continued line hid only the indent up to the item's words, so
'- first\n    continued' drew 'continued' two spaces right of the message.
A paragraph's continued line now hides its whole indent; inside code, only the
item's, since the rest is the code's. The draft-list test checks a deeper
continued line against the sent message.
# Conflicts:
#	skills/leaf/kernel/kernel.json

@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.

An indented code block inside a list still shifts when the draft is sent.

…before reading it

An indented code block inside a list item kept four visible spaces before its
code in the draft, where the message shows none. Each line of code now hides
its leading spaces beyond those the parser's reading of the line keeps, for
fenced and indented code alike, and an indented block takes the message's
8px padding at its ends (--pre-pad-block), since it has no fence lines to
stand in for it.

The draft-list test lets the panel settle after the draft goes in, so its
growth has ended before the caret moves (CI saw the field's words still
travelling as later keys landed), and checks an item's indented code against
the sent message.
@leaf-agent
leaf-agent merged commit a3cb0fa into main Oct 21, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the textbox-bullets branch October 21, 2026 16:33
leaf-agent added a commit that referenced this pull request Oct 21, 2026
The [main CI
run](https://github.com/max-sixty/leaf/actions/runs/39635877365) failed
two browser contracts after 4,849 tests passed. This change keeps both
contracts and makes their test setup match the input and rendering
boundaries they assert.

The repaint test now reads the settled state before dispatching the
press. A runtime `pointerdown` capture listener can queue repaint work
before the test's later capture listener runs, so the old “before”
reading was already after input. It still checks that the click leaves
rendering unsettled and that the Threads view appears after rendering
settles.

The Send-room test now waits for the long draft's scroll and size
observers to settle before replacing it with a short draft. The old test
started its next synthetic edit during the long draft's layout pass; the
run reported a passive 4px shift during that transition. The assertions
for room on the last line and on every scrolling line remain.

Both failed cases reproduced locally before the change. The three
focused browser cases passed in three consecutive runs after it; the
Chromium Send-room case passed three more consecutive runs. The change
leaves the draft layout and message rendering from #3486 intact.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 23, 2026
Restore the line-for-line draft preview promised by #3486. The panel's
user messages currently use more reading width than its editor, so the
first list item loses a wrapped line after Send. The shared scrollbar
clearance added in #3670 also makes sent code blocks taller than their
draft preview. Give user messages the editor's reading width inside the
panel and carry the same code-block clearance in the draft.

The unchanged list-preview test failed in [main run
39886063961](https://github.com/max-sixty/leaf/actions/runs/39886063961)
and passes with this change. The Markdown editing check, browser build
check, and all 523 runtime tests passed. The separate Send overlap
failure remains on this branch's base and is addressed by #3678.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 26, 2026
… stand for its padding (#4273)

A one-line fenced code block in a thread message was 70px tall in both
Chromium and Firefox, with 20px of that taken by its one line of text.
The rest was a full code line (20px) of padding above and below the
text, the 8px kept free for the sideways scrollbar, and the borders.
#3486 added that padding so a sent message would be exactly as tall as
its draft, where each ```` ``` ```` line takes a full line. Agent
replies never had a draft, but they got the padding too.

A fenced block in a message now gets the 8px padding (`--pre-pad-block`)
that every message code block already gets, so the same block is 46px.
The draft still matches the sent message, now by the method in-place
editing already used: a ```` ``` ```` line is as tall as that padding
(8px) while the caret is elsewhere, and opens to a full line showing its
backticks when the caret moves onto it. The in-place field still reads
its display's own padding over this rule (`readFaces`).

Behavior change: typing a fence in a draft now moves the text below it
by 12px when the caret leaves the ```` ``` ```` line.

Measured with `leaf-dev probe`, in both engines:

- The sent block is 46px.
- The draft's lines add up to the same 46px (opening fence line 8+1,
code line 20, closing fence line 8+8+1).
- The closing fence line grows to 29px when the caret moves onto it.

`test_a_draft_draws_a_list_as_the_message_will` already holds draft and
message to one height with a fenced block in the draft. Without the
draft rule it fails by 24px, 12px for each of the two fences.

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

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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