diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e57b8d5..b34d2fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [10.10.0] - 2025-xx-xx +- Removed the chatbot command and all related code and references - [#983](https://github.com/estruyf/vscode-front-matter/issues/983): Removal of the `frontMatter.sponsors.ai.enabled` features ### 🎨 Enhancements diff --git a/package.json b/package.json index 79ea6a48..3c57897b 100644 --- a/package.json +++ b/package.json @@ -2385,15 +2385,6 @@ "category": "Front Matter", "icon": "$(book)" }, - { - "command": "frontMatter.chatbot", - "title": "%command.frontMatter.chatbot%", - "category": "Front Matter", - "icon": { - "light": "assets/icons/chatbot-light.svg", - "dark": "assets/icons/chatbot-dark.svg" - } - }, { "command": "frontMatter.promoteSettings", "title": "%command.frontMatter.promoteSettings%", @@ -2560,11 +2551,6 @@ "command": "frontMatter.dashboard.close", "group": "navigation@-98", "when": "frontMatter:enabled == true && frontMatter:dashboard:open == true" - }, - { - "command": "frontMatter.chatbot", - "group": "navigation@-97", - "when": "resourceFilename == 'frontmatter.json'" } ], "explorer/context": [ @@ -2774,11 +2760,6 @@ "group": "navigation@-1", "when": "view == frontMatter.explorer" }, - { - "command": "frontMatter.chatbot", - "group": "navigation@0", - "when": "view == frontMatter.explorer" - }, { "command": "frontMatter.mode.switch", "group": "navigation@1", diff --git a/src/commands/Chatbot.ts b/src/commands/Chatbot.ts deleted file mode 100644 index ba1e616f..00000000 --- a/src/commands/Chatbot.ts +++ /dev/null @@ -1,126 +0,0 @@ -import { PreviewCommands, GeneralCommands } from './../constants'; -import { join } from 'path'; -import { commands, Uri, ViewColumn, window } from 'vscode'; -import { Extension } from '../helpers'; -import { WebviewHelper } from '@estruyf/vscode'; -import { getLocalizationFile } from '../utils/getLocalizationFile'; -import * as l10n from '@vscode/l10n'; -import { LocalizationKey } from '../localization'; -import { getWebviewJsFiles } from '../utils'; - -export class Chatbot { - /** - * Open the Chatbot in the editor - */ - public static async open(extensionPath: string) { - // Create the preview webview - const webView = window.createWebviewPanel( - 'frontMatterChatbot', - `Front Matter AI - ${l10n.t(LocalizationKey.commandsChatbotTitle)}`, - { - viewColumn: ViewColumn.Beside, - preserveFocus: true - }, - { - enableScripts: true - } - ); - - webView.iconPath = { - dark: Uri.file(join(extensionPath, 'assets/icons/frontmatter-short-dark.svg')), - light: Uri.file(join(extensionPath, 'assets/icons/frontmatter-short-light.svg')) - }; - - const cspSource = webView.webview.cspSource; - - const fetchLocalization = async (requestId: string) => { - if (!requestId) { - return; - } - - const fileContents = await getLocalizationFile(); - - webView.webview.postMessage({ - command: GeneralCommands.toVSCode.getLocalization, - requestId, - payload: fileContents - }); - }; - - webView.webview.onDidReceiveMessage(async (message) => { - const { command, requestId, payload, data } = message; - - switch (command) { - case PreviewCommands.toVSCode.open: - if (payload || data) { - commands.executeCommand('vscode.open', payload || data); - } - break; - case GeneralCommands.toVSCode.getLocalization: - fetchLocalization(requestId); - return; - } - }); - - const webviewFile = 'dashboard.main.js'; - const localPort = `9000`; - const localServerUrl = `localhost:${localPort}`; - - const nonce = WebviewHelper.getNonce(); - - const ext = Extension.getInstance(); - const isProd = ext.isProductionMode; - const version = ext.getVersion(); - const isBeta = ext.isBetaVersion(); - - const csp = [ - `default-src 'none';`, - `img-src ${cspSource} http: https:;`, - `script-src ${ - isProd ? `'nonce-${nonce}'` : `http://${localServerUrl} http://0.0.0.0:${localPort}` - } 'unsafe-eval'`, - `style-src ${cspSource} 'self' 'unsafe-inline' http: https:`, - `connect-src https://* ${ - isProd - ? `` - : `ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort}` - }` - ]; - - let scriptUris = []; - if (isProd) { - scriptUris = await getWebviewJsFiles('dashboard', webView.webview); - } else { - scriptUris.push(`http://${localServerUrl}/${webviewFile}`); - } - - // By default, the chatbot is seen as experimental - const experimental = true; - - webView.webview.html = ` - - -
- - - - -