-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(vscode): restore native diff approval after WebShell cutover #10534
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0e1bada
fix(vscode): restore native diff approval flow
yiliang114 f1f45f2
fix(vscode): only accept host-delivered web-shell permission decisions
yiliang114 1be6b2d
fix(vscode): open web-shell permission diffs read-only
yiliang114 f9a6d9b
fix(vscode): align showDiff overload signatures with options argument
yiliang114 2317625
fix(vscode): only vote web-shell approvals from the permission diff
yiliang114 1744245
fix(web-shell): lowercase tool names inside isEditToolName
yiliang114 5071a73
docs(web-shell): note pending-edit-approval exception in expand invar…
yiliang114 eb6ff92
test(web-shell): pin allow_once-first ladder for native edit approvals
yiliang114 8bac3fd
test(vscode): expect the readOnly options argument in showDiff comman…
yiliang114 868ade9
fix(vscode): accept host-relayed permission decisions by their source…
yiliang114 48cafd6
fix(vscode): only accept diff votes targeting a pending permission diff
yiliang114 59f8a6b
test(vscode): pin web-shell diff source to readOnly showDiff mapping
yiliang114 ee902f1
fix(vscode): keep read-only approval diffs from reusing writable twins
yiliang114 01546cf
fix(vscode): clear web-shell permission flag when the chat view disposes
yiliang114 446610c
test(vscode): pin the command-level diff vote gate chain
yiliang114 3e86689
test(vscode): expect pending:false when permission diffs are torn down
yiliang114 d8cefb2
fix(vscode): complete WebShell host interaction parity
yiliang114 4b408eb
merge: integrate concurrent VS Code diff safeguards
yiliang114 b546b30
fix(vscode): surface a notice when a diff vote is not applied
yiliang114 44b9d08
fix(vscode): complete native diff follow-ups
yiliang114 3a0824a
Merge branch 'main' into codex/vscode-webshell-diff-approval
yiliang114 258acf9
fix(vscode): address native diff verification findings
yiliang114 7ecdea9
test(vscode): cover legacy diff permission fallback
yiliang114 4fee90a
fix(web-shell): accept native votes for structured edits
yiliang114 427dc2e
Merge branch 'main' into codex/vscode-webshell-diff-approval
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| const executeCommand = vi.fn().mockResolvedValue(undefined); | ||
|
|
||
| vi.mock('vscode', () => { | ||
| class EventEmitter<T> { | ||
| private listeners = new Set<(event: T) => void>(); | ||
| event = (listener: (event: T) => void) => { | ||
| this.listeners.add(listener); | ||
| return { dispose: () => this.listeners.delete(listener) }; | ||
| }; | ||
| fire(event: T): void { | ||
| for (const listener of [...this.listeners]) listener(event); | ||
| } | ||
| dispose(): void { | ||
| this.listeners.clear(); | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| EventEmitter, | ||
| Uri: { | ||
| file: (filePath: string) => { | ||
| const uri: { | ||
| fsPath: string; | ||
| scheme: string; | ||
| query: string; | ||
| with: (change: Record<string, unknown>) => unknown; | ||
| toString: () => string; | ||
| } = { | ||
| fsPath: filePath, | ||
| scheme: 'file', | ||
| query: '', | ||
| with(change: Record<string, unknown>) { | ||
| return { ...uri, ...change }; | ||
| }, | ||
| toString() { | ||
| return `${uri.scheme}://${uri.fsPath}?${uri.query}`; | ||
| }, | ||
| }; | ||
| return uri; | ||
| }, | ||
| }, | ||
| ViewColumn: { Active: -1, Beside: -2 }, | ||
| commands: { executeCommand }, | ||
| window: { | ||
| activeTextEditor: undefined, | ||
| onDidChangeActiveTextEditor: vi.fn(() => ({ dispose: vi.fn() })), | ||
| tabGroups: { all: [] }, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| // Avoid pulling the full extension module graph; only the scheme constant is | ||
| // needed by the diff manager. | ||
| vi.mock('./extension.js', () => ({ DIFF_SCHEME: 'qwen-diff' })); | ||
|
|
||
| vi.mock('@qwen-code/qwen-code-core', () => ({ | ||
| IdeDiffAcceptedNotificationSchema: { parse: (value: unknown) => value }, | ||
| IdeDiffClosedNotificationSchema: { parse: (value: unknown) => value }, | ||
| })); | ||
|
|
||
| const { DiffContentProvider, DiffManager } = await import('./diff-manager.js'); | ||
|
|
||
| const WRITABLE_COMMAND = | ||
| 'workbench.action.files.setActiveEditorWriteableInSession'; | ||
|
|
||
| describe('DiffManager.showDiff writability', () => { | ||
| beforeEach(() => { | ||
| executeCommand.mockClear(); | ||
| }); | ||
|
|
||
| function createManager(): InstanceType<typeof DiffManager> { | ||
| return new DiffManager(() => {}, new DiffContentProvider()); | ||
| } | ||
|
|
||
| it('makes regular diffs editable so IDE-mode approvals can round-trip edits', async () => { | ||
| const manager = createManager(); | ||
|
|
||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new'); | ||
|
|
||
| expect(executeCommand).toHaveBeenCalledWith(WRITABLE_COMMAND); | ||
| }); | ||
|
|
||
| it('keeps read-only diffs locked for flows that cannot round-trip edits', async () => { | ||
| const manager = createManager(); | ||
|
|
||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new', { | ||
| readOnly: true, | ||
| }); | ||
|
|
||
| expect(executeCommand).not.toHaveBeenCalledWith(WRITABLE_COMMAND); | ||
| // The diff itself still opens. | ||
| expect(executeCommand).toHaveBeenCalledWith( | ||
| 'vscode.diff', | ||
| expect.anything(), | ||
| expect.anything(), | ||
| expect.stringContaining('foo.ts'), | ||
| expect.anything(), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('DiffManager.showDiff reuse', () => { | ||
| beforeEach(() => { | ||
| executeCommand.mockClear(); | ||
| }); | ||
|
|
||
| function createManager(): InstanceType<typeof DiffManager> { | ||
| return new DiffManager(() => {}, new DiffContentProvider()); | ||
| } | ||
|
|
||
| function diffOpenCount(): number { | ||
| return executeCommand.mock.calls.filter( | ||
| ([command]) => command === 'vscode.diff', | ||
| ).length; | ||
| } | ||
|
|
||
| it('opens a fresh diff instead of reusing a writable twin for a read-only request', async () => { | ||
| const manager = createManager(); | ||
|
|
||
| // IDE-mode flow opens a writable diff for this (path, old, new) triple. | ||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new'); | ||
| executeCommand.mockClear(); | ||
|
|
||
| // A web-shell approval for the same triple must get its own read-only | ||
| // diff; reusing the writable one would invite hand-edits that the | ||
| // approving tool then silently discards (and inside the dedupe window | ||
| // the request would otherwise be suppressed outright). | ||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new', { | ||
| readOnly: true, | ||
| }); | ||
|
|
||
| expect(diffOpenCount()).toBe(1); | ||
| expect(executeCommand).not.toHaveBeenCalledWith(WRITABLE_COMMAND); | ||
| }); | ||
|
|
||
| it('opens a fresh diff instead of reusing a read-only twin for a writable request', async () => { | ||
| const manager = createManager(); | ||
|
|
||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new', { | ||
| readOnly: true, | ||
| }); | ||
| executeCommand.mockClear(); | ||
|
|
||
| // The IDE-mode flow needs an editable right side to round-trip edits; | ||
| // refocusing the locked diff would take that away. | ||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new'); | ||
|
|
||
| expect(diffOpenCount()).toBe(1); | ||
| expect(executeCommand).toHaveBeenCalledWith(WRITABLE_COMMAND); | ||
| }); | ||
|
|
||
| it('still dedupes repeat requests with matching writability', async () => { | ||
| const manager = createManager(); | ||
|
|
||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new'); | ||
| executeCommand.mockClear(); | ||
|
|
||
| // Same writability inside the dedupe window: suppressed entirely. | ||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new'); | ||
| expect(diffOpenCount()).toBe(0); | ||
|
|
||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new', { | ||
| readOnly: true, | ||
| }); | ||
| executeCommand.mockClear(); | ||
| await manager.showDiff('/workspace/foo.ts', 'old', 'new', { | ||
| readOnly: true, | ||
| }); | ||
| expect(diffOpenCount()).toBe(0); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.