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

Conversation

hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Jul 10, 2025

image

Related GitHub Issue

Closes: #5524
Closes: #4860

Roo Code Task Context (Optional)

N/A

Description

This PR implements two new global settings to control diagnostic messages (linting errors, warnings) that appear in diff views and @problems mentions:

  1. includeDiagnosticMessages (boolean): Toggle to enable/disable the inclusion of diagnostic messages entirely
  2. maxDiagnosticMessages (number): Limit the number of diagnostic messages included (0 = unlimited)

Key Implementation Details:

  • Added settings to the global settings schema with sensible defaults (enabled, max 50 messages)
  • Updated diagnostic processing to respect these settings throughout the codebase
  • Integrated settings into the Context Management section of the Settings UI
  • Added comprehensive unit tests for both the diagnostic filtering logic and UI components
  • Implemented defensive coding to ensure backward compatibility
  • Added translations for all 17 supported languages

Design Choices:

  • Settings are placed in Context Management section as they control what context is sent to the AI
  • Default behavior maintains current functionality (diagnostics enabled)
  • When limiting messages, errors are prioritized over warnings
  • Settings take effect immediately for new tasks and @problems mentions

Test Procedure

Automated Tests:

  • Added unit tests for diagnostic filtering logic in src/integrations/diagnostics/__tests__/diagnostics.spec.ts
  • Added UI component tests in webview-ui/src/components/settings/__tests__/ContextManagementSettings.spec.tsx
  • All existing tests pass with the new changes

Manual Testing Steps:

  1. Open a project with linting errors/warnings
  2. Navigate to Settings > Context Management
  3. Toggle "Include diagnostic messages" off and verify no diagnostics appear in diff views or @problems mentions
  4. Toggle it back on and set "Maximum diagnostic messages" to a low number (e.g., 5)
  5. Create a file change that generates many diagnostics and verify only the specified number appear
  6. Use @problems mention and verify it respects the settings
  7. Restart VSCode and verify settings persist

Verification Results:

  • ✅ All unit tests passing
  • ✅ All UI component tests passing
  • ✅ Full test suite passing (npm test)
  • ✅ Build successful (npm run build)
  • ✅ Linting passed (npm run lint)

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Note: Screenshots need to be added manually showing:

  1. The new toggle for "Include diagnostic messages" in Settings > Context Management
  2. The new slider for "Maximum diagnostic messages" (visible when toggle is enabled)
  3. Example of diagnostics being limited in a diff view or @problems mention

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. User documentation should be updated to explain the new diagnostic control settings, including:
    • How to access the settings (Settings > Context Management)
    • What each setting does and when to use them
    • Examples of use cases (e.g., reducing noise in projects with many linting errors)
    • How the settings affect both diff views and @problems mentions

Additional Notes

This feature addresses a common pain point where projects with many linting errors can overwhelm the AI with diagnostic messages, leading to less focused responses. The implementation is backward compatible and provides users with fine-grained control over their AI interactions.

Get in Touch


Important

Add settings to control diagnostic messages, allowing toggling and limiting, with UI integration and tests.

  • Settings:
    • Add includeDiagnosticMessages and maxDiagnosticMessages to global-settings.ts.
    • Integrated into ContextManagementSettings.tsx and ClineProvider.ts.
  • Behavior:
    • Diagnostic messages can be toggled and limited in number.
    • Defaults: enabled, max 50 messages.
    • Prioritizes errors over warnings when limiting.
  • Tests:
    • Added unit tests in diagnostics.spec.ts and ContextManagementSettings.spec.tsx.
  • Translations:
    • Added translations for 17 languages.
  • Misc:
    • Updated index.ts and Task.ts to respect new settings.

This description was created by Ellipsis for 6e6c9c4. You can customize this summary. It will automatically update as commits are pushed.

Copy link

delve-auditor bot commented Jul 10, 2025

No security or compliance issues detected. Reviewed everything up to deb6ef4.

Security Overview
  • 🔎 Scanned files: 39 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 10, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jul 10, 2025
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 10, 2025
hannesrudolph added a commit that referenced this pull request Jul 14, 2025
- Standardize default max diagnostic messages to 50 across all files
- Extract diagnostic settings to centralized constants and helper functions
- Add comprehensive documentation for diagnostic settings
- Update UI to always show max diagnostic messages slider
- Add unit tests for ContextManagementSettings component
- Improve code organization and maintainability
@hannesrudolph hannesrudolph force-pushed the feat/issue-5524-diagnostic-settings branch from 73f5a27 to c9ebec1 Compare July 15, 2025 21:11
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to PR [Needs Prelim Review] in Roo Code Roadmap Jul 15, 2025
@hannesrudolph hannesrudolph marked this pull request as ready for review July 15, 2025 21:27
@Copilot Copilot AI review requested due to automatic review settings July 15, 2025 21:27
@hannesrudolph hannesrudolph requested review from mrubens, cte and jr as code owners July 15, 2025 21:27
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels Jul 15, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds user-configurable settings to control the inclusion and quantity of diagnostic messages (errors/warnings) in AI context, diff views, and @problems mentions.

  • Introduces two new settings:
    includeDiagnosticMessages (boolean toggle)
    maxDiagnosticMessages (numeric limit, 0 for unlimited)
  • Integrates settings end-to-end: global schema, VSCode webview UI, message handling, state persistence, and diagnostic processing.
  • Updates translations for all supported locales and adds comprehensive unit tests.

Reviewed Changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
webview-ui/src/i18n/locales/.../settings.json Add translation keys/values for the new diagnostic settings
webview-ui/src/context/ExtensionStateContext.tsx Extend extension state context with diagnostic settings fields
webview-ui/src/components/settings/ContextManagementSettings.tsx Add checkbox, slider, and reset button for diagnostic settings
webview-ui/src/components/settings/tests/ContextManagementSettings.spec.tsx Update UI tests to cover new diagnostic controls
src/integrations/diagnostics/index.ts Modify diagnosticsToProblemsString to respect new settings
src/integrations/diagnostics/tests/diagnostics.spec.ts Add tests for filtering and limiting diagnostics
src/core/webview/webviewMessageHandler.ts Handle saving/restoring diagnostic settings via messages
src/core/webview/ClineProvider.ts Persist diagnostic settings in the provider’s state
packages/types/src/global-settings.ts Add new fields to the global settings schema
Comments suppressed due to low confidence (2)

src/integrations/diagnostics/index.ts:149

  • [nitpick] Stat-ing and opening each document inside the loop can be costly. Consider caching file stats and opened TextDocuments to reduce repeated I/O operations.
							fileStat = await vscode.workspace.fs.stat(uri)

Copy link
Collaborator Author

@hannesrudolph hannesrudolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @copilot and @ellipsis-dev for the thorough review! I've addressed all the issues you identified:

  1. ✅ Fixed the zh-TW translation typo (duplicate '預' character)
  2. ✅ Fixed the Hindi translation typo (incorrect Punjabi character 'ਹੈ' replaced with Hindi 'है')
  3. ✅ Fixed the inconsistent default value in webviewMessageHandler.ts (changed from 100 to 50)
  4. ✅ Removed the unused 'diagnosticCount' variable and its increment statement

Regarding the code duplication suggestion - I appreciate the feedback! While there is some duplication between the limited and unlimited diagnostic processing blocks, I've decided to leave this refactoring for a future PR to keep this one focused on the diagnostic settings feature.

All changes have been committed in deb6ef4.

@hannesrudolph hannesrudolph moved this from PR [Needs Prelim Review] to PR [Draft / In Progress] in Roo Code Roadmap Jul 16, 2025
@hannesrudolph
Copy link
Collaborator Author

needs changes outlined in 4860

hannesrudolph and others added 18 commits July 23, 2025 13:06
- Description now updates in real-time as slider value changes
- Shows appropriate context level (minimal, moderate, comprehensive) based on threshold
- Improves user understanding of diagnostic context settings
- Remove dynamic description based on slider position
- Always show comprehensive description explaining all diagnostic levels
- Ensures users understand full range of options regardless of current setting
- Replace hardcoded 'Unlimited' text with proper translation key
- Remove unused 'unlimitedDescription' translation keys from all 18 language files
- Ensures consistent localization across all supported languages
- Remove getDiagnosticSettings() helper function and constants file
- Update DiffViewProvider to accept Task instance for direct state access
- Remove updateDiagnosticSettings method from DiffViewProvider
- Update all tools to access diagnostic settings directly from state
- Add ARIA labels to diagnostic messages slider for accessibility
- Add integration tests for diagnostic settings functionality
- Use inline defaults instead of separate constants file
- Fix typo in zh-TW translation (duplicate '預' character)
- Fix typo in Hindi translation (incorrect character 'ਹੈ' to 'है')
- Fix inconsistent default value in webviewMessageHandler.ts (100 to 50)
- Remove unused 'diagnosticCount' variable in diagnostics/index.ts
- Changed from count-based to size-based limiting to prevent context overflow
- Each unit of maxDiagnosticMessages now represents ~1KB of content
- Complete diagnostics are included up to the size limit
- Clear indication of omitted problems when limit is reached
- Updated tests to reflect new behavior
- Updated UI description to explain the new approach
…cks correctly

- Added role='combobox' to Select mock to fix accessibility test failures
- Fixed checkbox assertions to target the input element instead of the wrapper
- Added keyboard event handling to Slider mock for arrow key interactions
- All 31 tests now pass successfully
- Modified diagnosticsToProblemsString() to limit by message count instead of content size
- Updated UI description to accurately reflect count-based limiting
- Updated tests to verify count-based limiting works correctly
- When maxDiagnosticMessages is set to 1, it now shows exactly 1 diagnostic message
- Fix default value from 5 to 50 in ClineProvider.ts and tests
- Fix translation inconsistencies in Hindi and Turkish locales
- Move diagnostics delay setting from Auto-Approve to Context Management section
@daniel-lxs daniel-lxs force-pushed the feat/issue-5524-diagnostic-settings branch from 8f906fc to 9019ffe Compare July 23, 2025 18:11
daniel-lxs and others added 4 commits July 23, 2025 13:18
- Restored ${webview.cspSource} to connect-src directive in HMR HTML content
- Restored ${webview.cspSource} to connect-src directive in production HTML content
- These changes were unrelated to the diagnostic settings feature
Copy link
Collaborator

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 23, 2025
@mrubens mrubens merged commit 0323256 into main Jul 23, 2025
13 checks passed
@mrubens mrubens deleted the feat/issue-5524-diagnostic-settings branch July 23, 2025 18:49
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 23, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Changes Requested size:XXL This PR changes 1000+ lines, ignoring generated files. UI/UX UI/UX related or focused
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add settings to control diagnostic messages in diff views Uncapped Problems Output Can Overwhelm Session Context
4 participants