From c185807e6084de014be63020debed476007d3930 Mon Sep 17 00:00:00 2001 From: Animesh Gosain <126562373+animeshlego5@users.noreply.github.com> Date: Sat, 24 May 2025 17:44:32 +0530 Subject: [PATCH] feat: Add toggle to disable AI system message Refactor role mapping logic role Fix keymap for Void: Quick Edit to resolve conflict The current keymap causes a conflict between 'Void: Quick Edit' and 'Clear Console'/'Clear Terminal'. Using this _when_ expression, we can resolve the conflict without affecting functionality. * Add the when expression `editorFocus && !terminalFocus` to the keybinding for 'Void: Quick Edit' `void.ctrlKAction`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/voideditor/void?shareId=XXXX-XXXX-XXXX-XXXX). feat: add Devstral model mapping + fix quick-edit keybinding type claude 4 feat: Add to .gitignore remove whitespace changed gitignore changed gitignore again changed gitignore again --- .../platform/terminal/node/terminalProcess.ts | 4 ++-- .../browser/convertToLLMMessageService.ts | 22 ++++++++++--------- .../react/src/void-settings-tsx/Settings.tsx | 20 +++++++++++++++++ .../void/common/voidSettingsService.ts | 5 ++++- .../contrib/void/common/voidSettingsTypes.ts | 2 ++ 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/vs/platform/terminal/node/terminalProcess.ts b/src/vs/platform/terminal/node/terminalProcess.ts index ed74ee2f..2ecdba35 100644 --- a/src/vs/platform/terminal/node/terminalProcess.ts +++ b/src/vs/platform/terminal/node/terminalProcess.ts @@ -170,7 +170,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess cols, rows, useConpty, - ...(useConptyDll ? { useConptyDll } : {}) as IPtyForkOptions, + useConptyDll, // This option will force conpty to not redraw the whole viewport on launch conptyInheritCursor: useConpty && !!shellLaunchConfig.initialText }; @@ -392,7 +392,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess return; } // Don't throttle when using conpty.dll as it seems to have been fixed in later versions - if ((this._ptyOptions as any).useConptyDll) { + if (this._ptyOptions.useConptyDll) { return; } // Use a loop to ensure multiple calls in a single interval space out diff --git a/src/vs/workbench/contrib/void/browser/convertToLLMMessageService.ts b/src/vs/workbench/contrib/void/browser/convertToLLMMessageService.ts index 01fd58aa..795d9b58 100644 --- a/src/vs/workbench/contrib/void/browser/convertToLLMMessageService.ts +++ b/src/vs/workbench/contrib/void/browser/convertToLLMMessageService.ts @@ -250,8 +250,8 @@ const prepareOpenAIOrAnthropicMessages = ({ reservedOutputTokenSpace, }: { messages: SimpleLLMMessage[], - systemMessage: string, - aiInstructions: string, + systemMessage: string | undefined, + aiInstructions: string | undefined, supportsSystemMessage: false | 'system-role' | 'developer-role' | 'separated', specialToolFormat: 'openai-style' | 'anthropic-style' | undefined, supportsAnthropicReasoning: boolean, @@ -491,8 +491,8 @@ const prepareGeminiMessages = (messages: AnthropicLLMChatMessage[]) => { const prepareMessages = (params: { messages: SimpleLLMMessage[], - systemMessage: string, - aiInstructions: string, + systemMessage: string | undefined, + aiInstructions: string | undefined, supportsSystemMessage: false | 'system-role' | 'developer-role' | 'separated', specialToolFormat: 'openai-style' | 'anthropic-style' | 'gemini-style' | undefined, supportsAnthropicReasoning: boolean, @@ -520,7 +520,7 @@ const prepareMessages = (params: { export interface IConvertToLLMMessageService { readonly _serviceBrand: undefined; prepareLLMSimpleMessages: (opts: { simpleMessages: SimpleLLMMessage[], systemMessage: string, modelSelection: ModelSelection | null, featureName: FeatureName }) => { messages: LLMChatMessage[], separateSystemMessage: string | undefined } - prepareLLMChatMessages: (opts: { chatMessages: ChatMessage[], chatMode: ChatMode, modelSelection: ModelSelection | null }) => Promise<{ messages: LLMChatMessage[], separateSystemMessage: string | undefined }> + prepareLLMChatMessages: (opts: { chatMessages: ChatMessage[], chatMode: ChatMode, modelSelection: ModelSelection | null, explicitlyDisableSystemMessage?: boolean, explicitlyProvideAiInstructions?: string, }) => Promise<{ messages: LLMChatMessage[], separateSystemMessage: string | undefined }> prepareFIMMessage(opts: { messages: LLMFIMMessage, }): { prefix: string, suffix: string, stopTokens: string[] } } @@ -662,7 +662,7 @@ class ConvertToLLMMessageService extends Disposable implements IConvertToLLMMess }) return { messages, separateSystemMessage }; } - prepareLLMChatMessages: IConvertToLLMMessageService['prepareLLMChatMessages'] = async ({ chatMessages, chatMode, modelSelection }) => { + prepareLLMChatMessages: IConvertToLLMMessageService['prepareLLMChatMessages'] = async ({ chatMessages, chatMode, modelSelection, explicitlyDisableSystemMessage, explicitlyProvideAiInstructions, }) => { if (modelSelection === null) return { messages: [], separateSystemMessage: undefined } const { overridesOfModel } = this.voidSettingsService.state @@ -673,20 +673,22 @@ class ConvertToLLMMessageService extends Disposable implements IConvertToLLMMess contextWindow, supportsSystemMessage, } = getModelCapabilities(providerName, modelName, overridesOfModel) - const systemMessage = await this._generateChatMessagesSystemMessage(chatMode, specialToolFormat) + + const systemMessageFromGenerator = await this._generateChatMessagesSystemMessage(chatMode, specialToolFormat) const modelSelectionOptions = this.voidSettingsService.state.optionsOfModelSelection['Chat'][modelSelection.providerName]?.[modelSelection.modelName] // Get combined AI instructions - const aiInstructions = this._getCombinedAIInstructions(); - + const aiInstructions = explicitlyProvideAiInstructions || this._getCombinedAIInstructions(); + const globalDisableSystemMessageSetting = this.voidSettingsService.state.globalSettings.disableSystemMessage; + const finalSystemMessageForPrepareMessages = (explicitlyDisableSystemMessage || globalDisableSystemMessageSetting) ? undefined : systemMessageFromGenerator; const isReasoningEnabled = getIsReasoningEnabledState('Chat', providerName, modelName, modelSelectionOptions, overridesOfModel) const reservedOutputTokenSpace = getReservedOutputTokenSpace(providerName, modelName, { isReasoningEnabled, overridesOfModel }) const llmMessages = this._chatMessagesToSimpleMessages(chatMessages) const { messages, separateSystemMessage } = prepareMessages({ messages: llmMessages, - systemMessage, + systemMessage: finalSystemMessageForPrepareMessages, aiInstructions, supportsSystemMessage, specialToolFormat, diff --git a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx index a133ff49..0d23f5bb 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/void-settings-tsx/Settings.tsx @@ -5,6 +5,7 @@ import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react'; // Added useRef import just in case it was missed, though likely already present import { ProviderName, SettingName, displayInfoOfSettingName, providerNames, VoidStatefulModelInfo, customSettingNamesOfProvider, RefreshableProviderName, refreshableProviderNames, displayInfoOfProviderName, nonlocalProviderNames, localProviderNames, GlobalSettingName, featureNames, displayInfoOfFeatureName, isProviderNameDisabled, FeatureName, hasDownloadButtonsOnModelsProviderNames, subTextMdOfProviderName } from '../../../../common/voidSettingsTypes.js' +import { IVoidSettingsService, DISABLE_SYSTEM_MESSAGE_SETTING_ID } from '../../../../common/voidSettingsService.js'; import ErrorBoundary from '../sidebar-tsx/ErrorBoundary.js' import { VoidButtonBgDarken, VoidCustomDropdownBox, VoidInputBox2, VoidSimpleInputBox, VoidSwitch } from '../util/inputs.js' import { useAccessor, useIsDark, useRefreshModelListener, useRefreshModelState, useSettingsState } from '../util/services.js' @@ -1242,6 +1243,25 @@ Alternatively, place a \`.voidrules\` file in the root of your workspace. + {/* --- Disable System Message Toggle --- */} +
+ +
+ { + voidSettingsService.setGlobalSetting('disableSystemMessage', newValue); + }} + /> + + {settingsState.globalSettings.disableSystemMessage ? 'Minimal system messages sent' : 'Full system messages sent'} + +
+
+
When enabled, Void will send a minimal system message to the model to reduce token usage and improve model performance for certain tasks. +
+
diff --git a/src/vs/workbench/contrib/void/common/voidSettingsService.ts b/src/vs/workbench/contrib/void/common/voidSettingsService.ts index 73c9eceb..5c3ae2d6 100644 --- a/src/vs/workbench/contrib/void/common/voidSettingsService.ts +++ b/src/vs/workbench/contrib/void/common/voidSettingsService.ts @@ -13,7 +13,8 @@ import { IStorageService, StorageScope, StorageTarget } from '../../../../platfo import { IMetricsService } from './metricsService.js'; import { defaultProviderSettings, getModelCapabilities, ModelOverrides } from './modelCapabilities.js'; import { VOID_SETTINGS_STORAGE_KEY } from './storageKeys.js'; -import { defaultSettingsOfProvider, FeatureName, ProviderName, ModelSelectionOfFeature, SettingsOfProvider, SettingName, providerNames, ModelSelection, modelSelectionsEqual, featureNames, VoidStatefulModelInfo, GlobalSettings, GlobalSettingName, defaultGlobalSettings, ModelSelectionOptions, OptionsOfModelSelection, ChatMode, OverridesOfModel, defaultOverridesOfModel } from './voidSettingsTypes.js'; +import { defaultSettingsOfProvider, FeatureName, ProviderName, ModelSelectionOfFeature, SettingsOfProvider, SettingName, providerNames, ModelSelection, modelSelectionsEqual, featureNames, VoidStatefulModelInfo, GlobalSettings, GlobalSettingName, defaultGlobalSettings, ModelSelectionOptions, OptionsOfModelSelection, ChatMode, OverridesOfModel, defaultOverridesOfModel, } from './voidSettingsTypes.js'; +export const DISABLE_SYSTEM_MESSAGE_SETTING_ID = 'void.disableSystemMessage'; // name is the name in the dropdown @@ -272,6 +273,8 @@ class VoidSettingsService extends Disposable implements IVoidSettingsService { // autoapprove is now an obj not a boolean (1.2.5) if (typeof readS.globalSettings.autoApprove === 'boolean') readS.globalSettings.autoApprove = {} + + if (readS.globalSettings.disableSystemMessage === undefined) readS.globalSettings.disableSystemMessage = false; } catch (e) { readS = defaultState() diff --git a/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts b/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts index a911dfe6..f63abec5 100644 --- a/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts +++ b/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts @@ -434,6 +434,7 @@ export type GlobalSettings = { showInlineSuggestions: boolean; includeToolLintErrors: boolean; isOnboardingComplete: boolean; + disableSystemMessage: boolean; } export const defaultGlobalSettings: GlobalSettings = { @@ -447,6 +448,7 @@ export const defaultGlobalSettings: GlobalSettings = { showInlineSuggestions: true, includeToolLintErrors: true, isOnboardingComplete: false, + disableSystemMessage: false, } export type GlobalSettingName = keyof GlobalSettings