QOL: Add Automatic Code Block & Syntax Highlighting In Chat Input #128
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.

Summary
```lang) — including consuming an opening fence when code is pasted after itDetails
New file:
parse-user-code-blocks.tsparseCodeBlocks()/hasCodeBlocks()— split text by triple-backtick fences into typed segmentsdetectLanguage()— identify 20+ languages (PHP, TypeScript, Python, Java, C#, Ruby, Go, Rust, SQL, etc.) from text patternslooksLikeCode()— two-pass detection: language-specific patterns then structural analysis (indentation, line endings, special char density, balanced delimiters)Editor (
agents-mentions-editor.tsx)createCodeBlockNode()— creates acontenteditable=falseblock with language header, remove button, and async Shiki highlightingdata-code-blockis now checked before the generic<div>handler inserializeContent(), which was causing backtick fences to be lost```lang...```into styled blocks)skipSubtree()helper for TreeWalker traversalonThemeChangesubscriptionPaste handling (
paste-text.ts)isPastedFromCodeEditor()— detects VS Code, IntelliJ, etc. via clipboard HTML (monospace fonts, colored spans)consumeOpenFence()— if the user typed```phpbefore pasting, consumes the fence and uses its languageinsertCodeBlockAtCursor()— extracted helper for code block DOM insertion (was duplicated 3x)Sent message rendering (
render-file-mentions.tsx)UserCodeBlockcomponent — read-only Shiki-highlighted code block for sent messages, re-highlights on theme toggleRenderUserContent— wrapsRenderFileMentions, splits text by fenced code blocks and rendersUserCodeBlockfor code segmentsBug fixes
extractTextMentions()stripping code indentation (removed per-line.trim())RenderUserContentwrapper from<span>to<div>(code blocks are block-level elements)shiki-theme-loader.ts— languages not in the initial bundle load on demandTest plan
```php, then paste code — fence should be consumed, code block created withphplanguage```lang...```fences — should render as code blocks with surrounding text preserved