Skip to content

Commit f8c863d

Browse files
committed
Adds debug logging for code index settings
Implements comprehensive debug logging to better trace code index configuration changes: - Logs setting changes before saving - Verifies stored configurations by reading them back - Improves the order of webview updates - Ensures boolean settings persist correctly These changes enable better troubleshooting of configuration issues.
1 parent e872015 commit f8c863d

File tree

3 files changed

+47
-36
lines changed

3 files changed

+47
-36
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ interface PendingEditOperation {
116116

117117
export class ClineProvider
118118
extends EventEmitter<TaskProviderEvents>
119-
implements vscode.WebviewViewProvider, TelemetryPropertiesProvider, TaskProviderLike {
119+
implements vscode.WebviewViewProvider, TelemetryPropertiesProvider, TaskProviderLike
120+
{
120121
// Used in package.json as the view's id. This value cannot be changed due
121122
// to how VSCode caches views based on their id, and updating the id would
122123
// break existing instances of the extension.
@@ -221,7 +222,8 @@ export class ClineProvider
221222
}
222223
} catch (error) {
223224
this.log(
224-
`[onTaskAborted] Failed to rehydrate after streaming failure: ${error instanceof Error ? error.message : String(error)
225+
`[onTaskAborted] Failed to rehydrate after streaming failure: ${
226+
error instanceof Error ? error.message : String(error)
225227
}`,
226228
)
227229
}
@@ -879,7 +881,8 @@ export class ClineProvider
879881
} catch (error) {
880882
// Log the error but continue with task restoration.
881883
this.log(
882-
`Failed to restore API configuration for mode '${historyItem.mode}': ${error instanceof Error ? error.message : String(error)
884+
`Failed to restore API configuration for mode '${historyItem.mode}': ${
885+
error instanceof Error ? error.message : String(error)
883886
}. Continuing with default configuration.`,
884887
)
885888
// The task will continue with the current/default configuration.
@@ -1176,7 +1179,7 @@ export class ClineProvider
11761179
}
11771180

11781181
// Only update the task's mode after successful persistence.
1179-
; (task as any)._taskMode = newMode
1182+
;(task as any)._taskMode = newMode
11801183
} catch (error) {
11811184
// If persistence fails, log the error but don't update the in-memory state.
11821185
this.log(
@@ -2162,6 +2165,8 @@ export class ClineProvider
21622165
stateValues.codebaseIndexConfig?.codebaseIndexOpenAiCompatibleBaseUrl,
21632166
codebaseIndexSearchMaxResults: stateValues.codebaseIndexConfig?.codebaseIndexSearchMaxResults,
21642167
codebaseIndexSearchMinScore: stateValues.codebaseIndexConfig?.codebaseIndexSearchMinScore,
2168+
codebaseIndexBranchIsolationEnabled:
2169+
stateValues.codebaseIndexConfig?.codebaseIndexBranchIsolationEnabled ?? false,
21652170
},
21662171
profileThresholds: stateValues.profileThresholds ?? {},
21672172
includeDiagnosticMessages: stateValues.includeDiagnosticMessages ?? true,

src/core/webview/webviewMessageHandler.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ export const webviewMessageHandler = async (
13941394
} else {
13951395
vscode.window.showErrorMessage(
13961396
t("common:errors.invalid_character_limit") ||
1397-
"Terminal output character limit must be a positive number",
1397+
"Terminal output character limit must be a positive number",
13981398
)
13991399
}
14001400
break
@@ -2005,10 +2005,10 @@ export const webviewMessageHandler = async (
20052005
const existingMode = existingModes.find((mode) => mode.slug === message.modeConfig?.slug)
20062006
const changedSettings = existingMode
20072007
? Object.keys(message.modeConfig).filter(
2008-
(key) =>
2009-
JSON.stringify((existingMode as Record<string, unknown>)[key]) !==
2010-
JSON.stringify((message.modeConfig as Record<string, unknown>)[key]),
2011-
)
2008+
(key) =>
2009+
JSON.stringify((existingMode as Record<string, unknown>)[key]) !==
2010+
JSON.stringify((message.modeConfig as Record<string, unknown>)[key]),
2011+
)
20122012
: []
20132013

20142014
if (changedSettings.length > 0) {
@@ -2495,16 +2495,17 @@ export const webviewMessageHandler = async (
24952495
)
24962496
}
24972497

2498-
// Send success response first - settings are saved regardless of validation
2498+
// Update webview state FIRST to ensure React context has the new config
2499+
// before sending the success message
2500+
await provider.postStateToWebview()
2501+
2502+
// Send success response - settings are saved regardless of validation
24992503
await provider.postMessageToWebview({
25002504
type: "codeIndexSettingsSaved",
25012505
success: true,
25022506
settings: globalStateConfig,
25032507
})
25042508

2505-
// Update webview state
2506-
await provider.postStateToWebview()
2507-
25082509
// Then handle validation and initialization for the current workspace
25092510
const currentCodeIndexManager = provider.getCurrentWorkspaceCodeIndexManager()
25102511
if (currentCodeIndexManager) {
@@ -2605,13 +2606,13 @@ export const webviewMessageHandler = async (
26052606
const status = manager
26062607
? manager.getCurrentStatus()
26072608
: {
2608-
systemStatus: "Standby",
2609-
message: "No workspace folder open",
2610-
processedItems: 0,
2611-
totalItems: 0,
2612-
currentItemUnit: "items",
2613-
workspacePath: undefined,
2614-
}
2609+
systemStatus: "Standby",
2610+
message: "No workspace folder open",
2611+
processedItems: 0,
2612+
totalItems: 0,
2613+
currentItemUnit: "items",
2614+
workspacePath: undefined,
2615+
}
26152616

26162617
provider.postMessageToWebview({
26172618
type: "indexingStatusUpdate",

webview-ui/src/components/chat/CodeIndexPopover.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
233233
codebaseIndexMistralApiKey: "",
234234
codebaseIndexVercelAiGatewayApiKey: "",
235235
}
236+
236237
setInitialSettings(settings)
237238
setCurrentSettings(settings)
238239

@@ -511,8 +512,9 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
511512
settingsToSave[key] = value
512513
}
513514

514-
// Always include codebaseIndexEnabled to ensure it's persisted
515+
// Always include these boolean settings to ensure they're persisted (even if false)
515516
settingsToSave.codebaseIndexEnabled = currentSettings.codebaseIndexEnabled
517+
settingsToSave.codebaseIndexBranchIsolationEnabled = currentSettings.codebaseIndexBranchIsolationEnabled
516518

517519
// Save settings to backend
518520
vscode.postMessage({
@@ -719,15 +721,15 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
719721
{getAvailableModels().map((modelId) => {
720722
const model =
721723
codebaseIndexModels?.[
722-
currentSettings.codebaseIndexEmbedderProvider
724+
currentSettings.codebaseIndexEmbedderProvider
723725
]?.[modelId]
724726
return (
725727
<VSCodeOption key={modelId} value={modelId} className="p-2">
726728
{modelId}{" "}
727729
{model
728730
? t("settings:codeIndex.modelDimensions", {
729-
dimension: model.dimension,
730-
})
731+
dimension: model.dimension,
732+
})
731733
: ""}
732734
</VSCodeOption>
733735
)
@@ -976,15 +978,15 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
976978
{getAvailableModels().map((modelId) => {
977979
const model =
978980
codebaseIndexModels?.[
979-
currentSettings.codebaseIndexEmbedderProvider
981+
currentSettings.codebaseIndexEmbedderProvider
980982
]?.[modelId]
981983
return (
982984
<VSCodeOption key={modelId} value={modelId} className="p-2">
983985
{modelId}{" "}
984986
{model
985987
? t("settings:codeIndex.modelDimensions", {
986-
dimension: model.dimension,
987-
})
988+
dimension: model.dimension,
989+
})
988990
: ""}
989991
</VSCodeOption>
990992
)
@@ -1041,15 +1043,15 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
10411043
{getAvailableModels().map((modelId) => {
10421044
const model =
10431045
codebaseIndexModels?.[
1044-
currentSettings.codebaseIndexEmbedderProvider
1046+
currentSettings.codebaseIndexEmbedderProvider
10451047
]?.[modelId]
10461048
return (
10471049
<VSCodeOption key={modelId} value={modelId} className="p-2">
10481050
{modelId}{" "}
10491051
{model
10501052
? t("settings:codeIndex.modelDimensions", {
1051-
dimension: model.dimension,
1052-
})
1053+
dimension: model.dimension,
1054+
})
10531055
: ""}
10541056
</VSCodeOption>
10551057
)
@@ -1111,15 +1113,15 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
11111113
{getAvailableModels().map((modelId) => {
11121114
const model =
11131115
codebaseIndexModels?.[
1114-
currentSettings.codebaseIndexEmbedderProvider
1116+
currentSettings.codebaseIndexEmbedderProvider
11151117
]?.[modelId]
11161118
return (
11171119
<VSCodeOption key={modelId} value={modelId} className="p-2">
11181120
{modelId}{" "}
11191121
{model
11201122
? t("settings:codeIndex.modelDimensions", {
1121-
dimension: model.dimension,
1122-
})
1123+
dimension: model.dimension,
1124+
})
11231125
: ""}
11241126
</VSCodeOption>
11251127
)
@@ -1219,7 +1221,7 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
12191221
step={CODEBASE_INDEX_DEFAULTS.SEARCH_SCORE_STEP}
12201222
value={[
12211223
currentSettings.codebaseIndexSearchMinScore ??
1222-
CODEBASE_INDEX_DEFAULTS.DEFAULT_SEARCH_MIN_SCORE,
1224+
CODEBASE_INDEX_DEFAULTS.DEFAULT_SEARCH_MIN_SCORE,
12231225
]}
12241226
onValueChange={(values) =>
12251227
updateSetting("codebaseIndexSearchMinScore", values[0])
@@ -1265,7 +1267,7 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
12651267
step={CODEBASE_INDEX_DEFAULTS.SEARCH_RESULTS_STEP}
12661268
value={[
12671269
currentSettings.codebaseIndexSearchMaxResults ??
1268-
CODEBASE_INDEX_DEFAULTS.DEFAULT_SEARCH_RESULTS,
1270+
CODEBASE_INDEX_DEFAULTS.DEFAULT_SEARCH_RESULTS,
12691271
]}
12701272
onValueChange={(values) =>
12711273
updateSetting("codebaseIndexSearchMaxResults", values[0])
@@ -1297,7 +1299,10 @@ export const CodeIndexPopover: React.FC<CodeIndexPopoverProps> = ({
12971299
<VSCodeCheckbox
12981300
checked={currentSettings.codebaseIndexBranchIsolationEnabled ?? false}
12991301
onChange={(e: any) =>
1300-
updateSetting("codebaseIndexBranchIsolationEnabled", e.target.checked)
1302+
updateSetting(
1303+
"codebaseIndexBranchIsolationEnabled",
1304+
e.target.checked,
1305+
)
13011306
}>
13021307
<span className="text-sm font-medium">
13031308
{t("settings:codeIndex.branchIsolation.enableLabel")}

0 commit comments

Comments
 (0)