-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(core): include full filePath alongside fileName in edit/write-file diff results #8607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
26796d3
98d208e
a0e28cc
983ff5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1458,9 +1458,11 @@ function extractDiffContent(resultDisplay: unknown): ToolCallContent | null { | |
| return { | ||
| type: 'diff', | ||
| path: | ||
| typeof resultDisplay['fileName'] === 'string' | ||
| ? resultDisplay['fileName'] | ||
| : '', | ||
| typeof resultDisplay['filePath'] === 'string' | ||
| ? resultDisplay['filePath'] | ||
| : typeof resultDisplay['fileName'] === 'string' | ||
| ? resultDisplay['fileName'] | ||
| : '', | ||
|
Comment on lines
+1463
to
+1465
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The 中文说明
— qwen3.8-max via Qwen Code /review (v0.21.6) |
||
| oldText: | ||
| typeof resultDisplay['originalContent'] === 'string' | ||
| ? resultDisplay['originalContent'] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -327,7 +327,10 @@ function extractDiffContent( | |
| return [ | ||
| { | ||
| type: 'diff', | ||
| path: display['fileName'] as string, | ||
| path: | ||
| typeof display['filePath'] === 'string' | ||
| ? display['filePath'] | ||
| : (display['fileName'] as string), | ||
|
Comment on lines
+330
to
+333
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] This "prefer 中文说明这个"优先 — qwen3.8-max via Qwen Code /review (v0.21.6) |
||
| oldText: (display['originalContent'] as string) ?? '', | ||
| newText: display['newContent'] as string, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7673,6 +7673,7 @@ describe('CoreToolScheduler edit cancellation', () => { | |
| '--- test.txt\n+++ test.txt\n@@ -1,1 +1,1 @@\n-old content\n+new content', | ||
| ); | ||
| expect(cancelledCall.response.resultDisplay.fileName).toBe('test.txt'); | ||
| expect(cancelledCall.response.resultDisplay.filePath).toBe('test.txt'); | ||
|
Comment on lines
7675
to
+7676
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] R2-4: This new assertion cannot discriminate the field's source: the mock confirmation details set Failure scenario: if the cancelled-edit path is refactored to source Suggested fix — give the mock distinct values and assert the distinct literal: // mock confirmation details (~L6804): filePath: '/workspace/test.txt'
expect(cancelledCall.response.resultDisplay.filePath).toBe('/workspace/test.txt');中文说明这条新断言无法区分字段的来源:mock 确认详情把 失败场景:如果取消编辑路径被重构为从 建议修复——给 mock 设置不同的值并断言该不同的字面量(见上方代码块)。 — qwen3.8-max via Qwen Code /review (v0.21.6) |
||
| }); | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -697,6 +697,7 @@ class NotebookEditInvocation extends BaseToolInvocation< | |
| const displayResult = { | ||
| fileDiff, | ||
| fileName, | ||
| filePath: this.params.notebook_path, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] R2-2: The new Failure scenario: a future refactor that drops or renames this line regresses notebook-edit ACP/export diff paths to the basename while the whole suite stays green — re-introducing, scoped to notebook edits, the exact bug class this PR fixes. Verified by probe: deleting this line leaves all 31 tests green. Suggested fix — add one assertion in an existing success-path test (the temp-dir path is absolute and distinct from the basename): expect((result.returnDisplay as FileDiff).filePath).toBe(filePath);中文说明notebook 编辑新增的 失败场景:未来某次重构删除或改名这一行时,notebook 编辑的 ACP/导出 diff 路径会退回 basename,而整个测试套件仍是绿的——在 notebook 编辑范围内重新引入本 PR 所修复的这类 bug。已通过探针验证:删除这一行后全部 31 个测试仍然通过。 建议修复——在一个现有的成功路径测试中加入上方代码块中的断言(temp 目录路径是绝对路径且与 basename 不同)。 — qwen3.8-max via Qwen Code /review (v0.21.6) |
||
| originalContent: prepared.originalContent, | ||
| newContent: prepared.updatedContent, | ||
| diffStat, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1768,6 +1768,7 @@ export class ShellToolInvocation extends BaseToolInvocation< | |
| 'Proposed', | ||
| ), | ||
| fileName: edit.fileName, | ||
| filePath: edit.filePath, | ||
|
Comment on lines
1770
to
+1771
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] R2-3: Failure scenario: if this line is dropped or changed to Suggested fix — add to the 'applies a qualifying sed -i command' test: expect((result.returnDisplay as FileDiff).filePath).toBe(expectedSedFilePath);( 中文说明
失败场景:如果这一行被删除或改为 建议修复——在 'applies a qualifying sed -i command' 测试中加入上方代码块中的断言( — qwen3.8-max via Qwen Code /review (v0.21.6) |
||
| originalContent: edit.originalContent, | ||
| newContent: edit.newContent, | ||
| diffStat, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -813,6 +813,13 @@ export interface TaskListResultDisplay { | |||||
| export interface FileDiff { | ||||||
| fileDiff: string; | ||||||
| fileName: string; | ||||||
| /** | ||||||
| * Full (project-relative or absolute) path to the edited file, as passed | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] R2-6: The JSDoc contract written here misstates the field's invariant: it says "Full (project-relative or absolute) path to the edited file, as passed to the tool", but every producer guarantees an absolute path — Failure scenario: a future maintainer adding an edit-producing tool reads this doc and emits a project-relative
Suggested change
(then continue the JSDoc: producers resolve the path before setting this; consumers may rely on it being absolute) 中文说明此处写下的 JSDoc 约定与该字段的实际不变量不符:它写的是"编辑文件的完整(项目相对或绝对)路径,按传入工具时的原样",但每个生产者都保证路径是绝对路径—— 失败场景:未来某位维护者新增一个会产生编辑结果的工具,读到这段文档后输出了项目相对的 建议修复——把不变量改为"编辑文件的绝对路径。生产者必须在设置该字段前解析/规范化路径"(见上方 suggestion 块及补充说明)。 — qwen3.8-max via Qwen Code /review (v0.21.6) |
||||||
| * to the tool. UI consumers must prefer this over `fileName` when | ||||||
| * resolving a clickable/openable location — `fileName` is a basename and | ||||||
|
Comment on lines
+818
to
+819
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] R2-1: Three in-tree
Failure scenario: (1) A session editing a nested file emits an unresolvable basename to live clients while replay/export of the same session shows the full path — same data, different fidelity per view. (2) Exporting a session where sed-edits touched Suggested fix — prefer // live-task-service.ts (extend the local isFileDiff guard accordingly)
path: display.filePath ?? display.fileName,
// collect.ts
filePath = (typeof display.filePath === 'string' && display.filePath)
|| (args?.['file_path'] as string)
|| display.fileName;
// DataProcessor.ts
uniqueFiles.add(typeof diff.filePath === 'string' && diff.filePath ? diff.filePath : diff.fileName);Deferrable to a follow-up if you want to keep this PR scoped to the two ACP extractors. 中文说明树内还有三个
失败场景:(1) 编辑嵌套文件的会话在实时视图中向客户端发出无法解析的 basename,而同一会话的回放/导出却显示完整路径——同样的数据,不同视图保真度不同。(2) 导出一个用 sed 编辑过 建议修复——三处都在 — qwen3.8-max via Qwen Code /review (v0.21.6) |
||||||
| * cannot be used to locate files outside the workspace root. | ||||||
| */ | ||||||
| filePath?: string; | ||||||
|
Comment on lines
+818
to
+822
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The new 中文说明新增的 — qwen3.8-max via Qwen Code /review (v0.21.6) |
||||||
| originalContent: string | null; | ||||||
| newContent: string; | ||||||
| diffStat?: DiffStat; | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -632,6 +632,7 @@ class WriteFileToolInvocation extends BaseToolInvocation< | |
| const displayResult: FileDiff = { | ||
| fileDiff, | ||
| fileName, | ||
| filePath: file_path, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The cancelled-edit path drops this field. When the user cancels an edit at the confirmation prompt, the cancelled branch in 中文说明取消编辑的路径会丢弃这个字段。当用户在确认提示处取消编辑时, — qwen3.8-max via Qwen Code /review (v0.21.6) |
||
| originalContent, | ||
| newContent: content, | ||
| diffStat, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] R2-5: The new
filePath-over-fileNamepreference logic added to this exporter is unreachable by every test command: the file is a plain.jshelper outside all npm workspaces,integration-tests/vitest.config.tscollects only**/*.test.ts, it is invoked only by the manualrunner.pyharness, and no workflow or root npm script referencesconcurrent-runner.Failure scenario: if the
displayPathselection regresses (fallback order flipped, dedup comparing the wrong field), no unit or integration suite fails; the generated HTML report silently shows basename-only or wrongly deduplicated file locations — the exact bug this PR fixes elsewhere, reappearing here ungated.Suggested fix: add a colocated test the integration vitest root collects (e.g.
export-html-from-chatrecord-jsonl.test.jsimportingextractLocations/extractDiffContentand assertingfilePathis preferred when present andfileNameis the fallback), or extract the two pure functions into a workspace module with unit tests.中文说明
新增到这个导出器的"优先
filePath、回退fileName"逻辑对任何测试命令都不可达:该文件是位于所有 npm workspace 之外的纯.js辅助脚本,integration-tests/vitest.config.ts只收集**/*.test.ts,它仅由手动运行的runner.py调用,且没有任何 workflow 或根 npm 脚本引用concurrent-runner。失败场景:如果
displayPath选择逻辑退化(回退顺序颠倒、去重比较了错误的字段),没有任何单元或集成测试会失败;生成的 HTML 报告会悄悄显示仅含 basename 或被错误去重的文件位置——本 PR 在别处修复的 bug 在这里不受任何门禁保护地复现。建议修复:添加一个集成 vitest 根能收集的同目录测试(例如
export-html-from-chatrecord-jsonl.test.js,导入extractLocations/extractDiffContent,断言存在filePath时优先使用、回退到fileName),或把这两个纯函数提取到某个 workspace 模块中并配单元测试。— qwen3.8-max via Qwen Code /review (v0.21.6)