Repository navigation
feat(composer): style inline markdown while typing, behind a setting - #15031
bolichen97 merged 2 commits into
Conversation
|
Intent: A user who turns on Settings → Chat → Composer → Style Markdown While Typing sees bold, italic, strikethrough and inline code styled in the composer as they type, on the Lexical composer the setting switches them to; the sent text is exactly what they typed. |
UX Review (Opus 5.5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has looked at the new "Style Markdown While Typing" toggle or the styled composer; the screenshots show both, but this lane has no blind read. Watch
Suggestions
[UX-REVIEWED] 274a0af Description read[DESCRIPTION-READ] 85daca021381f1b884dbd26650e724b45c013099e91e9b02f91dc3317d57aacf That sha256 names everything this verdict read: the PR description, plus the 9 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS A display toggle is now the only way users reach the beta Lexical composer, so its gaps against the textarea ship as side effects of "style markdown." Watch
Suggestions
[DESIGN-REVIEWED] 274a0af Description read[DESCRIPTION-READ] 8553761a033ebbc4126cb7b6f7a9b54678bd0f7935d42c714b7d7cfc03ef1c3f That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The parse cache rests on no measured cost, and the side chat's caret code duplicates the Not justified as shipped
What this change shipsInventory (9 items) — 7 justifiedIntent: let a user who opts in see inline markdown styled while typing. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 274a0af Description read[DESCRIPTION-READ] caaacacc7a507cd4a133ed7f25c4c4d16f5fd2ce78943987b1fd48c1aaf2a147 That sha256 names the PR description this verdict read. Recompute it with |
issue (fixed, blocking): upheld. The row said the spans come from the same parser the transcript uses. They don't:
|
issue (fixed, blocking): upheld, and the clause is deleted, which is this item's own clear condition.
|
suggestion (fixed, non-blocking): upheld.
|
note (checked, non-blocking): checked by a human reader.
|
suggestion (applied, non-blocking): applied.
|
be5bc54 to
06a4278
Compare
|
Pushed 06a4278 (rebased on main 3afc7cd). This head addresses round 1: the parser-parity claim is removed from the feature-map row, body and issue; the setting description no longer says "the new message editor"; the feature-map row routes editor parity reports to the Lexical migration; the Settings screenshot is recaptured. Dispositions are posted above. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsAll three candidates fell apart once I checked them against the code:
No findings. [OPUS-REVIEWED] 274a0af |
suggestion (applied, non-blocking): applied.
|
chore (fixed, non-blocking): upheld, and the export is removed, which is this item's own clear condition.
|
06a4278 to
82f6ebc
Compare
note (acknowledged, non-blocking): that is the intended trade for this PR. The setting is off by default, and its description says it turns on a rich-text editor that is still in beta, so the person who flips it has been told which editor they get. It applies to every composer on purpose, so a draft never changes editor between the main chat, side chat and grid panes. An in-composer badge is a fair follow-up once the editor leaves beta; it would add UI to every composer for a state the user chose in Settings. |
suggestion (acknowledged, non-blocking): agreed that the clause is redundant with the toggle. It touches all 12 locale files, so I will fold the trim into the next push this PR needs for another reason, rather than spend a full CI round and shared runner quota on wording alone. |
suggestion (acknowledged, non-blocking): correcting my earlier reply. The next push is a conflict-only rebase onto #15911, and the trim is not in it. Trimming the clause in all 12 locales would also leave the Settings screenshot in this PR showing the old text, so it needs a recapture with it. I will send the trim and the new screenshot as a small follow-up after this PR merges, so this rebase changes nothing. |
note (acknowledged, non-blocking): the main composer case is covered by a test, not only the description. |
note (acknowledged, non-blocking): the markers use |
issue (fixed in af20f557b8, pending push): confirmed. Typing the closing |
issue (fixed in af20f557b8, pending push): agreed. A new |
issue (fixed in af20f557b8, pending push): agreed. When the composer mounts after the first frame (through the observer or the 5 s cap), the nudge now skips |
|
🤖 Kiro Crew [operator: dwu96#8c08bee0]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: no review lane blocks this PR. At head
I'll also fold in the three Opus findings you marked fixed at this head (spans If you'd prefer I don't touch this PR, add the |
|
note (non-blocking): rebased on main @dwu96 thanks for the 10-05 note. The branch hadn't moved since, so I'm taking it back from here. This head also carries the fixes for the three Opus findings on Two conflicts, both resolved with no behaviour change to either side:
gen:settings had nothing to regenerate. Typecheck, eslint, and 115 related frontend test files (2,109 tests, including the split-view focus tests) pass. |
|
Pushed
|
|
Round on
Could a maintainer rerun that job? I'm not pushing for it. |
|
note (non-blocking): replies to the UX watch items on Beta warning buried in the description. Agreed, and this is the same trim UX suggested on round 22. It changes the description in all 12 locale files and makes the Settings screenshot in this PR stale, so I'm doing it as a small follow-up PR right after this one merges. That PR will lead with the beta sentence and drop the closing sentence that repeats the first, using the wording UX suggested for Inline code hard to see in the light theme. Agreed. The code span uses the |
|
Fixed in the next push. Not pushed yet, waiting on a push slot. issue (blocking): lazy-composer waits omit the explicit timeout. Upheld. The Lexical composer mounts behind ChatInput's Every composer-mount This fix only changes test timing, so it can't produce a test that fails first. The five files pass (9 tests), and eslint and |
|
Pushed |
|
Round 25 on |
A Lexical TextNode transform restyles each edited run of composer text from parseInlineMarkdown: bold, italic, strikethrough and inline code get Lexical format bits, markers get a dimmed style. The editor stays in plain-text mode, so the stored and sent value is unchanged. Settings > Chat > Style Markdown While Typing turns it on; default off.
…exical composer A textarea cannot draw styled text, so Style Markdown While Typing now also opts the user into the Lexical composer. With the setting off (the default) ChatInput keeps the textarea. The setting description says so in all locales. Focusing the rich composer puts the caret at the end, the restyle parses each line once per edit, and a side-chat seed whose editor mounts late leaves focus where the user moved it.
|
Rebased onto main |
|
Backend Lint & Type Check (3.12) on The job runs close to that limit across the repo. On this run, black (baselined) took 15m10s and flake8 took 3m18s, so mypy started at minute 23. Other PRs' runs of this job in the same hour spent 9.5 to 15 minutes in black and took 21 to 23.5 minutes in total. Could a maintainer rerun this job? I won't push again for it, because a new head lands in the same queue. Raising |
bolichen97
left a comment
There was a problem hiding this comment.
Approving at 274a0af6. The plugin only sets Lexical format bits and a marker style, so the sent text stays the plain markdown the user typed, and the setting is off by default. Undo, focus and the side-chat seed paths are covered by tests on the Lexical composer. GPT and Opus pass, the other lanes are advisory, and all checks are green after the lint rerun.
Two of the advisory notes are worth a small follow-up: keep lastParse per editor instead of at module scope, and have SideChat.tsx call focusComposerElement instead of repeating it.
Problem / Motivation
Goal: A user who wants it can see bold, italic, strikethrough and inline code in the composer while typing, and every other user keeps the composer they have today.
The composer shows markdown as raw characters.
**bold**and*italic*look like plain text until the message is sent, so it is hard to tell whether a marker is closed or which words it covers. #14736 addedcomposerInlineMarkdown.ts, a small parser that reads those spans from the draft and follows the CommonMark emphasis rules for common cases (***both***,2*3*4,snake_case_name, an unmatched**). Nothing drew them yet.Why it matters
A marker left open, or a span that covers the wrong words, shows up before the send, not after. The composer parser is not the transcript's renderer, so a rare edge case can style differently from the sent bubble; the sent text is the same either way.
Not a goal
lexicalComposerstays off at everyChatInputcall site; only this setting turns it on, per user.What changed (motivation → approach → change)
website/src/components/InlineMarkdownPlugin.tsxparseInlineMarkdownand sets Lexical format bits (bold, italic, strikethrough, code) on the covered text and the theme's--mutedcolour on the markers, which keeps them readable in light themes (a fixed opacity fell below 4.5:1 there). The editor stays in plain-text mode, so the stored value is unchanged. It skips paste chips and mentions (only plaintextnodes in normal mode take part), skips text while an IME is composing, keeps the caret offset across the split. One keystroke parses the edited run once: the transforms Lexical runs for each node a restyle touched reuse the last parse, keyed on the run's text. Turning it on or off restyles the whole draft in a history-merged update, so the toggle adds no undo step; off clears the formats.website/src/components/LexicalComposerInput.tsxinlineMarkdownprop, the plugin, and the theme classes.website/src/components/ChatInput.tsxuseComposerInlineMarkdown. A textarea cannot draw styled text, solexicalComposeris nowlexicalComposerProp || inlineMarkdown: the setting moves that user onto the Lexical composer, and off leaves the textarea path untouched. The draft carries over when the setting is toggled live. The composer is controlled, so every pushed value (an Optimize result, ↑/↓ recall) clears Lexical's own undo history; the Lexical composer's UNDO/REDO commands therefore walk ChatInput's existing snapshot history (stepUndoHistoryinchat-input/draftHistory.ts), the same one the textarea's Ctrl/Cmd+Z uses, throughonHistorySteponLexicalComposerInput. The textarea's other chords are passed through too:onOptimizeChordbinds Cmd/Ctrl+Shift+Enter to Optimize when the host offers it, andonSend(alternate)carries the Cmd/Ctrl+Enter steer/queue flip.website/src/pages/chat/composerFocus.ts,website/src/pages/chat/SideChat.tsx,website/src/styles/cli-mode.csstextarea[data-composer-input], which misses the Lexical composer's div. They now match[data-composer-input]on either element, and the side chat's seed waits (MutationObserver, 5 s cap) for the lazy-loaded Lexical composer to mount before placing the caret. Focusing the Lexical composer collapses the caret to the end of its text (focusComposerElement), matching where a textarea leaves it after a pre-fill, and a seed whose composer mounts late leaves focus alone if the user has moved to another field. CLI mode's prompt-glyph indent and accent caret use the same selector, and the Lexical placeholder overlay (data-composer-placeholder) gets the same indent.website/src/pages/chat/ChatSettings.tsx,website/src/hooks/useComposerInlineMarkdown.ts,website/src/pages/settings/ChatPanel.tsxinlineMarkdowninmc-chat-config, defaultfalse, non-booleans coerced tofalse. Settings → Chat → Composer → Style Markdown While Typing. The description's second sentence says turning it on also switches the message input to a rich-text editor that is still in beta, and that turning it off goes back to the plain input.website/src/i18n/locales/en.manual.jsonand every locale, informal address per the style guides;en-XA.jsonregenerated.website/src/components/commandPalette/settingsKeywords.ts, settings registry,docs/feature-map/README.mdnpm run gen:settingsoutput, and a feature-map row.Backwards compatibility
Compatible. The setting defaults to off, and off renders the same textarea as before. A user with no stored config, or a stored non-boolean, gets off.
Tests
website/src/test/ChatInput.inlineMarkdownSetting.test.tsx: setting off gives a textarea with no styled element; setting on gives the Lexical composer withhiin a bold element and the**markers still in the text; switching the setting off live returns to the textarea with the draft kept.website/src/test/InlineMarkdownPlugin.test.tsx: styles while typing, caret stays put when a span closes, unmatched markers stay plain, no styling across a paste chip, disabling clears formats, undo returns to the earlier text with its own styling, turning styling on over an edited draft adds no undo step of its own, text under IME composition is left alone.website/src/test/ChatInput.lexicalUndo.test.tsx: on the Lexical composer, Ctrl+Z after Optimize restores the original draft and Ctrl+Shift+Z redoes it; the same keys undo and redo typed text through the snapshot history.website/src/test/ChatInput.lexicalKeys.test.tsx: on the Lexical composer, Ctrl+Shift+Enter optimizes and Ctrl+Enter performs the one-off steer/queue flip while a turn runs, as on the textarea.website/src/test/SideChat.lexicalSeedFocus.test.tsx: with the setting on, a Select-to-Ask seed focuses the Lexical composer once it mounts.website/src/test/SideChat.lexicalSeedLateFocus.test.tsx: a seed whose Lexical composer mounts late does not take focus from a field the user moved to.website/src/test/composerFocus.richCaret.test.ts:revealComposerandfocusComposerleave the caret at the end of a contenteditable composer's text.website/src/test/InlineMarkdownPlugin.parseOnce.test.tsx: a closing marker that restyles a many-node run parses it once.website/src/test/composerFocus.test.ts:queryComposer,focusComposerand the keyboard-switch blur all reach a contenteditablediv[data-composer-input].website/src/test/useComposerInlineMarkdown.test.ts: default off, a non-boolean stored value reads as off, follows the saved setting live.90 related frontend test files pass, plus
npm run typecheck, eslint,lint:i18n,i18n:checkandcheck_feature_map.py.Manual verification
Built the SPA from this head and ran it on the repo's feature-gateway harness (
fixture="minimal"). TypedShip **bold**, *italic*, ~~old~~ and `code` todaywith real key events. With the setting off the composer was aTEXTAREAshowing raw characters. After turning the toggle on in Settings, the composer was aDIVwithdata-lexical-composer, and the DOM had afont-boldelement containingbold.Screenshots / video
Setting off (default): plain textarea, raw markdown.
Settings → Chat → Composer, toggle on.
Setting on: the same text styled, markers in the theme's muted colour.
CLI interface mode, setting on: the placeholder and the typed text both clear the
>prompt glyph (computedpadding-left: 24pxon[data-composer-input]and[data-composer-placeholder], accent caret).Related Issues
Fixes #15030
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)