Repository navigation
fix(tui): fold previews only when collapsing saves rows - #4248
Conversation
Collapsing swaps the hidden rows for a one-line expand hint, so folding a single hidden row rendered at the same height as the full preview while hiding content behind ctrl+o. Thinking blocks, the generic truncated-output component, and the Write call preview now only fold when at least two rows are hidden.
🦋 Changeset detectedLatest commit: 6d18567 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff6e963341
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
CI |
The error-result branch of ToolCallComponent.computeHiddenContent and ShellRunComponent.hasHiddenContent still advertised ctrl+o when the preview hid exactly one row, which the preview now shows in full. Give both mirrors the same maxLines+1 threshold, and count Write rows in the expand predicate exactly like the renderer (highlightLines keeps a trailing empty entry that computeWriteStats strips), so a trailing newline no longer leaves the cap hint up while refusing expansion.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 418d845f18
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The error branch of computeHiddenContent counted non-empty lines, but the preview folds all rendered rows including interior blanks, so an error output of four non-empty rows plus a blank read as not-expandable while collapsing would still save a row. Count with the same trim-trailing-empty rule as the preview.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad5c906e49
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Bash's error preview renders sanitized output, so a trailing row that only carries an escape sequence disappears there but still counted toward hidden content, advertising ctrl+o for a card that cannot change. Count the same sanitized rows the preview folds.
) Ported from MoonshotAI/kimi-code 2.3.0 (8fcd332). Kept our cached finalLines count in shell-run's hasHiddenContent instead of re-splitting finalOutput per probe, applying upstream's +1 fold threshold to it. Kept our import ordering in tool-call and moved the new shell-output import into the #/ group, and dropped the now-unused computeWriteStats import. Shifted our shell-run line-count caching test to the new boundary (12 rows, not 11, now fold) because a single hidden row no longer gains anything.
Requirement or Bug
修复 TUI 折叠的一个 off-by-one:恰好只多出一行时,折叠提示行(
… (1 more lines, ctrl+o to expand))1:1 顶替被藏的那行,行数零节省,内容却被藏到 ctrl+o 后面(内部用户反馈,TUI p2)。Bug Reproduction Steps
Root Cause
三处折叠判断都是「藏 ≥1 行就折」(
length > maxLines/remaining > 0),没有扣除提示行自身占的 1 行:折叠净收益 = 隐藏行数 − 1,隐藏 1 行时收益为 0,纯损失一次 ctrl+o。根本修复(阈值修正),非绕过。Code Changes
tool-renderers/truncated.ts:TruncatedOutputComponent折叠条件改为contentLines.length > maxLines + 1(净省 ≥1 行才折);truncatedAtLastRender同步改,否则 ctrl+o 会在无内容可展时仍被广告(它经wasTruncated()喂hasHiddenContent());tail 分支共用同一条件,随之覆盖。thinking.ts:finalized 折叠分支与previewHidesLines改为contentLines.length > THINKING_PREVIEW_LINES + 1;live 流式滚动窗口(无提示行、机制不同)不动。tool-call.ts:Write 预览 cap 改为allLines.length > COMMAND_PREVIEW_LINES + 1;callPreviewHidesContent的 Write 镜像规则同步 +1,保持两处一致。录屏
真实 TUI(PR 分支 dev 构建)逐 case 录制,脚本带屏幕断言:每段都是「藏 1 行全显 → 藏 2 行折叠 → ctrl+o 展开 → 再折回」,右下角有按键回显。
thinking 块(3 行 / 4 行):
失败命令输出(共 4 行 / 共 5 行):
Write 预览(11 行 / 12 行):
已知同构、本 PR 不动(弹窗摘要场景、非 transcript 折叠,如需要可后续单独提):
approval-panel.tsfile_content 摘要(ctrl+e 预览)、question-dialog.tsbody 截断(无展开路径)。renderDiffLinesClustered按 cluster 边界截断、按 change 计数,数学不同,不在本 PR。Behavior Changes and Affected Users
!shell 卡片、通用工具错误结果)受影响模块:TUI transcript 渲染(
thinking.ts、tool-renderers/truncated.ts及其复用方 tool-call/shell-run/shell-execution、tool-call.tsWrite 预览)。仅 TUI 客户端;print 模式、desktop/web/VS Code 不经此路径。测试覆盖:三个组件各新增「藏 1 行 / 藏 2 行」边界用例;messages 目录相关套件 266 条全绿;tsc --noEmit、oxlint --type-aware、check-no-comments通过。真实 TUI 逐 case 录屏验证(thinking 3 行/4 行、失败命令 4 行/5 行、Write 11 行/12 行)见群话题。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.