orchestrator: S058 Pie-style ad removal animation (user, port of the original)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-14 00:36:14 -06:00
commit fefc1be75d
4 changed files with 53 additions and 2 deletions

View file

@ -0,0 +1,50 @@
# S058 — Ads vanish before your eyes (Pie-style removal animation, port of the original)
> Category 08 WebKit engine · Model: Opus · Effort: medium · Depends on: S057 · Size: S · Human: no · **cargo** (main target/)
> Files touched: src/inject.rs (`COSMETIC_JS` → zap script), src/adblock.rs / src/actions.rs (options to the page: colours, badge, timing, pause), src/theme.rs (badge colours), src/ui/pages/settings.rs (row text), tests/smoke/*, tests/smoke/pages/*
## Goal
The user asked for this before and it got lost (user, 2026-11-14): ads you can see should go away **right before your
eyes**, like Pie Adblock: a cookie-shaped overlay with a shield and check mark covers the ad, squishes and spins away,
and the space closes up. The original Python Nacre had it (`adblock.animate`, default on: "removed ads squish away in a
Material animation (visible ones only)"); the Rust port kept only a 250 ms fade + scale (`src/inject.rs` `COSMETIC_JS`
`hide()`, setting row "Animate ad removal" in `settings.rs` ~826, `s.adblock.animate`).
Port the original, which is the spec: `~/Documents/Apps/Nacre/nacre/services.py` `ZAP_JS` (~430–495) and
`zap_badge()` (~345), options from `window.py` ~1378–1390. Read them, don't change them (reference only).
- Detection: cosmetic rules don't hide directly; they give matches a 1 ms `__nz_detect` animation and the page's own
`animationstart` hands over each element as it renders (no selector scanning). Check WebKit fires it (it should).
- Overlay: an absolutely placed div over the ad's rect, background = the cookie badge (90-point polygon with 9 lobes,
shield, check mark; SVG data URI in the theme's primary/onPrimary) centred at `min(64px,40%)` over primaryContainer
at 92 %; keyframes `__nz_ov`: fade in, scale .97 with growing corner radius, then .72 rotated −4°, then 0 rotated
−14° with a circular clip; the ad fades out under it; then the slot collapses (height/width/margin/padding → 0 over
340 ms) and gets `display:none`.
- Safety: never touch elements that are or contain `<video>`/`<audio>`; ad bits inside a known player are hidden
quietly; tiny (< 24 px) or huge (> 60 % of the viewport) or off-screen elements are hidden without animation; at most
12 animations at once; per-site pause / ad blocker off = nothing.
- Timing and motion: duration = 900 ms × Nacre's motion scale (min 0.3); Motion off or the setting off → plain hide.
This is a deliberate, rarely-repeated "delight" moment, so the long duration is intended (motion audit rules allow
it for rare moments); the collapse stays ease-out.
- Colours follow the current theme (site colour / accent), light and dark.
- The shield's blocked count keeps counting these (as today: `cosmetic_removed`).
## Read
- The original files above (sections named), `src/inject.rs` `COSMETIC_JS`, where the cosmetic options reach the page
(grep `__ANIMATE__`), the S049 PROGRESS entry (cosmetic-only engine on WebKit).
## Steps
- [ ] Port `ZAP_JS` detection + overlay + collapse into the cosmetic script (keep the class/id → selectors round trip), options (animate, ms, bg, badge, off) from the browser per page; badge SVG built in Rust from theme colours.
- [ ] Safety rules (players, sizes, off-screen, max 12, paused sites) and Motion off / setting off → plain hide.
- [ ] Test page `tests/smoke/pages/ads.html` (a few visible ad boxes matching local cosmetic rules, one inside a fake player, one tiny, one off-screen) + smoke: shots mid-animation (overlay + badge visible) and after (slots collapsed, layout closed), player untouched, Motion off = instant; dark and light.
- [ ] Visible run on a real ad-heavy page (e.g. a news site) on DP-1 (D-045): watch it, read the shots; note anything that flickers or jumps.
- [ ] PROGRESS entry, INDEX line, tracker, commit `S058: …`, push.
## End criteria
- The smoke shows the overlay with the cookie shield mid-animation and the closed layout after; player element intact.
## Pitfalls
- Don't animate layout-heavy pages into jank: the overlay animates transform/opacity/clip-path only; only the final collapse animates size (as the original).
- Never connect to Tor or proxies in tests.
## Handoff (→ PROGRESS.md)
What differs from the original, if anything.

View file

@ -10,6 +10,7 @@ Dropped with Servo (D-032): S011, S029, S030, S032, S033, S037, S038.
## 08 WebKit engine (in this order)
- [ ] [S053 — Remove Servo: vendor crates, gst-mse, Servo-only tests/tools, docs and texts](08%20WebKit%20engine/S053-servo-removal.md) · Sonnet high
- [ ] [S057 — Small UI bugs: Customize panel scroll, site colour from the favicon, colour picker glyphs, beforeunload on quit](08%20WebKit%20engine/S057-small-ui-bugs.md) · Sonnet high
- [ ] [S058 — Ads vanish before your eyes: Pie-style cookie shield removal animation (port of the original)](08%20WebKit%20engine/S058-ad-removal-animation.md) · Opus medium
- [ ] [S051 — Profile folder, sealed cookies, site data, incognito, media source](08%20WebKit%20engine/S051-profile-cookies-media.md) · Opus medium
- [ ] [S052 — WebKit tuning defaults, background tabs, memory check](08%20WebKit%20engine/S052-tuning-defaults.md) · Sonnet high
- [ ] [S054 — Site pass on WebKit vs Chromium reference](08%20WebKit%20engine/S054-site-pass.md) · Opus high

View file

@ -24,7 +24,7 @@ Next: finish 08 → user reviews and gaps → UI polish and motion. Order = `Pla
## Next three steps
1. S053 box 7–8 (fresh session; nothing else uses cargo meanwhile).
2. S057 small UI bugs: Customize panel doesn't scroll (wheel goes to the page), site colour from the favicon (user: page colours are mostly black/white), colour picker glyphs, beforeunload on quit.
3. S051 profile/cookies/media, then S052 tuning (incl. the slow-connection pass the user asked for), S054 site pass.
3. S058 ad removal animation (user asked twice: Pie-style cookie shield, port of the original `ZAP_JS`), then S051 profile/cookies/media, then S052 tuning (incl. the slow-connection pass the user asked for), S054 site pass.
## Known bugs / watch
- User saw a page stop taking input after PiP → return → idle (old PiP code); not reproduced; watchdog prints

View file

@ -4,5 +4,5 @@
- Works: tabs, navigation, pages, find, dialogs, menus, permissions, full screen, Web Inspector, real PiP, ad
blocker, network bridge, HTTPS-only, certificates, downloads, privacy switches, disk cache.
- Not yet on WebKit: cookies persisted/sealed and profile move (S051), background-tab rest and final tuning (S052).
- Next plan: S053 box 7 (resume), then S057, S051, S052, S054.
- Next plan: S053 box 7 (resume), then S057, S058, S051, S052, S054.
- Tests: `cargo test` 80; hidden smokes green as of S056.