[PR #132] [MERGED] fix: include lizard map in backup and guard pre-lizard-mode restore #217

Closed
opened 2026-10-22 05:07:45 +00:00 by roman · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/safijari/openpuck/pull/132
Author: @Copilot
Created: 7/5/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @safijari

Base: main ← Head: copilot/fix-restoring-config-failure


📝 Commits (3)

  • 6901c7b fix: guard c.types in backup import and include lizard map in export
  • 57921dc fix: clarify c.types guard comment in importBackup
  • 7a981b9 Progress bar for config import

📊 Changes

1 file changed (+60 additions, -13 deletions)

View changed files

📝 docs/index.html (+60 -13)

📄 Description

Two bugs in the WebUSB backup/restore path caused restoring a pre-lizard-map backup to either crash mid-import or silently drop the lizard binding map.

Bugs fixed

TypeError crash on old backups
importBackup accessed c.types.length unconditionally. Backups predating per-type config don't have a types field → TypeError mid-flight, after partially replaying settings but before committing bonds or mode.

Lizard map silently dropped on backup/restore
The backup format never serialised g_lizardMap. A puck with a custom lizard key/mouse map exported and reimported would silently revert to factory defaults.

Changes

  • importBackup: Wrap c.types loop in Array.isArray(c.types); old backups without the field now log a diagnostic and continue cleanly to bonds/commit.

  • buildBackup: Include lizardMap in the exported config when the puck is v16+ and the map is fully loaded. !lizardBusy guards against the lazy-load race (empty lizardBindings would clear bindings on import).

  • importBackup — lizard restore: After settings replay, if c.lizardMap is present and the target firmware is v16+, replay it via the existing 0x13 / 0x12×N / 0x14 sequence, then drain the 0xAA echo before bond writes.

  • Backup version: Bumped to 2 when a lizard map is included; stays 1 otherwise. All restore branches gate on field presence, not version, so all prior backup versions import cleanly.

Compatibility matrix

Backup Target firmware Result
v1 — no types, no lizardMap v16+ ✅ imports, both fields skipped
v1 — has types, no lizardMap v16+ ✅ imports, lizard skipped
v2 — has types + lizardMap v16+ ✅ full restore
v2 — has types + lizardMap pre-v16 ✅ imports, lizard skipped (lizardCapable() false)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/safijari/openpuck/pull/132 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 7/5/2026 **Status:** ✅ Merged **Merged:** 7/5/2026 **Merged by:** [@safijari](https://github.com/safijari) **Base:** `main` ← **Head:** `copilot/fix-restoring-config-failure` --- ### 📝 Commits (3) - [`6901c7b`](https://github.com/safijari/openpuck/commit/6901c7b1351f1618816a3bf1d90b49caa84ce32a) fix: guard c.types in backup import and include lizard map in export - [`57921dc`](https://github.com/safijari/openpuck/commit/57921dc338a4bea1c2e9355ee26ed852a1c97eb1) fix: clarify c.types guard comment in importBackup - [`7a981b9`](https://github.com/safijari/openpuck/commit/7a981b9cebcce96cea7e8ce7c69c1b1c9d6e154d) Progress bar for config import ### 📊 Changes **1 file changed** (+60 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/index.html` (+60 -13) </details> ### 📄 Description Two bugs in the WebUSB backup/restore path caused restoring a pre-lizard-map backup to either crash mid-import or silently drop the lizard binding map. ## Bugs fixed **TypeError crash on old backups** `importBackup` accessed `c.types.length` unconditionally. Backups predating per-type config don't have a `types` field → `TypeError` mid-flight, after partially replaying settings but before committing bonds or mode. **Lizard map silently dropped on backup/restore** The backup format never serialised `g_lizardMap`. A puck with a custom lizard key/mouse map exported and reimported would silently revert to factory defaults. ## Changes - **`importBackup`**: Wrap `c.types` loop in `Array.isArray(c.types)`; old backups without the field now log a diagnostic and continue cleanly to bonds/commit. - **`buildBackup`**: Include `lizardMap` in the exported config when the puck is v16+ and the map is fully loaded. `!lizardBusy` guards against the lazy-load race (empty `lizardBindings` would clear bindings on import). - **`importBackup` — lizard restore**: After settings replay, if `c.lizardMap` is present and the target firmware is v16+, replay it via the existing `0x13 / 0x12×N / 0x14` sequence, then drain the `0xAA` echo before bond writes. - **Backup version**: Bumped to `2` when a lizard map is included; stays `1` otherwise. All restore branches gate on field presence, not version, so all prior backup versions import cleanly. ## Compatibility matrix | Backup | Target firmware | Result | |---|---|---| | v1 — no `types`, no `lizardMap` | v16+ | ✅ imports, both fields skipped | | v1 — has `types`, no `lizardMap` | v16+ | ✅ imports, lizard skipped | | v2 — has `types` + `lizardMap` | v16+ | ✅ full restore | | v2 — has `types` + `lizardMap` | pre-v16 | ✅ imports, lizard skipped (`lizardCapable()` false) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
roman 2026-10-22 05:07:45 +00:00
Sign in to join this conversation.
No labels
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
safijari/openpuck#217
No description provided.