Repository navigation
fix(verbose): 修复 thinking 多行阶梯错乱与中文截断乱码 - #1
Merged
Merged
Conversation
- thinking 内部 \n 统一转 \r\n,避免 raw 模式(OPOST 已清)下裸 \n 不回车导致的阶梯缩进 - preview 压成单行后再打印,避免工具输入中的换行同样阶梯错位 - 截断从字节 len 改为 rune len,避免中文(3字节)被切半出现 �,与 ci 中文用例一致 - 归一化 \r\n/\r -> \n 再转 \r\n,兼容不同模型返回
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.
问题
用户反馈
-display-thinking默认开启时,[thinking]在终端出现阶梯状缩进:且中文长思考被截断时出现
�。根因
\n未转\r\n:cli在term.MakeRaw后清OPOST,裸\n不回车。2028fc3只修了行尾\r\n,verbose.go:72的text内部多行仍是裸\n,每行起始列=上一行结束列,形成阶梯。preview同理。len(text)>500按字节,中文 1字3字节,text[:500]易切在字符中间。修复
thinking:统一\r\n/\r->\n,按[]rune截断 500,再\n->\r\n后打印,保持与cli.write一致的 raw 兼容preview:归一化后压成单行(\n-> 空格),按[]rune截断 300,避免多行工具输入同样阶梯验证
go test ./internal/hook/verbose -v通过,原有 ASCII 截断行为不变(rune len 对 ASCII 等价)go test ./...全绿郑州金水东路多行 thinking 与中重复截断不再出现乱码,换行正常回首列备注
新增注释为必要说明,解释非显而易见的 raw/UTF-8 处理意图,避免被回退。
Fixes: thinking 显示错乱