fix(diagram): updated dynamicViewVariant on navigation to dynamic view#2827
Conversation
🦋 Changeset detectedLatest commit: b75f8f8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 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 (2)
📝 WalkthroughWalkthroughUpdate navigation handling so Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/diagram/src/likec4diagram/state/machine.state.navigating.spec.ts`:
- Around line 9-22: The fixture mockElementView is using a double-cast "as
unknown as DiagramView" which bypasses TypeScript checks; replace the cast with
a proper typed fixture using either the "satisfies DiagramView" operator or an
explicit builder function so the object shape is validated at compile time.
Update mockElementView (and the similar fixtures at the other ranges mentioned)
to declare the literal as const and append "satisfies DiagramView" or construct
it via a typed helper (e.g., createDiagramView({...})) so the compiler enforces
the DiagramView/XY contract rather than using "as unknown as".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 47fd704e-7614-4986-a0a8-46e5265f299d
📒 Files selected for processing (2)
packages/diagram/src/likec4diagram/state/machine.state.navigating.spec.tspackages/diagram/src/likec4diagram/state/machine.state.navigating.ts
|
@davydkov would greatly appreciate a review of this PR. Will create a changeset as soon as you approve and are satisfied with it. |
davydkov
left a comment
There was a problem hiding this comment.
Looks good!
I think we can merge this (seems repetitive):
const actor = createTestActor(view)
actor.start()
advanceToReady(actor, view)I see you have asserts before advanceToReady, but I think they are redundant
What do you think?
|
Yea that makes sense |
|
@davydkov I removed the redundant asserts. Would greatly appreciate it if you could please take a look at the PR. I will add a changeset if you are satisfied. |
|
|
||
| it('sets dynamicViewVariant to "sequence" when navigating from a non-dynamic view', () => { | ||
| const actor = createTestActor(mockElementView) | ||
| actor.start() |
There was a problem hiding this comment.
You can move actor.start() to createTestActor
|
@davydkov updated! Added changeset as well. Would greatly appreciate a review. |
|
@davydkov just wanted to follow up on this. Thank you for your time! |
davydkov
left a comment
There was a problem hiding this comment.
Hey @kavishkartha05
This weekend was on holidays, sorry for delay
Checklist
mainbefore creating this PR.Fixes #2802. When navigating to a dynamic view, the XState machine's
enqueue.assignblock in the navigating state never updateddynamicViewVariantto match the incoming view's declared variant, but rather it inherited the previous view's value. AddeddynamicViewVariantto both the first-time navigation path and the history-restore path inmachine.state.navigating.ts. Added 4 tests covering both paths.