Skip to content

Conversation

@jadefr
Copy link

@jadefr jadefr commented Nov 28, 2025

Add Visual Highlighting for Unused Values in YAML Files

This PR adds visual highlighting for unused values in Helm values files, providing immediate feedback to users about
which values are not referenced in their templates.

Features

Visual Indicators: Unused values are highlighted with wavy underlines that adapt to light/dark themes
Real-time Updates: Decorations update immediately as users type, not just when diagnostics change
LSP Integration: Leverages helm-ls diagnostics with DiagnosticTagUnnecessary for accurate detection
Hover Information: Shows helpful messages when hovering over unused values
Theme Support: Uses appropriate colors for both light and dark VSCode themes

Implementation

• Added unusedValuesDecorator.ts utility in src/util/
• Integrated with existing LSP client in main extension
• Listens for both diagnostic changes and text document changes for responsive UX
• Filters diagnostics by source (helm-ls unused values) and diagnostic tags

Compatibility

Includes temporary compatibility with current helm-ls versions that send empty source strings. This will be cleaned
up once helm-ls commit 780fcd0 is merged.

Screenshots

image

Related Issues

Addresses the need for better visual feedback on unused Helm values, improving developer experience when working
with large values files.

Summary by CodeRabbit

  • New Features
    • Unused values in YAML files now display visual indicators with wavy underlines. Hover over highlighted areas for context. Indicators automatically adapt to your theme and update in real-time as you edit files.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add unusedValuesDecorator utility to highlight unused values with wavy underlines
- Listen for LSP diagnostics with DiagnosticTagUnnecessary from helm-ls
- Support both light and dark themes with appropriate colors
- Update decorations in real-time as users type in values.yaml files

Integrates with helm-ls unused values linting feature for better UX.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Walkthrough

The changes integrate a new unused values decorator utility into the VSCode extension that highlights unused YAML values with theme-aware visual decorations. The decorator synchronizes decorations with diagnostics from helm-ls and keeps them up-to-date during editor and text changes.

Changes

Cohort / File(s) Summary
Unused Values Decorator Integration
src/extension.ts
Added import of unusedValuesDecorator utility; integrated activate() call on extension activation and deactivate() call on extension deactivation.
New Decorator Utility
src/util/unusedValuesDecorator.ts
New file implementing theme-aware unused values decorator for YAML files. Exports activate(context) and deactivate() functions. Handles decoration creation, refreshing on theme changes, and synchronizing decorations with diagnostic updates, text edits, and active editor switches. Targets helm-ls diagnostics with "Unnecessary" tag.

Sequence Diagram

sequenceDiagram
    participant VSCode as VSCode Extension
    participant Decorator as Unused Values Decorator
    participant Diagnostics as Diagnostics (helm-ls)
    participant Theme as Theme Manager
    participant Editor as Active Editor

    VSCode->>Decorator: activate(context) on extension load
    Decorator->>Theme: Initialize decoration type (theme-aware)
    Decorator->>Diagnostics: Listen to diagnostic changes
    Decorator->>Editor: Listen to editor switches & text edits
    
    Note over Decorator: Setup complete

    Diagnostics-->>Decorator: Emit diagnostics update
    Decorator->>Editor: Filter helm-ls "Unnecessary" diagnostics
    Decorator->>Editor: Update decorations (wavy underline + ruler)

    Theme-->>Decorator: Emit theme change event
    Decorator->>Decorator: Refresh decoration type
    Decorator->>Editor: Reapply decorations to all open editors

    Editor-->>Decorator: Text document edited or editor changed
    Decorator->>Editor: Update decorations for active editor

    VSCode->>Decorator: deactivate() on extension unload
    Decorator->>Decorator: Dispose all decorations & event listeners
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Primary areas for attention:
    • Verification that diagnostic filtering logic correctly targets helm-ls diagnostics with "Unnecessary" tag
    • Event listener attachment/disposal correctness to ensure no memory leaks during theme changes and editor switches
    • Decoration refresh logic under various state transitions (active editor changes, diagnostics updates, theme changes)
    • Hover message attachment and content validity for end users

Poem

A decorator hops into the editor's light,
Painting unused values with wavy delight,
Through theme-aware colors and helm's wise call,
The rabbit ensures nothing slips through at all! 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding visual highlighting for unused values in YAML files, which directly matches the PR objectives and file changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07725fa and 2301bdc.

📒 Files selected for processing (2)
  • src/extension.ts (2 hunks)
  • src/util/unusedValuesDecorator.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/util/unusedValuesDecorator.ts (1)
src/extension.ts (2)
  • activate (26-85)
  • deactivate (87-94)
src/extension.ts (1)
src/util/unusedValuesDecorator.ts (1)
  • deactivate (90-94)
🔇 Additional comments (6)
src/extension.ts (1)

89-89: LGTM!

The deactivation order is correct: cleaning up the decorator before stopping the language client ensures decorations are removed before the diagnostic source is terminated.

src/util/unusedValuesDecorator.ts (5)

5-17: LGTM!

The theme-aware decoration options are appropriate for indicating unused values. The wavy underline pattern and overview ruler integration align well with VSCode conventions for "unnecessary" code indicators.


19-61: LGTM!

The event listener setup comprehensively covers all scenarios where decorations need updating: diagnostic changes, text edits, editor switches, and theme changes. All listeners are properly registered to context.subscriptions for automatic cleanup.


67-71: LGTM!

The helper correctly iterates through all visible editors to refresh decorations, which is appropriate for theme change scenarios.


90-94: LGTM!

The deactivation properly disposes of the decoration type, which automatically clears all decorations. Event listeners registered to context.subscriptions in the activate function will be automatically disposed by VSCode.


76-81: Based on the web search results about VS Code's DiagnosticTag.Unnecessary, I can now analyze the review comment's validity:

Key Finding: DiagnosticTag.Unnecessary is purely a rendering hint for presentation purposes, not a semantic filter for identifying unused values. This means:

  1. The concern in the review is technically valid - Multiple sources could set the Unnecessary tag on their diagnostics
  2. The empty source filter is indeed risky - Any diagnostic source sending diagnostics with an empty source string + Unnecessary tag would be matched, not just helm-ls
  3. The protection is incomplete - DiagnosticTag.Unnecessary doesn't prevent other tools from sending similar diagnostic patterns

However, I cannot verify:

  • Whether the isValuesFile() helper function actually exists in the codebase
  • Whether this is a practical concern in the real world
  • Whether the suggested fix is implementable

Given that the repository is inaccessible and the core concern about the empty source filter's inadequacy is technically sound based on VS Code API documentation, but the specific suggested fix cannot be validated:


Empty source filter accepts diagnostics from any tool with Unnecessary tag, not just helm-ls.

The temporary workaround accepting diagnostics with empty source (line 79) is broader than intended. DiagnosticTag.Unnecessary is only a rendering hint and doesn't filter by semantic meaning—any diagnostic source setting this tag with an empty source string would match, creating false positives beyond helm-ls unused values.

Verify that isValuesFile() exists and is accessible in scope before applying the suggested constraint. If unavailable, consider alternative validation (e.g., checking diagnostic message pattern or adding a more specific source identifier).

Comment on lines 82 to +84
client.start();

unusedValuesDecorator.activate(context);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Await client.start() before activating the decorator to prevent race conditions.

The decorator is activated immediately after client.start() without awaiting the Promise. Since the decorator relies on diagnostics from helm-ls, activating it before the language server is fully initialized could lead to missing or incomplete decorations.

Apply this diff to await the client initialization:

-  client.start();
-
-  unusedValuesDecorator.activate(context);
+  await client.start();
+  unusedValuesDecorator.activate(context);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
client.start();
unusedValuesDecorator.activate(context);
await client.start();
unusedValuesDecorator.activate(context);
🤖 Prompt for AI Agents
In src/extension.ts around lines 82 to 84, the code calls client.start() and
immediately activates unusedValuesDecorator which can race with language-server
initialization; change the call to await client.start() (ensuring the enclosing
function is async) so the Promise resolves before calling
unusedValuesDecorator.activate(context); optionally add a try/catch around await
client.start() to log or handle startup failures before activating the
decorator.

Comment on lines +63 to +65
function isValuesFile(fileName: string): boolean {
return fileName.includes('values.yaml') || fileName.includes('values.yml');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Align the file pattern check with the document selector in extension.ts.

The isValuesFile check uses a simple substring match that is inconsistent with the document selector pattern **/values*.yaml defined in extension.ts (line 68). This could cause decorations to appear in files like "myvalues.yaml" that aren't monitored by the language server, or miss files with uppercase extensions.

Apply this diff to align with the document selector pattern:

 function isValuesFile(fileName: string): boolean {
-    return fileName.includes('values.yaml') || fileName.includes('values.yml');
+    const lowerFileName = fileName.toLowerCase();
+    return /values.*\.ya?ml$/.test(lowerFileName);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function isValuesFile(fileName: string): boolean {
return fileName.includes('values.yaml') || fileName.includes('values.yml');
}
function isValuesFile(fileName: string): boolean {
const lowerFileName = fileName.toLowerCase();
return /values.*\.ya?ml$/.test(lowerFileName);
}
🤖 Prompt for AI Agents
In src/util/unusedValuesDecorator.ts around lines 63-65, the current
isValuesFile uses a simple substring check that doesn't match the document
selector **/values*.yaml and is case-sensitive; replace it so it normalizes to
the filename basename and matches the pattern used by extension.ts, e.g. test
the basename against a case-insensitive pattern for values*.ya?ml (match
/^values.*\.ya?ml$/i) or use the same glob/minimatch pattern, ensuring only
files whose basename begins with "values" and ends with .yml or .yaml
(case-insensitive) return true.

@qvalentin
Copy link
Owner

Hi and thanks for the suggestion.
I found that you can achieve a similar look just by configuring VS code: https://stackoverflow.com/questions/53517219/vs-code-how-to-show-unused-variables-as-red

So I would rather not include a hard coded color scheme for this in the extension.
For me personally the default look is also quite nice and I don't really see the befit of adding this to the extension.

@jadefr
Copy link
Author

jadefr commented Dec 1, 2025

Hi @qvalentin,

I tested it with your PR, and it works:

image

I'll close this PR.

Thank you.

@jadefr jadefr closed this Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants