Skip to content

fix(core): inherit relationship styles from spec in dynamic views#2864

Merged
davydkov merged 2 commits intomainfrom
fix-relationship-style-in-dynamic-views
Apr 8, 2026
Merged

fix(core): inherit relationship styles from spec in dynamic views#2864
davydkov merged 2 commits intomainfrom
fix-relationship-style-in-dynamic-views

Conversation

@davydkov
Copy link
Copy Markdown
Member

@davydkov davydkov commented Apr 8, 2026

Inherit relationship style properties (color, line, head, tail) from specification defaults in dynamic views. Previously only technology was inherited when a step had a kind. Now all visual style properties follow the same pattern with correct precedence: step explicit values > model relationship values > specification defaults.

Fixes #2797

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).

Extend dynamic view computation to inherit color, line, head, and tail
properties from the relationship specification defaults, not just
technology. Properties follow the precedence: step > model > spec.

Fixes #2797

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: 4046e7f

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
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

Dynamic view computation now inherits relationship style fields (color, line, head, tail) from the model specification when a step specifies a kind, in addition to previously inherited technology. Tests and a changeset were added to reflect and validate this behavior.

Changes

Cohort / File(s) Summary
Changelog Entry
.changeset/dynamic-view-spec-styles.md
Added a changeset for @likec4/core (patch) documenting that dynamic views inherit relationship style fields (color, line, head, tail) from the specification.
Test Suite
packages/core/src/compute-view/dynamic-view/__test__/step-fields.spec.ts
Added Style inheritance from specification tests verifying that computed dynamic-view edges inherit color, line, head, tail from specification relationships, that explicit step-level values override spec defaults, that model relationship styles take precedence, and that spec-derived styles combine with other spec attributes (e.g., technology).
Core Logic
packages/core/src/compute-view/dynamic-view/compute.ts
Updated dynamic view step derivation to lookup model.specification.relationships[step.kind] and conditionally merge technology, color, line, head, and tail into computed steps when those fields are absent on the step or derived relation. Replaced prior technology-only conditional with multi-field kindSpec merging.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: inheriting relationship styles from specification in dynamic views.
Linked Issues check ✅ Passed The PR fully addresses issue #2797 by implementing inheritance of relationship style properties (color, line, head, tail) from specification defaults in dynamic views with correct precedence.
Out of Scope Changes check ✅ Passed All changes are directly related to the objective: a changeset entry, test suite for style inheritance, and updated dynamic view computation logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description clearly explains the changes, references the fixed issue (#2797), and includes a complete checklist with all items properly checked based on the author's work.

✏️ 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-relationship-style-in-dynamic-views

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/core/src/compute-view/dynamic-view/__test__/step-fields.spec.ts (1)

248-250: Consider using stricter typing for relationship kinds in tests.

The as any cast for kind is repeated in multiple tests. While acceptable in test files, you could define a local type alias or use the Builder's type inference to maintain type safety.

♻️ Optional: Define a type alias for the test
// At the top of the describe block or file
type TestRelationKind = 'action' | 'requests'

// Then use:
kind: 'action' as TestRelationKind,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/compute-view/dynamic-view/__test__/step-fields.spec.ts`
around lines 248 - 250, The test uses an unsafe cast ("kind: 'action' as any")
when calling computeEdgeFromStep; replace the repeated any casts by introducing
a local narrower type alias (e.g., TestRelationKind = 'action' | 'requests') at
the top of the test file or describe block and use it for the kind field, or
leverage the Builder's type inference so calls to computeEdgeFromStep(...) pass
a properly typed kind value instead of using as any; update other similar test
cases to use the same alias to remove duplicated any casts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/core/src/compute-view/dynamic-view/__test__/step-fields.spec.ts`:
- Around line 248-250: The test uses an unsafe cast ("kind: 'action' as any")
when calling computeEdgeFromStep; replace the repeated any casts by introducing
a local narrower type alias (e.g., TestRelationKind = 'action' | 'requests') at
the top of the test file or describe block and use it for the kind field, or
leverage the Builder's type inference so calls to computeEdgeFromStep(...) pass
a properly typed kind value instead of using as any; update other similar test
cases to use the same alias to remove duplicated any casts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2170903e-a3c2-4116-8905-7da54752ab17

📥 Commits

Reviewing files that changed from the base of the PR and between 062c600 and d49a9b8.

📒 Files selected for processing (3)
  • .changeset/dynamic-view-spec-styles.md
  • packages/core/src/compute-view/dynamic-view/__test__/step-fields.spec.ts
  • packages/core/src/compute-view/dynamic-view/compute.ts

Remove derived.head/tail checks (findRelations doesn't return these)
and inline spec defaults into the push call to avoid exact() type issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@davydkov davydkov merged commit 6b87578 into main Apr 8, 2026
16 checks passed
@davydkov davydkov deleted the fix-relationship-style-in-dynamic-views branch April 8, 2026 17:09
@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.

Dynamic view uses relationship styles from specification

1 participant