fix(desktop): preserve explicit text code fences - #57542
Conversation
Duplicate of #49972 — same file and mechanism (adds a |
|
Independently reproduced this on current Revalidated this PR's exact commit on top of current upstream
This PR is the correct upstream fix; explicit |
|
Confirming that we are also seeing this in a real Hermes Desktop session. The backend stored valid fenced Markdown, but Desktop rendered multi-line So this is not only a synthetic test case; it is affecting normal Desktop output in active use. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused Desktop fix. The premise is confirmed on current main: apps/desktop/src/lib/markdown-code.ts:301-308 demotes multi-line text-family fences, and apps/desktop/src/components/chat/shiki-highlighter.tsx:133 has a separate render-time prose classification path.
Problems
- The new direct test in
apps/desktop/src/lib/markdown-code.test.ts:5coversisLikelyProseFence()only; it does not protect the newisLikelyProseCodeBlock()guard used atapps/desktop/src/components/chat/shiki-highlighter.tsx:133. - The one-line
plaintextfixture inapps/desktop/src/lib/markdown-preprocess.test.ts:18-22already passes on current main becauseapps/desktop/src/lib/markdown-code.ts:323-325requires at least three prose lines to demote that language.
Suggested changes
- Add a multi-line direct render-classification regression for
isLikelyProseCodeBlock('text', body). - Parameterize multi-line preprocessing coverage across
text,plain, andplaintext.
Automated hermes-sweeper review.
|
|
||
| it('preserves explicit plain text fences', () => { | ||
| const input = ['```plaintext', 'hello world', '```'].join('\n') | ||
|
|
There was a problem hiding this comment.
This one-line plaintext fixture already passes on current main: isLikelyProseFence() demotes this language only when proseLines >= 3 (markdown-code.ts:323-325). Use the same three-line body as the text case so the test fails before the new explicit-language guard.
What does this PR do?
Prevents explicit
text,plain, andplaintextfenced blocks from beingdowngraded to prose by the desktop Markdown preprocessor.
Previously, prose-like content such as file paths could trigger the heuristic,
causing the language tag (
text) to leak into the rendered response. Explicitplain-text fences now remain code blocks. The fix also corrects previously
persisted messages when they are rendered again; it does not depend on the
agent producing a new response.
Related Issue
Fixes #57540
Type of Change
Changes Made
text,plain, andplaintextfences inapps/desktop/src/lib/markdown-code.ts.preprocessing.
How to Test
Open Hermes Desktop.
Ask the assistant to return several file paths inside an explicitly tagged
textfence.Confirm the paths remain inside a
Code · textblock andtextdoes notleak into prose.
Continue the conversation or reload the persisted session and confirm the
existing block still renders correctly.
Run:
npm run test:ui --workspace apps/desktop -- \ src/lib/markdown-code.test.ts \ src/lib/markdown-preprocess.test.ts npm run typecheck --workspace apps/desktop npm exec --workspace apps/desktop eslint -- \ src/lib/markdown-code.ts \ src/lib/markdown-code.test.ts \ src/lib/markdown-preprocess.test.tsChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
The before/after screenshots are attached to #57540. They show the same
persisted assistant message: before the fix, the
texttag and file paths arerendered as prose; after the fix, the message renders as a
Code · textblock.Targeted verification completed: