From 76e0ca8826daa6c56f04de735000deff4397a33b Mon Sep 17 00:00:00 2001 From: Royalaid <2439803+royalaid@users.noreply.github.com> Date: Wed, 19 Aug 2026 01:24:11 -0700 Subject: [PATCH] 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 --- apps/desktop/e2e/glyph-spinner.spec.ts | 17 ++++++++++++----- .../thread/status-invalidation-scope.test.tsx | 4 +++- .../desktop/src/components/ui/glyph-spinner.css | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/apps/desktop/e2e/glyph-spinner.spec.ts b/apps/desktop/e2e/glyph-spinner.spec.ts index e920daa143..9ef8790bd3 100644 --- a/apps/desktop/e2e/glyph-spinner.spec.ts +++ b/apps/desktop/e2e/glyph-spinner.spec.ts @@ -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))) diff --git a/apps/desktop/src/components/assistant-ui/thread/status-invalidation-scope.test.tsx b/apps/desktop/src/components/assistant-ui/thread/status-invalidation-scope.test.tsx index 435fe9dee4..b6fc34ec1d 100644 --- a/apps/desktop/src/components/assistant-ui/thread/status-invalidation-scope.test.tsx +++ b/apps/desktop/src/components/assistant-ui/thread/status-invalidation-scope.test.tsx @@ -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() + const actual = await importActual() return { ...actual, diff --git a/apps/desktop/src/components/ui/glyph-spinner.css b/apps/desktop/src/components/ui/glyph-spinner.css index 4656074f10..12118ba004 100644 --- a/apps/desktop/src/components/ui/glyph-spinner.css +++ b/apps/desktop/src/components/ui/glyph-spinner.css @@ -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);