Skip to content

Add registryDependencies to strategies for selective regeneration#30102

Draft
piitaya wants to merge 5 commits intodevfrom
registry-dependencies
Draft

Add registryDependencies to strategies for selective regeneration#30102
piitaya wants to merge 5 commits intodevfrom
registry-dependencies

Conversation

@piitaya
Copy link
Member

@piitaya piitaya commented Mar 11, 2026

Proposed change

Note: this PR stacks on top of #30101.

Strategies currently regenerate whenever any registry changes (entities, devices, areas, floors), even for strategies like iframe or map that don't depend on any registry data.

Each strategy can now declare which registries it depends on via a static registryDependencies property. Regeneration only happens when relevant data changes. Strategies with no dependencies never regenerate; strategies like the home dashboard only regenerate when areas change.

Regeneration checks are also extended to views and sections, not just dashboards.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to backend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

To help with the load of incoming pull requests:

@piitaya piitaya marked this pull request as draft March 11, 2026 17:27
@piitaya piitaya force-pushed the registry-dependencies branch from 773faba to 47996c8 Compare March 11, 2026 17:29
Base automatically changed from refactor-lovelace-views to dev March 24, 2026 16:41
piitaya and others added 4 commits March 24, 2026 17:59
- Remove `force` flag from `hui-root` that was clearing the entire view
  cache and destroying all cached view DOM on any config change. Views
  now receive updated lovelace in place and handle config changes
  internally.
- Add `_cleanupViewCache` to remove stale cache entries when views are
  added, removed, or reordered.
- Remove `@ll-rebuild` handler from `hui-root`. Cards and badges already
  handle `ll-rebuild` via their `hui-card`/`hui-badge` wrappers. Sections
  now always stop propagation and rebuild locally.
- Add `deepEqual` guard in `hui-view._setConfig` and
  `hui-section._initializeConfig` to skip re-rendering when strategy
  regeneration produces an identical config.
- Simplify `hui-view` refresh flow: remove `_refreshConfig`,
  `_rendered` flag, `strategy-config-changed` event, and
  connected/disconnected callbacks. Registry changes now debounce
  directly into `_initializeConfig`.
- Fix `isStrategy` check in `hui-view._initializeConfig` to use the raw
  config (before strategy expansion) rather than the generated config.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y interface

Strategies can now declare which registries they depend on via a static
`registryDependencies` property. A `shouldRegenerate` method can also
be implemented for custom logic. The `checkStrategyShouldRegenerate`
helper uses these to decide whether regeneration is needed, falling
back to checking entities, devices, areas, and floors by default.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace hardcoded registry checks with checkStrategyShouldRegenerate
in hui-view, hui-section, ha-panel-lovelace, and ha-panel-home.
Regeneration checks are also extended to sections (previously only
dashboards and views were checked).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@piitaya piitaya force-pushed the registry-dependencies branch from 47996c8 to ea5c481 Compare March 24, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant