Skip to content

Add verified HX Stomp .hlx import and fix snapshot metadata - #36

Merged
john-baxter-dev merged 2 commits into
john-baxter-dev:masterfrom
Potato83:feat/hlx-import
Nov 22, 2026
Merged

john-baxter-dev merged 2 commits into
john-baxter-dev:masterfrom
Potato83:feat/hlx-import

Conversation

@Potato83

Copy link
Copy Markdown
Contributor

HX Stomp users currently have to convert an HX Edit .hlx manually 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 A or parallel SABJ routing. 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/8 counts controller places, while 10/6 carries 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:

  • 11 synthetic core integration tests cover conversion, routing guards, parameter completeness, source selection, controller counts and semantic read-back. Dispatch and frontend mock regressions cover refusal and explicit destination handling.
  • All 422 tests in the default offline Rust suites passed, as did the frontend tests, production frontend build, CLI build and desktop GUI build. Four existing update-probe tests requiring local sockets are excluded in this sandbox; their code is unchanged.
  • Hardware: HX Stomp, firmware approximately 3.80 as reported by the owner. An amp, amp+cab, three named snapshots, snapshot bypass and Drive recall, custom footswitch label/colour, and a file selecting snapshot 3 passed import/save/reload through the command layer.
  • Hardware preview and rejected requests preserved the loaded buffer. Writes were restricted to 04A; its pre-test loaded state was restored afterward. Stored 01A–03C and 04B–04C matched their original backups. Private preset data and hardware captures are not included.
  • Audio equivalence, other models/routing combinations and other devices have not been verified. This remains a partial conversion with explicit omissions.

Related to the direct .hlx workflow described in #33; this does not close that Floor destination issue.

@john-baxter-dev john-baxter-dev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. A failed import leaves the pedal on the destination slot while the GUI still shows the old preset (inline on hlx.rs and App.svelte). A Save after that writes into the wrong slot.
  2. Only a readback mismatch reverts; a set_snapshot or readback I/O error after write_preset leaves the unverified document in the edit buffer.
  3. The 10 → 8 rewrite and the 10 → 6 read apply to every device, not just the Stomp — this changes .hxb conversion 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_parameters also walks dsp1, 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-coded 0x4246; PID_HX_STOMP and an Error::Invalid would be safer.
  • The protocol finding should land in STATUS.md with a [solid] tag (the stream.rs doc comment has the date but no tag).

Comment thread crates/fretwire-core/src/hlx.rs Outdated
if session.device().model_code != Some("P33") {
return Err(Error::Invalid(".hlx restore requires an HX Stomp".into()));
}
session.goto_preset(bank, slot)?;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/fretwire-core/src/hlx.rs Outdated
// 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())?;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/fretwire-core/src/hlx.rs Outdated
// 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)?;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/fretwire-core/src/hlx.rs Outdated
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;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) };

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/fretwire-data/src/tone.rs Outdated
let Some(group) = map_get_mut(&mut donor.preset, 10) else {
return;
};
set_map_key(group, 8, Value::from(placed.len() as i64));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread crates/fretwire-data/src/stream.rs Outdated
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);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/fretwire-commands/src/lib.rs Outdated
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)?;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/fretwire-data/src/tone.rs Outdated
/// `.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")) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@john-baxter-dev

Copy link
Copy Markdown
Owner

Thanks for the thorough follow-up. Every point from the last review is covered!

  • Any failure after selecting the destination now reloads that slot, Save is refused until a confirmed re-read, and history is cleared before the switch.
  • The document is verified before the snapshot switch, and the snapshot is confirmed from read-info rather than the blob.
  • Restore writes the exact cached preview, so the donor can't change under the user.
  • The 10 → 8 count and the 10 → 6 read are limited to P33, with the count limited to places that have rows, and the Stomp/XL fixture test pins both.
  • The nits and the docs are done.

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.

@john-baxter-dev
john-baxter-dev merged commit d3479dd into john-baxter-dev:master Nov 22, 2026
4 checks passed
@Potato83

Copy link
Copy Markdown
Contributor Author

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants