refactor(vscode-ide-companion/extension): disable unused path import and diff relay

Temporarily disable unused path import and diff event relaying functionality
that was causing issues.

TODO: 没有生效 - temporarily disabled due to commented out usage
This commit is contained in:
yiliang114
2025-12-05 12:42:44 +08:00
parent 0851ab572d
commit 5ed60348d6

View File

@@ -5,7 +5,7 @@
*/
import * as vscode from 'vscode';
import * as path from 'node:path';
// import * as path from 'node:path'; // TODO: 没有生效 - temporarily disabled due to commented out usage
import { IDEServer } from './ide-server.js';
import semver from 'semver';
import { DiffContentProvider, DiffManager } from './diff-manager.js';
@@ -167,44 +167,45 @@ export async function activate(context: vscode.ExtensionContext) {
createWebViewProvider,
);
// TODO: 没有生效
// Relay diff accept/cancel events to the chat webview as assistant notices
// so the user sees immediate feedback in the chat thread (Claude Code style).
context.subscriptions.push(
diffManager.onDidChange((notification) => {
try {
const method = (notification as { method?: string }).method;
if (method !== 'ide/diffAccepted' && method !== 'ide/diffClosed') {
return;
}
// context.subscriptions.push(
// diffManager.onDidChange((notification) => {
// try {
// const method = (notification as { method?: string }).method;
// if (method !== 'ide/diffAccepted' && method !== 'ide/diffClosed') {
// return;
// }
const params = (
notification as unknown as {
params?: { filePath?: string };
}
).params;
const filePath = params?.filePath ?? '';
const fileBase = filePath ? path.basename(filePath) : '';
const text =
method === 'ide/diffAccepted'
? `Accepted changes${fileBase ? ` to ${fileBase}` : ''}.`
: `Cancelled changes${fileBase ? ` to ${fileBase}` : ''}.`;
// const params = (
// notification as unknown as {
// params?: { filePath?: string };
// }
// ).params;
// const filePath = params?.filePath ?? '';
// const fileBase = filePath ? path.basename(filePath) : '';
// const text =
// method === 'ide/diffAccepted'
// ? `Accepted changes${fileBase ? ` to ${fileBase}` : ''}.`
// : `Cancelled changes${fileBase ? ` to ${fileBase}` : ''}.`;
for (const provider of webViewProviders) {
const panel = provider.getPanel();
panel?.webview.postMessage({
type: 'message',
data: {
role: 'assistant',
content: text,
timestamp: Date.now(),
},
});
}
} catch (e) {
console.warn('[Extension] Failed to relay diff event to chat:', e);
}
}),
);
// for (const provider of webViewProviders) {
// const panel = provider.getPanel();
// panel?.webview.postMessage({
// type: 'message',
// data: {
// role: 'assistant',
// content: text,
// timestamp: Date.now(),
// },
// });
// }
// } catch (e) {
// console.warn('[Extension] Failed to relay diff event to chat:', e);
// }
// }),
// );
context.subscriptions.push(
vscode.workspace.onDidCloseTextDocument((doc) => {