Skip to content

Draw the composer's Markdown preview in the sent message's faces - #1271

Merged
max-sixty merged 3 commits into
mainfrom
agent-ab64e595348afcdf5
Sep 27, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-ab64e595348afcdf5

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A draft in the composer now reads in the faces of the message it will send. The Markdown preview (composing/text-field.js, #1234) took its constructs from the message renderer but wrote its own faces, which disagreed with the message from the start:

construct draft before sent message
inline code 0.9em, 3px chip 82%, 4px chip, 1px/5px padding
strong, heading weight 650 700
quote upright, 3px --border-2 rule, 8px inset italic, 2px --rule rule, 10px inset in the panel
link underline in full accent underline at 35% accent
code block --code-bg strip at 0.9em framed --pre-bg block at --code-size

The theme's element rules stop at the field's closed shadow root, so the values they draw are now :root tokens in theme.css (--code-inline-size/-pad/-r, --quote-rule/-style/-inset, --pre-inset, --link-underline, --link-underline-offset). The code, pre, blockquote and a rules and the preview read the same tokens, and custom properties inherit into the shadow root. Strong, emphasis and strikethrough are drawn as strong, em and del elements, so the browser's default styles apply to them in the field as in the message; inline code is a code element. The preview draws a code block line by line, so its frame is each line's sides, closed on the first and last lines.

The panel's narrower insets were .lf-msg-body pre and .lf-msg-body blockquote paddings in chrome.css. They are now the same tokens set on .lf-thread-panel, so a draft in the panel insets as the panel's messages do. This hunk sits at the message-body rules, away from the Threads-panel rules the unmerged Codex gallery tree edits.

Page elements compute as before: on a served page, a quote, code block, inline code and link compute the values the old rules stated. The remaining difference is the container: the composer sets its words at 14px and a panel message at 13px, and a draft marks a heading by weight only.

Before (current main), a sent message above the same Markdown drafted in the Threads panel's composer:

Before: the draft's quote is upright under a dark rule, its code block a tinted strip

After:

After: the draft's quote, code, link and code block match the sent message

Test: test_a_draft_wears_the_faces_its_sent_message_wears (tests/test_chrome_contracts.py) writes a Markdown comment to the log, opens it in the panel, drafts the same Markdown in the general composer, and compares each construct's computed face. It reads the draft through DevTools, which reaches the closed root. Setting the quote back to its old rule or inline code back to 0.9em fails it.

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 26, 2026 21:32
The composer's preview (`composing/text-field.js`, #1234) took its
constructs from the message renderer but wrote its own faces, and they
disagreed with the message from birth: inline code at 0.9em with a 3px
chip against the message's 82% and 4px, strong and headings at weight
650 against 700, a quote upright under a 3px `--border-2` rule against
italic under a 2px `--rule` rule, a link underlined in full accent
against 35%, and a code block as a tinted strip against a framed white
block.

The theme's element rules stop at the field's closed shadow root, so
the faces those rules draw are now `:root` tokens in `theme.css`
(`--code-inline-*`, `--quote-*`, `--pre-inset`, `--link-underline*`),
which the `code`, `pre`, `blockquote` and `a` rules and the preview
both read. Strong, emphasis and strikethrough are drawn as the
`strong`, `em` and `del` elements, so the platform dresses them in the
field as it does in the message; inline code is a `code` element. The
panel's narrower insets for a quote and a code block are those tokens
set on `.lf-thread-panel`, so a draft in the panel insets as the panel's
messages do.

Behaviour that moved: a draft's inline code, strong, headings, quotes,
links and code blocks now read as the sent message does. Page elements
compute exactly as before.

`test_a_draft_wears_the_faces_its_sent_message_wears` compares each
construct's computed face in the draft (read through DevTools, which
reaches the closed root) with the same Markdown sent in the panel.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 8a7c428 into main Sep 27, 2026
7 of 8 checks passed
@max-sixty
max-sixty deleted the agent-ab64e595348afcdf5 branch September 27, 2026 05:15
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