Skip to content

Commit 3fe4964

Browse files
committed
feat: Add settings to control diagnostic messages (#5524)
- Add includeDiagnosticMessages toggle setting - Add maxDiagnosticMessages slider setting (1-100) - Update diagnostic processing to respect settings - Add UI controls in Context Management settings - Update all 17 language translations - Add comprehensive unit tests - Fix default value consistency
1 parent 50598b2 commit 3fe4964

38 files changed

+801
-509
lines changed

packages/types/src/global-settings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ export const globalSettingsSchema = z.object({
5454
autoCondenseContextPercent: z.number().optional(),
5555
maxConcurrentFileReads: z.number().optional(),
5656

57+
includeDiagnosticMessages: z.boolean().optional(),
58+
maxDiagnosticMessages: z.number().optional(),
59+
5760
browserToolEnabled: z.boolean().optional(),
5861
browserViewportSize: z.string().optional(),
5962
screenshotQuality: z.number().optional(),
@@ -232,6 +235,9 @@ export const EVALS_SETTINGS: RooCodeSettings = {
232235
showRooIgnoredFiles: true,
233236
maxReadFileLine: -1, // -1 to enable full file reading.
234237

238+
includeDiagnosticMessages: true,
239+
maxDiagnosticMessages: 50,
240+
235241
language: "en",
236242
telemetrySetting: "enabled",
237243

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 = 5,
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 = 5,
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 = 5,
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,11 @@ export class Task extends EventEmitter<ClineEvents> {
12151215
}),
12161216
)
12171217

1218-
const { showRooIgnoredFiles = true } = (await this.providerRef.deref()?.getState()) ?? {}
1218+
const {
1219+
showRooIgnoredFiles = true,
1220+
includeDiagnosticMessages = true,
1221+
maxDiagnosticMessages = 50,
1222+
} = (await this.providerRef.deref()?.getState()) ?? {}
12191223

12201224
const parsedUserContent = await processUserContentMentions({
12211225
userContent,
@@ -1224,6 +1228,8 @@ export class Task extends EventEmitter<ClineEvents> {
12241228
fileContextTracker: this.fileContextTracker,
12251229
rooIgnoreController: this.rooIgnoreController,
12261230
showRooIgnoredFiles,
1231+
includeDiagnosticMessages,
1232+
maxDiagnosticMessages,
12271233
})
12281234

12291235
const environmentDetails = await getEnvironmentDetails(this, includeFileDetails)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ describe("writeToFileTool", () => {
149149
finalContent: "final content",
150150
}),
151151
scrollToFirstDiff: vi.fn(),
152+
updateDiagnosticSettings: vi.fn(),
152153
pushToolWriteResult: vi.fn().mockImplementation(async function (
153154
this: any,
154155
task: any,

src/core/tools/applyDiffTool.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ export async function applyDiffToolLegacy(
141141
cline.consecutiveMistakeCount = 0
142142
cline.consecutiveMistakeCountForApplyDiff.delete(relPath)
143143

144+
// Get diagnostic settings from state
145+
const state = await cline.providerRef?.deref()?.getState()
146+
const includeDiagnosticMessages = state?.includeDiagnosticMessages ?? true
147+
const maxDiagnosticMessages = state?.maxDiagnosticMessages
148+
149+
// Update DiffViewProvider with diagnostic settings
150+
cline.diffViewProvider.updateDiagnosticSettings(includeDiagnosticMessages, maxDiagnosticMessages)
151+
144152
// Show diff view before asking for approval
145153
cline.diffViewProvider.editType = "modify"
146154
await cline.diffViewProvider.open(relPath)

src/core/tools/insertContentTool.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ export async function insertContentTool(
9797

9898
cline.diffViewProvider.editType = fileExists ? "modify" : "create"
9999
cline.diffViewProvider.originalContent = fileContent
100+
101+
// Update diagnostic settings from global state
102+
const state = await cline.providerRef?.deref()?.getState()
103+
if (state) {
104+
cline.diffViewProvider.updateDiagnosticSettings(
105+
state.includeDiagnosticMessages ?? true,
106+
state.maxDiagnosticMessages ?? 5,
107+
)
108+
}
100109
const lines = fileExists ? fileContent.split("\n") : []
101110

102111
const updatedContent = insertGroups(lines, [

src/core/tools/searchAndReplaceTool.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ export async function searchAndReplaceTool(
190190
cline.diffViewProvider.editType = "modify"
191191
cline.diffViewProvider.originalContent = fileContent
192192

193+
// Update diagnostic settings from global state
194+
const state = await cline.providerRef?.deref()?.getState()
195+
if (state) {
196+
cline.diffViewProvider.updateDiagnosticSettings(
197+
state.includeDiagnosticMessages ?? true,
198+
state.maxDiagnosticMessages ?? 5,
199+
)
200+
}
201+
193202
// Generate and validate diff
194203
const diff = formatResponse.createPrettyPatch(validRelPath, fileContent, newContent)
195204
if (!diff) {

src/core/tools/writeToFileTool.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ export async function writeToFileTool(
9696
isProtected: isWriteProtected,
9797
}
9898

99+
// Get diagnostic settings from state
100+
const state = await cline.providerRef?.deref()?.getState()
101+
const includeDiagnosticMessages = state?.includeDiagnosticMessages ?? true
102+
const maxDiagnosticMessages = state?.maxDiagnosticMessages
103+
104+
// Update DiffViewProvider with diagnostic settings
105+
cline.diffViewProvider.updateDiagnosticSettings(includeDiagnosticMessages, maxDiagnosticMessages)
106+
99107
try {
100108
if (block.partial) {
101109
// update gui message

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,9 @@ export class ClineProvider
16751675
codebaseIndexEmbedderModelId: "",
16761676
},
16771677
profileThresholds: stateValues.profileThresholds ?? {},
1678+
// Add diagnostic message settings
1679+
includeDiagnosticMessages: stateValues.includeDiagnosticMessages ?? true,
1680+
maxDiagnosticMessages: stateValues.maxDiagnosticMessages ?? 5,
16781681
}
16791682
}
16801683

0 commit comments

Comments
 (0)