From d3f326722eee5aa4b8c0d08fdcd9e13bfd934e76 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Mon, 13 Apr 2026 15:01:10 +0200 Subject: [PATCH] feat: re-add GitHub Copilot settings and enhance integration checks --- CHANGELOG.md | 1 + package.json | 5 +++++ package.nls.json | 3 ++- src/constants/settings.ts | 1 + src/helpers/PanelSettings.ts | 4 +++- src/helpers/Questions.ts | 6 +++++- src/listeners/panel/DataListener.ts | 27 ++++++++++++++++++++++++- src/listeners/panel/TaxonomyListener.ts | 16 +++++++++++++++ src/models/PanelSettings.ts | 1 + 9 files changed, 60 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77268b3a..762287bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### 🐞 Fixes - [#1023](https://github.com/estruyf/vscode-front-matter/issues/1023): Fix validation errors for image, file, and keywords fields +- [#1024](https://github.com/estruyf/vscode-front-matter/issues/1024): Re-add the `frontMatter.copilot.enabled` setting to allow users to disable the GitHub Copilot integration ## [10.10.0] - 2026-04-03 - [Release notes](https://beta.frontmatter.codes/updates/v10.10.0) diff --git a/package.json b/package.json index 76df0927..3272d275 100644 --- a/package.json +++ b/package.json @@ -2128,6 +2128,11 @@ "type": "string", "default": "gpt-4o-mini", "markdownDescription": "%setting.frontMatter.copilot.family.markdownDescription%" + }, + "frontMatter.copilot.enabled": { + "type": "boolean", + "default": true, + "markdownDescription": "%setting.frontMatter.copilot.enabled.markdownDescription%" } } }, diff --git a/package.nls.json b/package.nls.json index 30905db4..3973023b 100644 --- a/package.nls.json +++ b/package.nls.json @@ -292,5 +292,6 @@ "setting.frontMatter.git.disableOnBranches.markdownDescription": "Specify the branches on which you want to disable the Git actions. [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.disableonbranches) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.git.disableonbranches%22%5D)", "setting.frontMatter.git.requiresCommitMessage.markdownDescription": "Specify if you want to require a commit message when publishing your changes for a specified branch. [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.git.requirescommitmessage) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.git.requirescommitmessage%22%5D)", - "setting.frontMatter.copilot.family.markdownDescription": "Specify the LLM family of the Copilot you want to use. [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.copilot.family) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.copilot.family%22%5D)" + "setting.frontMatter.copilot.family.markdownDescription": "Specify the LLM family of the Copilot you want to use. [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.copilot.family) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.copilot.family%22%5D)", + "setting.frontMatter.copilot.enabled.markdownDescription": "Specify if you want to enable GitHub Copilot AI suggestions (requires GitHub Copilot extension). [Docs](https://frontmatter.codes/docs/settings/overview#frontmatter.copilot.enabled) - [View in VS Code](command:simpleBrowser.show?%5B%22https://frontmatter.codes/docs/settings/overview%23frontmatter.copilot.enabled%22%5D)" } diff --git a/src/constants/settings.ts b/src/constants/settings.ts index dbbb3e66..cb138441 100644 --- a/src/constants/settings.ts +++ b/src/constants/settings.ts @@ -117,6 +117,7 @@ export const SETTING_SNIPPETS_WRAPPER = 'snippets.wrapper.enabled'; export const SETTING_WEBSITE_URL = 'website.host'; export const SETTING_COPILOT_FAMILY = 'copilot.family'; +export const SETTING_COPILOT_ENABLED = 'copilot.enabled'; export const SETTING_LOGGING = 'logging'; diff --git a/src/helpers/PanelSettings.ts b/src/helpers/PanelSettings.ts index caf415e7..27468fa0 100644 --- a/src/helpers/PanelSettings.ts +++ b/src/helpers/PanelSettings.ts @@ -1,7 +1,8 @@ import { SETTING_GLOBAL_TIMEZONE, SETTING_PANEL_ACTIONS_DISABLED, - SETTING_WEBSITE_URL + SETTING_WEBSITE_URL, + SETTING_COPILOT_ENABLED } from './../constants/settings'; import { workspace } from 'vscode'; import { ContentType, Extension, Logger, Settings, TaxonomyHelper } from '.'; @@ -51,6 +52,7 @@ export class PanelSettings { try { return { + aiEnabled: Settings.get(SETTING_COPILOT_ENABLED) !== false, copilotEnabled: await Copilot.isInstalled(), git: await GitListener.getSettings(), seo: { diff --git a/src/helpers/Questions.ts b/src/helpers/Questions.ts index 45f8a96e..d6d8604b 100644 --- a/src/helpers/Questions.ts +++ b/src/helpers/Questions.ts @@ -1,8 +1,10 @@ import { QuickPickItem, QuickPickItemKind, window } from 'vscode'; import { Folders } from '../commands/Folders'; +import { SETTING_COPILOT_ENABLED } from '../constants'; import { ContentType } from './ContentType'; import { Notifications } from './Notifications'; import { Logger } from './Logger'; +import { Settings } from './SettingsHelper'; import * as l10n from '@vscode/l10n'; import { LocalizationKey } from '../localization'; import { ContentFolder } from '../models'; @@ -37,12 +39,14 @@ export class Questions { * @returns */ public static async ContentTitle(showWarning = true): Promise { + const copilotEnabled = Settings.get(SETTING_COPILOT_ENABLED) !== false; let title: string | undefined = ''; const isCopilotInstalled = await Copilot.isInstalled(); let aiTitles: string[] | undefined; - if (isCopilotInstalled) { + // Only show AI suggestions if both the setting is enabled and Copilot is installed + if (copilotEnabled && isCopilotInstalled) { title = await window.showInputBox({ title: l10n.t(LocalizationKey.helpersQuestionsContentTitleAiInputTitle), prompt: l10n.t(LocalizationKey.helpersQuestionsContentTitleAiInputPrompt), diff --git a/src/listeners/panel/DataListener.ts b/src/listeners/panel/DataListener.ts index 2ea7f904..900da475 100644 --- a/src/listeners/panel/DataListener.ts +++ b/src/listeners/panel/DataListener.ts @@ -26,7 +26,8 @@ import { SETTING_DATE_FORMAT, SETTING_GLOBAL_ACTIVE_MODE, SETTING_GLOBAL_MODES, - SETTING_TAXONOMY_CONTENT_TYPES + SETTING_TAXONOMY_CONTENT_TYPES, + SETTING_COPILOT_ENABLED } from '../../constants'; import { Article, Preview } from '../../commands'; import { FrontMatterParser, ParsedFrontMatter } from '../../parsers'; @@ -124,6 +125,15 @@ export class DataListener extends BaseListener { return; } + // Check if Copilot is enabled and installed + const copilotEnabled = Settings.get(SETTING_COPILOT_ENABLED) !== false; + const isCopilotInstalled = await Copilot.isInstalled(); + + if (!copilotEnabled || !isCopilotInstalled) { + this.sendRequestError(command, requestId, 'Copilot is not enabled or installed'); + return; + } + const aiTitles = await Copilot.suggestTitles(title); title = await Questions.pickTitleSuggestions(title, aiTitles || [], true); @@ -145,6 +155,21 @@ export class DataListener extends BaseListener { return; } + // Check if Copilot is enabled and installed + const copilotEnabled = Settings.get(SETTING_COPILOT_ENABLED) !== false; + const isCopilotInstalled = await Copilot.isInstalled(); + + if (!copilotEnabled || !isCopilotInstalled) { + const extPath = Extension.getInstance().extensionPath; + const panel = PanelProvider.getInstance(extPath); + panel.getWebview()?.postMessage({ + command, + requestId, + error: l10n.t(LocalizationKey.servicesCopilotGetChatResponseError) + } as MessageHandlerData); + return; + } + const article = ArticleHelper.getActiveFile(); if (!article) { return; diff --git a/src/listeners/panel/TaxonomyListener.ts b/src/listeners/panel/TaxonomyListener.ts index 65b92935..b8b3d735 100644 --- a/src/listeners/panel/TaxonomyListener.ts +++ b/src/listeners/panel/TaxonomyListener.ts @@ -4,6 +4,7 @@ import { BaseListener } from './BaseListener'; import { authentication, window } from 'vscode'; import { ArticleHelper, Extension, Settings, TaxonomyHelper } from '../../helpers'; import { BlockFieldData, CustomTaxonomyData, PostMessageData, TaxonomyType } from '../../models'; +import { SETTING_COPILOT_ENABLED } from '../../constants'; import { DataListener } from '.'; import { SettingsListener as PanelSettingsListener } from '.'; import { SettingsListener as DashboardSettingsListener } from '../dashboard'; @@ -84,6 +85,21 @@ export class TaxonomyListener extends BaseListener { return; } + // Check if Copilot is enabled and installed + const copilotEnabled = Settings.get(SETTING_COPILOT_ENABLED) !== false; + const isCopilotInstalled = await Copilot.isInstalled(); + + if (!copilotEnabled || !isCopilotInstalled) { + const extPath = Extension.getInstance().extensionPath; + const panel = PanelProvider.getInstance(extPath); + panel.getWebview()?.postMessage({ + command, + requestId, + error: l10n.t(LocalizationKey.servicesCopilotGetChatResponseError) + } as MessageHandlerData); + return; + } + const article = ArticleHelper.getActiveFile(); if (!article) { return; diff --git a/src/models/PanelSettings.ts b/src/models/PanelSettings.ts index c567751c..d11d885e 100644 --- a/src/models/PanelSettings.ts +++ b/src/models/PanelSettings.ts @@ -28,6 +28,7 @@ export interface PanelSettings { dataTypes: DataType[] | undefined; fieldGroups: FieldGroup[] | undefined; commaSeparatedFields: string[]; + aiEnabled: boolean; copilotEnabled: boolean; contentFolders: ContentFolder[]; websiteUrl: string;