Fix raw </pre> handling in response renderer#1150
Fix raw </pre> handling in response renderer#1150bsgdigital wants to merge 2 commits intonesquena:masterfrom
Conversation
|
Thanks for this PR! The stash-and-restore pattern for protecting raw The fix is well-targeted:
One note on scope: The PR also includes commits touching Files changed:
The renderer fix itself looks correct and low-risk. The bundled update management changes will need separate careful review. |
🔴 Hold: Please split into two PRsThis PR is being placed on hold because it bundles two unrelated changes that each deserve their own review track. Change 1 —
|
Stash raw pre blocks before inline code-tag normalization so multiline code content is not rewritten into stray backticks that can corrupt subsequent code box rendering. Add a JS-renderer behavior test that guards balanced pre/code output across multiple raw code blocks. Made-with: Cursor
Rename the raw pre stash variable so static substring checks for _pre_stash continue to target the intended code-block stash section. Made-with: Cursor
f0359fc to
18870cf
Compare
|
@nesquena-hermes apologies, fixed now |
|
Integrated via #1172. Thank you @bsgdigital! |
…, .env (#1179) Merged as v0.50.228. 2644 tests passing. Browser QA 21/21 (desktop 1440×900 + mobile iPhone 14). All 5 fix invariants verified live in browser. **Fix verifications:** - #1172 (`renderMd` pre-stash): `rawPreStash` present in function, `<pre>` blocks pass through without content rewrite ✅ - #1174 (model race guard): `syncTopbar()` contains `liveStillPending` guard ✅ - #1175 (tool card): `.tool-card-result pre` max-height=360px, `.tool-card.open .tool-card-detail` overflow=auto, cap=600px ✅ - #1176 (empty session guard): double-click New Conversation on empty session → stays on same session, composer focused ✅ - #1178 (`.env` atomic write): `tempfile.mkstemp + os.replace` in `providers.py`, 9/9 env tests pass ✅ Thanks @bsgdigital (#1150) and @bergeouss (#1178)!
…, .env (nesquena#1179) Merged as v0.50.228. 2644 tests passing. Browser QA 21/21 (desktop 1440×900 + mobile iPhone 14). All 5 fix invariants verified live in browser. **Fix verifications:** - nesquena#1172 (`renderMd` pre-stash): `rawPreStash` present in function, `<pre>` blocks pass through without content rewrite ✅ - nesquena#1174 (model race guard): `syncTopbar()` contains `liveStillPending` guard ✅ - nesquena#1175 (tool card): `.tool-card-result pre` max-height=360px, `.tool-card.open .tool-card-detail` overflow=auto, cap=600px ✅ - nesquena#1176 (empty session guard): double-click New Conversation on empty session → stays on same session, composer focused ✅ - nesquena#1178 (`.env` atomic write): `tempfile.mkstemp + os.replace` in `providers.py`, 9/9 env tests pass ✅ Thanks @bsgdigital (nesquena#1150) and @bergeouss (nesquena#1178)!
Bug Description
Fixes response rendering where raw HTML code blocks could consume following content.
When model output included raw
<pre><code>...</code></pre>, later message content could be rendered as if still inside a code box. This was especially visible when multiple code boxes appeared in one response.Root Cause
renderMd()instatic/ui.jsperforms a safe inline-HTML normalization pass that rewrites<code>...</code>to markdown backticks.That rewrite was applied globally, including inside raw
<pre>blocks coming from model output. For multiline code inside<pre><code>...</code></pre>, this could degrade block structure (introducing stray backticks and malformed code-box boundaries), which then cascaded into subsequent content rendering incorrectly.Fix
Stash raw
<pre>...</pre>blocks before the inline<code>normalization pass, then restore them immediately after.This is a minimal, targeted change: only raw
<pre>regions are protected from the inline<code>rewrite; the rest of the markdown pipeline remains unchanged.Files Changed
static/ui.js— protect raw<pre>blocks during inline HTML normalizationtests/test_renderer_js_behaviour.py— add regression test for multiple multiline raw<pre><code>blocksHow to Verify
Send output that contains multiple raw HTML code blocks, e.g.:
Before fix: code-box boundaries could degrade and later content could appear inside a code box.
After fix: each code block stays balanced and plain text between/after blocks renders normally.
Test Plan
tests/test_renderer_js_behaviour.py(TestRawPreCodePreservation)renderMdsmoke verification for multiline raw<pre><code>blockspytestrunRisk Assessment
Low — change scope is limited to stashing/restoring raw
<pre>segments around one inline rewrite pass. No CSS/layout changes and no behavior changes for fenced markdown code blocks.