components: slim index + lazy-loaded bodies#939
Open
marcelveldt wants to merge 2 commits into
Open
Conversation
Eager-loading the full ~22MB component catalog at startup carries the per-field config_entries tree for every user session, even though list / search / filter paths don't touch it. The slim index loads at startup (~370KB); per-id body files hydrate on demand through a bounded LRU when the user opens a detail view. - definitions/components.index.json is the slim catalog; bodies live at definitions/components/<id>.json. - ComponentCatalog.load() parses the index only. get_body(id) reads the body file through asyncio.to_thread and caches up to 64 entries in an LRU. - components/get_components returns the slim ComponentCatalogIndexEntry shape; components/get_component keeps the full detail shape for the form renderer. Frontend coordination needed — companion PR drops list-view reads of config_entries. - script/sync_components.py emits the split layout; build-time files swap atomically through a sibling components.next/ dir.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #939 +/- ##
==========================================
- Coverage 99.24% 99.23% -0.02%
==========================================
Files 191 191
Lines 14243 14296 +53
==========================================
+ Hits 14136 14186 +50
- Misses 107 110 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
Author
|
codeql is flagging the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
PR 3 from #934 — split the component catalog so an idle dashboard stops carrying every component's
config_entriestree in RAM. The slim index loads eagerly at startup; per-id bodies hydrate lazily on detail-view open through a bounded LRU.Related issue:
Changes
definitions/components.index.json(slim, ~370KB) loads at startup; bodies live atdefinitions/components/<id>.jsonand hydrate viaComponentCatalog.get_bodythrough a 64-entry LRU.script/sync_components.pyemits the split layout — bodies land in a siblingcomponents.next/dir first, then the whole dir + index swap into place so a Ctrl-C mid-write leaves the old catalog intact.components/get_components(list) returns the slimComponentCatalogIndexEntryshape;components/get_component(detail) keeps the full shape._FeaturedRecordstoresunderlying_id: strinstead of the body; the body is fetched at materialise time.resolve_default_components/_apply_featured_presetsthread the body through explicitly.validate_definitions,check_catalog,sync_esphome_devices) join the index with the on-disk body files.Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
components/get_componentslist responses drop theconfig_entriesfield (the form renderer never used it on list views — it re-fetches viaget_componentwhen a card opens). Companion frontend PR needs to land in the same release window.Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.index.json/definitions/components/*.jsonhave not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.