PR: Harden Legacy Module Resolution for Complex IDs & Improve Dev Diagnostics #50
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.
PR: Harden Legacy Module Resolution for Complex IDs & Improve Dev Diagnostics
Summary
This PR makes the unified dynamic page renderer resilient to deeply composed module IDs and adds clearer dev-mode diagnostics. We correctly resolve modules when IDs follow patterns like
ServiceExample_Theme_userId_ServiceExample_Theme_actualModuleId_timestamp, and we emit structured logs that explain how a module was resolved (or why it wasn’t).The result is fewer “module not found” cases, stable layout extraction, and faster debugging—with no API or schema changes.
Closes [#30](#30).
Problem / Motivation
Plugin_module_timestampshape and failed on richer IDs produced by federated/legacy paths.What’s Changed
1) Frontend – Legacy Module Adapter
File:
frontend/src/features/unified-dynamic-page-renderer/adapters/LegacyModuleAdapter.tsxPrimary extractor updated: Use the 6th segment (
parts[5]) asactualModuleIdfor complex IDs:(Targets Theme modules like
ThemeDisplay/ThemeController.)New combined-ID fallback: Try
plugin_moduleform (e.g.,ServiceExample_Theme) and relaxed matches:m.id === combined, orm.id.endsWith(parts[2]), orm.name === parts[2].Final name-based fallback: Match against
name/displayName(and last-resortid.includes) using the module name segment (parts[2]).Richer dev diagnostics (
NODE_ENV === 'development'only):actualModuleId, and resolved module{ id, name, displayName, hasComponent }.{ id, name, displayName }.Keeps original simple-pattern fallback (
baseModuleId = moduleId.replace(/-\d+$/, '')) for backward compatibility.2) Frontend – Layout Engine Alignment
File:
frontend/src/features/unified-dynamic-page-renderer/components/LayoutEngine.tsxConsistent extraction: Aligns with adapter logic by using the 6th segment (
parts[5]) when deriving a “simple” module ID from complex IDs for:_legacy.moduleIdprop plumbingUpdated inline docs to reflect the canonical pattern and example.
User-Visible Behavior
Backward Compatibility
Risks & Mitigations
parts.length >= Nchecks and multi-step fallbacks (combined ID, name/displayName, simple pattern strip).endsWith, and only finallyincludesas a last resort (dev visibility via logs).