-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: prevent context compression trigger when saving unchanged settings #7947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -296,79 +296,233 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const handleSubmit = () => { | ||||||||||||||||||||||||
| if (isSettingValid) { | ||||||||||||||||||||||||
| vscode.postMessage({ type: "language", text: language }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowReadOnly", bool: alwaysAllowReadOnly }) | ||||||||||||||||||||||||
| vscode.postMessage({ | ||||||||||||||||||||||||
| type: "alwaysAllowReadOnlyOutsideWorkspace", | ||||||||||||||||||||||||
| bool: alwaysAllowReadOnlyOutsideWorkspace, | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowWrite", bool: alwaysAllowWrite }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowWriteOutsideWorkspace", bool: alwaysAllowWriteOutsideWorkspace }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowWriteProtected", bool: alwaysAllowWriteProtected }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowExecute", bool: alwaysAllowExecute }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowBrowser", bool: alwaysAllowBrowser }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowMcp", bool: alwaysAllowMcp }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "allowedCommands", commands: allowedCommands ?? [] }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "deniedCommands", commands: deniedCommands ?? [] }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "allowedMaxRequests", value: allowedMaxRequests ?? undefined }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "allowedMaxCost", value: allowedMaxCost ?? undefined }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "autoCondenseContext", bool: autoCondenseContext }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "autoCondenseContextPercent", value: autoCondenseContextPercent }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "browserToolEnabled", bool: browserToolEnabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "soundEnabled", bool: soundEnabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "ttsEnabled", bool: ttsEnabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "ttsSpeed", value: ttsSpeed }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "soundVolume", value: soundVolume }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "diffEnabled", bool: diffEnabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "enableCheckpoints", bool: enableCheckpoints }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "browserViewportSize", text: browserViewportSize }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "remoteBrowserHost", text: remoteBrowserHost }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "remoteBrowserEnabled", bool: remoteBrowserEnabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "fuzzyMatchThreshold", value: fuzzyMatchThreshold ?? 1.0 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "writeDelayMs", value: writeDelayMs }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "screenshotQuality", value: screenshotQuality ?? 75 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalOutputLineLimit", value: terminalOutputLineLimit ?? 500 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalOutputCharacterLimit", value: terminalOutputCharacterLimit ?? 50000 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalShellIntegrationTimeout", value: terminalShellIntegrationTimeout }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalShellIntegrationDisabled", bool: terminalShellIntegrationDisabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalCommandDelay", value: terminalCommandDelay }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalPowershellCounter", bool: terminalPowershellCounter }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalZshClearEolMark", bool: terminalZshClearEolMark }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalZshOhMy", bool: terminalZshOhMy }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalZshP10k", bool: terminalZshP10k }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalZdotdir", bool: terminalZdotdir }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "terminalCompressProgressBar", bool: terminalCompressProgressBar }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "mcpEnabled", bool: mcpEnabled }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysApproveResubmit", bool: alwaysApproveResubmit }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "requestDelaySeconds", value: requestDelaySeconds }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxOpenTabsContext", value: maxOpenTabsContext }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxWorkspaceFiles", value: maxWorkspaceFiles ?? 200 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "showRooIgnoredFiles", bool: showRooIgnoredFiles }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxReadFileLine", value: maxReadFileLine ?? -1 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxImageFileSize", value: maxImageFileSize ?? 5 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxTotalImageSize", value: maxTotalImageSize ?? 20 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxConcurrentFileReads", value: cachedState.maxConcurrentFileReads ?? 5 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "includeDiagnosticMessages", bool: includeDiagnosticMessages }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "maxDiagnosticMessages", value: maxDiagnosticMessages ?? 50 }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "currentApiConfigName", text: currentApiConfigName }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "updateExperimental", values: experiments }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowModeSwitch", bool: alwaysAllowModeSwitch }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowSubtasks", bool: alwaysAllowSubtasks }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowFollowupQuestions", bool: alwaysAllowFollowupQuestions }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "alwaysAllowUpdateTodoList", bool: alwaysAllowUpdateTodoList }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "followupAutoApproveTimeoutMs", value: followupAutoApproveTimeoutMs }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "condensingApiConfigId", text: condensingApiConfigId || "" }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "updateCondensingPrompt", text: customCondensingPrompt || "" }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "updateSupportPrompt", values: customSupportPrompts || {} }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "includeTaskHistoryInEnhance", bool: includeTaskHistoryInEnhance ?? true }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "upsertApiConfiguration", text: currentApiConfigName, apiConfiguration }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "telemetrySetting", text: telemetrySetting }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "profileThresholds", values: profileThresholds }) | ||||||||||||||||||||||||
| vscode.postMessage({ type: "openRouterImageApiKey", text: openRouterImageApiKey }) | ||||||||||||||||||||||||
| vscode.postMessage({ | ||||||||||||||||||||||||
| type: "openRouterImageGenerationSelectedModel", | ||||||||||||||||||||||||
| text: openRouterImageGenerationSelectedModel, | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
| // Helper function to check if a value has changed | ||||||||||||||||||||||||
| const hasChanged = (cachedValue: any, originalValue: any): boolean => { | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| const hasChanged = (cachedValue: any, originalValue: any): boolean => { | |
| const hasChanged = <T,>(cachedValue: T, originalValue: T): boolean => { | |
| // Handle objects and arrays with deep comparison | |
| if (typeof cachedValue === "object" && cachedValue !== null) { | |
| return JSON.stringify(cachedValue) !== JSON.stringify(originalValue) | |
| } | |
| return cachedValue !== originalValue | |
| } |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is using JSON.stringify for deep comparison intentional here? For large configuration objects, this could be expensive. Have you considered using a more efficient deep equality check library like lodash.isEqual or memoizing the stringified values?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice there's significant repetition in the conditional checks (lines 309-525). Each setting follows the same pattern. Could we refactor this into a more maintainable approach? For example:
| if (hasChanged(language, extensionState.language)) { | |
| // Helper to send message only if changed | |
| const sendIfChanged = <T,>(key: keyof ExtensionStateContextType, messageType: string, value: T, messageBuilder: (value: T) => any) => { | |
| if (hasChanged(value, extensionState[key])) { | |
| vscode.postMessage(messageBuilder(value)) | |
| } | |
| } | |
| // Usage | |
| sendIfChanged('language', 'language', language, (val) => ({ type: 'language', text: val })) | |
| sendIfChanged('alwaysAllowReadOnly', 'alwaysAllowReadOnly', alwaysAllowReadOnly, (val) => ({ type: 'alwaysAllowReadOnly', bool: val })) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using cachedState.maxConcurrentFileReads here but all other lines use the destructured variable. Should this be maxConcurrentFileReads for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix correctly addresses the issue by only sending messages for changed settings. However, I notice we're missing test coverage for this new hasChanged helper function and the conditional message sending logic. Could we add tests to ensure this critical functionality works as expected?