已开启
fix(tuix): inflight 重绘改走 cell-diff, 消除光标闪烁 #1104
郑育强创建于 11 天前
fix(tuix): inflight 重绘改走 cell-diff, 消除光标闪烁 #1104
已开启
合并受阻
atomgit-bot
11 天前 评论:
11 天前 评论:
变更摘要
本 PR 修复了工具调用进行中时 TUI 光标闪烁的问题。根因是 render_inflight_tool 的 in-place 分支在更新模型之外,还直接向终端裸写 \x1b[{r};1H\x1b[2K 加行内容,绕过了 render_diff 的 DECSET 2026 同步帧与光标隐藏,导致物理光标滞留在 Running 行尾,在高延迟链路上以约 10Hz 在 Running 行与输入框之间乒乓闪烁。修复方式是让 in-place 分支只做模型更新(body_lines 替换、sentinel invalidate_rows_from、dirty),重绘统一交由 cell-diff 在同步帧内完成,与 live spinner 路径 push_or_update_live_spinner 保持一致,并补充回归测试。
主要改动
- 移除 inflight in-place 分支的终端裸写: 删除了逐行
\x1b[{r};1H\x1b[2K与serialize_row的直写循环,避免绕过屏幕模型与 DECSET 2026 同步帧。 - in-place 分支改为纯模型更新 + sentinel 失效: 仅替换
body_lines尾部切片并触发invalidate_rows_from,由后续flush_deferred经 cell-diff 在同步帧内重绘,保持帧原子化。 - 新增回归测试: 新增
retained_inflight_inplace_rewrite_stays_inside_sync_envelope,断言 inflight tick 输出不再包含裸写签名\x1b[2K,同时校验 Running 行仍正常重绘。


不准确?
atomgit-bot
11 天前 评论:
11 天前 评论:
atomgit-bot
11 天前 评论:
11 天前 评论:
问题
工具调用进行中(如长 bash 命令), TUI 的 Running liveness 行每 ~100ms 重绘。实测(本机与高延迟链路均可复现)可见光标在 Running 行尾与输入框之间以 ~10Hz 乒乓闪烁。
根因:
render_inflight_tool的 in-place 分支在更新模型之外, 还直接向终端裸写\x1b[{r};1H\x1b[2K+ 行内容(retained.rs)。这段裸写:render_diff的 DECSET 2026 同步帧与?25l光标隐藏;live spinner 此前已修复过同款问题(
push_or_update_live_spinner, 改走 cell-diff), inflight 路径是它遗漏的孪生分支。修复
in-place 分支只做模型更新(
body_lines替换 + sentinelinvalidate_rows_from+dirty), 重绘统一由 cell-diff 在 DECSET 2026 同步帧内完成。sentinel 本就强制 strip 每格出 patch, 裸写删除后视觉无损失; 唯一差异是重绘推迟到 ≤5ms 的合并帧, 不可感知。验证
retained_inflight_inplace_rewrite_stays_inside_sync_envelope: 断言 inflight tick 输出不再出现裸写签名\x1b[2K(该序列全仓仅裸写路径使用), 且 Running 行仍正常重绘 —— 修复前红、修复后绿cargo test -p atomcode-tuix: 2134 通过; 3 个失败(dir_picker ×2、kitty_keyboard ×1)经 stash 基线对照确认是 main 上已有的环境相关失败, 与本改动无关cargo fmt --all -- --check通过已知未验证范围