fix(desktop): order-independent selection guard, layer-hint scoping, honest compositor receipt

Review-round residuals: the spinner's user-select guard now beats
[data-selectable-text] regardless of stylesheet order; the will-change
layer hint clears under the global renderer pause and reduced motion so
parked spinners hold no compositor layer; the e2e travel assertion reads
the engine's keyframes (a computed transform always serializes to a
matrix, so the old '%' check could never fail); inline import() type
hoisted for the lint gate.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Royalaid
2026-08-19 01:24:11 -07:00
committed by Teknium
parent 0269504250
commit 76e0ca8826
3 changed files with 30 additions and 7 deletions
+12 -5
View File
@@ -20,7 +20,7 @@
* Prerequisite: `npm run build` must have been run so dist/ exists.
*/
import { expect, test, type Page } from '@playwright/test'
import { expect, type Page, test } from '@playwright/test'
import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'
@@ -74,8 +74,12 @@ test.describe('GlyphSpinner (compositor animation)', () => {
durationMs: animations[0]?.effect?.getTiming().duration ?? null,
names: animations.map(a => (a as CSSAnimation).animationName),
// A percentage translate makes the animation layout-dependent, which
// Chromium refuses to composite. The travel must resolve to a length.
transform: style.transform
// Chromium refuses to composite. Read the engine's own keyframes: a
// revert to translateY(-100%) shows up here, while the computed
// `style.transform` always serializes to a matrix and can't tell.
travel: ((animations[0]?.effect as KeyframeEffect | undefined)?.getKeyframes() ?? [])
.map(k => String((k as Keyframe & { transform?: string }).transform ?? ''))
.join(' | ')
}
}, STRIP)
@@ -88,9 +92,10 @@ test.describe('GlyphSpinner (compositor animation)', () => {
// One full cycle is frames x interval, so the duration must be a positive
// multiple of the frame count — not the single-frame interval.
expect(observed.durationMs).toBeGreaterThan(0)
// A resolved matrix, never a percentage: `translateY(-100%)` would keep
// Length-typed travel, never a percentage: `translateY(-100%)` would keep
// the animation off the compositor.
expect(observed.transform).not.toContain('%')
expect(observed.travel).toContain('calc(')
expect(observed.travel).not.toContain('%')
})
test('is promoted to a layer while running, and neither animates nor holds a layer when parked', async () => {
@@ -119,6 +124,7 @@ test.describe('GlyphSpinner (compositor animation)', () => {
const previous = viewport.getAttribute('data-paused')
viewport.setAttribute('data-paused', 'true')
const state = {
playState: getComputedStyle(el).animationPlayState,
willChange: getComputedStyle(el).willChange
@@ -174,6 +180,7 @@ test.describe('GlyphSpinner (compositor animation)', () => {
const textAtStart = el.textContent
const deadline = performance.now() + duration
while (performance.now() < deadline) {
seen.add(getComputedStyle(el).transform)
await new Promise(resolve => requestAnimationFrame(() => resolve(null)))
@@ -16,12 +16,14 @@ import { AssistantRuntimeProvider, type ThreadMessage, useExternalStoreRuntime }
import { cleanup, render, waitFor } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type * as messageReactionsModule from '@/components/assistant-ui/thread/use-message-reactions'
import { Thread } from '.'
let rootRenders = 0
vi.mock('@/components/assistant-ui/thread/use-message-reactions', async importActual => {
const actual = await importActual<typeof import('@/components/assistant-ui/thread/use-message-reactions')>()
const actual = await importActual<typeof messageReactionsModule>()
return {
...actual,
@@ -47,7 +47,9 @@
`[data-selectable-text='true'] *` rule carries the same (0,1,0) specificity,
so relying on inheritance would make the winner depend on stylesheet order. */
.glyph-spinner,
.glyph-spinner * {
.glyph-spinner *,
[data-selectable-text='true'] .glyph-spinner,
[data-selectable-text='true'] .glyph-spinner * {
-webkit-user-select: none;
user-select: none;
}
@@ -66,6 +68,18 @@
will-change: transform;
}
/* The global renderer pause and the reduced-motion freeze stop the animation;
drop the layer hint there too, so parked spinners hold no compositor layer. */
:root[data-renderer-animations-paused] .glyph-spinner__strip {
will-change: auto;
}
@media (prefers-reduced-motion: reduce) {
.glyph-spinner__strip {
will-change: auto;
}
}
.glyph-spinner__frame {
display: block;
height: var(--glyph-spinner-frame-height, 1em);