Repository navigation
refactor(protocol): derive cursor animation numeric conversions - #501
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (2)
✨ Finishing Touches📝 Generate docstrings
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.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open finding
What changed in this PR
Refactors CursorAnimStyle numeric encoding/decoding to rely on derived num_enum conversions instead of a handwritten decoder, while preserving the existing from_u8 API and the “unknown => Exponential” behavior.
Changes:
- Derive
num_enum::FromPrimitiveandnum_enum::IntoPrimitiveforCursorAnimStyleand markExponentialas the default fallback. - Re-implement
CursorAnimStyle::from_u8by delegating to the derivedFrom<u8>conversion. - Expand tests to validate round-trip conversions for known discriminants and fallback behavior for all unknown bytes.
| File | Description |
|---|---|
| crates/neomacs-display-protocol/src/types.rs | Adds derived numeric conversions and default fallback; simplifies from_u8 implementation. |
| crates/neomacs-display-protocol/src/types/tests/types_test.rs | Updates tests to cover derived conversions and exhaustive unknown-byte fallback behavior. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fn test_cursor_anim_style_unknown_defaults_to_exponential() { | ||
| assert_eq!(CursorAnimStyle::from_u8(8), CursorAnimStyle::Exponential); | ||
| assert_eq!(CursorAnimStyle::from_u8(255), CursorAnimStyle::Exponential); | ||
| for raw in 8..=u8::MAX { |

CursorAnimStyle::from_u8duplicated the enum’s numeric discriminants in a handwritten decoder. Derivenum_enum::FromPrimitiveandIntoPrimitiveso the enum declaration defines both conversions.Keep the existing
from_u8API and numeric values. MarkExponentialas the numeric fallback, preserving behavior for unknown bytes. Existing serde names and strum variant names remain unchanged. Reuse the existing protocol crate dependency.Validation: all 851 protocol library tests pass. Conversion tests cover all eight known discriminants in both directions and every unknown byte from 8 through 255. Formatting and diff checks pass; tests remain in
types/tests/types_test.rs.