Repository navigation
Conversation
A model turn that only calls a tool has no text and shows no reply on screen, but /copy counted it, so after any tool use /copy 2 reported "AI message 2 contains no text to copy." instead of copying the previous reply. Count only model messages that carry non-thought text.
|
Thanks for the PR — and for filing the issue first with a real reproduction attached. That made this one easy to judge. Template looks good ✓ — every required section is filled in, including Before/After evidence and the Chinese translation. Problem: observed, not theoretical. #17384 carries concrete steps against a real CLI build ( Direction: aligned. Size: not applicable — no core paths. Both files are under Approach: the scope feels right, and I could not find a cheaper fix. Reusing the exact predicate the command already applies when extracting text ( One scope question before the code review, not a blocker: the docs above still say "AI message" without qualifying it. After this change an "AI message" for counting purposes means one with copyable text. A one-line clarification in Risk: no elevated risk signals — neither changed file matches the high-risk paths we track for post-merge reverts. Moving on to code review. 🔍 中文说明感谢贡献——也感谢先开 issue 并附上真实复现,这让判断变得很容易。 模板完整 ✓——所有必填章节都写了,包括 Before/After 证据和中文翻译。 问题:是已观测到的 bug,不是理论性加固。#17384 给出了针对真实 CLI 构建( **方向:**对齐。 **规模:**不适用——未触及核心路径。两个文件都在 **方案:**范围合理,我也没找到更省的改法。复用命令在提取文本时已经使用的同一个判定条件( 进入代码审查前先提一个范围问题,不是阻塞项:上面提到的文档仍然只写"AI 消息",没有限定条件。本次改动之后,计数意义上的"AI 消息"指的是有可复制文本的消息。在 **风险:**无升级风险信号——两个改动文件都不匹配我们为合并后回滚所跟踪的高风险路径。 进入代码审查 🔍 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
Code reviewI read the base file first and wrote down what I would have done before opening the diff: narrow the Because there is no executed evidence to lean on (see below), I verified as much as I could statically:
Two non-blocking notes:
Test evidenceStating plainly what this section carries: no executed test evidence exists for this PR at this time. Every CI workflow run on the reviewed commit concluded
The check-runs that do exist on this SHA are all bot orchestration, not the PR's own CI: Not verified, and why: unit tests, lint, Prettier formatting of the new lines, and Sandboxed verification would settle this: 中文说明代码审查我先读了改动前的文件,并在打开 diff 之前写下自己会怎么改:把 由于没有可依赖的执行证据(见下文),我尽可能做了静态验证:
两条非阻塞意见:
测试证据明确说明本节承载的内容:目前不存在任何已执行的测试证据。 被审 commit 上的每一个 CI 工作流运行结论都是 上面表格中的四项均为 该 SHA 上存在的检查运行全是机器人编排任务,而不是 PR 自身的 CI: 未验证项及原因:单元测试、lint、新增代码行的 Prettier 格式、 沙箱验证可以定论此事: — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
Confidence: 3/5 — the code review is clean and I would not change a line of the fix; the missing point is that nothing has executed, so "ready to ship" is not a claim I can make on this PR's behalf yet. Stepping back over the whole picture. I verified the problem exists rather than accepting the framing: the base file really does build its list with The things I usually worry about are all absent. Nine production lines in one non-core file, no new abstraction, no drive-by refactor, no formatting churn, no unrelated edits smuggled in. The predicate choice is the right one for a reason that outlives this bug: reusing the text-extraction test means the counted set and the copyable set cannot drift apart in a later change. The Web Shell already behaves this way, so this is convergence on existing repo behaviour rather than a new opinion. The author filed the issue first, with a reproduction, then wrote the fix — that is the order we ask for, and it is a first PR with no pattern of volume behind it, so I am judging it on merit and not through fatigue. In six months I would thank them, not curse them. So why not approve? Because the one thing I could not do is see it run, and this PR's entire value is a behavioural claim. Every CI run on the head is The asymmetry settles it for me. Branch protection dismisses stale reviews on a new push, not on a red check, so an approval cast now would still be standing if CI later fails. And a maintainer has to act on this PR regardless — the workflows need a human click before they run at all — so withholding my vote costs the PR nothing in wall-clock terms while keeping the record honest. If CI lands green on this SHA, my read is that this merges; the two notes in the review above (the now-unreachable Escalating to the maintainer rather than approving or rejecting — the code is not in question, the evidence is. 中文说明Confidence: 3/5——代码审查是干净的,修复本身我一行都不会改;差的那一分在于没有任何东西真正执行过,因此我还不能替这个 PR 说出"可以合并"。 退一步看全局。我核实了问题确实存在,而不是接受 PR 的说法:改动前的文件确实用 我通常担心的那些问题这里全都没有。一个非核心文件里的 9 行生产代码,没有新抽象,没有顺手重构,没有格式抖动,没有夹带无关改动。判定条件的选择之所以对,原因比这个 bug 本身更长久:复用文本提取时的判定,意味着"被计数的集合"和"可复制的集合"在以后的改动中不会各自漂移。Web Shell 早就是这个行为,所以这是向仓库既有行为收敛,而不是引入一种新主张。作者先开了 issue、带上复现,然后才写修复——这正是我们要求的顺序;而且这是其第一个 PR,背后没有批量投稿的模式,所以我是就事论事地评判,而不是在疲劳之下评判。半年后再看,我会感谢作者,而不是骂他。 那为什么不批准?因为唯一我做不到的事就是看它跑起来,而这个 PR 的全部价值恰恰是一个行为性主张。head 上的每一个 CI 运行都是 不对称性替我做了决定。分支保护会在有新 push 时驳回过期评审,但不会因为检查变红而驳回,所以现在投出的批准票即使日后 CI 失败也依然 standing。而且维护者无论如何都得在这个 PR 上动手——工作流需要人点一下才会跑——所以此时不投票不会让 PR 多等一分钟,却让记录保持诚实。如果 CI 在这个 SHA 上变绿,我的判断是可以合并;上面审查里的两条意见(现在不可达的 转交维护者,而不是批准或拒绝——被质疑的不是代码,是证据。 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
⏸️ Deferring to the maintainers — needs a human call on this one. Escalating this one to you — the code review is done and clean, so this is not a "please review it for me". It is one specific thing I cannot resolve from the diff, the tests, and the PR description. What I cannot resolve: there is no executed evidence at all. Every CI workflow run on What I did resolve, so you do not repeat it. I wrote my own fix from the title and motivation before reading the diff, and it was the same one-expression narrowing this PR ships — there is no simpler path being withheld. The problem is real: the base code counts every What I need from you:
My read: once CI is green on this SHA it merges. The two notes in my review — the 中文说明把这个转交给你——代码审查已经做完且是干净的,所以这不是"帮我 review 一下"。是一件我无法从 diff、测试和 PR 描述中解决的具体事情。 我无法解决的:完全不存在已执行的证据。 我已经解决的,免得你重复劳动。 我在读 diff 之前先根据标题和动机写了自己的修复方案,结果与本 PR 提交的单表达式收窄完全一致——没有被藏起来的更简路径。问题是真实的:改动前的代码会计入每一条 需要你做的:
我的判断:CI 在这个 SHA 上变绿之后就可以合并。我审查里的两条意见—— — Qwen Code · qwen3.8-max-2026-09-02 |
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed. Suggestions are inline.
Not reviewed: build-and-test — the review's own packages/cli build hit its budget timeout and CI skipped verify / tmux-testing at this commit; the changed suite (copyCommand.test.ts) was run green three times during the review, but no full build or integration run covers this change.
中文说明
仅完成部分审查,审查缺口已披露。 建议见行内评论。
未审查(原文为英文):build-and-test — the review's own packages/cli build hit its budget timeout and CI skipped verify / tmux-testing at this commit; the changed suite (copyCommand.test.ts) was run green three times during the review, but no full build or integration run covers this change.
— deepseek-v4.1-flash-1017@1f214e4e via Qwen Code /review (v0.27.4)
Count AI messages by the same non-thought text that /copy extracts, so the counted set and the copyable set cannot drift, and drop the "contains no text to copy" branch that this made unreachable. Document that /copy and /copy N skip turns with no visible text, and pin the preamble plus tool call turn and the bare /copy cases with tests.
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed.
Not reviewed: reverse audit — stopped before round 1 by the review time budget.
中文说明
仅完成部分审查,审查缺口已披露。
未审查:反向审计——评审时间预算不足,未能开始第 1 轮。
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.4)
… message Count a model turn only when a non-thought part has non-blank text, and extract text just for the selected turn. When model turns exist but none has text, report that the last AI output has no text to copy instead of claiming the history is empty. Narrow the comment and doc wording so they no longer promise that every counted turn is rendered as a reply.
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed. Suggestions are inline.
1 Suggestion-level finding(s) this review confirmed are already reported on this PR and are not repeated:
- R1-1 two-predicate count/extract split — the count predicate re-derives the extraction rule; still open (comment 4580137634)
Not reviewed: build-and-test — the packages/cli build was killed at its deadline twice and no full suite ran; only the changed test file was executed (48/48 green), so the cli typecheck and the rest of the cli suite are unmeasured.
Convergence: round 3 posted 2 inline comment(s), 2 of them reported for the first time; the previous round posted 4 (4 new). Findings keep coming back to the same files: packages/cli/src/ui/commands/copyCommand.ts (findings in round 2; 1 more now). A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. No Critical finding is open on this round, so merging and moving the remaining Suggestion threads to a follow-up issue is available as an ending — a merged pull request cannot diverge further. (Observation only — nothing was withheld from this review because of this observation.)
中文说明
仅完成部分审查,审查缺口已披露。 建议见行内评论。
本轮确认的 1 条建议级发现已在 PR 上报告过,不再重复发布(列表见上方英文部分)。
未审查(原文为英文):build-and-test — the packages/cli build was killed at its deadline twice and no full suite ran; only the changed test file was executed (48/48 green), so the cli typecheck and the rest of the cli suite are unmeasured.
收敛情况:第 3 轮发布了 2 条行内评论,其中 2 条是首次提出;上一轮发布了 4 条(其中 4 条首次提出)。发现反复回到同一批文件:packages/cli/src/ui/commands/copyCommand.ts(第 2 轮已出过发现,本轮又有 1 条)。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。本轮没有未决的 Critical,因此"合入后把剩余 Suggestion 线程转到后续 issue"是一个可选的结束方式——已合入的 PR 不会继续发散。(仅为观察——本轮评审未因此扣留任何内容。)
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.4)
A session whose model turns all lack text returned the no-text message for /copy 0 and /copy N. Parse and validate the index first so an indexed call reports the argument error or the real count, as on main; plain /copy keeps the no-text message. The docs now state that a turn with text before a tool call still counts toward N.
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed. Suggestions are inline.
3 Suggestion-level finding(s) this review confirmed are already reported on this PR and are not repeated:
- R1-1 count/extract two-predicate split — already reported and still open (comment 4580137634)
- R1-2 bare /copy falls back to an older reply while the wording still says last output — already reported and still open (comment 4580137645)
- R2-4 post-compaction synthetic acknowledgement counted as an AI message — already reported and still open (comment 4580533838)
Not explored to full depth (tool budget reached): "agent 3b": whether ui.history keeps pre-compression gemini items after a compaction** (this decides whether /copy N also reports "Only N AI messages" for replies sti….
Convergence: round 4 posted 1 inline comment(s), 1 of them reported for the first time; the previous round posted 2 (2 new). Findings keep coming back to the same files: packages/cli/src/ui/commands/copyCommand.ts (findings in round 3; 1 more now). A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. No Critical finding is open on this round, so merging and moving the remaining Suggestion threads to a follow-up issue is available as an ending — a merged pull request cannot diverge further. (Observation only — nothing was withheld from this review because of this observation.)
中文说明
已审查。 建议见行内评论。
本轮确认的 3 条建议级发现已在 PR 上报告过,不再重复发布(列表见上方英文部分)。
未探索到全部深度(达到工具调用预算):"agent 3b":whether ui.history keeps pre-compression gemini items after a compaction** (this decides whether /copy N also reports "Only N AI messages" for replies sti…。
收敛情况:第 4 轮发布了 1 条行内评论,其中 1 条是首次提出;上一轮发布了 2 条(其中 2 条首次提出)。发现反复回到同一批文件:packages/cli/src/ui/commands/copyCommand.ts(第 3 轮已出过发现,本轮又有 1 条)。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。本轮没有未决的 Critical,因此"合入后把剩余 Suggestion 线程转到后续 issue"是一个可选的结束方式——已合入的 PR 不会继续发散。(仅为观察——本轮评审未因此扣留任何内容。)
— deepseek-v4.1-flash-1017@1f214e4e via Qwen Code /review (v0.27.4)
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestions are inline.
Convergence: round 5 posted 2 inline comment(s), 2 of them reported for the first time; the previous round posted 1 (1 new). Findings keep coming back to the same files: packages/cli/src/ui/commands/copyCommand.ts (findings in round 3; 1 more now). The rate of new findings is not falling. A cluster that keeps producing siblings usually means the fixes are treating instances of a shared root cause — triaging that cause before the next round, or splitting an independent cluster into its own pull request, tends to end the loop faster than fixing them one at a time. Batching the remaining fixes and verifying them before the next push, or dropping this PR's reviews to --severity-floor critical, keeps the loop from re-deriving the same set. No Critical finding is open on this round, so merging and moving the remaining Suggestion threads to a follow-up issue is available as an ending — a merged pull request cannot diverge further. (Observation only — nothing was withheld from this review because of this observation.)
中文说明
已审查——无阻断问题。 建议见行内评论。
收敛情况:第 5 轮发布了 2 条行内评论,其中 2 条是首次提出;上一轮发布了 1 条(其中 1 条首次提出)。发现反复回到同一批文件:packages/cli/src/ui/commands/copyCommand.ts(第 3 轮已出过发现,本轮又有 1 条)。新发现的产出速度没有下降。一个不断再生兄弟发现的簇,通常意味着逐条修复只在处理同一根因的实例——先定位并处理该根因,或把独立的簇拆成单独的 PR,通常比逐条修复更快结束循环。把剩余修复攒成一批、验证后再推送,或将本 PR 的评审降到 --severity-floor critical,可以避免循环反复推导同一组发现。本轮没有未决的 Critical,因此"合入后把剩余 Suggestion 线程转到后续 issue"是一个可选的结束方式——已合入的 PR 不会继续发散。(仅为观察——本轮评审未因此扣留任何内容。)
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.4)
Reword the /copy description (en, zh, zh-TW, ca), the commands table row, and the out-of-range message so they all say N counts only AI messages with text.
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed.
Not reviewed: build-and-test — the harness build of packages/cli (the changed workspace) was killed at its 178s deadline after 18 of 20 sibling workspaces built green, and its test phase never ran, so the changed package's build and suite have no verdict from the harness; three other agents ran the changed suite directly and got 49/49 green.
Round shape: this re-review ran as a fix-audit round under the critical posting posture (engaged by the round schedule) — the territory fan-out covered the commits since the previous round (no still-clean importer re-entered the scope), and the reverse-audit waves re-launched delta territories under the ordinary retirement rules (a twice-dry one only on its cold-check rounds) and non-delta chunks the previous waves could not certify dry (a yield, an uncertified receipt, or no audit history keeps a chunk in the wave; a dry receipt returns it to the ordinary retirement rules when it shares its launch with a yield or uncertified receipt — rounds 1 and 2, the convergence pair, are one launch — was built on the same findings-list bytes as one, was built before one came back, or ran in a different session from some earlier return that was not dry, or beside one no session stamped). The floor was engaged and nothing below Critical reached it this round — any such finding would have been recorded and deferred, never posted (pre-confirmed [build]/[test]/[probe] findings excepted).
中文说明
仅完成部分审查,审查缺口已披露。
未审查(原文为英文):build-and-test — the harness build of packages/cli (the changed workspace) was killed at its 178s deadline after 18 of 20 sibling workspaces built green, and its test phase never ran, so the changed package's build and suite have no verdict from the harness; three other agents ran the changed suite directly and got 49/49 green.
轮次形态:本次 re-review 以 critical 发布姿态下的 fix-audit 轮运行(由轮次日程触发)——领地扇出只覆盖上一轮以来的 commits(没有仍然干净的 importer 重新进入范围),反向审计各波按普通退役规则重发 delta 领地(两次干燥的只在其冷检轮重发),并重发此前各波未能证实干燥的非 delta chunk(出过发现、收据未认证或无审计历史,都会让 chunk 留在波内;干燥收据若与出过发现或未认证的收据属于同一次启动——第 1、2 轮的收敛对算作一次启动——或与之使用字节完全相同的发现清单,或构建于这类收据返回之前,又或与此前某个非干燥返回不在同一个会话里(或该返回没有会话戳),则该 chunk 回到普通退役规则)。下限已生效,本轮没有任何低于 Critical 的发现触及它——若有,也只会记录延后、不发布(预确认的 [build]/[test]/[probe] 发现除外)。
— deepseek-v4.1-flash-1017@1f214e4e via Qwen Code /review (v0.27.4)
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed.
Not reviewed: build-and-test — the harness build of packages/cli (the changed workspace) was killed at its deadline after 20 of 21 scoped workspaces built green, so the package's build/typecheck and suite have no harness verdict; the changed suite was run green separately (copyCommand 59/59) but the rest of the cli suite is unmeasured.
中文说明
仅完成部分审查,审查缺口已披露。
未审查(原文为英文):build-and-test — the harness build of packages/cli (the changed workspace) was killed at its deadline after 20 of 21 scoped workspaces built green, so the package's build/typecheck and suite have no harness verdict; the changed suite was run green separately (copyCommand 59/59) but the rest of the cli suite is unmeasured.
— deepseek-v4.1-flash-1017 via Qwen Code /review (v0.27.4)
The msgid now says "AI message with text" in en, ca, zh and zh-TW; ru still had the old key, so mustTranslateKeys failed and Russian fell back to English.
What this PR does
/copy Nnow counts only model messages that contain copyable text. Model turns that consist only of a tool call (or only of thinking, or only of whitespace) are skipped when picking the Nth-last message, so/copy 2and its sub-selectors (/copy 2 code,/copy 2 latex, ...) land on the reply before the latest one. Plain/copyfollows the same rule, so it copies the latest reply with visible text: if the newest model turn only called a tool (for example it was interrupted before replying),/copynow copies the previous reply instead of reportingLast AI output contains no text to copy.; the user docs now say thatNcounts only messages with text. When the session has model turns but none of them has text,/copystill reportsLast AI output contains no text to copy.;No output in historystays reserved for a session with no model output at all. Out-of-range and/copy 0handling, and every block selector, are unchanged. Counting and copying share one text rule, so the counted set and the copied text cannot drift apart.flowchart TD A["/copy N"] --> B["Chat history"] B --> C{"Model entry with non-thought text?"} C -- "yes" --> D["Counted as an AI message"] C -- "no: tool call or thinking only" --> E["Skipped (before: counted)"] D --> F["Pick the Nth-last counted message"] F --> G["Apply code / LaTeX selector or copy whole reply"]Why it's needed
A tool-call-only model turn shows no reply on screen, but it was still counted. After any turn that used a tool,
/copy 2reportedAI message 2 contains no text to copy.and/copy 2 codecould not reach the code block in the previous reply; the user had to guess a higher number that depends on how many tool rounds the model made. The command is documented as copying the Nth-last reply, and the feature request that introduced/copy Nwas about reaching the substantive reply one turn back.Reviewer Test Plan
How to verify
/copycopies the latest reply (unchanged)./copy 2copies the reply from step 1 (before:AI message 2 contains no text to copy.)./copy 2 codecopies the code block from step 1 (before: same "no text" message)./copy 0is still rejected withMessage index must be a positive integer (1 = last AI message).Unit test:
cd packages/cli && npx vitest run src/ui/commands/copyCommand.test.tspasses 49/49 on this branch; the new tests that build a realistic history (reply, tool-call-only turn, function response, reply) and a history whose newest turn only called a tool fail onmain, a separate test pins that a turn with preamble text plus a tool call still counts as a message, another pins that a turn whose only text is whitespace (next to a tool call) is skipped rather than copied as a blank line, and another pins that a session whose only model turn called a tool reportsLast AI output contains no text to copy.while/copy 0in that session is still rejected as an invalid index. One existing test that asserted the old counting of text-less model messages was updated to the new expectation (/copy 2past a text-less message now reports the real count). ESLint and Prettier are clean on the changed files andtsc --noEmitforpackages/clipasses.Evidence (Before & After)
Real CLI built from this repo, driven in a real terminal (vhs) against the repo's fake OpenAI-compatible server, so no API key is involved. Part 1 is
main, part 2 is this branch, same script: two edge cases (/copy 2,/copy 2 code) and two unchanged behaviours (/copy,/copy 0), then the clipboard contents.qwen-copy-n-before-after.mp4
Tested on
Environment (optional)
Built with
npm run build, run withnode packages/cli/dist/index.js --auth-type openaiagainst the local fake server.Risk & Scope
Linked Issues
Fixes #17384
中文说明
这个 PR 做了什么
/copy N现在只统计包含可复制文本的模型消息。仅包含工具调用(或仅包含思考内容、或仅包含空白字符)的模型轮次在选取倒数第 N 条消息时会被跳过,因此/copy 2及其子选择器(/copy 2 code、/copy 2 latex等)会定位到最新回复之前的那条回复。普通的/copy遵循同一规则,因此会复制最新一条含可见文本的回复:如果最新的模型轮次只调用了工具(例如在回复前被中断),/copy现在会复制上一条回复,而不是提示Last AI output contains no text to copy.;用户文档已说明N只统计含文本的消息。如果会话中有模型轮次但都不含文本,/copy仍提示Last AI output contains no text to copy.;No output in history只用于完全没有模型输出的会话。超出范围和/copy 0的处理,以及所有代码块选择器的行为保持不变。计数与复制共用同一条文本规则,因此计入的消息与实际复制的文本不会脱节。(流程图见上方英文部分:
/copy N→ 聊天历史 → 判断模型条目是否含有非思考文本 → 是则计为一条 AI 消息,否(仅工具调用或仅思考)则跳过(修复前会被计入)→ 选取倒数第 N 条已计入的消息 → 应用代码 / LaTeX 选择器或复制整条回复。)为什么需要
仅包含工具调用的模型轮次在屏幕上不显示任何回复,但此前仍会被计数。只要某一轮使用了工具,
/copy 2就会报告AI message 2 contains no text to copy.,/copy 2 code也无法取到上一条回复中的代码块;用户只能去猜一个更大的数字,而这个数字取决于模型进行了几轮工具调用。文档中该命令的语义是复制倒数第 N 条回复,而引入/copy N的功能请求本身就是为了取到上一轮中有实质内容的回复。审阅者测试计划
如何验证
/copy复制最新回复(行为不变)。/copy 2复制第 1 步的回复(修复前:AI message 2 contains no text to copy.)。/copy 2 code复制第 1 步回复中的代码块(修复前:同样的 “no text” 提示)。/copy 0仍会被拒绝,并提示Message index must be a positive integer (1 = last AI message).单元测试:
cd packages/cli && npx vitest run src/ui/commands/copyCommand.test.ts在本分支上 49/49 通过;新增的测试构造了真实的历史记录(回复、仅工具调用的轮次、函数响应、回复)以及最新轮次只调用了工具的历史记录,这些测试在main上失败;另有一个测试固定了「开场文本 + 工具调用」的轮次仍计为一条消息,一个测试固定了文本仅为空白字符(并带工具调用)的轮次会被跳过、不会把空行复制到剪贴板,还有一个测试固定了唯一的模型轮次只调用了工具时提示Last AI output contains no text to copy.,而在该会话中/copy 0仍按无效索引被拒绝。一个断言旧计数方式(统计无文本模型消息)的现有测试已更新为新的预期(越过无文本消息执行/copy 2时报告真实的消息数量)。改动文件的 ESLint 和 Prettier 检查通过,packages/cli的tsc --noEmit通过。证据(修复前与修复后)
使用本仓库构建的真实 CLI,在真实终端(vhs)中运行,连接仓库自带的模拟 OpenAI 兼容服务器,因此不涉及任何 API 密钥。第 1 部分为
main,第 2 部分为本分支,脚本相同:两个边界场景(/copy 2、/copy 2 code)和两个保持不变的行为(/copy、/copy 0),最后展示剪贴板内容。视频见上方英文部分。
测试平台
环境(可选)
使用
npm run build构建,通过node packages/cli/dist/index.js --auth-type openai连接本地模拟服务器运行。风险与范围
关联 Issue
Fixes #17384