Add module-aware template resolution to prevent false update banners - #382
Add module-aware template resolution to prevent false update banners#382SaravanakumarR2018 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3ceca9371
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Object.values(data[curr]).forEach((component: APIKindType[keyof APIKindType]) => { | ||
| const moduleName = component?.metadata?.module; | ||
| if (moduleName && !acc[moduleName]) { | ||
| acc[moduleName] = component as APIClassType; | ||
| } |
There was a problem hiding this comment.
Keep per-module mappings from colliding
The new module map only retains the first component for each metadata.module, so any additional components in the same module will be resolved to the wrong template. The repository already ships component metadata where many components share a module (e.g. src/lfx/src/lfx/_assets/component_index.json reports far fewer modules than components), so resolveTemplateEntry will return a mismatched template for most components in those modules. That will make checkCodeValidity compare a node’s code/outputs against the wrong template, producing false “update available” banners or missing real updates for those components. Consider keying by {module, type} or storing a module→type map rather than a single component per module.
Useful? React with 👍 / 👎.
Motivation
metadata.modulewhen present.Description
src/frontend/src/utils/component-template-utils.tsexposingbuildTemplatesByModuleto build a module->template map andresolveTemplateEntryto prefer a module-match when resolving templates.templatesByModuleto theTypesStoreType, initializing it inuseTypesStore, and generating it insetTypesusingbuildTemplatesByModule.resolveTemplateEntryfromcheck-code-validityand by passingtemplatesByModuleintocheckCodeValidityfromflowStore.Testing
src/frontend/src/stores/__tests__/typesStore.test.tsandsrc/frontend/src/stores/__tests__/flowStore.test.ts) to mockbuildTemplatesByModuleand to asserttemplatesByModuleis produced and consumed.Codex Task