Skip to content

Start the homepage environment fade even when a long task delays the next frame - #1993

Merged
David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-environment-fade-race
Oct 30, 2026
Merged

David Pine (IEvangelist) merged 1 commit into
mainfrom
aspireagent/fix-environment-fade-race

Conversation

@davidfowl

Copy link
Copy Markdown
Contributor

Summary

On the homepage's environment section (Local / Test / Production), switching environments is supposed to fade the new panel in. HomeEnvironment.astro removed data-transition with a 200 ms timer that started at click time. If a long task delayed the next rendering frame past that timer, the attribute was gone before style was recalculated. The fade never started, so visitors on busy or low-end devices got an abrupt swap.

The same race is the recurring homepage E2E flake fades environment changes and pauses independent resource motion. It failed on the first attempt and passed on retry in 5 of the 15 most recent successful ci.yml runs I scanned. Both failures I inspected show the same signature: data-test-fade-seen Expected "true", Received "false". For example:

Fix: after setting data-transition, call nextPanel.getAnimations(). This flushes style, so the CSS fade is created synchronously. The panels then settle when that animation's finished promise resolves, or immediately if no fade applies, for example when motion isn't active. No timeouts, sleeps or retries are added; the fixed timer is removed. Cancelled animations (a new selection, pause, hidden page or scrolling away) still go through the existing settlePanels() paths.

Regression test: starts the environment fade even when a long task delays the next frame clicks Test and then blocks the main thread for 250 ms in the same task. It asserts that the fade's animationstart fires and that data-transition clears.

No screenshots: the panel looks the same before and after once it settles. The fix restores a 180 ms opacity animation, which a still image can't show. The evidence is the animationstart assertion above.

Third-party links and affiliations

None

Validation

  • New regression test, run locally against astro dev in desktop, tablet and mobile Chromium:
    • Without the fix, on the same branch: 9/9 failed (3 repeats per project), with data-test-fade-seen Expected "true", Received "false". This matches the CI flake.
    • With the fix: 30/30 passed (10 repeats per project).
  • All homepage tests matching environment, run twice each across the 3 projects (including the existing fade test): 24/24 passed.
  • vitest run: 82 files; 1108 passed, 1 skipped.
  • eslint . --max-warnings 0 passes, and prettier --check on HomeEnvironment.astro passes. The new test block is Prettier-clean; homepage.spec.ts already has a Prettier warning on main.

🤖 Posted by AspireAgent (AI Agent)

The environment panel transition cleared data-transition with a 200 ms timer
started at click time. When a long task delayed the next rendering frame past
that timer, the attribute was removed before style was recalculated, so the
fade-in never started and visitors got an abrupt swap. This is also the
recurring "fades environment changes" homepage E2E flake.

Flush style with getAnimations() so the CSS fade starts synchronously, and
settle the panels when that animation finishes (or immediately when no fade
applies) instead of racing a fixed timer.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #1993. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #1993 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 30, 2026 11:48
Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:48

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the environment-switching fade fix and its regression coverage.

No open issues 🎉

What changed in this PR

This PR fixes a homepage environment-switching race that could skip the fade when a long task delayed rendering.

Changes:

  • Replaces the fixed cleanup timer with synchronous animation creation and cleanup when the fade finishes.
  • Adds a regression test that blocks the main thread after switching environments and verifies the fade starts and transition state clears.
File Description
src/​frontend/​tests/​e2e/​homepage.spec.ts Adds regression coverage for environment fades during a delayed frame.
src/​frontend/​src/​components/​home/​HomeEnvironment.astro Uses the fade animation’s completion promise instead of a fixed timer to settle panels.

Review effort: Balanced

@IEvangelist
David Pine (IEvangelist) merged commit 2955005 into main Oct 30, 2026
20 checks passed
@IEvangelist
David Pine (IEvangelist) deleted the aspireagent/fix-environment-fade-race branch October 30, 2026 13:20
David Pine (IEvangelist) pushed a commit that referenced this pull request Nov 1, 2026
…ation events (#2005)

## Summary

Fixes a recurring retry-only E2E flake in `tests/e2e/homepage.spec.ts` ›
"fades environment changes and pauses independent resource motion". No
open issue tracks it. It still occurs after #1993 because #1993 fixed a
different root cause, in product code.

**Signature**, from all three projects:

```
expect(locator).toHaveAttribute(expected) failed
Locator:  locator('[data-home-environments]').locator('[data-environment-panel="test"]')
Expected: "true"
Received: "false"
… <article … data-transition="fade-in" data-test-fade-seen="false" …>
```

**Occurrences since #1993 merged (2026-10-30 13:20Z):** the test passed
only on retry in these CI jobs:
-
[41063267878](https://github.com/microsoft/aspire.dev/actions/runs/41063267878)
(mobile)
-
[41073244315](https://github.com/microsoft/aspire.dev/actions/runs/41073244315)
(desktop)
-
[41077887607](https://github.com/microsoft/aspire.dev/actions/runs/41077887607)
(tablet)
-
[41079312370](https://github.com/microsoft/aspire.dev/actions/runs/41079312370)
(mobile and desktop)
-
[41089832463](https://github.com/microsoft/aspire.dev/actions/runs/41089832463)
(mobile)

**Root cause (test-only):** the test recorded the fade with an
`animationstart` listener registered with `{ once: true }` and no target
check. Revealing a panel restarts its topology animations, such as
`topology-node-idle` and `topology-cycle-four`, and their
`animationstart` events bubble to the panel. When one of them is
dispatched before the panel's own `environment-panel-fade-in` event, it
consumes the one-shot listener. The real fade then goes unrecorded, even
though it ran. The product behavior is correct: the snapshot above shows
`data-transition="fade-in"` on the panel.

**Fix:** a shared `recordPanelFade()` helper. It only accepts
`environment-panel-fade-in` events whose target is the panel itself, and
removes its listener after recording one. The two inline listeners in
the fade test and the one in the long-task fade test now use it. No
assertions, timeouts or retries changed, and the product code is
unchanged.

**Regression test:** "records the environment fade when a descendant
animation starts first". It dispatches a bubbling `animationstart` from
a topology card before clicking **Test**, then asserts that the panel's
own fade is still recorded. This deterministically reproduces the
ordering seen in CI.

This doesn't change any rendered output, so there are no screenshots.

## Third-party links and affiliations

None.

## Validation

**Reproduced on unmodified `main` (f05f556):** I ran a local dev
server, loaded a fresh page in a mobile 390×844 context each time with
no CPU throttling, and made the first **Test** click while recording
events with both the old one-shot listener and a persistent listener.
- In 5 of 32 loads, the first `animationstart` reaching the panel came
from a descendant (`topology-node-idle` or `topology-cycle-four`), and
the old listener missed the fade.
- The persistent listener saw the fade in 32 of 32 loads.

**Fail before, pass after:**
- New regression test with the old `{ once: true }` listener: **9/9
failed** (3 projects × 3 repeats), `Received: "false"`.
- With the fix, the new test, the fade test and the long-task fade test
(3 projects × 3 repeats): 26 of 27 passed.
- The one failure was the existing long-task test on desktop, the second
test of the run on a cold dev server. Its unchanged `data-transition`
settle assertion timed out after 2s.
- Re-running the long-task and new tests (3 projects × 4 repeats) gave
**24/24 passed**.

**Other checks:**
- `npx vitest run`: 84 files, 1,120 passed, 1 skipped.
- `npx eslint . --max-warnings 0`: clean.

---

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sébastien Ros (sebastienros) added a commit that referenced this pull request Nov 11, 2026
- TypeScript API parameter descriptions (#2009)
- No locale prefix or hreflang alternates for English-only pages: the footer
  language picker (#1988), hreflang (#1987) and the sidebar Glossary link (#1989)
- Footer link to the Aspire MIT license
- Homepage: environment fade (#1993), stale AppHost animations (#1950), the
  dashboard carousel keeps the selected slide on activation
- Search: first-result highlight with out-of-order renders (#2007), hover cursor
  flicker (#1977)
- Live status over WebSocket (#1942) and twoslash hover, merged into the copies
  of the frontend scripts
- Icon data 5.40.0 and the regenerated sprite
- src/frontend now uses Bun: README and script usage updated
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.

3 participants