Skip to content

feat: Add settings to control diagnostic messages (#5524) #5582

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

Merged
merged 31 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0325eaa
feat: Add settings to control diagnostic messages (#5524)
hannesrudolph Jul 10, 2025
d5457aa
fix: address PR #5582 review feedback
hannesrudolph Jul 14, 2025
72fbd7a
fix: ensure 'Include diagnostic messages in context' checkbox persist…
hannesrudolph Jul 14, 2025
6afc75a
fix: preserve explicit false values in diagnostic settings synchroniz…
hannesrudolph Jul 15, 2025
2e0e637
feat: diagnostic settings working correctly - checkbox state persists…
hannesrudolph Jul 15, 2025
93860c7
feat: enhance diagnostic settings UI with reset button and unlimited …
hannesrudolph Jul 15, 2025
ea0c94a
feat: improve unlimited diagnostics UI with integrated slider design
hannesrudolph Jul 15, 2025
f407483
test: fix insertContentTool mock to match actual implementation
hannesrudolph Jul 15, 2025
85ef45d
fix: respect maxDiagnosticMessages setting in workspace problems mention
hannesrudolph Jul 15, 2025
5f0b06c
fix: update diagnostic slider description dynamically based on value
hannesrudolph Jul 15, 2025
31ec17b
chore(i18n): remove unused translation keys
hannesrudolph Jul 15, 2025
fd722d2
fix: make diagnostic settings description static
hannesrudolph Jul 15, 2025
b088e4a
fix: resolve localization issues in ContextManagementSettings
hannesrudolph Jul 15, 2025
fdcefbe
fix: refactor diagnostic settings to follow project patterns
hannesrudolph Jul 15, 2025
2a9c2d6
fix: add null checks to integration test to fix TypeScript errors
hannesrudolph Jul 15, 2025
c01c9ed
fix: correct parameter name mismatch for diagnostic settings
hannesrudolph Jul 15, 2025
88e08f1
chore: remove temporary analysis files
hannesrudolph Jul 15, 2025
2a2a66b
chore: remove diagnostics integration test (out of scope for this PR)
hannesrudolph Jul 15, 2025
e1d3022
fix: address bot review comments
hannesrudolph Jul 15, 2025
6b98b67
feat: implement size-based limiting for diagnostic messages
roomote-agent Jul 21, 2025
a0c25cc
fix: update ContextManagementSettings tests to handle UI component mo…
roomote-agent Jul 21, 2025
2b1b6a6
fix: change diagnostic limiting from size-based to count-based
hannesrudolph Jul 23, 2025
a2c5f42
fix: add Button component import to ContextManagementSettings
daniel-lxs Jul 23, 2025
f57308f
fix: address PR #5582 review feedback for diagnostic messages feature
daniel-lxs Jul 23, 2025
9ef5624
fix: add missing writeDelayMs prop to ContextManagementSettings test
daniel-lxs Jul 23, 2025
7e6cd48
revert: remove unintended whitespace formatting change in insertConte…
daniel-lxs Jul 23, 2025
9019ffe
fix: update Content Security Policy to remove redundant webview.cspSo…
daniel-lxs Jul 23, 2025
9ba7d1e
fix: revert unrelated CSP changes in ClineProvider.ts
daniel-lxs Jul 23, 2025
6e6c9c4
feat: add missing translations for diagnostic settings
daniel-lxs Jul 23, 2025
59cdee3
Delete src/core/webview/__tests__/diagnosticSettingsBugFix.spec.ts
daniel-lxs Jul 23, 2025
2a753ad
Delete src/core/webview/__tests__/diagnosticSettingsPersistence.spec.ts
daniel-lxs Jul 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ export const globalSettingsSchema = z.object({
autoCondenseContextPercent: z.number().optional(),
maxConcurrentFileReads: z.number().optional(),

/**
* Whether to include diagnostic messages (errors, warnings) in tool outputs
* @default true
*/
includeDiagnosticMessages: z.boolean().optional(),
/**
* Maximum number of diagnostic messages to include in tool outputs
* @default 50
*/
maxDiagnosticMessages: z.number().optional(),

browserToolEnabled: z.boolean().optional(),
browserViewportSize: z.string().optional(),
screenshotQuality: z.number().optional(),
Expand Down Expand Up @@ -261,6 +272,9 @@ export const EVALS_SETTINGS: RooCodeSettings = {
showRooIgnoredFiles: true,
maxReadFileLine: -1, // -1 to enable full file reading.

includeDiagnosticMessages: true,
maxDiagnosticMessages: 50,

language: "en",
telemetrySetting: "enabled",

Expand Down
12 changes: 10 additions & 2 deletions src/core/mentions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export async function parseMentions(
fileContextTracker?: FileContextTracker,
rooIgnoreController?: RooIgnoreController,
showRooIgnoredFiles: boolean = true,
includeDiagnosticMessages: boolean = true,
maxDiagnosticMessages: number = 50,
): Promise<string> {
const mentions: Set<string> = new Set()
let parsedText = text.replace(mentionRegexGlobal, (match, mention) => {
Expand Down Expand Up @@ -165,7 +167,7 @@ export async function parseMentions(
}
} else if (mention === "problems") {
try {
const problems = await getWorkspaceProblems(cwd)
const problems = await getWorkspaceProblems(cwd, includeDiagnosticMessages, maxDiagnosticMessages)
parsedText += `\n\n<workspace_diagnostics>\n${problems}\n</workspace_diagnostics>`
} catch (error) {
parsedText += `\n\n<workspace_diagnostics>\nError fetching diagnostics: ${error.message}\n</workspace_diagnostics>`
Expand Down Expand Up @@ -286,12 +288,18 @@ async function getFileOrFolderContent(
}
}

async function getWorkspaceProblems(cwd: string): Promise<string> {
async function getWorkspaceProblems(
cwd: string,
includeDiagnosticMessages: boolean = true,
maxDiagnosticMessages: number = 50,
): Promise<string> {
const diagnostics = vscode.languages.getDiagnostics()
const result = await diagnosticsToProblemsString(
diagnostics,
[vscode.DiagnosticSeverity.Error, vscode.DiagnosticSeverity.Warning],
cwd,
includeDiagnosticMessages,
maxDiagnosticMessages,
)
if (!result) {
return "No errors or warnings detected."
Expand Down
10 changes: 10 additions & 0 deletions src/core/mentions/processUserContentMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ export async function processUserContentMentions({
fileContextTracker,
rooIgnoreController,
showRooIgnoredFiles = true,
includeDiagnosticMessages = true,
maxDiagnosticMessages = 50,
}: {
userContent: Anthropic.Messages.ContentBlockParam[]
cwd: string
urlContentFetcher: UrlContentFetcher
fileContextTracker: FileContextTracker
rooIgnoreController?: any
showRooIgnoredFiles?: boolean
includeDiagnosticMessages?: boolean
maxDiagnosticMessages?: number
}) {
// Process userContent array, which contains various block types:
// TextBlockParam, ImageBlockParam, ToolUseBlockParam, and ToolResultBlockParam.
Expand All @@ -46,6 +50,8 @@ export async function processUserContentMentions({
fileContextTracker,
rooIgnoreController,
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
),
}
}
Expand All @@ -63,6 +69,8 @@ export async function processUserContentMentions({
fileContextTracker,
rooIgnoreController,
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
),
}
}
Expand All @@ -81,6 +89,8 @@ export async function processUserContentMentions({
fileContextTracker,
rooIgnoreController,
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
),
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class Task extends EventEmitter<ClineEvents> {
this.consecutiveMistakeLimit = consecutiveMistakeLimit ?? DEFAULT_CONSECUTIVE_MISTAKE_LIMIT
this.providerRef = new WeakRef(provider)
this.globalStoragePath = provider.context.globalStorageUri.fsPath
this.diffViewProvider = new DiffViewProvider(this.cwd)
this.diffViewProvider = new DiffViewProvider(this.cwd, this)
this.enableCheckpoints = enableCheckpoints

this.rootTask = rootTask
Expand Down Expand Up @@ -1225,7 +1225,11 @@ export class Task extends EventEmitter<ClineEvents> {
}),
)

const { showRooIgnoredFiles = true } = (await this.providerRef.deref()?.getState()) ?? {}
const {
showRooIgnoredFiles = true,
includeDiagnosticMessages = true,
maxDiagnosticMessages = 50,
} = (await this.providerRef.deref()?.getState()) ?? {}

const parsedUserContent = await processUserContentMentions({
userContent,
Expand All @@ -1234,6 +1238,8 @@ export class Task extends EventEmitter<ClineEvents> {
fileContextTracker: this.fileContextTracker,
rooIgnoreController: this.rooIgnoreController,
showRooIgnoredFiles,
includeDiagnosticMessages,
maxDiagnosticMessages,
})

const environmentDetails = await getEnvironmentDetails(this, includeFileDetails)
Expand Down
1 change: 1 addition & 0 deletions src/core/tools/__tests__/insertContentTool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe("insertContentTool", () => {
finalContent: "final content",
}),
scrollToFirstDiff: vi.fn(),
updateDiagnosticSettings: vi.fn(),
pushToolWriteResult: vi.fn().mockImplementation(async function (
this: any,
task: any,
Expand Down
1 change: 1 addition & 0 deletions src/core/tools/__tests__/writeToFileTool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe("writeToFileTool", () => {
finalContent: "final content",
}),
scrollToFirstDiff: vi.fn(),
updateDiagnosticSettings: vi.fn(),
pushToolWriteResult: vi.fn().mockImplementation(async function (
this: any,
task: any,
Expand Down
9 changes: 7 additions & 2 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,8 @@ export class ClineProvider
profileThresholds,
alwaysAllowFollowupQuestions,
followupAutoApproveTimeoutMs,
diagnosticsEnabled,
includeDiagnosticMessages,
maxDiagnosticMessages,
} = await this.getState()

const telemetryKey = process.env.POSTHOG_API_KEY
Expand Down Expand Up @@ -1560,7 +1561,8 @@ export class ClineProvider
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
diagnosticsEnabled: diagnosticsEnabled ?? true,
includeDiagnosticMessages: includeDiagnosticMessages ?? true,
maxDiagnosticMessages: maxDiagnosticMessages ?? 50,
}
}

Expand Down Expand Up @@ -1726,6 +1728,9 @@ export class ClineProvider
codebaseIndexSearchMinScore: stateValues.codebaseIndexConfig?.codebaseIndexSearchMinScore,
},
profileThresholds: stateValues.profileThresholds ?? {},
// Add diagnostic message settings
includeDiagnosticMessages: stateValues.includeDiagnosticMessages ?? true,
maxDiagnosticMessages: stateValues.maxDiagnosticMessages ?? 50,
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,16 @@ export const webviewMessageHandler = async (
await updateGlobalState("maxConcurrentFileReads", valueToSave)
await provider.postStateToWebview()
break
case "includeDiagnosticMessages":
// Only apply default if the value is truly undefined (not false)
const includeValue = message.bool !== undefined ? message.bool : true
await updateGlobalState("includeDiagnosticMessages", includeValue)
await provider.postStateToWebview()
break
case "maxDiagnosticMessages":
await updateGlobalState("maxDiagnosticMessages", message.value ?? 50)
await provider.postStateToWebview()
break
case "setHistoryPreviewCollapsed": // Add the new case handler
await updateGlobalState("historyPreviewCollapsed", message.bool ?? false)
// No need to call postStateToWebview here as the UI already updated optimistically
Expand Down
Loading