Repository navigation
feat(web): highlight markdown syntax while typing in the composer - #26
Merged
Merged
Conversation
The prompt composer rendered every character the same, so a pasted code fence or an inline `snippet` was indistinguishable from prose until the message was sent. Paint markdown syntax live using Lexical text formats on the composer's own text nodes rather than an overlay, so the highlight shares a layout pass with the existing mention and skill chips instead of competing with them for position. Node text is never rewritten: the submitted prompt is byte-identical to what was typed. Covers fenced blocks (including half-typed ones), inline code, bold, italic, strikethrough, headings, quotes, lists, thematic breaks, and links. Delimiters are dimmed rather than hidden. Chips are opaque to the scanner so a path like @src/_a_/b.ts cannot read as emphasis, and the scan is skipped past 20k characters to keep large pastes cheap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The prompt composer rendered every character the same, so a pasted code fence or an inline
snippetwas indistinguishable from prose until the message was sent.Fix
Paint markdown syntax live using Lexical text formats on the composer's own text nodes rather than an overlay, so the highlight shares a layout pass with the existing mention/skill chips instead of competing with them for position. Node text is never rewritten — the submitted prompt stays byte-identical to what was typed (locked by a test).
Covers fenced blocks (including half-typed ones), inline code with N backticks, bold, italic, strikethrough, headings, quotes, lists, thematic breaks, and links/images. Delimiters are dimmed rather than hidden, so the text stays plain markdown.
composerMarkdownSyntax.ts— pure scanner, text in → styled ranges out. A highlighter, not a CommonMark parser: staying cheap and stable while a construct is half-typed beats matching every reference edge case.composerMarkdownHighlight.ts— Lexical layer. Transforms onTextNode(typing) andParagraphNode(structural rebuilds, chip insertion).Notes:
@src/_a_/b.tscannot read as emphasis and offsets past a chip stay aligned..chat-markdownvariant) so the caret and line boxes never shift while typing.Verification
vp test runon the two new suites (30 cases) plus the nine neighbouring composer suites (190 cases), targeted lint, andtsgo --noEmitonapps/web— all green.Not visually verified in a real client. No before/after images: the change was never opened in a browser, so the paint is proven by unit and headless-Lexical tests only.
Written by Claude Opus 5 in T3 Code.