Skip to content

Installer: accept a widget icon trailer, strip it for stubs before 10 - #117

Draft
freethinkel wants to merge 1 commit into
mainfrom
widget-icon-trailer
Draft

freethinkel wants to merge 1 commit into
mainfrom
widget-icon-trailer

Conversation

@freethinkel

@freethinkel freethinkel commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

Watch apps (.wp2app) can now carry their widget icons in a trailer after the relocation table. The spec is cmf-watch-sdk docs/app-icons.md "Widget icons", from the widget-templates branch (cmf-watch-sdk PR #23, still a draft). Until now planInstall refused such a package as "truncated or padded". The first package with icons will be Weather 0.2.0.

  • planInstall (device/lib/wp2.ts) accepts a well-formed trailer: WP2W, version 1, count 1..16, size 40, a zero pad byte, length 12 + count·4800, and the CRC32 of the pixels. A broken trailer is refused as "broken widget icon trailer", and that message is translated in all five locales in device/messages.ts.
  • A package without a trailer must still have its exact size. A shorter file is still "truncated or padded". The body CRC now covers only the image and the relocations, which matches what the header declares.
  • planInstall returns body, the bytes to send. From stub 10 on that is the whole package. A stub before 10 gets the package cut at the relocations, which is the same bytes as package.strip_trailer. Watch.installPackage sends body, and BEGIN carries its size and CRC. The stub version comes from the readWp2 state that the installer already receives.
  • Other places that read a package, checked and left unchanged: the store's fetchLoaderHeadersFx / app header fetch and the dev panel's sniff only read the 64-byte header. Nothing displays a package size, and there is no upload path.

Fixtures tests/__fixtures__/icons.wp2app (2 icons, 10 708 B) and icons-stripped.wp2app (1 096 B) were built with cmf-watch-sdk's package.pack at 7966ba2. The CLI's pack needs a linked ELF, so I called the same function the SDK's own tests call, and asserted strip_trailer(full) == plain.

Checks (local)

  • Failing test first: the 10 new wp2.browser.test.ts cases failed on truncated or padded before the change.
  • pnpm lint: passed (0 errors; the warnings are in files this PR doesn't touch).
  • pnpm format:check: passed.
  • pnpm check: passed, 0 errors, 0 warnings.
  • pnpm test (Playwright headless Chromium, as in CI): passed, 87 files, 492 passed, 1 skipped, 0 failed. An earlier full run had one failure in tree-panel-drag.browser.test.ts, an editor test this PR doesn't touch. It passed when run alone and in this rerun, so it is a flake under load.
  • pnpm build: passed.

Not run

  • Nothing on a real watch or phone: no install, no OTA, no BLE. A stub before 10 has not actually received a stripped package, and stub 10 has not received one whole.
  • No real Weather 0.2.0 package was used, only the SDK-built fixtures.

Merging

Merging to main deploys. There is no deploy job in CI: kuzyo polls main and deploys a commit once CI passes on it (deploy/autodeploy.sh). After this merges, the live store will accept and install packages with widget icons.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CQSU8MAPYkhktGkGdxdk2C

A .wp2app may carry its widget icons after the relocation table
(cmf-watch-sdk docs/app-icons.md, "Widget icons"). planInstall refused
such a package as "truncated or padded". It now checks the trailer
(magic, version, count 1..16, size 40, zero pad, length, CRC) and refuses
a broken one as "broken widget icon trailer", translated in every locale.
A package without a trailer still has to match its exact size, and the
body CRC now covers only image and relocations, as the header says.

Stubs before 10 refuse any byte past the relocations, so planInstall hands
back the body to send: the package whole for stub 10 and later, cut at the
relocations for an older stub. installPackage sends that body, and its
size and CRC go into BEGIN.

The fixtures are built by cmf-watch-sdk's package.pack (widget-templates):
an app with 2 icons, and the same app packed without them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQSU8MAPYkhktGkGdxdk2C
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