Repository navigation
fix(chat): preserve punctuated fenced code language tags - #1061
Conversation
dovvnloading
left a comment
There was a problem hiding this comment.
Reviewed all three changed files against #1036. The new fence matcher separates the complete opening info line from the code, preserves punctuated aliases in both wrapped and unwrapped branches, supports CRLF and longer fences, and keeps ordinary inline triple-backtick text intact. The parametrized parser and real send/regenerate code-node regressions cover the reported cases. No blocking findings in the reviewed diff. Verified CI run 45587668309 for this head: frontend checks, Windows Python checks (including compile, lint, pytest and performance suite), POSIX checks and wheel build/install passed; optional Playwright boot smoke was skipped. Checked intervening main changes: four commits, no overlap with the three changed files. Native desktop launch/manual save-reload verification was not performed; for this focused backend fix I am relying on the passing automated integration coverage and the maintainer's request to process and merge. GitHub review is a comment rather than an approval because the connected account is also the PR author.
Summary
Fixes #1036. Fenced model replies used a word-only language capture and an optional newline, so punctuation in language aliases was incorrectly inserted into generated code. Match the opening and closing fence lines, read the complete info string separately, and use its first token as the language.
What Changed
<code_block>wrappers in both parser branches.Why
The opening info line is metadata rather than source code. Explicit boundaries prevent the suffix of a language tag or a filename attribute from becoming the first line of the generated program. Requiring complete fence lines also avoids interpreting ordinary inline backtick spans as blocks.
Validation
python -m compileall -q .passes (run from the repo root - matches CI)python -m pytest -qpasses (run from the repo root - matches CI)cd web_ui && npm run checkpasses (matches CI)Local full checkout is blocked by GitHub DNS resolution. The local harness does not load the full provider module, application, or repository conftest; the send/regenerate integration tests are committed but not run locally. Required CI, full lint, build and manual checks remain pending.
Focused verification from a configured checkout with the repository's Python 3.12 environment:
Manual verification: send a chat asking for fenced C++, C#, and Objective-C examples; inspect each generated code node's language and first line. Regenerate the response, verify the old code child is replaced and the new source is intact, then save/reload. Check ordinary Python and unlabelled fences too.
UI Notes
Additional Context
This intentionally recognizes complete backtick fence lines, rather than the legacy permissive same-line pseudo-fences; inline triples remain text. This is not a full CommonMark tokenizer (e.g. tilde fences and nested blockquote parsing remain out of scope). Existing whitespace trimming, multiple-block combination, wrappers and reasoning handling are otherwise unchanged. The separate literal reasoning-tag issue #1047 is out of scope. No dependency, schema, frontend, or CI changes. Draft pending required checks and manual verification; do not merge until those pass.