Repository navigation
Add verified HX Stomp .hlx import and fix snapshot metadata - #36
Conversation
john-baxter-dev
left a comment
There was a problem hiding this comment.
Thanks for this — the preview/acknowledge/verify-before-save flow is exactly the right shape, and the 10 → 8 / 10 → 6 finding is a real catch.
A few things before merge, mostly around the failure paths:
Needs a change
- A failed import leaves the pedal on the destination slot while the GUI still shows the old preset (inline on
hlx.rsandApp.svelte). A Save after that writes into the wrong slot. - Only a readback mismatch reverts; a
set_snapshotor readback I/O error afterwrite_presetleaves the unverified document in the edit buffer. - The
10 → 8rewrite and the10 → 6read apply to every device, not just the Stomp — this changes.hxbconversion and offline snapshot display for Floor/LT/XL/POD Go. Could you either gate both on P33, or show they hold on another device (e.g. the XL fixtures)?
Questions
4. set_snapshot runs before the readback. Does a snapshot switch reload live values from that snapshot's stored scene? If so, a file whose live values differ from its current snapshot would always fail verification. You've tested on hardware, so you may already know.
5. restore_hlx re-reads the donor at confirm time rather than reusing the previewed one. If the pedal changes preset while the dialog is open, the import uses different routing than the one the user reviewed. Intentional?
Small things — happy to tidy these on merge if you'd rather not
validate_tone_parametersalso walksdsp1, which the Stomp never converts, so leftover split/join nodes there can refuse an otherwise fine file.- Preset name length isn't checked in
parse, so an over-long name only fails at the save, after the buffer write. validate_destination.expects on a hard-coded0x4246;PID_HX_STOMPand anError::Invalidwould be safer.- The protocol finding should land in
STATUS.mdwith a[solid]tag (thestream.rsdoc comment has the date but no tag).
| if session.device().model_code != Some("P33") { | ||
| return Err(Error::Invalid(".hlx restore requires an HX Stomp".into())); | ||
| } | ||
| session.goto_preset(bank, slot)?; |
There was a problem hiding this comment.
Every ? after this returns with the pedal moved to slot. Combined with the GUI keeping the old preset on error (see App.svelte), a following Save sends save_preset for the old slot index with this slot's buffer. Could the error path re-read the live preset (or the GUI call read_preset in its catch)? clear_history() also only runs on success, so undo would replay the old slot's history here.
| // Open the freshly selected edit buffer before the chunked write. | ||
| session.read_preset_raw()?; | ||
| let expected = PresetStream::parse(&self.raw)?; | ||
| session.write_preset(expected.to_blob())?; |
There was a problem hiding this comment.
From here on, any error (not only the verify_readback mismatch) should best-effort revert_preset(). Today a timeout in set_snapshot or the second read_preset_raw leaves the converted, unverified document live in the edit buffer, where the next save commits it.
| // A whole-document write resets the live selection. Restore the file's | ||
| // snapshot before saving, so save commits its live controller values | ||
| // into the matching scene. | ||
| session.set_snapshot(self.active_snapshot)?; |
There was a problem hiding this comment.
Question: does switching snapshots here reload block parameters/bypass from the stored scene? If so, expected (the file's live values) and actual would diverge whenever an export's live values weren't re-stored into its current snapshot, and verification would refuse a valid file. Verifying before the switch, or building expected live values from the selected snapshot, would avoid that.
| pub fn validate_destination(bank: i64, slot: i64) -> Result<()> { | ||
| let size = fretwire_protocol::Device::by_pid(0x4246) | ||
| .and_then(|d| d.setlist_size) | ||
| .expect("known HX Stomp setlist size") as i64; |
There was a problem hiding this comment.
Nit: fretwire_protocol::PID_HX_STOMP rather than the literal, and an Error::Invalid instead of .expect, so a device-table change can't panic the command layer (HTTP/MCP included).
| await refreshPresets(); | ||
| status = `Imported ${preset.name} to slot ${slot}.`; | ||
| } catch (e) { | ||
| if (hlxDlg) hlxDlg = { ...hlxDlg, error: String(e) }; |
There was a problem hiding this comment.
On failure the backend may already have moved the pedal to the destination slot, but preset still shows the old one. Refreshing preset here (and refreshPresets()) would keep the GUI and the pedal in step.
| let Some(group) = map_get_mut(&mut donor.preset, 10) else { | ||
| return; | ||
| }; | ||
| set_map_key(group, 8, Value::from(placed.len() as i64)); |
There was a problem hiding this comment.
apply_tone is shared with the .hxb conversion for every device, so this now rewrites 10 → 8 for Floor/LT/XL/POD Go too, and the omission note about it is gone for all of them. The controller-count reading was observed on a Stomp; could this be gated on P33 until it's seen elsewhere? Also, placed.len() includes controllers with place >= len2, which get no key-2 row below. Should the count only include placed rows?
| pub fn snapshots(&self) -> (Option<i64>, Vec<String>) { | ||
| let root = self.field(10); | ||
| let active = root.and_then(|m| map_get(m, 8)).and_then(Value::as_i64); | ||
| let active = root.and_then(|m| map_get(m, 6)).and_then(Value::as_i64); |
There was a problem hiding this comment.
Same scope question: this changes active_snapshot in offline views (load_preset, preset-show, backup-show) for every device. Does 10 → 6 hold on the XL fixtures? If not checked, gating on P33 (or falling back) would be safer.
| let source = fretwire_core::hlx::HlxPreset::parse(&json).map_err(|e| e.to_string())?; | ||
| fretwire_core::hlx::validate_destination(bank, slot).map_err(|e| e.to_string())?; | ||
| run(state, move |s| { | ||
| let prepared = prepare_hlx(s, &source)?; |
There was a problem hiding this comment.
This converts against whatever preset is loaded at confirm time, not the one used for the preview. If the pedal changes preset while the dialog is open, the user approved a report for a different donor. Reusing the prepared result from the preview, or refusing if the donor changed, would close that gap.
| /// `.hlx` import uses this before applying an untrusted file to a device-authored donor. | ||
| /// Loopers intentionally store only a subset of their symbol's live transport parameters. | ||
| pub fn validate_tone_parameters(tone: &JsonMap<String, Json>, syms: &DeviceSymbols) -> Result<()> { | ||
| for (dsp_name, dsp) in tone.iter().filter(|(k, _)| k.starts_with("dsp")) { |
There was a problem hiding this comment.
Nit: for the Stomp import only dsp0 is converted, but this also requires full parameter sets on dsp1's split/join, so leftover nodes there can refuse an otherwise valid file.
|
Thanks for the thorough follow-up. Every point from the last review is covered!
One small thing, not blocking: Where does the 32-byte name limit come from? If it's measured on the Stomp, a line in docs/protocol.md next to the save op would help; if it's a guess, a [hypothesis] note. I don't have .hlx files here to try an import on my own Stomp, so your hardware run is the evidence for that path. If anyone reports a problem after merge I'll loop you in. |
|
Thanks for the review and for merging this! The 32 UTF‑8 byte cap is a validation rule in the importer. Fretwire’s Save As and Rename dialogs already use maxlength="32", which counts UTF‑16 code units. My Stomp tests used shorter names for the import/save/reload checks, so the actual firmware limit is still unknown. I’ll add a hypothesis note next to op 71 in docs/protocol.md. Happy to help reproduce anything that comes up on a Stomp. |
HX Stomp users currently have to convert an HX Edit
.hlxmanually before restoring it. This adds Import .hlx preset… to the existing preset menu, with a read-only conversion preview, an explicit destination, acknowledgement of omissions, and read-back verification before the slot is saved. Preview and Cancel make no device writes.The converter accepts Stomp/P33 files with serial
Aor parallelSABJrouting. It refuses foreign devices, invalid block placement, incomplete split/join nodes, unknown models and missing stored parameters. Undecoded settings, including Stomp input/output routing, come from the currently loaded donor; the dialog explains this before import. IR audio and cross-device adaptation are outside this change.Hardware testing also exposed a snapshot conversion bug:
10/8counts controller places, while10/6carries snapshot selection. Rebuilding the count makes imported snapshot parameter values recall correctly; selection is carried separately. The importer verifies the decoded edit buffer before saving, allowing map reordering and the two automatic display fields of bypass bindings while still comparing custom labels, colours, controller tables and DSP routing.Offline conversion is available as
fretwire hlx-convert preset.hlx --donor stomp-donor.bin --out imported.json, using the existing export format. No dependencies or USB protocol builders are added; the existing visual style is retained.Validation:
Related to the direct
.hlxworkflow described in #33; this does not close that Floor destination issue.