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