Skip to Content
Motion probes

Motion probes

The probes I use to keep navigation and motion from regressing, and the budgets they enforce. The tokens and the behavior they guard are in Motion and transitions. None of them runs in CI, so I run them myself.

The transition probe

scripts/probes/transitions.mjs drives a running production server with headless Chromium (Playwright, 1440 by 900). It samples every animation frame around client navigations and hard loads: URL and scroll, title opacity and position, whether the “Loading…” fallback is on screen, the header logo position, document height and layout shift (CLS). Each scenario runs with motion allowed and with reduced motion.

pnpm build && pnpm start -p 3000 # one terminal pnpm probe:transitions # another; prints a table
VariableMeaning
PROBE_BASEbase URL, default http://localhost:3000
PROBE_BUDGETSJSON of budget overrides, for example '{"clientFullMs":300}', to see a failure on purpose
PROBE_ATTEMPTStries per scenario before it counts as failed, default 2 (a real regression fails every try)
PROBE_ONLYrun only scenarios whose id contains this text, for example dialog (skips the cross-checks)
PROBE_JSON1 prints the raw metrics as JSON instead of the table

What the probes need

  • A production build. pnpm build && pnpm start -p 3000. The dev server animates and compiles on demand, so its timings mean nothing. Do not set SKIP_ENV_VALIDATION to get a build through; see quality gates.
  • No .env. Every variable is optional (.env.example). Without them the content, role pages and /resume still render and the dialog still opens. The /resume dialog is only opened and closed, never submitted, so no Resend or Turnstile keys are needed.
  • Playwright’s Chromium. npx playwright install chromium once.
  • The splash. A hard load holds a full-viewport splash for 1300 to 1900 ms plus its dissolve (splash in src/config/motion.ts), and every other animation waits until data-splash-active leaves <html>. The probes wait for that attribute instead of a fixed delay, and a hard-load entrance is measured from the moment it clears. A click made earlier lands on the splash, and an entrance measured from DOMContentLoaded reads 1.7 to 2.4 s.
  • Not networkidle. The /api/flags request and the route prefetches can stay pending for many seconds on repeat loads in one browser context, so networkidle may never fire. The probes wait on load and the splash.
  • A quiet machine. Run one probe at a time. Leftover browsers from an interrupted run and a second probe in parallel both push timings over budget.

The exit code is 0 when every budget holds, 1 on a budget failure (each failure is listed with the measured value, the limit and where to look), and 2 when the probe cannot run (no server, no Chromium). It builds nothing and is not part of pnpm test. The unit tests for the evaluation logic (scripts/probes/budgets.test.mjs) do run in pnpm test.

Scenarios

Landing to /about, landing to a role page, role to the adjacent role, /about back to the landing page through its back link (/#summary), the footer link from a role page to /resume, the floating-nav pill from /resume to #experience, browser back from /about to / (scroll restoration), and hard loads of /, /about, a role page and /resume. The resume dialog (a name and email form that sends the PDF by email; there is no direct download) has seven more: open, close by the Close button and by Escape, scroll-behind on desktop (wheel and keys, 1440 by 900) and on mobile (touch swipe, 390 by 844), a cursor check (a screenshot pixel check that the dot is drawn at the pointer over the left panel, the form and the Send button, mid-enter and mid-exit, and that the popover and body cursor are restored after closing), and one behaviour check (Tab never reaches the page behind, and focus returns to the Download button after closing). Each samples the dialog’s computed display and opacity, and its ::backdrop opacity, every frame; Escape is a real key press.

The landing focus motion adds four more (see “Landing focus motion”): focus: nav active section (no label at the top, the right label at Summary, Impact and Experience, and a click from the top to Experience never shows another label), focus: experience timeline (the role at the reading line is the active one and every other role is receded), focus: about gallery (the soft layer is soft as an image enters and sharp in the reading zone; absent under reduced motion) and focus: skills index (every row reveals on first view and can receive the pointer when scrolled to mid-viewport, a search leaves exactly the rows the “N of 22 skills” readout reports, no row keeps a filter, and under reduced motion the search applies on the first frames).

Budgets

The numbers live in scripts/probes/budgets.mjs (BUDGETS). Each is the value measured on a production build plus a margin. Measured: nine runs (six alone, three at once) on a healthy build, headless Chromium, localhost. The three focus budgets (focusInactiveMax, focusGalleryEnterMin, focusGalleryReadMax) are instead thresholds derived from the token values plus slack; their “measured” column is a single observed value, not a 9-run worst case.

Budget (key)LimitMeasured (worst of 9 runs)Applies to
loadingFrames00every navigation and hard load
cls0.020every navigation, hard load and browser back
clsLanding0.10arrival on the landing page
clientTitleMs150 ms43 msmotion allowed: title in the DOM after a click
clientHalfMs300 ms148 msmotion allowed: title at least half opaque, client nav
clientFullMs650 ms498 msmotion allowed: title fully opaque, client nav
hardHalfMs300 ms149 msmotion allowed: title at least half opaque, hard load
hardFullMs700 ms532 msmotion allowed: title fully opaque, hard load
clientVsHardMs100 msabout 25 msclient nav no slower than the hard load of the same page
morphWaitMs300 ms265 ms over the hard loadlanding -> /about only: extra time its title gets on clientHalfMs, clientFullMs and clientVsHardMs, because the About entrance starts aboutEntrance.arrivalDelayMs (160 ms) into the portrait morph and the route needs about 100 ms to commit first. It still fails if the page goes back to waiting out the whole 400 ms morph
travelPx24 px18 pxmotion allowed: entrance travel (token is 20, sampled late); not applied to the landing hero title, which travels a full line by design (hero.title)
logoMovedPx2 px0logo must not move between sub-pages or from the landing top
scrollRestorePx4 px0browser back restores scroll
anchorTopPx2 px0nav pill ends with #experience at the top
reducedFirstOpacity0.991reduced motion: title opaque on its first frame
dialogFirstOpacity0.950 (backdrop)motion allowed: the ::backdrop is not fully opaque on its first frame (the dialog itself is opaque by design)
dialogEnterMs450 ms250 msmotion allowed: dialog and backdrop opacity at least 0.99 (99% on an ease-out lands before the 400 ms end)
dialogExitMs260 ms229 msmotion allowed: dialog removed after Close, Escape, Skip, Download
dialogExitMinFrames312motion allowed: frames it stays rendered while fading (not a cut)
dialogReducedGoneMs50 ms16 msreduced motion: dialog gone on the first frame after closing
dialogScrollBehindPx0 px0page scrollY while the dialog is open (wheel, keys, touch)
dialogScrollRestorePx0 px0scrollY exactly restored after closing
dialogCursorDiff100213 (weakest spot)the cursor dot differs from its surroundings by this much (0-255) over the dialog
focusInactiveMax0.650.6motion allowed: a timeline role away from the reading line is at most this opaque
focusGalleryEnterMin0.80.95 (passes)motion allowed: gallery soft layer at least this opaque as the image enters the viewport
focusGalleryReadMax0.050 (passes)motion allowed: gallery soft layer at most this opaque in the reading zone
(fixed)0 px0reduced motion: no travel at all
(fixed)monotonicmonotonicdialog opacity only rises on enter and only falls on exit
(fixed)truetruefocus returns to the trigger, Tab stays in the dialog
(fixed)no reloaddocument keptfooter link and nav pill are client navigations

Not a budget, by design: the logo legitimately docks and eases in on the way back to the landing page (about 51 px), and the probe only checks that the hash link scrolled somewhere.

When a budget fails, fix the cause rather than loosening the number. If a change to the motion tokens is intended (for example a longer duration.slow), update the budgets and this page in the same change.

The route-scroll probe

scripts/probes/route-scroll.mjs drives the same running server (PROBE_BASE, same requirements) with four browser contexts at once: 1440 and 390 px wide, each with motion allowed and reduced. It prints one PASS line per context and throws on the first failed assertion. For every skill tile on the landing page it scrolls to the tile, starts a wheel scroll, clicks mid-scroll and checks that the detail page starts at the top and stays there. For the first skill it also checks Back and Forward restoration (Back must return to the last landing position before the route changed, within 40 px; the wheel scroll is still animating at the click, so the position at the click is about 80 to 150 px short of it), then a click on a related skill. It ends with a direct load, the #impact anchor (the section heading lands at the shared clearance, as in docs/anchor-navigation.md), a role page and, on mobile, a touch swipe followed by a tap.

PROBE_BASE=http://localhost:3000 pnpm probe:route-scroll

What I have not fixed

These show up while running the probes and are not budget misses.

  • /api/flags and prefetch requests stall. On repeat loads in one browser context they can stay pending for tens of seconds. The probes do not wait on network idle for that reason. I have not fixed the cause.

In CI

The probe does not run in CI. I run it locally before merging changes to motion, navigation or the landing sections.

Last updated on