Skip to content

fix(core): custom element description/summary overridden by spec defaults#2860

Merged
davydkov merged 3 commits into
mainfrom
fix-element-props-in-builder
Apr 8, 2026
Merged

fix(core): custom element description/summary overridden by spec defaults#2860
davydkov merged 3 commits into
mainfrom
fix-element-props-in-builder

Conversation

@davydkov

@davydkov davydkov commented Apr 8, 2026

Copy link
Copy Markdown
Member

Fixes #2795

In the Builder API, ...spec was spread after custom description/summary properties, causing specification defaults to silently overwrite user-provided values. Moved ...spec before the custom property spreads so user values take precedence. Applied the same fix for both model elements and deployment nodes.

Checklist

  • I've thoroughly read the latest contribution guidelines.
  • I've rebased my branch onto main before creating this PR.
  • I've added tests to cover my changes (if applicable).
  • I've verified pnpm typecheck and pnpm test.
  • I've added changesets (you can use /changeset-generator SKILL).
  • My change requires documentation updates.
  • I've updated the documentation accordingly (or will do in follow-up PR).

…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-bot

changeset-bot Bot commented Apr 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 492d418

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@likec4/core Patch
@likec4/playground Patch
@likec4/config Patch
@likec4/diagram Patch
@likec4/generators Patch
@likec4/language-server Patch
@likec4/language-services Patch
@likec4/layouts Patch
@likec4/leanix-bridge Patch
likec4 Patch
@likec4/mcp Patch
@likec4/react Patch
@likec4/vite-plugin Patch
@likec4/vscode-preview Patch
likec4-vscode Patch
@likec4/docs-astro Patch
@likec4/lsp Patch
@likec4/style-preset Patch
@likec4/styles Patch
@likec4/log Patch
@likec4/tsconfig Patch

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

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e494b4c-407b-4c1a-b7cb-947ab2d31467

📥 Commits

Reviewing files that changed from the base of the PR and between f8dad8c and 492d418.

📒 Files selected for processing (2)
  • packages/core/src/builder/Builder-style2.spec.ts
  • packages/core/src/builder/Builder.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/core/src/builder/Builder-style2.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/builder/Builder.ts

📝 Walkthrough

Walkthrough

Reorders object spread in Builder so specification defaults are applied before derived and user-provided fields; ensures instance- or deployment-level description/summary/links override spec defaults. Adds a test validating precedence and a changeset documenting the patch.

Changes

Cohort / File(s) Summary
Changeset Entry
.changeset/fix-builder-description-override.md
Adds a changeset for @likec4/core (patch) describing the fix where custom description/summary were previously overwritten by spec defaults.
Test Coverage
packages/core/src/builder/Builder-style2.spec.ts
Adds a Vitest test verifying that instance-level description/summary/links override spec defaults, and that instances without overrides inherit spec values.
Builder Fix
packages/core/src/builder/Builder.ts
Moves ...spec earlier in object construction, computes mappedLinks = mapLinks(links) and conditionally sets links, and updates title fallback to title ?? spec.title ?? nameFromFqn(_id), ensuring spec defaults apply before user-provided overrides.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main bug fix: custom element description/summary properties being overwritten by spec defaults.
Description check ✅ Passed The PR description follows the template, addresses the linked issue, and includes completed checklist items. Documentation updates are noted as not required.
Linked Issues check ✅ Passed The changes directly address issue #2795 by reordering spec spread to occur before custom properties, ensuring user-provided description/summary/links take precedence for both elements and deployment nodes.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the spec spread order issue (#2795): the Builder.ts refactor, comprehensive test coverage, and changelog entry. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-element-props-in-builder

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Same links regression 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 with undefined when 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

📥 Commits

Reviewing files that changed from the base of the PR and between c0048b6 and 2868591.

📒 Files selected for processing (3)
  • .changeset/fix-builder-description-override.md
  • packages/core/src/builder/Builder-style2.spec.ts
  • packages/core/src/builder/Builder.ts

davydkov and others added 2 commits April 8, 2026 18:10
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>
@davydkov davydkov enabled auto-merge (squash) April 8, 2026 16:28
@davydkov davydkov disabled auto-merge April 8, 2026 16:30
@davydkov davydkov merged commit f684e2f into main Apr 8, 2026
16 checks passed
@davydkov davydkov deleted the fix-element-props-in-builder branch April 8, 2026 16:30
@likec4-ci likec4-ci Bot mentioned this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Custom element description and summary are overwritten by specification's element kind properties

1 participant