fix: strip segment text to remove extra blank lines in segmented reply#8304
fix: strip segment text to remove extra blank lines in segmented reply#8304Blueteemo wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the warning message for slow text-to-image rendering to direct users to the WebUI and ensures that plain text segments are stripped before being appended to the result chain. A review comment suggests optimizing the stripping logic by assigning the stripped string to a variable to avoid redundant computations and improve code readability.
关于 gemini-code-assist 的审查建议gemini-code-assist 建议将
保持当前的一行式写法即可。 关于 pytest 检查未通过失败的测试是 所有其他检查均通过:format-check ✅ / CodeQL ✅ / 跨平台 Smoke Test × 8 ✅ / Dashboard CI ✅ / Sourcery review ✅ 本 PR 改动清晰、风险极低,可以合并。 |
修复说明
修复分段回复时 Plain(seg) 未 strip 导致 QQ 消息出现多余空行的问题。
问题描述
在 stage.py 的分段回复逻辑中,分段后的文本 seg 在添加到 new_chain 前只做了非空判断(if seg.strip()),但实际添加到链中时使用的是原始的 Plain(seg) 而非 Plain(seg.strip()),这导致每段文本的收尾空格/换行被保留,在 QQ 消息中产生多余空行。
修复方案
将 new_chain.append(Plain(seg)) 改为 new_chain.append(Plain(seg.strip())),确保每段文本的首尾空白字符被去除。
关联 Issue: #8300
Summary by Sourcery
Strip whitespace in segmented replies to avoid extra blank lines and clarify guidance for disabling text-to-image mode when rendering is slow.
Bug Fixes:
Enhancements: