Skip to content

fix(mochi): draw Lottie through core's fenced player - #11172

Merged
iamwhatever merged 2 commits into
mainfrom
fix/mochi-lottie-fence-10249
Sep 16, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
fix/mochi-lottie-fence-10249

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What

Mochi's vendored website/src/apps/mochi/src/renderer/LottieRenderer.tsx is now a one-line re-export of core's fenced player, website/src/components/appearancePacks/LottieRenderer.tsx — the same shape as the vendored SpriteRenderer shim. git grep loadAnimation website/src now finds one production call site: the core renderer.

A new structural test, website/src/test/lottiePlayerBoundary.test.ts, pins the convention the Design Review on #10108 asked for: the core renderer is the only production module under src/ that value-imports lottie-web, and what it imports is the light build. It replaces mochiLottieLightPlayer.test.ts, whose scan covered src/apps only.

Why

PR #10108 moved Crew Companion's Lottie player into core and fenced it: referencesRemoteAsset refuses a clip that names a remote image or font before loadAnimation, because lottie-web resolves those by requesting them from the dashboard's own authenticated origin. Mochi's copy of the player had the light import but not the fence, so it was the one loadAnimation in the tree an attacker-authored clip could reach unrefused. Mochi renders bundled presets today, so nothing crossed that gap yet — but the moment Mochi accepts an imported pack it would have, and the fence has to already be standing. One player means one fence to keep.

How

  • apps/mochi/src/renderer/LottieRenderer.tsx: 266 lines → one export { LottieRenderer } from '../../../../components/appearancePacks/LottieRenderer'. PetWidget.tsx and GalleryPanel.tsx keep importing ./LottieRenderer byte-identical to upstream, as the vendoring rule requires (apps/mochi/README.md, updated to name both shims). Neither caller passes onReady/onError, so core's effect-dependency contract on those callbacks costs Mochi nothing.
  • apps/mochi/test/mochiLottieRenderer.test.tsx: rewritten to read the component through Mochi's import path and hold it to the fence — a remote image and a remote font are each refused with no loadAnimation call; a clean clip still loads renderer: 'svg', loop: true, autoplay: true (what Mochi's callers rely on); the shim resolves to the very same function core exports; and each of the four shipped ghost presets clears the two checks core adds that the old copy never ran (isValidLottie shape, referencesRemoteAsset), so the switch cannot have blanked the built-in ghost.
  • test/lottiePlayerBoundary.test.ts: scans every production .ts/.tsx under src/ (tests exempt, import type … from 'lottie-web' exempt), asserts the only value importer is the core renderer, that its only lottie specifier is lottie-web/build/player/lottie_light, and a non-vacuity floor (>100 files scanned, the renderer among them).
  • docs/system-specs/modules/learn-cron-dashboard.md: the appearance-library paragraph now names both shims and the new boundary test.
  • components/appearancePacks/LottieRenderer.tsx (second commit): carries over the one behaviour Mochi's copy had that core lacked — container.replaceChildren() before building. destroy() removes only what the instance knows about; one torn down before its SVG finished building (React's development double-mount gives every clip a load/destroy/load cycle) can leave an orphan node, and the next build then draws beside stale children. Pinned by a new test that records the container's child count at each loadAnimation call across a clip swap after a "leaked" node ([0, 0]); red with the guard removed. Flagged by the First Principles lane on the first head — the first body's "diagnostics only" dropped-list was wrong about this hunk.
  • test/MochiPetWidget.coverage.test.tsx (second commit): the parse-failure pin now expects core's [appearance-pack] lottie JSON parse failed breadcrumb — the one test outside the Mochi Lottie suite that read the old [mochi] prefix (Frontend Tests (4) on the first head).

Dropped with the copy: Mochi's stripExpressions / countEffects console warnings and its "loaded but painted nothing" breadcrumb. These were diagnostics, not behaviour — the light player ships no expression machinery (grep -c initiateExpression lottie_light.js → 0), so a string x is ignored whether or not it is deleted first, and mochiLottieAssets.test.ts continues to pin that the shipped clips carry no expressions and no effects. Core's own parse/shape/fence refusals log under [appearance-pack]. Also new for Mochi clips: core's isValidLottie shape check runs before the fence; all four shipped presets pass it (pinned).

Tests

Run by path from website/:

npx vitest run src/apps/mochi/test/mochiLottieRenderer.test.tsx src/test/lottiePlayerBoundary.test.ts \
  src/test/appearancePacksCoreBoundary.test.ts src/components/appearancePacks/LottieRenderer.test.tsx \
  src/test/GalleryPanelCoverage.test.tsx src/test/MochiPetWidget.coverage.test.tsx \
  src/test/PackAvatar.test.tsx src/test/CrewAvatarPackRecovery.test.tsx
→ all pass (88 + 95 across the two runs)

Red on base / mutation-verified:

  • Restoring the base Mochi copy in place of the shim: 4 tests red (is core's player, both remote-asset refusals, boundary no production module outside the core renderer).
  • Disabling referencesRemoteAsset in core: both Mochi refusal tests red.
  • Switching core's import to the bare lottie-web: boundary imports the light player, and only the light player red.
  • Removing replaceChildren() from core: hands the player an empty container… red.

tsc --noEmit and eslint on the changed files: clean.

Other

No user-visible UI change: the shipped presets pass the fence and render through the same light player with the same options, so no-screenshots applies.

iamwhatever is co-assigned on the issue as the deferred-finding author; no branch or PR of theirs covered it at preflight.

Pattern harvest

Rule candidate: lottiePlayerBoundary.test.ts
Pattern: when a sanitising wrapper moves into core, pin with a source-text scan that the wrapped dependency is value-imported by exactly one production module — a second importer is a second copy of the fence to keep.

Closes #10249

@CrysisDeu
CrysisDeu requested review from a team September 16, 2026 02:55
@CrysisDeu CrysisDeu added the no-screenshots PR has no visual delta; screenshot gate exempt label Sep 16, 2026
@CrysisDeu
CrysisDeu requested a review from Zedmor September 16, 2026 02:55
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of 97db9196b60072204445da5a54d0139730d0b252 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Verify the four shipped ghost presets still animate in a live dashboard — the swap's only pixel risk, pinned by tests but never eyeballed.

The diff adds or changes no user-visible control, string, or state: Mochi's vendored renderer becomes a re-export of core's player with identical output options (svg, loop, autoplay) for every clip Mochi ships, the dropped warnings were console-only, and the replaceChildren() guard removes a stale-node artifact rather than adding one. With no user-visible surface changed, the absent screenshots and blind read are not evidence gaps, per the refactor carve-out.

[UX-REVIEWED] 97db919

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 97db9196b60072204445da5a54d0139730d0b252 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the four ghost presets still draw in a live Mochi widget — every test mocks loadAnimation, so parity is pinned at the fence, not the pixels.

Suggestions

  • Mochi's most-used diagnostic — the "lottie loaded but painted nothing" DOM check on DOMLoaded — was dropped rather than moved; it is renderer-generic and cheap, so consider carrying it into core's player the way the container guard was.
  • When Mochi gains pack import (the future mochi: its LottieRenderer is the only loadAnimation call site without the remote-asset fence #10249 cites), its call sites pass no onError, so a refused clip is a silent empty pet; note that wiring as part of that follow-up.

[DESIGN-REVIEWED] 97db919

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 97db9196b60072204445da5a54d0139730d0b252 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

One residual to weigh: the "loaded but painted nothing" DOM-outcome breadcrumb has no core equivalent, so a Mochi clip that loads yet draws blank is silent again.

Every other dropped Mochi diagnostic is evidenced in the description (light player ships no expression machinery; mochiLottieAssets.test.ts still pins shipped clips expression- and effect-free), and keeping any of them meant keeping the copy the fix exists to delete. Verified in the tree: referencesRemoteAsset and isValidLottie run before loadAnimation in core; the shim has exactly 2 consumers (PetWidget.tsx:35, GalleryPanel.tsx:20, neither passing onReady/onError); grep for production loadAnimation finds one call site, the core renderer; the deleted mochiLottieLightPlayer.test.ts pins are strictly subsumed by the new tree-wide scan.

Inventory (9 items) — 9 justified

Intent: close #10249 — the one loadAnimation an attacker-authored clip could reach unfenced — by making Mochi draw through core's fenced player. FIX.

  1. Mochi clips naming a remote image or font are now refused before loading — justified
  2. Mochi clips now pass core's isValidLottie shape check first — justified
  3. Mochi's expression-strip warn, effect warn and "painted nothing" breadcrumb dropped — justified
  4. Parse-failure console prefix changes [mochi] → [appearance-pack] — justified
  5. Core's player empties its container before every build (all pack avatars) — justified
  6. Tree-wide lottiePlayerBoundary.test.ts replaces the src/apps-only scan — justified
  7. Mochi README and spec paragraph name both re-export shims — justified
  8. Mochi renderer tests rewritten to hold the shim to the fence — justified
  9. MochiPetWidget.coverage pin retargeted to core's breadcrumb — justified

[FIRST-PRINCIPLES-REVIEWED] 97db919

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 97db9196b60072204445da5a54d0139730d0b252 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 97db919

Verdict parsed from the review's SHA-scoped output markers for commit 97db9196b60072204445da5a54d0139730d0b252.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 97db9196b60072204445da5a54d0139730d0b252: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 97db9196b60072204445da5a54d0139730d0b252 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 97db919

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 97db9196b60072204445da5a54d0139730d0b252: <one-sentence reason>

Mochi's vendored `LottieRenderer.tsx` was the one `loadAnimation` call
site in the tree without the remote-asset fence: a clip naming a remote
image or font went straight to the player, which resolves those by
requesting them from the dashboard's own authenticated origin. Mochi
draws bundled presets today, so nothing crossed that gap yet, but a
Mochi that accepts an imported pack would have.

The file is now a one-line re-export of
`components/appearancePacks/LottieRenderer.tsx`, the same shape as the
vendored `SpriteRenderer` shim, so the other vendored files' import path
stays byte-identical to upstream. One player, one fence.

`lottiePlayerBoundary.test.ts` pins the convention the Design Review on
#10108 asked for: the core renderer is the only production module that
value-imports `lottie-web`, and it imports the light build. It replaces
`mochiLottieLightPlayer.test.ts`, whose scope was `src/apps` only. The
Mochi renderer pins now read the component through Mochi's own import
path and hold it to the fence, and show every shipped ghost preset still
clears the two checks core adds (document shape, asset references).

Closes #10249
…the Mochi parse pin

Mochi's copy of the player emptied its container before every build:
`destroy()` removes only what the instance knows about, and one torn down
before its SVG finished building (React's development double-mount gives
every clip a load/destroy/load cycle) can leave an orphan node the next
build then draws beside. Core's player had no equivalent, so the move in
the previous commit would have dropped a behaviour, not a diagnostic.
The guard now lives in core, pinned by a test that records the
container's child count at each `loadAnimation` across a clip swap.

`MochiPetWidget.coverage.test.tsx` read the old `[mochi]` parse
breadcrumb; it now expects core's.
@CrysisDeu
CrysisDeu force-pushed the fix/mochi-lottie-fence-10249 branch from cd9cbbb to 97db919 Compare September 16, 2026 03:13
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after a full read of the diff on the current head: the change matches the linked issue and body, every load-bearing claim was spot-checked against main, tests pin the behaviour, all review lanes are clean and nothing is left undisposed on this head.

@iamwhatever
iamwhatever merged commit 0f6bbff into main Sep 16, 2026
116 of 117 checks passed
@iamwhatever
iamwhatever deleted the fix/mochi-lottie-fence-10249 branch September 16, 2026 05:22
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 16, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
* fix(mochi): draw Lottie through core's fenced player

Mochi's vendored `LottieRenderer.tsx` was the one `loadAnimation` call
site in the tree without the remote-asset fence: a clip naming a remote
image or font went straight to the player, which resolves those by
requesting them from the dashboard's own authenticated origin. Mochi
draws bundled presets today, so nothing crossed that gap yet, but a
Mochi that accepts an imported pack would have.

The file is now a one-line re-export of
`components/appearancePacks/LottieRenderer.tsx`, the same shape as the
vendored `SpriteRenderer` shim, so the other vendored files' import path
stays byte-identical to upstream. One player, one fence.

`lottiePlayerBoundary.test.ts` pins the convention the Design Review on
kirodotdev#10108 asked for: the core renderer is the only production module that
value-imports `lottie-web`, and it imports the light build. It replaces
`mochiLottieLightPlayer.test.ts`, whose scope was `src/apps` only. The
Mochi renderer pins now read the component through Mochi's own import
path and hold it to the fence, and show every shipped ghost preset still
clears the two checks core adds (document shape, asset references).

Closes kirodotdev#10249

* fix(appearance-packs): empty the container before building; retarget the Mochi parse pin

Mochi's copy of the player emptied its container before every build:
`destroy()` removes only what the instance knows about, and one torn down
before its SVG finished building (React's development double-mount gives
every clip a load/destroy/load cycle) can leave an orphan node the next
build then draws beside. Core's player had no equivalent, so the move in
the previous commit would have dropped a behaviour, not a diagnostic.
The guard now lives in core, pinned by a test that records the
container's child count at each `loadAnimation` across a clip swap.

`MochiPetWidget.coverage.test.tsx` read the old `[mochi]` parse
breadcrumb; it now expects core's.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-screenshots PR has no visual delta; screenshot gate exempt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mochi: its LottieRenderer is the only loadAnimation call site without the remote-asset fence

2 participants