feat(state): macro data model + persistence (macros.json)#174
Conversation
First leaf of the macros epic (#170). Adds `src/state/macros.rs` defining `Step`, `Macro`, and `MacroStore` with CRUD + JSON persistence, mirroring the established one-file-per-collection pattern of `slots.rs`/`sound_meta.rs` (`ProjectDirs` + serde + `ConfigError`, default-empty on missing/corrupt file). - Reuses the `EffectSettings` type that #164 merged (single definition; the issue body predated #164 and proposed a new one) — a step's effect chain is `crate::audio::effects::EffectSettings`, defaulting to fully bypassed. - Sound identity is `PathBuf`, matching `SlotMap` (slots reference macros by id in #169). - Stable, unique ids without a new crate: hex of a std `DefaultHasher` over name + wall-clock nanos, with a salt that retries on the rare same-instant collision (`DefaultHasher` already used by `state::library`). - `gain` clamps to [0.0, 2.0] on every setter (`Step::with_gain`, `replace_steps`); new/optional fields use `#[serde(default)]` for forward compatibility. State only — no playback/scheduling (#166), no UI (#168). TDD: round-trip save/load (incl. effects + gain), gain clamp, CRUD + unknown-id no-ops, missing/corrupt-file fallback, forward-compat default fields. 10 new tests; full suite 528 pass, clippy -D warnings clean. Closes #165. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 38 minutes and 27 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ 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 |
Why
The macros epic (#170) needs a persisted, serializable model before playback (#166), recording (#167), the timeline editor (#168), or slot assignment (#169) can be built. This is the foundational, dependency-free leaf.
What
New
src/state/macros.rs(Step,Macro,MacroStore) with CRUD + JSON persistence, mirroringslots.rs/sound_meta.rsexactly (ProjectDirs+ serde +ConfigError; default-empty on missing/corrupt file).EffectSettingsfrom feat(audio): polyphonic playback + per-voice effects + overlap mode #164 — the issue body predated feat(audio): polyphonic playback + per-voice effects + overlap mode #164 and proposed a new type; per its own "single definition" note, a step's effects arecrate::audio::effects::EffectSettings, defaulting to bypassed.PathBuf(matchesSlotMap; feat(state,ui): assign macros to slots #169 references macros by id).DefaultHasherover name + nanos, salted to avoid same-instant collisions (DefaultHasheralready used bystate::library).gainclamps to[0.0, 2.0]on every setter; new fields use#[serde(default)]for forward-compat.State only — no audio/UI.
Testing
gainclamps (RED-verified)cargo clippy --all-targets --all-features -- -D warningsclean; fmt clean; 528 tests pass🤖 Co-authored by Claude Opus 4.8. Closes #165.