Skip to content

v0.0.4: fix config save silently dropped on real watches - #5

Merged
eldios merged 2 commits into
watchfacefrom
fix/v0.0.4-config-decode
Jun 14, 2026
Merged

v0.0.4: fix config save silently dropped on real watches#5
eldios merged 2 commits into
watchfacefrom
fix/v0.0.4-config-decode

Conversation

@eldios

@eldios eldios commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

The actual fix for settings not saving on a real watch (0.0.2/0.0.3 never resolved it — wrong diagnosis).

Root cause. webviewclosed always ran decodeURIComponent(e.response), but the phone app hands e.response back already decoded. As soon as the payload contained a literal % — which the default strftime_format "%Y-%m-%d" always does — decodeURIComponent threw URIError: URI malformed, the surrounding catch swallowed it, and the entire save was silently dropped (nothing applied, nothing even written to localStorage). This is exactly why settings worked before and died right after the 0.0.2 WYSIWYG change: WYSIWYG started sending strftime_format on every save, so the % was always present. 0.0.3's payload-size change reduced the close URL but did not touch the real fault.

Fix. Decode like Clay (the reference Pebble config framework): only decodeURIComponent when the response is still percent-encoded — raw.match(/^\{/) ? raw : decodeURIComponent(raw). An encoded payload starts with %7B, an already-decoded one with {. Also serve the config page as charset=utf-8 (as Clay does) so accented translation strings survive.

The nice custom config page is unchanged — only the decode path is fixed.

Test plan

  • Reproduced the failure: with e.response delivered decoded (containing %Y-%m-%d), JSON.parse(decodeURIComponent(...)) throws URIError: URI malformed → caught → nothing saved. The Clay-style decode parses it correctly.
  • Verified in the compiled bundle (build/pebble-js-app.js, mocked Pebble runtime) for both delivery modes: decoded (real-watch case — previously broken, now 34 keys delivered) and URL-encoded (emulator case — still works). strftime_format survives in both.
  • Host suite 18/18; pebble build on basalt/diorite/emery/flint; strict-check clean under cloud -Werror.
  • Needs a physical-watch confirmation: install, open settings, change something, Save — it should now apply and persist.

eldios added 2 commits June 14, 2026 14:46
webviewclosed always ran decodeURIComponent on e.response, but the phone app
hands it back already decoded. The moment the payload held a literal % — which
the default strftime_format "%Y-%m-%d" always does — decodeURIComponent threw
"URI malformed", the catch swallowed it, and the whole save was silently
dropped. This is why settings died after the 0.0.2 WYSIWYG change started
sending strftime_format on every save.

Decode like Clay: only decodeURIComponent when the response is still
percent-encoded (an encoded payload starts with %7B, a decoded one with {).
Verified against both delivery modes in the compiled bundle. Also serve the
config page as charset=utf-8 (as Clay does) so accented translations survive.
App version to 0.0.4 (package.json, splash, README, CHANGELOG, PUBLISHING).
CONFIG_VERSION unchanged (3.0): the save wire format is the same as 0.0.3.
@eldios eldios self-assigned this Jun 14, 2026
@eldios
eldios merged commit 2991105 into watchface Jun 14, 2026
2 checks passed
@eldios
eldios deleted the fix/v0.0.4-config-decode branch June 14, 2026 12:47
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.

1 participant