Skip to content

Commit 0323256

Browse files
hannesrudolphroomote-agentdaniel-lxs
authored
feat: Add settings to control diagnostic messages (#5524) (#5582)
Co-authored-by: Roo Code <roomote@roocode.com> Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com> Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
1 parent d720d35 commit 0323256

37 files changed

+1197
-209
lines changed

packages/types/src/global-settings.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ export const globalSettingsSchema = z.object({
7272
autoCondenseContextPercent: z.number().optional(),
7373
maxConcurrentFileReads: z.number().optional(),
7474

75+
/**
76+
* Whether to include diagnostic messages (errors, warnings) in tool outputs
77+
* @default true
78+
*/
79+
includeDiagnosticMessages: z.boolean().optional(),
80+
/**
81+
* Maximum number of diagnostic messages to include in tool outputs
82+
* @default 50
83+
*/
84+
maxDiagnosticMessages: z.number().optional(),
85+
7586
browserToolEnabled: z.boolean().optional(),
7687
browserViewportSize: z.string().optional(),
7788
screenshotQuality: z.number().optional(),
@@ -261,6 +272,9 @@ export const EVALS_SETTINGS: RooCodeSettings = {
261272
showRooIgnoredFiles: true,
262273
maxReadFileLine: -1, // -1 to enable full file reading.
263274

275+
includeDiagnosticMessages: true,
276+
maxDiagnosticMessages: 50,
277+
264278
language: "en",
265279
telemetrySetting: "enabled",
266280

src/core/mentions/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export async function parseMentions(
8080
fileContextTracker?: FileContextTracker,
8181
rooIgnoreController?: RooIgnoreController,
8282
showRooIgnoredFiles: boolean = true,
83+
includeDiagnosticMessages: boolean = true,
84+
maxDiagnosticMessages: number = 50,
8385
): Promise<string> {
8486
const mentions: Set<string> = new Set()
8587
let parsedText = text.replace(mentionRegexGlobal, (match, mention) => {
@@ -165,7 +167,7 @@ export async function parseMentions(
165167
}
166168
} else if (mention === "problems") {
167169
try {
168-
const problems = await getWorkspaceProblems(cwd)
170+
const problems = await getWorkspaceProblems(cwd, includeDiagnosticMessages, maxDiagnosticMessages)
169171
parsedText += `\n\n<workspace_diagnostics>\n${problems}\n</workspace_diagnostics>`
170172
} catch (error) {
171173
parsedText += `\n\n<workspace_diagnostics>\nError fetching diagnostics: ${error.message}\n</workspace_diagnostics>`
@@ -286,12 +288,18 @@ async function getFileOrFolderContent(
286288
}
287289
}
288290

289-
async function getWorkspaceProblems(cwd: string): Promise<string> {
291+
async function getWorkspaceProblems(
292+
cwd: string,
293+
includeDiagnosticMessages: boolean = true,
294+
maxDiagnosticMessages: number = 50,
295+
): Promise<string> {
290296
const diagnostics = vscode.languages.getDiagnostics()
291297
const result = await diagnosticsToProblemsString(
292298
diagnostics,
293299
[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning],
294300
cwd,
301+
includeDiagnosticMessages,
302+
maxDiagnosticMessages,
295303
)
296304
if (!result) {
297305
return "No errors or warnings detected."

src/core/mentions/processUserContentMentions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ export async function processUserContentMentions({
1313
fileContextTracker,
1414
rooIgnoreController,
1515
showRooIgnoredFiles = true,
16+
includeDiagnosticMessages = true,
17+
maxDiagnosticMessages = 50,
1618
}: {
1719
userContent: Anthropic.Messages.ContentBlockParam[]
1820
cwd: string
1921
urlContentFetcher: UrlContentFetcher
2022
fileContextTracker: FileContextTracker
2123
rooIgnoreController?: any
2224
showRooIgnoredFiles?: boolean
25+
includeDiagnosticMessages?: boolean
26+
maxDiagnosticMessages?: number
2327
}) {
2428
// Process userContent array, which contains various block types:
2529
// TextBlockParam, ImageBlockParam, ToolUseBlockParam, and ToolResultBlockParam.
@@ -46,6 +50,8 @@ export async function processUserContentMentions({
4650
fileContextTracker,
4751
rooIgnoreController,
4852
showRooIgnoredFiles,
53+
includeDiagnosticMessages,
54+
maxDiagnosticMessages,
4955
),
5056
}
5157
}
@@ -63,6 +69,8 @@ export async function processUserContentMentions({
6369
fileContextTracker,
6470
rooIgnoreController,
6571
showRooIgnoredFiles,
72+
includeDiagnosticMessages,
73+
maxDiagnosticMessages,
6674
),
6775
}
6876
}
@@ -81,6 +89,8 @@ export async function processUserContentMentions({
8189
fileContextTracker,
8290
rooIgnoreController,
8391
showRooIgnoredFiles,
92+
includeDiagnosticMessages,
93+
maxDiagnosticMessages,
8494
),
8595
}
8696
}

src/core/task/Task.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export class Task extends EventEmitter<ClineEvents> {
260260
this.consecutiveMistakeLimit = consecutiveMistakeLimit ?? DEFAULT_CONSECUTIVE_MISTAKE_LIMIT
261261
this.providerRef = new WeakRef(provider)
262262
this.globalStoragePath = provider.context.globalStorageUri.fsPath
263-
this.diffViewProvider = new DiffViewProvider(this.cwd)
263+
this.diffViewProvider = new DiffViewProvider(this.cwd, this)
264264
this.enableCheckpoints = enableCheckpoints
265265

266266
this.rootTask = rootTask
@@ -1225,7 +1225,11 @@ export class Task extends EventEmitter<ClineEvents> {
12251225
}),
12261226
)
12271227

1228-
const { showRooIgnoredFiles = true } = (await this.providerRef.deref()?.getState()) ?? {}
1228+
const {
1229+
showRooIgnoredFiles = true,
1230+
includeDiagnosticMessages = true,
1231+
maxDiagnosticMessages = 50,
1232+
} = (await this.providerRef.deref()?.getState()) ?? {}
12291233

12301234
const parsedUserContent = await processUserContentMentions({
12311235
userContent,
@@ -1234,6 +1238,8 @@ export class Task extends EventEmitter<ClineEvents> {
12341238
fileContextTracker: this.fileContextTracker,
12351239
rooIgnoreController: this.rooIgnoreController,
12361240
showRooIgnoredFiles,
1241+
includeDiagnosticMessages,
1242+
maxDiagnosticMessages,
12371243
})
12381244

12391245
const environmentDetails = await getEnvironmentDetails(this, includeFileDetails)

src/core/tools/__tests__/insertContentTool.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ describe("insertContentTool", () => {
9696
finalContent: "final content",
9797
}),
9898
scrollToFirstDiff: vi.fn(),
99+
updateDiagnosticSettings: vi.fn(),
99100
pushToolWriteResult: vi.fn().mockImplementation(async function (
100101
this: any,
101102
task: any,

src/core/tools/__tests__/writeToFileTool.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ describe("writeToFileTool", () => {
157157
finalContent: "final content",
158158
}),
159159
scrollToFirstDiff: vi.fn(),
160+
updateDiagnosticSettings: vi.fn(),
160161
pushToolWriteResult: vi.fn().mockImplementation(async function (
161162
this: any,
162163
task: any,

src/core/webview/ClineProvider.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,8 @@ export class ClineProvider
14391439
profileThresholds,
14401440
alwaysAllowFollowupQuestions,
14411441
followupAutoApproveTimeoutMs,
1442-
diagnosticsEnabled,
1442+
includeDiagnosticMessages,
1443+
maxDiagnosticMessages,
14431444
} = await this.getState()
14441445

14451446
const telemetryKey = process.env.POSTHOG_API_KEY
@@ -1560,7 +1561,8 @@ export class ClineProvider
15601561
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
15611562
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
15621563
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
1563-
diagnosticsEnabled: diagnosticsEnabled ?? true,
1564+
includeDiagnosticMessages: includeDiagnosticMessages ?? true,
1565+
maxDiagnosticMessages: maxDiagnosticMessages ?? 50,
15641566
}
15651567
}
15661568

@@ -1726,6 +1728,9 @@ export class ClineProvider
17261728
codebaseIndexSearchMinScore: stateValues.codebaseIndexConfig?.codebaseIndexSearchMinScore,
17271729
},
17281730
profileThresholds: stateValues.profileThresholds ?? {},
1731+
// Add diagnostic message settings
1732+
includeDiagnosticMessages: stateValues.includeDiagnosticMessages ?? true,
1733+
maxDiagnosticMessages: stateValues.maxDiagnosticMessages ?? 50,
17291734
}
17301735
}
17311736

src/core/webview/webviewMessageHandler.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,16 @@ export const webviewMessageHandler = async (
12541254
await updateGlobalState("maxConcurrentFileReads", valueToSave)
12551255
await provider.postStateToWebview()
12561256
break
1257+
case "includeDiagnosticMessages":
1258+
// Only apply default if the value is truly undefined (not false)
1259+
const includeValue = message.bool !== undefined ? message.bool : true
1260+
await updateGlobalState("includeDiagnosticMessages", includeValue)
1261+
await provider.postStateToWebview()
1262+
break
1263+
case "maxDiagnosticMessages":
1264+
await updateGlobalState("maxDiagnosticMessages", message.value ?? 50)
1265+
await provider.postStateToWebview()
1266+
break
12571267
case "setHistoryPreviewCollapsed": // Add the new case handler
12581268
await updateGlobalState("historyPreviewCollapsed", message.bool ?? false)
12591269
// No need to call postStateToWebview here as the UI already updated optimistically

0 commit comments

Comments
 (0)