Skip to content

Commit 2158165

Browse files
authored
[PROTOBUS] updateSettings & didUpdateSettings (RooCodeInc#4073)
* updateSettings proto mvp * changeset
1 parent 78792c2 commit 2158165

File tree

9 files changed

+582
-139
lines changed

9 files changed

+582
-139
lines changed

.changeset/blue-cobras-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Migrated updateSettings to protos, removed didUpdateSettings, altered Plan/Act toggling in settings menu

proto/state.proto

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ service StateService {
1313
rpc togglePlanActMode(TogglePlanActModeRequest) returns (Empty);
1414
rpc updateTerminalConnectionTimeout(Int64Request) returns (Int64);
1515
rpc updateAutoApprovalSettings(AutoApprovalSettingsRequest) returns (Empty);
16+
rpc updateSettings(UpdateSettingsRequest) returns (Empty);
1617
}
1718

1819
message State {
@@ -64,3 +65,126 @@ message AutoApprovalSettingsRequest {
6465
bool enable_notifications = 6;
6566
repeated string favorites = 7;
6667
}
68+
69+
// Message for updating settings
70+
message UpdateSettingsRequest {
71+
Metadata metadata = 1;
72+
optional ApiConfiguration api_configuration = 2;
73+
optional string custom_instructions_setting = 3;
74+
optional string telemetry_setting = 4;
75+
optional bool plan_act_separate_models_setting = 5;
76+
optional bool enable_checkpoints_setting = 6;
77+
optional bool mcp_marketplace_enabled = 7;
78+
optional ChatSettings chat_settings = 8;
79+
optional int64 shell_integration_timeout = 9;
80+
optional bool terminal_reuse_enabled = 10;
81+
optional bool mcp_responses_collapsed = 11;
82+
}
83+
84+
// Complete API Configuration message
85+
message ApiConfiguration {
86+
// Core API fields
87+
optional string api_provider = 1;
88+
optional string api_model_id = 2;
89+
optional string api_key = 3; // anthropic
90+
optional string api_base_url = 4;
91+
92+
// Provider-specific API keys
93+
optional string cline_api_key = 5;
94+
optional string openrouter_api_key = 6;
95+
optional string anthropic_base_url = 7;
96+
optional string openai_api_key = 8;
97+
optional string openai_native_api_key = 9;
98+
optional string gemini_api_key = 10;
99+
optional string deepseek_api_key = 11;
100+
optional string requesty_api_key = 12;
101+
optional string together_api_key = 13;
102+
optional string fireworks_api_key = 14;
103+
optional string qwen_api_key = 15;
104+
optional string doubao_api_key = 16;
105+
optional string mistral_api_key = 17;
106+
optional string nebius_api_key = 18;
107+
optional string asksage_api_key = 19;
108+
optional string xai_api_key = 20;
109+
optional string sambanova_api_key = 21;
110+
optional string cerebras_api_key = 22;
111+
112+
// Model IDs
113+
optional string openrouter_model_id = 23;
114+
optional string openai_model_id = 24;
115+
optional string anthropic_model_id = 25;
116+
optional string bedrock_model_id = 26;
117+
optional string vertex_model_id = 27;
118+
optional string gemini_model_id = 28;
119+
optional string ollama_model_id = 29;
120+
optional string lm_studio_model_id = 30;
121+
optional string litellm_model_id = 31;
122+
optional string requesty_model_id = 32;
123+
optional string together_model_id = 33;
124+
optional string fireworks_model_id = 34;
125+
126+
// AWS Bedrock fields
127+
optional bool aws_bedrock_custom_selected = 35;
128+
optional string aws_bedrock_custom_model_base_id = 36;
129+
optional string aws_access_key = 37;
130+
optional string aws_secret_key = 38;
131+
optional string aws_session_token = 39;
132+
optional string aws_region = 40;
133+
optional bool aws_use_cross_region_inference = 41;
134+
optional bool aws_bedrock_use_prompt_cache = 42;
135+
optional bool aws_use_profile = 43;
136+
optional string aws_profile = 44;
137+
optional string aws_bedrock_endpoint = 45;
138+
139+
// Vertex AI fields
140+
optional string vertex_project_id = 46;
141+
optional string vertex_region = 47;
142+
143+
// Base URLs and endpoints
144+
optional string openai_base_url = 48;
145+
optional string ollama_base_url = 49;
146+
optional string lm_studio_base_url = 50;
147+
optional string gemini_base_url = 51;
148+
optional string litellm_base_url = 52;
149+
optional string asksage_api_url = 53;
150+
151+
// LiteLLM specific fields
152+
optional string litellm_api_key = 54;
153+
optional bool litellm_use_prompt_cache = 55;
154+
155+
// Model configuration
156+
optional int64 thinking_budget_tokens = 56;
157+
optional string reasoning_effort = 57;
158+
optional int64 request_timeout_ms = 58;
159+
160+
// Fireworks specific
161+
optional int64 fireworks_model_max_completion_tokens = 59;
162+
optional int64 fireworks_model_max_tokens = 60;
163+
164+
// Azure specific
165+
optional string azure_api_version = 61;
166+
167+
// Ollama specific
168+
optional string ollama_api_options_ctx_num = 62;
169+
170+
// Qwen specific
171+
optional string qwen_api_line = 63;
172+
173+
// OpenRouter specific
174+
optional string openrouter_provider_sorting = 64;
175+
176+
// VSCode LM (stored as JSON string due to complex type)
177+
optional string vscode_lm_model_selector = 65;
178+
179+
// Model info objects (stored as JSON strings)
180+
optional string openrouter_model_info = 66;
181+
optional string openai_model_info = 67;
182+
optional string requesty_model_info = 68;
183+
optional string litellm_model_info = 69;
184+
185+
// OpenAI headers (stored as JSON string)
186+
optional string openai_headers = 70;
187+
188+
// Favorited model IDs
189+
repeated string favorited_model_ids = 71;
190+
}

src/core/controller/index.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -285,61 +285,6 @@ export class Controller {
285285
await this.postStateToWebview()
286286
break
287287
}
288-
case "updateSettings": {
289-
// api config
290-
if (message.apiConfiguration) {
291-
await updateApiConfiguration(this.context, message.apiConfiguration)
292-
if (this.task) {
293-
this.task.api = buildApiHandler(message.apiConfiguration)
294-
}
295-
}
296-
297-
// custom instructions
298-
await this.updateCustomInstructions(message.customInstructionsSetting)
299-
300-
// telemetry setting
301-
if (message.telemetrySetting) {
302-
await this.updateTelemetrySetting(message.telemetrySetting)
303-
}
304-
305-
// plan act setting
306-
await updateGlobalState(this.context, "planActSeparateModelsSetting", message.planActSeparateModelsSetting)
307-
308-
if (typeof message.enableCheckpointsSetting === "boolean") {
309-
await updateGlobalState(this.context, "enableCheckpointsSetting", message.enableCheckpointsSetting)
310-
}
311-
312-
if (typeof message.mcpMarketplaceEnabled === "boolean") {
313-
await updateGlobalState(this.context, "mcpMarketplaceEnabled", message.mcpMarketplaceEnabled)
314-
}
315-
316-
if (typeof message.mcpResponsesCollapsed === "boolean") {
317-
await updateGlobalState(this.context, "mcpResponsesCollapsed", message.mcpResponsesCollapsed)
318-
}
319-
320-
// chat settings (including preferredLanguage and openAIReasoningEffort)
321-
if (message.chatSettings) {
322-
await updateGlobalState(this.context, "chatSettings", message.chatSettings)
323-
if (this.task) {
324-
this.task.chatSettings = message.chatSettings
325-
}
326-
}
327-
328-
// terminal settings
329-
if (typeof message.shellIntegrationTimeout === "number") {
330-
await updateGlobalState(this.context, "shellIntegrationTimeout", message.shellIntegrationTimeout)
331-
}
332-
333-
if (typeof message.terminalReuseEnabled === "boolean") {
334-
await updateGlobalState(this.context, "terminalReuseEnabled", message.terminalReuseEnabled)
335-
}
336-
337-
// after settings are updated, post state to webview
338-
await this.postStateToWebview()
339-
340-
await this.postMessageToWebview({ type: "didUpdateSettings" })
341-
break
342-
}
343288
case "clearAllTaskHistory": {
344289
const answer = await vscode.window.showWarningMessage(
345290
"What would you like to delete?",
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { Controller } from ".."
2+
import { Empty } from "../../../shared/proto/common"
3+
import { UpdateSettingsRequest } from "../../../shared/proto/state"
4+
import { updateApiConfiguration } from "../../storage/state"
5+
import { buildApiHandler } from "../../../api"
6+
import { convertProtoApiConfigurationToApiConfiguration } from "../../../shared/proto-conversions/state/settings-conversion"
7+
import { convertProtoChatSettingsToChatSettings } from "../../../shared/proto-conversions/state/chat-settings-conversion"
8+
import { TelemetrySetting } from "@/shared/TelemetrySetting"
9+
10+
/**
11+
* Updates multiple extension settings in a single request
12+
* @param controller The controller instance
13+
* @param request The request containing the settings to update
14+
* @returns An empty response
15+
*/
16+
export async function updateSettings(controller: Controller, request: UpdateSettingsRequest): Promise<Empty> {
17+
try {
18+
// Update API configuration
19+
if (request.apiConfiguration) {
20+
const apiConfiguration = convertProtoApiConfigurationToApiConfiguration(request.apiConfiguration)
21+
await updateApiConfiguration(controller.context, apiConfiguration)
22+
23+
if (controller.task) {
24+
controller.task.api = buildApiHandler(apiConfiguration)
25+
}
26+
}
27+
28+
// Update custom instructions
29+
if (request.customInstructionsSetting !== undefined) {
30+
await controller.updateCustomInstructions(request.customInstructionsSetting)
31+
}
32+
33+
// Update telemetry setting
34+
if (request.telemetrySetting) {
35+
await controller.updateTelemetrySetting(request.telemetrySetting as TelemetrySetting)
36+
}
37+
38+
// Update plan/act separate models setting
39+
if (request.planActSeparateModelsSetting !== undefined) {
40+
await controller.context.globalState.update("planActSeparateModelsSetting", request.planActSeparateModelsSetting)
41+
}
42+
43+
// Update checkpoints setting
44+
if (request.enableCheckpointsSetting !== undefined) {
45+
await controller.context.globalState.update("enableCheckpointsSetting", request.enableCheckpointsSetting)
46+
}
47+
48+
// Update MCP marketplace setting
49+
if (request.mcpMarketplaceEnabled !== undefined) {
50+
await controller.context.globalState.update("mcpMarketplaceEnabled", request.mcpMarketplaceEnabled)
51+
}
52+
53+
// Update MCP responses collapsed setting
54+
if (request.mcpResponsesCollapsed !== undefined) {
55+
await controller.context.globalState.update("mcpResponsesCollapsed", request.mcpResponsesCollapsed)
56+
}
57+
58+
// Update chat settings
59+
if (request.chatSettings) {
60+
const chatSettings = convertProtoChatSettingsToChatSettings(request.chatSettings)
61+
await controller.context.globalState.update("chatSettings", chatSettings)
62+
if (controller.task) {
63+
controller.task.chatSettings = chatSettings
64+
}
65+
}
66+
67+
// Update terminal timeout setting
68+
if (request.shellIntegrationTimeout !== undefined) {
69+
await controller.context.globalState.update("shellIntegrationTimeout", Number(request.shellIntegrationTimeout))
70+
}
71+
72+
// Update terminal reuse setting
73+
if (request.terminalReuseEnabled !== undefined) {
74+
await controller.context.globalState.update("terminalReuseEnabled", request.terminalReuseEnabled)
75+
}
76+
77+
// Post updated state to webview
78+
await controller.postStateToWebview()
79+
80+
return Empty.create()
81+
} catch (error) {
82+
console.error("Failed to update settings:", error)
83+
throw error
84+
}
85+
}

src/shared/ExtensionMessage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface ExtensionMessage {
2222
| "mcpServers"
2323
| "relinquishControl"
2424
| "mcpDownloadDetails"
25-
| "didUpdateSettings"
2625
| "userCreditsBalance"
2726
| "userCreditsUsage"
2827
| "userCreditsPayments"

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export interface WebviewMessage {
1717
| "searchCommits"
1818
| "fetchLatestMcpServersFromHub"
1919
| "telemetrySetting"
20-
| "updateSettings"
2120
| "clearAllTaskHistory"
2221
| "fetchUserCreditsData"
2322
| "grpc_request"

0 commit comments

Comments
 (0)