Skip to content

fix: preserve slot_position and slot_width in YAML serialization#1564

Merged
ggfevans merged 2 commits intoRackulaLives:mainfrom
lorenzowood:fix/half-width-slot-position-serialization
Apr 16, 2026
Merged

fix: preserve slot_position and slot_width in YAML serialization#1564
ggfevans merged 2 commits intoRackulaLives:mainfrom
lorenzowood:fix/half-width-slot-position-serialization

Conversation

@lorenzowood
Copy link
Copy Markdown
Contributor

@lorenzowood lorenzowood commented Apr 6, 2026

User description

Summary

  • slot_position (half-width device left/right placement) and slot_width (half-width device type flag) were accidentally stripped from YAML output in dd25f4c when the YAML editor panel feature was added
  • This caused two half-width devices placed side-by-side to serialize identically, losing their left/right distinction and crashing on reload with each_key_duplicate
  • Restores the fix originally introduced in 3661eba

Root cause

dd25f4c ("feat: add YAML editor panel") removed both fields from orderPlacedDeviceFields() and orderDeviceTypeFields() in yaml.ts, and rewrote the round-trip test to assert they were absent — incorrectly labelling them as "deprecated NetBox fields". slot_position is Rackula's own placement field; it was never deprecated.

Changes

  • src/lib/utils/yaml.ts — restore slot_position in orderPlacedDeviceFields() and slot_width in orderDeviceTypeFields()
  • src/tests/yaml-roundtrip.test.ts — replace the incorrect test with one that verifies both fields survive a full save/load round-trip for a pair of side-by-side half-width devices

Test plan

  • npm run test:run -- yaml-roundtrip passes
  • Place two half-width devices side-by-side, save, reload — layout renders correctly

🤖 Generated with Claude Code


CodeAnt-AI Description

Preserve half-width device placement in YAML save and load

What Changed

  • Half-width device types now keep their half-width setting when saved to YAML, so they load back with the correct width.
  • Devices placed side by side now keep their left/right slot position, so both placements remain distinct after saving and reopening.
  • The round-trip test now checks a pair of half-width devices to confirm both width and position survive serialization.

Impact

✅ Correct half-width device placement
✅ Fewer layout reload errors
✅ Safer YAML save and restore

🔄 Retrigger CodeAnt AI Review

Details

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

slot_position (half-width device placement) and slot_width (half-width
device type flag) were accidentally stripped from YAML output in dd25f4c
when the YAML editor panel feature was added. This caused two half-width
devices placed side-by-side to serialize identically, losing their
left/right distinction and crashing on reload with each_key_duplicate.

Restores the fix originally introduced in 3661eba.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Apr 6, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai bot added the size:S This PR changes 10-29 lines, ignoring generated files label Apr 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

This change updates YAML serialization logic to conditionally include slot_width in DeviceType and slot_position in PlacedDevice field sequences during schema v1.0.0 serialization, with corresponding test updates to verify these fields are correctly emitted and round-tripped.

Changes

Cohort / File(s) Summary
YAML Serialization Schema
src/lib/utils/yaml.ts
Added conditional serialization of slot_width in DeviceType and slot_position in PlacedDevice within ordered field sequences; adjusted field-mapping control flow to emit these fields at specified positions when defined.
YAML Round-trip Tests
src/tests/yaml-roundtrip.test.ts
Inverted test assertions to expect slot_width and slot_position fields in serialized YAML output; enhanced round-trip validation to verify specific restored values: DeviceType slot_width equals 1, and PlacedDevice slot_position values are "left" and "right"; extended test data with a second placed device to support both assertions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

size:M

Poem

A rabbit hops through YAML fields so neat,
Slot widths and positions find their seat,
In ordered sequences they now reside,
Round-tripping left and right with pride,
The schema dances, complete! 🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: restoring slot_position and slot_width fields to YAML serialization to fix a bug that prevented correct save/load of half-width device placements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description clearly explains the bug, root cause, and changes made to restore slot_position and slot_width fields in YAML serialization.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Apr 6, 2026

CodeAnt AI finished reviewing your PR.

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Apr 16, 2026

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai bot added size:S This PR changes 10-29 lines, ignoring generated files and removed size:S This PR changes 10-29 lines, ignoring generated files labels Apr 16, 2026
@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Apr 16, 2026

CodeAnt AI Incremental review completed.

@ggfevans ggfevans merged commit d1fe42a into RackulaLives:main Apr 16, 2026
6 of 7 checks passed
@ggfevans
Copy link
Copy Markdown
Collaborator

Thanks for your contribution, @lorenzowood !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants