fix: preserve half-width slot placement on save/load (#1248)#1302
fix: preserve half-width slot placement on save/load (#1248)#1302
Conversation
|
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 · |
📝 WalkthroughWalkthroughAdds YAML serialization ordering for Changes
Sequence Diagram(s)(Skipped — changes are limited to serialization ordering and a unit test; no multi-component sequential flow to visualize.) Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 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 |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
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 `@src/tests/yaml-roundtrip.test.ts`:
- Line 27: Remove the redundant override `face: "front"` in the test fixture
since `createTestDevice` already defaults to face="front"; locate the test
object in yaml-roundtrip.test.ts where `face: "front"` is set (the literal shown
in the diff) and delete that property so the test relies on the factory default
from `createTestDevice`.
src/tests/yaml-roundtrip.test.ts
Outdated
| id: "placed-1", | ||
| device_type: halfWidth.slug, | ||
| position: 10, | ||
| face: "front", |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Redundant face override
face: "front" is already the default in createTestDevice, so this override is a no-op.
🧹 Suggested cleanup
createTestDevice({
id: "placed-1",
device_type: halfWidth.slug,
position: 10,
- face: "front",
slot_position: "left",
}),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| face: "front", | |
| createTestDevice({ | |
| id: "placed-1", | |
| device_type: halfWidth.slug, | |
| position: 10, | |
| slot_position: "left", | |
| }), |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/tests/yaml-roundtrip.test.ts` at line 27, Remove the redundant override
`face: "front"` in the test fixture since `createTestDevice` already defaults to
face="front"; locate the test object in yaml-roundtrip.test.ts where `face:
"front"` is set (the literal shown in the diff) and delete that property so the
test relies on the factory default from `createTestDevice`.
The createTestDevice factory already defaults face to "front", so the explicit assignment was unnecessary. Addresses CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5b1ae17 to
41ede6f
Compare
|
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 · |
Sequence DiagramThe PR ensures device_types.slot_width and placed device slot_position are included in YAML output so a serialize -> parse round-trip preserves half-width device placement; the test covers serializing a layout and parsing it back to assert both fields survive. sequenceDiagram
participant Test
participant YAMLUtil
participant Serializer
participant Parser
Test->>YAMLUtil: serializeLayoutToYaml(layout with half-width device & left slot)
YAMLUtil->>Serializer: include device_types.slot_width and devices.slot_position
Serializer-->>YAMLUtil: YAML string (layout)
YAMLUtil->>Parser: parseLayoutYaml(YAML string)
Parser-->>YAMLUtil: restored layout (slot_width and slot_position preserved)
YAMLUtil-->>Test: return restored layout
Test->>Test: assert restored.device_types.slot_width == 1 and restored.racks[0].devices[0].slot_position == "left"
Generated by CodeAnt AI |
|
CodeAnt AI Incremental review completed. |
User description
Summary
device_types[].slot_widthduring YAML serializationracks[].devices[].slot_positionduring YAML serializationTest Plan
npm run test:run -- src/tests/yaml-roundtrip.test.tsnpm run buildcodeant static-analysis --uncommitted --fail-on INFOcodeant security-analysis --uncommitted --fail-on INFOcodeant secrets --uncommitted --fail-on allcoderabbit --prompt-only --type uncommittednpm run lint(fails on unrelated baseline issues inapi/src/*andscripts/*)npm run test:run(fails on unrelated baseline timeouts insrc/tests/App.startScreen.test.tsandsrc/tests/App.cleanupPrompt.test.ts)Closes #1248
CodeAnt-AI Description
Preserve half-width device slot width and placement in layout YAML
What Changed
Impact
✅ Preserved half-width device placement after save/load✅ Accurate rack layout after YAML import✅ Fewer layout round-trip regressions💡 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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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.