From 31e379bc09dd7973d3359ca6a3e50fe0f8ed707a Mon Sep 17 00:00:00 2001 From: wwayne Date: Thu, 30 May 2024 12:58:55 +0800 Subject: [PATCH] fix(vscode): copy function for vscode and remove codeblock download --- clients/vscode/src/chat/ChatViewProvider.ts | 16 +++++++- ee/tabby-ui/components/ui/codeblock.tsx | 39 +------------------ .../lib/hooks/use-copy-to-clipboard.tsx | 29 +++++++------- 3 files changed, 28 insertions(+), 56 deletions(-) diff --git a/clients/vscode/src/chat/ChatViewProvider.ts b/clients/vscode/src/chat/ChatViewProvider.ts index e1510b0f4466..fdf4949c9a13 100644 --- a/clients/vscode/src/chat/ChatViewProvider.ts +++ b/clients/vscode/src/chat/ChatViewProvider.ts @@ -62,8 +62,15 @@ export class ChatViewProvider implements WebviewViewProvider { }); webviewView.webview.onDidReceiveMessage(async (message) => { - if (message.action === "rendered") { - await this.initChatPage(); + switch (message.action) { + case "rendered": { + await this.initChatPage(); + return; + } + case "copy": { + env.clipboard.writeText(message.data); + return; + } } }); @@ -165,6 +172,10 @@ export class ChatViewProvider implements WebviewViewProvider { syncTheme(); return; } + if (event.data.action === 'copy') { + vscode.postMessage(event.data); + return; + } if (event.data.data) { chatIframe.contentWindow.postMessage(event.data.data[0], "${endpoint}"); @@ -180,6 +191,7 @@ export class ChatViewProvider implements WebviewViewProvider {