fix(desktop): code block lang detection + overlay header + icon-only copy button#1661
Merged
esengine merged 1 commit intoMay 24, 2026
Merged
Conversation
esengine
added a commit
that referenced
this pull request
May 24, 2026
#1661 fixed the lang-detection bug for desktop only. Dashboard's pre handler has the same `c.type === "code"` check that fails when react-markdown's component override replaces `code` — the element's type is the override function, not the string "code". For dashboard this didn't just mislabel the language; the fallback returned a vanilla `<pre>` and skipped CodeBlock entirely, so syntax highlighting and the copy button were missing for every fenced code block. Extracted the lang lookup into `extractFencedLang` in both files so it can be unit-tested without rendering CodeView (prism-react-renderer pulls in each package's own React copy under vitest, which breaks full-render tests across desktop/dashboard). Co-authored-by: reasonix <reasonix@deepseek.com>
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.
Summary
Three code block visual fixes: lang detection, header overlay, and icon-only copy button.
Changes
Markdown.tsx — Fix lang detection: react-markdown v9 wraps the code element in nested children; switch from looking for a
<code>element by type to readingclassNamedirectly from child element props. This fixes code blocks with language tags showing "text" instead of the actual language. Also removes the "Copy"/"Copied" text label from the copy button (icon only).styles.css — Make the code block header (
codeblock-head) an absolute-positioned overlay floating at the top of the code block (transparent background, no border), so lang label and copy button feel like part of the code content. Button becomes a 22px icon-only square with hover opacity.Verification
npm run verifypasses