Skip to content

Commit 0b057be

Browse files
committed
feat:发送到聊天按钮新增自动打开聊天页面功能
1 parent b82f651 commit 0b057be

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/chatPanel.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,17 @@ export class ChatPanel {
473473
return conversation;
474474
}
475475

476-
public static insertFilePathToInput(filePath: string): void {
476+
public static insertFilePathToInput(context: vscode.ExtensionContext, filePath: string): void {
477+
if (!ChatPanel.currentPanel) {
478+
ChatPanel.createOrShow(context);
479+
}
480+
477481
if (ChatPanel.currentPanel) {
478482
const formattedPath = `@file:${filePath}`;
479483
ChatPanel.currentPanel.panel.webview.postMessage({
480484
command: 'insertFilePath',
481485
content: formattedPath
482486
});
483-
} else {
484-
vscode.window.showInformationMessage('No active chat panel. Please open a chat panel first.');
485487
}
486488
}
487489

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export function activate(context: vscode.ExtensionContext) {
400400

401401
let sendFileToChatCommand = vscode.commands.registerCommand('codeReDesign.sendToChat', async (uri: vscode.Uri) => {
402402
if (uri && uri.scheme === 'file') {
403-
ChatPanel.insertFilePathToInput(uri.fsPath);
403+
ChatPanel.insertFilePathToInput(context, uri.fsPath);
404404
}
405405
});
406406

src/siderBar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function registerCvbContextMenu(context: vscode.ExtensionContext) {
8484

8585
const sendToChatommand = vscode.commands.registerCommand('codeReDesign.sendThisToChat', async (cvb: CvbFile) => {
8686
const filePath = cvb.resourceUri?.fsPath || "";
87-
await sendToChat(filePath);
87+
await sendToChat(context, filePath);
8888
});
8989
context.subscriptions.push(sendToChatommand);
9090

@@ -463,6 +463,6 @@ async function summaryThisCvb(filePath: string) {
463463
vscode.window.showInformationMessage(`Conversation log saved as: ${filePath}`);
464464
}
465465

466-
async function sendToChat(filePath: string) {
467-
ChatPanel.insertFilePathToInput(filePath);
466+
async function sendToChat(context: vscode.ExtensionContext, filePath: string) {
467+
ChatPanel.insertFilePathToInput(context, filePath);
468468
}

0 commit comments

Comments
 (0)