Get the chatsettings back to global

This commit is contained in:
arafatkatze
2025-07-07 18:54:55 -06:00
parent 4260f1d4e2
commit f88ef4f075
4 changed files with 12 additions and 21 deletions
+2 -2
View File
@@ -400,9 +400,9 @@ export class Controller {
}
}
// Save only non-mode properties to workspace storage
// Save only non-mode properties to global storage
const { mode, ...persistentChatSettings }: { mode: string } & StoredChatSettings = chatSettings
await updateWorkspaceState(this.context, "chatSettings", persistentChatSettings)
await updateGlobalState(this.context, "chatSettings", persistentChatSettings)
await this.postStateToWebview()
if (this.task) {
+5 -10
View File
@@ -59,22 +59,17 @@ export async function updateSettings(controller: Controller, request: UpdateSett
if (request.chatSettings) {
const chatSettings = convertProtoChatSettingsToChatSettings(request.chatSettings)
// Split settings: mode goes to global, other settings to workspace
// Store mode to global state
if (chatSettings.mode !== undefined) {
await controller.context.globalState.update("mode", chatSettings.mode)
}
// Store workspace-specific settings (excluding mode)
const { mode, ...workspaceChatSettings } = chatSettings
await controller.context.workspaceState.update("chatSettings", workspaceChatSettings)
// Store chat settings (excluding mode) to global state
const { mode, ...globalChatSettings } = chatSettings
await controller.context.globalState.update("chatSettings", globalChatSettings)
if (controller.task) {
// Ensure task settings include the current mode from global state
const currentMode = (await controller.context.globalState.get("mode")) as "plan" | "act" | undefined
controller.task.chatSettings = {
...chatSettings,
mode: chatSettings.mode || currentMode || "plan",
}
controller.task.chatSettings = chatSettings
}
}
+2 -6
View File
@@ -79,6 +79,7 @@ export type GlobalStateKey =
| "sapAiResourceGroup"
| "claudeCodePath"
// Settings around plan/act and ephemeral model configuration
| "chatSettings"
| "mode"
// Current active model configuration (per workspace)
| "apiProvider"
@@ -112,9 +113,4 @@ export type GlobalStateKey =
| "previousModeAwsBedrockCustomModelBaseId"
| "previousModeSapAiCoreModelId"
export type LocalStateKey =
| "localClineRulesToggles"
| "localCursorRulesToggles"
| "localWindsurfRulesToggles"
| "workflowToggles"
| "chatSettings"
export type LocalStateKey = "localClineRulesToggles" | "localCursorRulesToggles" | "localWindsurfRulesToggles" | "workflowToggles"
+3 -3
View File
@@ -204,7 +204,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) {
const localClineRulesToggles = (await getWorkspaceState(context, "localClineRulesToggles")) as ClineRulesToggles
const [
workspaceChatSettings,
chatSettings,
currentMode,
storedApiProvider,
apiModelId,
@@ -236,7 +236,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) {
previousModeSapAiCoreModelId,
sapAiCoreModelId,
] = await Promise.all([
getWorkspaceState(context, "chatSettings") as Promise<StoredChatSettings | undefined>,
getGlobalState(context, "chatSettings") as Promise<StoredChatSettings | undefined>,
getGlobalState(context, "mode") as Promise<"plan" | "act" | undefined>,
getGlobalState(context, "apiProvider") as Promise<ApiProvider | undefined>,
getGlobalState(context, "apiModelId") as Promise<string | undefined>,
@@ -391,7 +391,7 @@ export async function getAllExtensionState(context: vscode.ExtensionContext) {
browserSettings: { ...DEFAULT_BROWSER_SETTINGS, ...browserSettings }, // this will ensure that older versions of browserSettings (e.g. before remoteBrowserEnabled was added) are merged with the default values (false for remoteBrowserEnabled)
chatSettings: {
...DEFAULT_CHAT_SETTINGS, // Apply defaults first
...(workspaceChatSettings || {}), // Spread fetched workspace chatSettings, which includes preferredLanguage, and openAIReasoningEffort
...(chatSettings || {}), // Spread fetched global chatSettings, which includes preferredLanguage, and openAIReasoningEffort
mode: currentMode || "plan", // Merge mode from global state
},
userInfo,