fix(core): custom element description/summary overridden by spec defaults#2860
Conversation
…ults Move `...spec` spread before custom `description`/`summary` in Builder so user-provided values take precedence over specification defaults. Fixes #2795 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 492d418 The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReorders object spread in Builder so specification defaults are applied before derived and user-provided fields; ensures instance- or deployment-level Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/src/builder/Builder.ts (1)
876-897:⚠️ Potential issue | 🟠 MajorSame
linksregression applies to deployment nodes.Consistent with the element creation, the deployment node creation has the same issue where
links: mapLinks(links)will override spec-defined links withundefinedwhen user doesn't provide links.Proposed fix
+ const mappedLinks = mapLinks(links) b.__addDeployment( exact({ id: _id, kind: kind as any, ...spec, title: title ?? nameFromFqn(_id), ...(description && { description: toMarkdownOrString(description) }), ...(summary && { summary: toMarkdownOrString(summary) }), style: exact({ icon: icon as IconUrl | undefined, color: color ?? specStyle?.color, shape: shape ?? specStyle?.shape, border: specStyle?.border, opacity: specStyle?.opacity, size: specStyle?.size, padding: specStyle?.padding, textSize: specStyle?.textSize, ...style, }) satisfies ElementStyle, - links: mapLinks(links), + ...(mappedLinks && { links: mappedLinks }), ...props, }) satisfies DeploymentNode, )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/builder/Builder.ts` around lines 876 - 897, The Deployment creation call in __addDeployment is unconditionally setting links: mapLinks(links), which can overwrite spec-provided links with undefined when the user omits links; update the object construction so links are only assigned if the incoming links variable is defined (mirror the element creation fix) — e.g., conditionally include links: mapLinks(links) instead of always setting it, ensuring spec.links remains intact; change the DeploymentNode build in __addDeployment to only spread the mapped links when links is not undefined and keep the rest of the props unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/core/src/builder/Builder.ts`:
- Around line 876-897: The Deployment creation call in __addDeployment is
unconditionally setting links: mapLinks(links), which can overwrite
spec-provided links with undefined when the user omits links; update the object
construction so links are only assigned if the incoming links variable is
defined (mirror the element creation fix) — e.g., conditionally include links:
mapLinks(links) instead of always setting it, ensuring spec.links remains
intact; change the DeploymentNode build in __addDeployment to only spread the
mapped links when links is not undefined and keep the rest of the props
unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 76f220b0-c159-4018-99b9-a904a10ec681
📒 Files selected for processing (3)
.changeset/fix-builder-description-override.mdpackages/core/src/builder/Builder-style2.spec.tspackages/core/src/builder/Builder.ts
The previous fix moved `...spec` before `title` to prevent spec defaults from overwriting custom description/summary, but `nameFromFqn` fallback always produced a value, unconditionally overwriting spec's title. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make links conditional in element and deployment node creation so spec-defined links are not overwritten with undefined when user omits them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes #2795
In the Builder API,
...specwas spread after customdescription/summaryproperties, causing specification defaults to silently overwrite user-provided values. Moved...specbefore the custom property spreads so user values take precedence. Applied the same fix for both model elements and deployment nodes.Checklist
mainbefore creating this PR.pnpm typecheckandpnpm test./changeset-generatorSKILL).