Skip to content

[PR] fix(pi): keep Fleet frames stable for CRLF and paint truncated background - #4386

Closed
omovomo wants to merge 12 commits into
ranxianglei:masterfrom
omovomo:2026-10-23_fix-fleet-crlf-background
Closed

omovomo wants to merge 12 commits into
ranxianglei:masterfrom
omovomo:2026-10-23_fix-fleet-crlf-background

Conversation

@omovomo

@omovomo omovomo commented Oct 23, 2026

Copy link
Copy Markdown

Fixes #4385

Problem

The Pi /acp-fleet transcript has two independent rendering defects:

  • CRLF-delimited tool output is split on \n but retains \r in the displayed rows. A terminal interprets the carriage return as cursor movement, which can overwrite text and shift frame borders.
  • truncateToWidth() inserts an SGR reset ahead of its generated ellipsis; the outer full-width background wrapper cannot reliably paint the ellipsis and remaining padding.

The first issue is frame geometry, not a missing ANSI reset. The second is a background notch during truncation. Full-width tool backgrounds themselves are intentional and are preserved.

Changes

  • Normalize CRLF to LF when rendering Fleet tool-result rows, without changing persisted text or tool execution arguments.
  • Treat CRLF as one line break in bash command preview labels.
  • Pass a background-painted ellipsis to truncateToWidth() and explicitly paint the remaining padding using visibleWidth() (including wide Unicode cases).
  • Add regression tests covering CRLF/LF equivalence, immutability, frame cursor behavior, ANSI foreground/reset handling, truncation and ASCII/CJK/emoji/combining characters across narrow and wide viewport widths.
  • Bump the vendored pi-subagents component version from 0.2.2 to 0.2.3 per the component version guard. The root billion-context version is unchanged.

Reproduction and evidence

Minimal fixture:

{ kind: "toolResult", name: "read", text: "short\r\n123456789012345\r\n\r\ntail\r\n" }

Before the fix, trailing CR in displayed lines can return the cursor to column zero and corrupt the framed row. In local replay of an ACP session, original rendering emitted CR on 16 / 26 / 28 rows at widths 40 / 80 / 120, respectively; the patched renderer emitted zero.

When truncating 200 ASCII or 100 CJK characters to width 21, the original rendering left 3 default-background cells around the ellipsis, versus 0 with the patch. Output width remains 21.

The combined fix was confirmed in Windows Terminal by the reporter.

Validation (local, on patch base aa198fe613b4ff5252ddfccdf6704290ad37d9ab)

  • Fleet inspector: 19/19 passed
  • pi-subagents suite: 266/266 passed
  • Host integration tests (pi-subagent-channel, pi-subagent-registry, pi-subagents-wiring): 43/43 passed
  • npm run typecheck: passed
  • npm run build: passed
  • git diff --check: passed
  • Packed bundle extraction, hash parity and standalone Pi extension import: passed
  • Windows Terminal manual verification: passed

Before merge: rebase/apply to current master, run full repository npm test, typecheck and build, and confirm remote CI. These were not independently verified on current master in the attached report.

Impact and boundaries

  • Pi Fleet UI only: no changes to ACP scheduling, execution, notifications, wait/cancel, resumeFrom, config schema, persistence, or compression kernel.
  • No new runtime dependencies, public exports or configuration keys.
  • The existing full-width success/error/pending backgrounds are retained.
  • Arbitrary cursor-moving ANSI sequences and standalone-CR progress animations remain out of scope.
  • Kernel change: none. Config surface: none.

@ranxianglei ranxianglei changed the title fix(pi): keep Fleet frames stable for CRLF and paint truncated background [PR] fix(pi): keep Fleet frames stable for CRLF and paint truncated background Oct 23, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 检索了 open+closed issue/PR(fleet、CRLF、transcript frame、truncateToWidth、background notch 等关键词组合),无同类在途或已合并条目;本 PR 与 #4385 是同一缺陷的「报告→修复」配对,#4385 保持 open 待本 PR 合入后关闭。

标签: bug pi scope/ui p2 — Pi Fleet 检视器渲染缺陷(CRLF 帧几何损坏 + 截断处背景缺口),仅影响 /acp-fleet 展示面,不触及压缩/持久化/内核,属「能用但有明显问题」档。

初审状态(完整八问结论随后补):

  • 范围核实通过:PR 实际贡献 = 单个 fix commit(dac285fd8,分支上的 merge-master commit 只是同步),净 diff 恰好 3 个文件(pi-subagents/src/fleet-inspector.ts +12/-7、pi-subagents/tests/fleet-inspector.test.ts +84/-1、pi-subagents/package.json 0.2.2→0.2.3),与描述一致;根包版本未动,符合发版纪律。
  • rebase 干净:已在本地把 fix commit rebase 到当前 master(50e250685),无冲突,diff 不变。
  • 正在本地跑定向验证(pi-subagents 套件 + fleet 定向测试 + host 集成测试 + typecheck/build),并逐行核对 truncateToWidth/visibleWidth 的字节级行为。结果稍后按结构化八问回复。

@ranxianglei ranxianglei added bug Something isn't working p2 pi scope/ui labels Oct 23, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

审核结论(结构化八问)

1. 是什么问题:Pi /acp-fleet 检视器两个独立渲染缺陷——CRLF 工具输出的行尾 \r 被终端解释为回车,光标跳回行首覆盖填充/边框(帧几何损坏);截断行的省略号及其后填充格丢失整行背景(背景缺口)。

2. 什么原因导致的:① pushToolGroup 只按 \n 切分、保留 \r——产噪点在显示边界;② pi-tui truncateToWidth 的收尾是 prefix + \x1b[0m + ellipsis + \x1b[0m,旧 bar() 把整行包在一个 theme.bg(...) 里,中途这个 reset 杀掉背景后再无人重新点亮,省略号+填充格全部落在默认背景上。我逐行读了 pi-tui 0.83.0 的 truncateToWidth/finalizeTruncatedResult/truncateFragmentToWidth 源码独立确认了字节级成因,与作者诊断一致。修法打在产噪点(显示边界归一化 + 预点亮省略号),不是治标。

3. 影响范围与严重程度:仅 Pi Fleet 检视器展示面(TUI overlay),Windows/CRLF 工具输出场景下帧错位、文字被覆盖;不触及压缩、持久化、执行参数、调度。能用但体验明显受损 → p2,与已打标签一致。

4. 怎么修复的:CRLF→LF 只在渲染时归一化(存储文本与 bash 执行参数不动,有不可变断言钉住);给 truncateToWidth 传入自带背景的省略号,剩余填充用 visibleWidth() 显式补画。窄视口(宽 1–3)走 pi-tui 的省略号自裁剪路径,我核过源码能正确产出恰好 1–3 列且全点亮。

5. 是否有回归问题:逐项清点过既有行为——LF-only 输出字节不变;截断标记字符本来就是 ASCII ...(pi-tui 默认值),视觉标记未变、只是补上了背景;每行可见宽度仍恒等于 innerW(1..120 全测过,含 CJK/emoji/组合符),外层 frame() 的 padTo 不受影响;bash 标签对 LF/tab 输入与旧版完全一致(既有测试钉住);user/thinking/text/meta 路径未被 diff 触碰且新测试证明无 CR 泄漏;非 TUI 快照路径未动。有意变更披露:bar 行的 SGR 字节布局变化(短行从 1 个 bg 对变 2 个、截断行多一组点亮序列)——纯字节级外观差异,无任何下游消费者解析这些字节(pi-tui 契约本就每行末尾全量 reset)。未发现无意回归。

6. 是否破坏缓存:不涉及——纯显示层,不碰前缀缓存、重试、游标、去重键。

7. 是否改了设计方向:不涉及。整行彩色背景设计保留(issue 明确要求)。

8. 是否引入新配置:无新 env/config/导出/依赖(visibleWidth 来自既有依赖 pi-tui 0.83.0 的现有导出,已核实)。

本地验证(rebase 到当前 master 50e250685 后,分支头 a6fd9d0de)

  • rebase 干净无冲突,净 diff 恰为 3 文件 +91/-7,与描述一致;merge-base 之后 master 在 pi-subagents/ 与 tests/pi-subagent* 上零提交,无热文件竞争
  • fleet-inspector.test.ts 19/19 · pi-subagents 套件 266/266 · host 集成三文件 43/43(channel 15 / registry 10 / wiring 18,逐文件跑;三个文件并行同跑会互相抢资源假红,属本地环境噪音,以 CI 为准)
  • typecheck ✅ · build ✅(dist-import-annotations/dist-external OK)· git diff --check ✅
  • 根包版本未动,pi-subagents 0.2.2→0.2.3 符合组件版本守卫;lockfile 无漂移(npm ci 实跑通过)

测试质量与代码质量

新测试是真测试:终端光标模拟器(\r 重置列号)+ 负向对照(未归一化的 CR 确实会推倒边框)证明断言有牙;背景连续性用真实 SGR 状态机解析,任何一格漏画都会红;宽度×内容矩阵(1..120 × ASCII/CJK/emoji-ZWJ/ANSI 前景色)覆盖了缺陷的完整失败签名。一处顺手改动:既有 usageSummary 测试把硬编码 "1,234" 改为 (1234).toLocaleString()——原断言在非美式 locale 下会假红(实现内部就是 toLocaleString),属合理的 locale 加固小修,单独成块、不改测试语义。代码本身命名清晰、无死代码、风格与文件一致,外部提交达到项目标准,无需对齐重构。

判定

可合并——待推送头的远程 CI 全量绿即可合(全量回归判定归 CI)。#4385 由 PR 的 Fixes 关联在合并时自动关闭,无需手动处理。

ci-check and others added 5 commits October 26, 2026 10:18
…ound' into 2026-10-23_fix-fleet-crlf-background
The component version bump moved pi-subagents/package.json to 0.2.3 but the root package-lock.json still recorded 0.2.2 in the file-dependency directory entry, so the lock-sync gate's regeneration rewrote that one field and failed. Regenerated with the gate's own command (npm install --package-lock-only); result verified byte-identical to the CI-expected output and idempotent under re-run, kernel lockfile step clean.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

lock-sync 红已修(CI auto-fix lane):独立 commit 4f74e438d 已推到 PR 分支,等 CI 重触发确认。

八问

  1. 是什么问题:PR 的 CI 唯一红条 lock-sync(lockfile 同步门禁)失败。
  2. 什么原因导致的:本 PR 按组件版本守卫把 pi-subagents/package.json 从 0.2.2 升到 0.2.3,但根 package-lock.json 里 file 依赖目录条目仍记录 0.2.2——门禁用 npm install --package-lock-only 重生成后比 diff,正好命中这一行漂移。非 master 继承:本分支已包含全部 master(rev-list 计数 0),master 自身 lockfile 自洽。
  3. 影响范围与严重程度:仅本 PR 检查矩阵的一个门禁红;无用户/运行时影响,纯元数据一致性。
  4. 怎么修复的:用门禁自己的命令重新生成根 lockfile(记录版本对齐 0.2.3),独立标注 commit、无其他改动。本地三点验证:① 重生成产物与 CI 日志中期望的 diff 逐字节一致(blob 相同);② 在修后树上重跑零变化(幂等);③ kernel/package-lock.json 步骤零漂移。
  5. 是否有回归问题:无。diff 仅 lockfile 一行(组件记录版本字段),不涉产品代码/配置/wire 语义。既有行为审计:lock-sync 门禁本身保持有效——修前树重跑仍红、修后树零漂移。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有。
  8. 是否引入新配置:没有。

判定:机制性小修(几行级),无需决策立项;CI 重跑后 lock-sync 转绿、其余门禁维持原状即可走合并(合并仍由人执行)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

✅ 三次 Sync 完成:master 又前进了 153 个提交(58e61a3d5,含 #5079 prompt-cache-key 默认关、#5120 hermetic test roots、#5136 post-fold credit 等),已合入 PR 分支,无冲突、净 diff 不变(仍为 4 文件 +92/-8);合并后树本地 typecheck / build / pi-subagents 套件 266/266 全绿;分支头已更新到 ab1faaf70,GitHub API 确认 mergeable=true(mergeable_state=blocked 仅为 CI 重跑中),不再落后 master(behind=0)。

ranxianglei pushed a commit that referenced this pull request Nov 13, 2026
…tor CRLF fix

The #4386 batch changed pi-subagents/src/fleet-inspector.ts (CRLF tool-label
normalization + background-bar painting) without bumping the component version,
so the pi-subagents-guard CI job failed. Bump pi-subagents/package.json (and the
matching package-lock.json file: entry) so the version discipline guard passes.
@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6482 (merged) — closing as superseded.

@ranxianglei ranxianglei reopened this Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Verified — supersession confirmed, and I deliberately skipped the round-6 branch sync for this reason:

Per policy I won't close it myself — the close is yours. Nothing further needed from this branch; the 5 prior sync pushes (rounds 1–5) are historical no-ops now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p2 pi scope/ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Pi] /acp-fleet transcript frame corruption with CRLF tool output and unpainted truncation ellipsis

2 participants