The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
perf(desktop): harden the spinner strip and tighten status invalidation
Royalaid73dcd75afe1e
diff --git a/apps/desktop/scripts/run-short-session-hang-repro.mjs b/apps/desktop/scripts/run-short-session-hang-repro.mjsindex ff544ec87d1..8a97acaef2c 100644--- a/apps/desktop/scripts/run-short-session-hang-repro.mjs+++ b/apps/desktop/scripts/run-short-session-hang-repro.mjs@@ -928,9 +928,16 @@ async function runRealChatChecks(cdp, timed, measure, mock, runDir, appPid, nati// Settled = no streaming marker anywhere in the row's subtree. The// marker moved off the message root onto a hidden leaf inside it — a// per-flip attribute write on the root widened style recalc across the- // whole message subtree — so this matches the descendant instead of the+ // whole message subtree — so this counts the descendant instead of the// root's own attribute. Same rows, same gate.- `document.querySelectorAll('[data-slot="aui_assistant-message-root"]:not(:has([data-message-streaming="true"]))').length`+ //+ // Counted by subtraction rather than with+ // `:not(:has([data-message-streaming="true"]))`, which makes the engine+ // walk every row's subtree on each evaluation — and this probe runs+ // inside the very latency window it is measuring, so that cost lands in+ // the number. At most one marker per row carries the attribute, so+ // roots - streaming is exactly the settled count.+ `document.querySelectorAll('[data-slot="aui_assistant-message-root"]').length - document.querySelectorAll('[data-message-streaming="true"]').length`))const composer = await timed(`real-chat.composer-focus.${exchange}`, () =>@@ -1025,7 +1032,9 @@ async function runRealChatChecks(cdp, timed, measure, mock, runDir, appPid, natiawait measure(`real-chat.assistant-response.${exchange}`, () =>waitForResponsive(cdp,- `document.querySelectorAll('[data-slot="aui_assistant-message-root"]:not(:has([data-message-streaming="true"]))').length > ${beforeAssistant}`,+ // Same count-by-subtraction as the pre-send probe above: no `:has()`+ // subtree walk inside the responsiveness measurement window.+ `document.querySelectorAll('[data-slot="aui_assistant-message-root"]').length - document.querySelectorAll('[data-message-streaming="true"]').length > ${beforeAssistant}`,STREAM_RESPONSE_TIMEOUT_MS,`real assistant response ${exchange}`,STREAM_RESPONSE_EVALUATION_TIMEOUT_MSdiff --git a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsxindex 059aa30bae3..f2cfdc09c11 100644--- a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx@@ -7,7 +7,7 @@ import {useMessageRuntime} from '@assistant-ui/react'import { useStore } from '@nanostores/react'-import { type FC, useCallback, useMemo, useState } from 'react'+import { type FC, type ReactNode, useCallback, useMemo, useState } from 'react'import { useSessionView } from '@/app/chat/session-view'import { ChangedFilesCard } from '@/components/assistant-ui/thread/changed-files-card'@@ -111,47 +111,56 @@ export const AssistantMessage: FC<AssistantMessageProps> = props => {)}+/** The compact stand-in a settled inter-agent reply collapses to (Grok-bots+ * parity — the transcript shows the event; the text is one click away). */+const InterAgentCollapsedNotice: FC<{ sender: string }> = ({ sender }) => (+ <div className="flex max-w-[min(86%,44rem)] flex-col gap-0.5 self-center px-2 py-0.5 text-[0.6875rem] leading-5 text-muted-foreground/60">+ <span className="flex items-center justify-center gap-1.5">+ <Codicon className="shrink-0 text-muted-foreground/55" name="arrow-small-right" size="0.8125rem" />+ <span className="wrap-anywhere">Replied to {sender}</span>+ </span>+ <details className="self-center">+ <summary className="cursor-pointer select-none text-center text-muted-foreground/45 hover:text-muted-foreground/70">+ show reply+ </summary>+ <div className="mt-1 max-w-[36rem] rounded-lg border border-(--ui-stroke-tertiary) px-3 py-2 text-left text-[0.75rem] leading-5 text-foreground/85">+ {MESSAGE_PARTS}+ </div>+ </details>+ </div>+)+/*** An assistant reply that answers an inter-agent delivery. Owns the only* root-level `isRunning` subscription left in this file, and it is confined to* the rare inter-agent case: the reply renders collapsed once it settles, so* the gate genuinely needs live status. Never collapse while streaming — the* user should see progress.+ *+ * The collapse is expressed as a CHILD of the normal body, not as a competing+ * root. Returning a bare MessagePrimitive.Root here for the settled case put a+ * different element type in this position than the running case+ * (AssistantMessageBody), so settling unmounted the whole row and mounted a+ * fresh one — throwing away the DOM the scroll anchor was holding, which can+ * jump the transcript under the reader. One component, one root, children+ * vary: settling is now a prop change React applies in place.*/const InterAgentAssistantMessage: FC<AssistantMessageProps & { sender: string }> = ({ sender, ...props }) => {const isRunning = useAuiState(s => s.message.status?.type === 'running')- if (isRunning) {- return <AssistantMessageBody {...props} />- }-- // Render collapsed (Grok-bots parity — the transcript shows the event; the- // text is one click away).return (- <MessagePrimitive.Root- className="group flex w-full min-w-0 max-w-full flex-col gap-0 self-start overflow-hidden pb-(--conversation-turn-gap)"- data-role="assistant"- data-slot="aui_assistant-message-root"- >- <div className="flex max-w-[min(86%,44rem)] flex-col gap-0.5 self-center px-2 py-0.5 text-[0.6875rem] leading-5 text-muted-foreground/60">- <span className="flex items-center justify-center gap-1.5">- <Codicon className="shrink-0 text-muted-foreground/55" name="arrow-small-right" size="0.8125rem" />- <span className="wrap-anywhere">Replied to {sender}</span>- </span>- <details className="self-center">- <summary className="cursor-pointer select-none text-center text-muted-foreground/45 hover:text-muted-foreground/70">- show reply- </summary>- <div className="mt-1 max-w-[36rem] rounded-lg border border-(--ui-stroke-tertiary) px-3 py-2 text-left text-[0.75rem] leading-5 text-foreground/85">- {MESSAGE_PARTS}- </div>- </details>- </div>- </MessagePrimitive.Root>+ <AssistantMessageBody+ {...props}+ collapsedNotice={isRunning ? null : <InterAgentCollapsedNotice sender={sender} />}+ />)}-const AssistantMessageBody: FC<AssistantMessageProps> = ({ onBranchInNewChat, onDismissError }) => {+const AssistantMessageBody: FC<AssistantMessageProps & { collapsedNotice?: null | ReactNode }> = ({+ collapsedNotice = null,+ onBranchInNewChat,+ onDismissError+}) => {const messageId = useAuiState(s => s.message.id)const messageRuntime = useMessageRuntime()const { t } = useI18n()@@ -191,52 +200,62 @@ const AssistantMessageBody: FC<AssistantMessageProps> = ({ onBranchInNewChat, onreturn (<MessagePrimitive.Root- className="group flex w-full min-w-0 max-w-full flex-col gap-0 self-start overflow-hidden"+ className={cn(+ 'group flex w-full min-w-0 max-w-full flex-col gap-0 self-start overflow-hidden',+ collapsedNotice && 'pb-(--conversation-turn-gap)'+ )}data-role="assistant"data-slot="aui_assistant-message-root"- onDoubleClick={onDoubleClick}+ // Collapsed inter-agent rows never carried the tapback listener; keeping+ // that exact truth table means gating it on the notice rather than on+ // whether the hook returned a handler.+ onDoubleClick={collapsedNotice ? undefined : onDoubleClick}ref={enterRef}>- <div- className="wrap-anywhere min-w-0 max-w-full overflow-hidden text-pretty text-[length:var(--conversation-text-font-size)] leading-(--dt-line-height) text-foreground"- data-slot="aui_assistant-message-content"- >- {/* Todos render in the composer status stack now, not inline. */}- {MESSAGE_PARTS}- <AssistantStatusSlot />- <AssistantPreviewEmbeds />- <MessagePrimitive.Error>- <ErrorPrimitive.Root- className="mt-1.5 flex items-start gap-1.5 text-[0.78rem] leading-5 text-[color-mix(in_srgb,var(--dt-destructive)_78%,var(--ui-text-secondary))]"- role="alert"+ {collapsedNotice ?? (+ <>+ <div+ className="wrap-anywhere min-w-0 max-w-full overflow-hidden text-pretty text-[length:var(--conversation-text-font-size)] leading-(--dt-line-height) text-foreground"+ data-slot="aui_assistant-message-content">- <ErrorPrimitive.Message className="min-w-0 flex-1" />- {onDismissError && (- <TooltipIconButton- className="-my-0.5 shrink-0 text-current opacity-70 hover:opacity-100"- onClick={() => onDismissError(messageId)}- side="top"- tooltip={t.assistant.thread.dismissError}+ {/* Todos render in the composer status stack now, not inline. */}+ {MESSAGE_PARTS}+ <AssistantStatusSlot />+ <AssistantPreviewEmbeds />+ <MessagePrimitive.Error>+ <ErrorPrimitive.Root+ className="mt-1.5 flex items-start gap-1.5 text-[0.78rem] leading-5 text-[color-mix(in_srgb,var(--dt-destructive)_78%,var(--ui-text-secondary))]"+ role="alert">- <XIcon className="size-3.5" />- </TooltipIconButton>- )}- </ErrorPrimitive.Root>- </MessagePrimitive.Error>- </div>- <MessageTimelineTimestamp className="px-(--message-text-indent) pt-0.5" suppressIfDuplicatePart />- {hasVisibleText && !isInterim && (- <AssistantFooter- durationS={turnDurationS}- getMessageText={getMessageText}- messageId={messageId}- onBranchInNewChat={onBranchInNewChat}- />- )}- {/* Last thing in the turn — under the action bar, the way Cursor ends a+ <ErrorPrimitive.Message className="min-w-0 flex-1" />+ {onDismissError && (+ <TooltipIconButton+ className="-my-0.5 shrink-0 text-current opacity-70 hover:opacity-100"+ onClick={() => onDismissError(messageId)}+ side="top"+ tooltip={t.assistant.thread.dismissError}+ >+ <XIcon className="size-3.5" />+ </TooltipIconButton>+ )}+ </ErrorPrimitive.Root>+ </MessagePrimitive.Error>+ </div>+ <MessageTimelineTimestamp className="px-(--message-text-indent) pt-0.5" suppressIfDuplicatePart />+ {hasVisibleText && !isInterim && (+ <AssistantFooter+ durationS={turnDurationS}+ getMessageText={getMessageText}+ messageId={messageId}+ onBranchInNewChat={onBranchInNewChat}+ />+ )}+ {/* Last thing in the turn — under the action bar, the way Cursor ends aturn on its summary rather than burying it above the controls. */}- <SettledChangedFiles />- <StreamingMarker />+ <SettledChangedFiles />+ <StreamingMarker />+ </>+ )}</MessagePrimitive.Root>)}@@ -267,18 +286,25 @@ const AssistantMessageBody: FC<AssistantMessageProps> = ({ onBranchInNewChat, on* itself a leaf and this stays off the message root either way.*/const AssistantStatusSlot: FC = () => {- const isLastMessage = useAuiState(s => s.thread.messages[s.thread.messages.length - 1]?.id === s.message.id)- const isPlaceholder = useAuiState(s => s.message.status?.type === 'running' && s.message.content.length === 0)+ // ONE subscription, not one per input. Each useAuiState is a separate store+ // subscription with its own equality check and its own chance to schedule a+ // render, and these inputs always move together on a status flip — so+ // reading them separately just multiplies the wake-ups for a single logical+ // change. The selector collapses them to one stable string, which bails out+ // on every flush that does not actually change what this slot renders.+ const slot = useAuiState(s => {+ if (s.thread.messages[s.thread.messages.length - 1]?.id !== s.message.id) {+ return 'none'+ }- if (!isLastMessage) {- return null- }+ return s.message.status?.type === 'running' && s.message.content.length === 0 ? 'placeholder' : 'activity'+ })- if (isPlaceholder) {- return <ResponseLoadingIndicator />+ if (slot === 'none') {+ return null}- return <TurnActivityIndicator />+ return slot === 'placeholder' ? <ResponseLoadingIndicator /> : <TurnActivityIndicator />}/**@@ -362,11 +388,13 @@ const SettledChangedFiles: FC = () => {** The flag has no CSS behind it (every `[data-streaming='true']` rule targets* `[data-slot='code-card']`), but it is not dead: it is the settled-row signal- * for the short-session hang repro, which counts- * `[data-slot='aui_assistant-message-root']:not(:has([data-message-streaming='true']))`- * and gates the assistant-response wait on that count growing.+ * for the short-session hang repro, which derives the settled count by+ * subtracting the number of `[data-message-streaming='true']` markers from the+ * number of message roots, and gates the assistant-response wait on that count+ * growing. At most one marker per row carries the attribute, which is what+ * makes the subtraction exact.*- * Deliberately NOT named `data-streaming`: shiki-highlighter.tsx:148 puts that+ * Deliberately NOT named `data-streaming`: shiki-highlighter.tsx puts that* exact attribute on a deferred `[data-slot='code-card']`, which is a* descendant of this root. Once the repro matches on a descendant rather than* the root's own attribute, a shared name would make any message holding a@@ -377,12 +405,12 @@ const SettledChangedFiles: FC = () => {* whole message subtree, which is the invalidation this prong exists to remove.* Three properties make this placement cheap and behaviour-neutral:*- * - A ROOT-LEVEL sibling, not a child of the message content. The rules at- * styles.css:1995-2003 match the first/last block *inside*- * `[data-slot='aui_assistant-message-content']`; a node added there would- * steal `:last-child` from the stall indicator and silently change the gap- * between bubbles mid-stream. No rule selects message-root children by- * position, so this slot is inert.+ * - A ROOT-LEVEL sibling, not a child of the message content. The+ * `:first-child` / `:last-child` margin rules in styles.css match blocks+ * *inside* `[data-slot='aui_assistant-message-content']`; a node added+ * there would steal `:last-child` from the status indicator and silently+ * change the gap between bubbles mid-stream. No rule selects message-root+ * children by position, so this slot is inert.* - PERMANENTLY MOUNTED, toggling only the attribute. Mounting/unmounting per* flip would be a DOM structure change and dirty its siblings; an attribute* write on a childless node invalidates exactly one element.@@ -395,7 +423,14 @@ const SettledChangedFiles: FC = () => {const StreamingMarker: FC = () => {const isRunning = useAuiState(s => s.message.status?.type === 'running')- return <span aria-hidden="true" className="hidden" data-message-streaming={isRunning ? 'true' : undefined} />+ return (+ <span+ aria-hidden="true"+ className="hidden"+ data-message-streaming={isRunning ? 'true' : undefined}+ data-slot="aui_message-streaming-marker"+ />+ )}const AssistantActionBar: FC<MessageActionProps> = ({ messageId, getMessageText, onBranchInNewChat }) => {diff --git a/apps/desktop/src/components/assistant-ui/thread/inter-agent-collapse.test.tsx b/apps/desktop/src/components/assistant-ui/thread/inter-agent-collapse.test.tsxindex 8bc7cbf4f2a..803d1f3bd47 100644--- a/apps/desktop/src/components/assistant-ui/thread/inter-agent-collapse.test.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/inter-agent-collapse.test.tsx@@ -8,8 +8,8 @@// likely to break if the split is revisited.// 2. The streaming marker. `data-message-streaming` moved off the message root// onto a permanently-mounted hidden leaf, and-// scripts/run-short-session-hang-repro.mjs counts settled rows with-// `[data-slot="aui_assistant-message-root"]:not(:has([data-message-streaming="true"]))`.+// scripts/run-short-session-hang-repro.mjs derives its settled-row count by+// subtracting `[data-message-streaming="true"]` markers from message roots.// Nothing in the app itself reads it, so without this test a delete would// look free and would silently regress that repro's response gate.import { AssistantRuntimeProvider, type ThreadMessage, useExternalStoreRuntime } from '@assistant-ui/react'@@ -112,6 +112,8 @@ describe('inter-agent collapse gate', () => {await screen.findByText('done')expect(container.querySelector('[data-message-streaming="true"]')).toBeNull()// The marker element itself stays mounted (attribute toggles, no remount).- expect(container.querySelector('[data-slot="aui_assistant-message-root"] span.hidden')).toBeTruthy()+ expect(+ container.querySelector('[data-slot="aui_assistant-message-root"] [data-slot="aui_message-streaming-marker"]')+ ).toBeTruthy()})})diff --git a/apps/desktop/src/components/ui/glyph-spinner.css b/apps/desktop/src/components/ui/glyph-spinner.cssindex 1b176adaabc..4656074f108 100644--- a/apps/desktop/src/components/ui/glyph-spinner.css+++ b/apps/desktop/src/components/ui/glyph-spinner.css@@ -4,22 +4,25 @@* `glyph.textContent` every frame. Replacing a text node is a structural DOM* mutation, so each tick scheduled a style recalculation — and because these* spinners sit inside the transcript, that recalc resolved against the whole- * document. Scheduler attribution on the incident trace put 133 of 138 wide- * document-scale recalcs on this ticker (0 of 254 cheap ones), which is the- * incident.+ * document. Scheduler attribution on an incident trace put the large majority+ * of the wide document-scale recalcs on this ticker, and none of the cheap+ * scoped ones; the trace numbers are in the PR that introduced this file.** Every frame is now in the DOM from mount as a vertical strip, and a* `transform: translateY` keyframes animation scrolls it one frame at a time.* Transform animations run on the compositor: no JS timer, no text mutation,* no style recalc, no layout, nothing scheduled per frame.*- * The strip is N frames tall and each frame is exactly 1em, so translating by- * -100% travels exactly N frames. `steps(N)` (jump-end) samples that travel at- * 0, 1/N, ... (N-1)/N, i.e. it parks on frame 0..N-1 for one interval each and- * then wraps — the same sequence and cadence the ticker produced. Both N and- * the duration arrive as custom properties set inline per spinner, so all 18- * spinner variants (16 distinct frame/interval shapes) share this one rule set- * with no generated or colliding per-variant keyframes.+ * The strip is N frames tall and each frame is exactly 1em, so travelling N+ * frame-heights scrolls through the whole strip exactly once. `steps(N)`+ * (jump-end) samples that travel at 0, 1/N, ... (N-1)/N, i.e. it parks on+ * frame 0..N-1 for one interval each and then wraps — the same sequence and+ * cadence the ticker produced. Both N and the duration arrive as custom+ * properties set inline per spinner, so all 18 spinner variants (16 distinct+ * frame/interval shapes) share this one rule set with no generated or+ * colliding per-variant keyframes. Every var() carries the braille default as+ * its fallback, so a missing custom property degrades to a working spinner+ * rather than an invalid declaration.*/.glyph-spinner {@@ -31,37 +34,58 @@--glyph-spinner-frame-height: 1em;display: block;- height: var(--glyph-spinner-frame-height);+ height: var(--glyph-spinner-frame-height, 1em);overflow: hidden;line-height: 1;- /* Decorative and aria-hidden, so it must not land in a transcript copy.- These spinners sit inside [data-selectable-text] subtrees (tool/delegate,- tool/fallback), where the strip would otherwise contribute all N glyphs to- a selection where the old one-character implementation contributed one. */+}++/* Decorative and aria-hidden, so it must not land in a transcript copy. These+ spinners sit inside [data-selectable-text] subtrees (tool/delegate,+ tool/fallback), where the strip would otherwise contribute all N glyphs to a+ selection where the old one-character implementation contributed one.+ Descendants are named explicitly rather than left to inherit: the competing+ `[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 * {-webkit-user-select: none;user-select: none;}.glyph-spinner__strip {display: block;- animation: glyph-spinner-advance var(--glyph-spinner-duration) steps(var(--glyph-spinner-frames)) infinite;- /* Promote to a compositor layer. Without it, trace instrumentation recorded- a non-zero compositeFailed on every animation record. */+ animation: glyph-spinner-advance var(--glyph-spinner-duration, 800ms) steps(var(--glyph-spinner-frames, 10)) infinite;+}++/* Promote to a compositor layer — without it, trace instrumentation recorded a+ non-zero compositeFailed on every animation record. Scoped to spinners that+ are actually animating: a permanently promoted layer per parked spinner is+ pure memory at fan-out breadth, where many spinners sit mounted and paused+ at once. */+.glyph-spinner:not([data-paused='true']) .glyph-spinner__strip {will-change: transform;}.glyph-spinner__frame {display: block;- height: var(--glyph-spinner-frame-height);+ height: var(--glyph-spinner-frame-height, 1em);+ /* Clip each frame to its own box. Braille (U+2800..U+28FF) renders from a+ system fallback face — JetBrains Mono has no glyphs in that block — and+ fallback metrics are not guaranteed to fit the 1em box, so ink from the+ neighbouring frames could otherwise bleed into the viewport. */+ overflow: hidden;line-height: 1;}-/* Kept-alive pane that is currently an inactive tab. Hidden panes normally get- `content-visibility: hidden`, which already stops animations in the skipped- subtree, but that containment has a runtime kill switch and older pane layers- only set `visibility: hidden` — which does NOT stop an animation. This keeps- the original explicit guarantee ("N mounted tabs each ticking burns CPU for- pixels nobody can see") independent of which of those is in play. */+/* Parked, for either of two reasons: the pane is a kept-alive but inactive tab+ (usePaneVisible), or the caller passed `paused` to hold the spinner still+ while it stays mounted through a fade-out (ChatSwapOverlay). Hidden panes+ normally get `content-visibility: hidden`, which already stops animations in+ the skipped subtree, but that containment has a runtime kill switch and+ older pane layers only set `visibility: hidden` — which does NOT stop an+ animation. This keeps the original explicit guarantee ("N mounted tabs each+ ticking burns CPU for pixels nobody can see") independent of which of those+ is in play. */.glyph-spinner[data-paused='true'] .glyph-spinner__strip {animation-play-state: paused;}@@ -69,16 +93,17 @@/* The travel MUST be an absolute length, never a percentage. A percentagetranslate resolves against the strip's own box, so Chromium treats theanimation as layout-dependent and refuses to composite it — trace- instrumentation showed compositeFailed set on 184/184 records (codes- 131072 / 131104) with translateY(-100%), while a sibling transform- animation using an absolute length composited clean. N frames x the frame- height is the same distance, computed rather than box-relative. */+ instrumentation showed compositeFailed set on every record while the+ keyframes used translateY(-100%), and clean compositing on a sibling+ transform animation that travelled an absolute length (numbers in the PR).+ N frames x the frame height is the same distance, computed rather than+ box-relative. */@keyframes glyph-spinner-advance {from {transform: translateY(0);}to {- transform: translateY(calc(var(--glyph-spinner-frames) * -1 * var(--glyph-spinner-frame-height)));+ transform: translateY(calc(var(--glyph-spinner-frames, 10) * -1 * var(--glyph-spinner-frame-height, 1em)));}}diff --git a/apps/desktop/src/components/ui/glyph-spinner.test.tsx b/apps/desktop/src/components/ui/glyph-spinner.test.tsxindex 652a7aa263d..2ae3260cff2 100644--- a/apps/desktop/src/components/ui/glyph-spinner.test.tsx+++ b/apps/desktop/src/components/ui/glyph-spinner.test.tsx@@ -13,15 +13,13 @@// - the custom properties feeding `steps()` / duration match the source data,// so cadence per variant is preserved;// - no timer is ever created (the ticker is really gone);-// - the kept-alive-tab gate still resolves to a paused animation;-// - the strip is named in the global renderer-pause rule, which is what now-// delivers the window-blur / minimize / document-hidden suspension that-// this component used to implement itself via-// createRendererLoopPauseController. That mechanism has its own coverage in-// lib/renderer-loop-pause.test.ts.-import { readFileSync } from 'node:fs'-import { resolve } from 'node:path'-+// - the kept-alive-tab gate still resolves to a paused animation.+//+// The CSS itself is verified where it can actually run: e2e/glyph-spinner.spec.ts+// reads getComputedStyle / getAnimations in a real browser. Asserting on the+// text of the stylesheet from here would test the shape of the source rather+// than its behaviour (banned outright — see AGENTS.md), and did in fact break+// on a pure var()-fallback edit that changed no rendered pixel.import { render, screen } from '@testing-library/react'import { Profiler, type ProfilerOnRenderCallback } from 'react'import spinners from 'unicode-animations'@@ -156,38 +154,4 @@ describe('GlyphSpinner', () => {expect(viewport()?.hasAttribute('data-paused')).toBe(false)})- it('travels an absolute length, so the animation can be composited', () => {- // A percentage translate resolves against the strip's own box, which makes- // the animation layout-dependent and Chromium refuses to composite it:- // instrumentation recorded compositeFailed on 184/184 records while the- // keyframes used translateY(-100%). This guards the regression back to it,- // which is invisible in jsdom and subtle on screen.- const css = readFileSync(resolve(process.cwd(), 'src/components/ui/glyph-spinner.css'), 'utf8')- const keyframes = css.slice(css.indexOf('@keyframes glyph-spinner-advance'))-- expect(keyframes).not.toMatch(/translateY\(\s*-?\d+%/)- expect(keyframes).toContain('var(--glyph-spinner-frame-height)')- expect(css).toContain('will-change: transform')- })-- it('keeps the decorative strip out of text selection', () => {- // These sit inside [data-selectable-text] subtrees; without this a- // transcript copy would pick up all N glyphs of every spinner.- const css = readFileSync(resolve(process.cwd(), 'src/components/ui/glyph-spinner.css'), 'utf8')-- expect(css.slice(css.indexOf('.glyph-spinner {'), css.indexOf('.glyph-spinner__strip'))).toContain(- 'user-select: none'- )- })-- it('is wired into the global renderer-animation pause rule', () => {- // Window blur / minimize / document-hidden suspension now comes from this- // rule rather than from a per-spinner pause controller. Dropping the class- // from it would silently leave every spinner animating behind an inactive- // window — the CPU burn the original implementation existed to avoid.- const css = readFileSync(resolve(process.cwd(), 'src/styles.css'), 'utf8')- const pauseRule = css.slice(css.indexOf(':root[data-renderer-animations-paused]'))-- expect(pauseRule.slice(0, pauseRule.indexOf('animation-play-state'))).toContain('.glyph-spinner__strip')- })})diff --git a/apps/desktop/src/components/ui/glyph-spinner.tsx b/apps/desktop/src/components/ui/glyph-spinner.tsxindex 07a762d0645..0056a083e00 100644--- a/apps/desktop/src/components/ui/glyph-spinner.tsx+++ b/apps/desktop/src/components/ui/glyph-spinner.tsx@@ -13,6 +13,18 @@ interface NormalisedSpinner {interval: number}+/**+ * The two custom properties `glyph-spinner.css` reads off the strip to size+ * `steps()` and the cycle duration. Naming them in a type, rather than casting+ * the inline style with a bare `as CSSProperties`, makes a typo in a property+ * name a compile error instead of a silently dead declaration that falls back+ * to the braille defaults at runtime.+ */+export type GlyphSpinnerVars = CSSProperties & {+ '--glyph-spinner-duration': string+ '--glyph-spinner-frames': number+}+// Some spinners ship multi-character frames. Pull the first cell so each// frame fits in one monospace box — matches how the TUI uses them.const FRAMES_BY_NAME: Record<SpinnerName, NormalisedSpinner> = (() => {@@ -70,8 +82,16 @@ export function GlyphSpinner({// `:root[data-renderer-animations-paused]` rule in styles.css that// main.tsx's installRendererAnimationPauseState() drives — the same// mechanism every other continuous decorative animation already uses.+ // Note that only the primary window arms that attribute: a spinner mounted+ // in an overlay / quick / wake window keeps animating while its window is+ // blurred, exactly as the other decorative animations there do.const visible = usePaneVisible()+ const vars: GlyphSpinnerVars = {+ '--glyph-spinner-duration': `${spin.frames.length * spin.interval}ms`,+ '--glyph-spinner-frames': spin.frames.length+ }+return (<spanaria-label={ariaLabel}@@ -83,15 +103,7 @@ export function GlyphSpinner({implementation rewrote its text ~12x/second, which would announce anew glyph on every tick. */}<span aria-hidden="true" className="glyph-spinner" data-paused={paused || !visible ? 'true' : undefined}>- <span- className="glyph-spinner__strip"- style={- {- '--glyph-spinner-duration': `${spin.frames.length * spin.interval}ms`,- '--glyph-spinner-frames': spin.frames.length- } as CSSProperties- }- >+ <span className="glyph-spinner__strip" style={vars}>{spin.frames.map((frame, index) => (<span className="glyph-spinner__frame" key={`${index}:${frame}`}>{frame}