Skip to content

Find themes in dashboards that do not exist - #1930

Merged
frenck merged 6 commits into
mainfrom
frenck/dashboard-unknown-themes
Oct 11, 2026
Merged

frenck merged 6 commits into
mainfrom
frenck/dashboard-unknown-themes

Conversation

@frenck

@frenck frenck commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Description

A card, section or view with theme: Midnight after that theme was renamed or removed gets the default look, and nothing says why. The frontend only applies a theme it has (src/common/dom/apply_themes_on_element.ts:114-131, an exact, case sensitive lookup).

Spook now raises one issue per dashboard listing those themes, with an edit link to the first view that has one. It checks views and sections of any type (the frontend applies their theme whatever the type), and the 24 core cards that apply a theme themselves, nested ones too (stacks, grids, conditional and entity filter cards, view header and footer cards, sidebar sections). Cards that ignore theme (tile, heading, stacks and others) are not reported: fixing those would change nothing on screen. default, none and every loaded theme are fine. Templates, custom cards and their contents, contents of custom views and sections, and strategies are left alone. It looks again when themes are reloaded, so adding the theme back clears the issue.

Not included, on purpose: frontend.set_theme with an unknown name (core refuses it with an error, so it is not silent), the backend default themes (core resets those itself when their theme is gone), and the per user profile theme (same ghost, but it needs reading every user's frontend store; possible as its own PR).

New repair kind lovelace_unknown_theme_references with a new {themes} placeholder, so it needs a Weblate pull and pass before release. TEMPLATE_MARKERS moved into dashboard_extraction.py, shared with the navigation repair.

Motivation and Context

A renamed or removed theme leaves every card and view using it in the default look, with nothing pointing at the cause.

How has this been tested?

31 tests through the real repair with real themes loaded through the frontend integration: card, view and section themes, sidebar sections, nested cards, all 24 theming card types, ignored card types, built in and known names, near misses (case, trailing space, Default, None), templates, custom cards, custom views and sections, strategies, frontend.reload_themes adding and removing a theme, saving the dashboard to clear the issue. 23 mutations, one per guard, all caught. Full suite: 4679 passed; pylint, ruff and prettier clean.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 11:10
@frenck frenck added new-feature New features or options. and removed new-feature New features or options. labels Oct 11, 2026
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca223549-2cb1-44ed-bd5f-6962b88c980f

📥 Commits

Reviewing files that changed from the base of the PR and between 894e288 and 27ae4af.


📒 Files selected for processing (8)
  • custom_components/spook/dashboard_extraction.py
  • custom_components/spook/ectoplasms/lovelace/repairs/unknown_theme_references.py
  • custom_components/spook/ectoplasms/lovelace/repairs/unknown_view_references.py
  • custom_components/spook/repair_documentation.py
  • custom_components/spook/translations/en.json
  • documentation/integrations/lovelace.md
  • plugins/spook/skills/spook/references/repairs.md
  • tests/ectoplasms/lovelace/repairs/test_unknown_theme_references.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 15dd43c7-c68d-45d0-966d-5fd4aabdc305



📥 Commits

Reviewing files that changed from the base of the PR and between 9daa96b and 894e288.




📒 Files selected for processing (8)
  • custom_components/spook/dashboard_extraction.py
  • custom_components/spook/ectoplasms/lovelace/repairs/unknown_theme_references.py
  • custom_components/spook/ectoplasms/lovelace/repairs/unknown_view_references.py
  • custom_components/spook/repair_documentation.py
  • custom_components/spook/translations/en.json
  • documentation/integrations/lovelace.md
  • plugins/spook/skills/spook/references/repairs.md
  • tests/ectoplasms/lovelace/repairs/test_unknown_theme_references.py



Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds dashboard-view theme extraction and a Lovelace repair that reports extracted theme names missing from frontend theme data. It also reuses template markers in view-reference validation and adds repair translations, documentation, and tests.

Changes

Unknown theme repair

Layer / File(s) Summary
Extract themes from rendered views
custom_components/spook/dashboard_extraction.py
The new extractor collects nonempty, non-template theme names from supported view layouts, cards, and sections.
Inspect dashboards and report unknown themes
custom_components/spook/ectoplasms/lovelace/repairs/unknown_theme_references.py, custom_components/spook/ectoplasms/lovelace/repairs/unknown_view_references.py, custom_components/spook/repair_documentation.py, custom_components/spook/translations/en.json, documentation/integrations/lovelace.md, plugins/spook/skills/spook/references/repairs.md, tests/ectoplasms/lovelace/repairs/test_unknown_theme_references.py
The repair checks configured dashboards against frontend theme names, excludes built-in values, and creates issues for unknown references. View-reference validation now uses the shared template markers. The added translations, documentation, and tests cover the repair and its behavior.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LovelaceEvents
  participant SpookRepair
  participant FrontendThemes
  participant DashboardConfigs
  participant RepairIssues
  LovelaceEvents->>SpookRepair: Trigger inspection
  SpookRepair->>FrontendThemes: Read known theme names
  FrontendThemes-->>SpookRepair: Return theme data
  SpookRepair->>DashboardConfigs: Read configured dashboards
  DashboardConfigs-->>SpookRepair: Return dashboard configurations
  SpookRepair->>RepairIssues: Create issues for unknown themes
Loading




Merge Risk: ⚪ Minimal · up to 894e2

This adds a new dashboard repair that flags themes which do not exist. The change is additive, has broad tests, and no concrete merge-blocking risk was found.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check Passed The description clearly explains the new unknown-theme repair, its detection scope, exclusions, documentation impact, and testing performed. It is directly related to the changeset.
Title check Passed The title clearly summarizes the main change: detecting dashboard themes that do not exist. It is concise and specific.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 39 functions across 5 files. (3 skipped: 3…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.





✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR




🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR





  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

I’m a rabbit with a theme in my burrow tonight.
I hop through the views, checking each name in sight.
If one is missing, a repair sign will appear.
Built-in names stay tucked away, safe and clear.
I nibble the docs, then bound through the grass.
The dashboards bloom as my whiskers brush past.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Theme extraction misses nested sections and can both suppress valid findings and report ignored card properties.

2 open findings
What changed in this PR

Adds Lovelace repair detection for references to unavailable frontend themes.

Changes:

  • Extracts theme references from dashboard views, sections, and supported cards.
  • Raises and refreshes repair issues when dashboards or themes change.
  • Adds tests, translations, and documentation.
File Description
tests/​ectoplasms/​lovelace/​repairs/​test_unknown_theme_references.py Tests theme detection and repair lifecycle.
plugins/​spook/​skills/​spook/​references/​repairs.md Lists the new repair kind.
documentation/​integrations/​lovelace.md Documents unknown-theme detection.
custom_components/​spook/​translations/​en.json Adds repair text.
custom_components/​spook/​repair_documentation.py Maps the repair to documentation.
custom_components/​spook/​ectoplasms/​lovelace/​repairs/​unknown_view_references.py Reuses shared template markers.
custom_components/​spook/​ectoplasms/​lovelace/​repairs/​unknown_theme_references.py Implements repair inspection and issue creation.
custom_components/​spook/​dashboard_extraction.py Adds dashboard theme extraction.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread custom_components/spook/dashboard_extraction.py Outdated
Comment thread custom_components/spook/dashboard_extraction.py Outdated
Copilot AI balanced review requested due to automatic review settings October 11, 2026 12:08
@frenck
frenck force-pushed the frenck/dashboard-unknown-themes branch from 66d2ef5 to a238d4a Compare October 11, 2026 12:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Theme extraction misses nested sections and can report themes from dashboard content that is not rendered.

3 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment thread custom_components/spook/dashboard_extraction.py
Comment thread custom_components/spook/dashboard_extraction.py Outdated
Comment thread custom_components/spook/dashboard_extraction.py Outdated
Copilot AI balanced review requested due to automatic review settings October 11, 2026 12:35
@frenck
frenck force-pushed the frenck/dashboard-unknown-themes branch from a238d4a to e8f999d Compare October 11, 2026 12:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches frontend behavior and is supported by comprehensive tests and documentation.

0 open findings

3 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 11, 2026 13:03
@frenck
frenck force-pushed the frenck/dashboard-unknown-themes branch from e8f999d to b9630ff Compare October 11, 2026 13:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Invalid section layouts currently cause false reports for child themes that are never rendered.

1 open finding

🧠 Review effort: Balanced

Comment thread custom_components/spook/dashboard_extraction.py
Copilot AI balanced review requested due to automatic review settings October 11, 2026 15:49
coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches frontend behavior, handles lifecycle updates, and has comprehensive focused tests.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 11, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

View-type detection mishandles JavaScript truthiness for empty arrays, causing false theme reports.

1 open finding

🧠 Review effort: Balanced

Comment thread custom_components/spook/dashboard_extraction.py Outdated
Copilot AI balanced review requested due to automatic review settings October 11, 2026 16:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches frontend rendering behavior and is comprehensively tested and documented.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@frenck
frenck merged commit 9026018 into main Oct 11, 2026
19 checks passed
@frenck
frenck deleted the frenck/dashboard-unknown-themes branch October 11, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants