diff --git a/config/scripts/preflight/changed-checks/check-changed-selection.mjs b/config/scripts/preflight/changed-checks/check-changed-selection.mjs index 0129170270be..2cba286304aa 100644 --- a/config/scripts/preflight/changed-checks/check-changed-selection.mjs +++ b/config/scripts/preflight/changed-checks/check-changed-selection.mjs @@ -45,6 +45,7 @@ const RATCHET_INPUTS = { 'check-e2e-typecheck-ratchet.mjs': ['tests/', 'config/tsconfig.e2e.json'], 'check-focus-read-ratchet.mjs': ['src/renderer/src/', 'src/shared/'], 'check-host-list-render-ratchet.mjs': ['src/renderer/src/'], + 'check-visible-animation-ratchet.mjs': ['src/renderer/src/'], 'check-id-only-store-write-ratchet.mjs': ['src/main/persistence/'], 'check-layout-writer-ratchets.mjs': ['src/main/', 'src/renderer/src/'], // Both build the event-loop import graph, so anything that changes graph edges selects them. diff --git a/config/scripts/preflight/changed-checks/run-lint.mjs b/config/scripts/preflight/changed-checks/run-lint.mjs index 4582ec4736dc..2f857c719854 100644 --- a/config/scripts/preflight/changed-checks/run-lint.mjs +++ b/config/scripts/preflight/changed-checks/run-lint.mjs @@ -51,6 +51,7 @@ export const LINT_STEPS = [ 'check:node-runtime-pin', 'check:path-literal-ratchet', 'check:host-list-render-ratchet', + 'check:visible-animation-ratchet', 'verify:skill-bundle-manifest', 'check:reliability-gates', 'verify:bundled-skill-guides', diff --git a/config/scripts/static-analysis/ratchets/renderer-state/check-visible-animation-ratchet.mjs b/config/scripts/static-analysis/ratchets/renderer-state/check-visible-animation-ratchet.mjs new file mode 100644 index 000000000000..63d166eaddfd --- /dev/null +++ b/config/scripts/static-analysis/ratchets/renderer-state/check-visible-animation-ratchet.mjs @@ -0,0 +1,53 @@ +import process from 'node:process' +import { pathToFileURL } from 'node:url' +import { readTrackedSources, runCountRatchet } from '../../ratchet-baseline/ratchet-baseline.mjs' + +const SCAN_ROOT = 'src/renderer/src' +const BASELINE_PATH = 'config/visible-animation-baseline.txt' +const HEADER = [ + '# Raw spin/pulse class tokens in Electron renderer sources. Baseline: 0.', + '# Web-only entry points and mobile-page.css do not run in Electron UI windows.' +] +const RAW_ANIMATION = /(? 0) { + counts.set(rel, count) + } + } + return counts +} + +export function main(root = process.cwd(), arg = undefined) { + return runCountRatchet( + { + name: 'visible-animation', + baselinePath: BASELINE_PATH, + header: HEADER, + collect: collectVisibleAnimationCounts, + unit: 'raw spin/pulse class token(s)', + fix: [ + 'Use visible-animate-spin or visible-animate-pulse and attach observeVisibleAnimation', + 'to the same element. Preserve motion-safe and motion-reduce variants.' + ] + }, + root, + arg + ) +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + process.exit(main(process.cwd(), process.argv[2])) +} diff --git a/config/visible-animation-baseline.txt b/config/visible-animation-baseline.txt new file mode 100644 index 000000000000..5fb8b1456ea0 --- /dev/null +++ b/config/visible-animation-baseline.txt @@ -0,0 +1,2 @@ +# Raw spin/pulse class tokens in Electron renderer sources. Baseline: 0. +# Web-only entry points and mobile-page.css do not run in Electron UI windows. diff --git a/package.json b/package.json index 09e3d617b8b5..5fd8ec82edb4 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "check:max-lines-ratchet": "node config/scripts/static-analysis/ratchets/source-budget/check-max-lines-ratchet.mjs", "check:ts-nocheck-ratchet": "node config/scripts/static-analysis/ratchets/source-budget/check-ts-nocheck-ratchet.mjs", "check:host-list-render-ratchet": "node config/scripts/static-analysis/ratchets/renderer-state/check-host-list-render-ratchet.mjs", + "check:visible-animation-ratchet": "node config/scripts/static-analysis/ratchets/renderer-state/check-visible-animation-ratchet.mjs", "check:memo-translate-subscription-ratchet": "node config/scripts/static-analysis/ratchets/renderer-state/check-memo-translate-subscription-ratchet.mjs", "check:react-compiler-compat-ratchet": "node config/scripts/static-analysis/ratchets/react-compiler/check-react-compiler-compat-ratchet.mjs", "check:render-path-translate-ratchet": "node config/scripts/static-analysis/ratchets/renderer-state/check-render-path-translate-ratchet.mjs", diff --git a/src/main/window/createMainWindow.ts b/src/main/window/createMainWindow.ts index d185052e0414..fd844ef12c54 100644 --- a/src/main/window/createMainWindow.ts +++ b/src/main/window/createMainWindow.ts @@ -50,6 +50,7 @@ import { rectHasVisibleAreaOnAnyDisplay } from './presentation/window-bounds-val import { installWindowsPathRegistryChangeListener } from '../pty/environment/windows-path-registry-change' import { recordAgentSessionRuntimeEnd } from '../runtime/agent-session/records/agent-session-runtime-end-record' import { installNativeUnloadCoordinator } from './renderer-relays/native-unload-coordinator' +import { MAIN_THREAD_ANIMATION_ARGUMENTS } from './presentation/main-thread-animation-arguments' import { WEB_CONTENTS_MAX_LISTENERS_PER_EVENT } from './web-contents-listener-budget' export function loadMainWindow(mainWindow: BrowserWindow, observer?: MainWindowLoadObserver): void { @@ -165,6 +166,7 @@ export function createMainWindow( webviewTag: true, // Pass host identity at birth so the renderer has it before first snapshot, without waiting for IPC registration. additionalArguments: [ + ...MAIN_THREAD_ANIMATION_ARGUMENTS, formatBrowserClientHostIdArgument(getBrowserClientHostId()), ...(windowMaterial === 'off' ? [] : [formatWindowMaterialArgument(windowMaterial)]), ...(pumpHiddenFrames ? [formatHiddenWindowFramePumpArgument()] : []), diff --git a/src/main/window/dashboard-popout-window.ts b/src/main/window/dashboard-popout-window.ts index 11dff8a9a93b..645cdecef062 100644 --- a/src/main/window/dashboard-popout-window.ts +++ b/src/main/window/dashboard-popout-window.ts @@ -21,6 +21,7 @@ import type { KeybindingOverrides } from '../../shared/keybindings/types' import { wslHostsWindowArguments } from '../wsl/host-lifecycle/wsl-host-gate' +import { MAIN_THREAD_ANIMATION_ARGUMENTS } from './presentation/main-thread-animation-arguments' import { isMacAppPasteInput } from './editing/mac-app-paste-input' const MIN_WIDTH = 480 @@ -168,7 +169,7 @@ export function createOrFocusDashboardPopout( partition: DASHBOARD_POPOUT_PARTITION, // No webviews run here; disable embedding and omit host identity so client-placed pages stay mirrors. webviewTag: false, - ...(wslArguments.length > 0 ? { additionalArguments: wslArguments } : {}) + additionalArguments: [...MAIN_THREAD_ANIMATION_ARGUMENTS, ...wslArguments] } }) installPrivilegedWindowNavigationPolicy(window.webContents) diff --git a/src/main/window/presentation/main-thread-animation-arguments.ts b/src/main/window/presentation/main-thread-animation-arguments.ts new file mode 100644 index 000000000000..3e1b3d9acb73 --- /dev/null +++ b/src/main/window/presentation/main-thread-animation-arguments.ts @@ -0,0 +1,3 @@ +// A compositor animation ticking through a multi-second main-thread task wedges Chromium's frame sorter, +// pinning a compositor core until the window hides (#14882); main-thread animations pause with the task. +export const MAIN_THREAD_ANIMATION_ARGUMENTS: readonly string[] = ['--disable-threaded-animation'] diff --git a/src/main/window/workspace-space-window.ts b/src/main/window/workspace-space-window.ts index 4c141e9c7809..d1eed2170cae 100644 --- a/src/main/window/workspace-space-window.ts +++ b/src/main/window/workspace-space-window.ts @@ -13,6 +13,7 @@ import { type UIZoomDirection } from '../../shared/app-lifecycle/windows/ui-zoom-level' import { wslHostsWindowArguments } from '../wsl/host-lifecycle/wsl-host-gate' +import { MAIN_THREAD_ANIMATION_ARGUMENTS } from './presentation/main-thread-animation-arguments' let spaceWindow: BrowserWindow | null = null @@ -67,7 +68,7 @@ export function createOrFocusWorkspaceSpaceWindow(store: Store): BrowserWindow { sandbox: true, partition: 'orca-workspace-space-window', webviewTag: false, - ...(wslArguments.length > 0 ? { additionalArguments: wslArguments } : {}) + additionalArguments: [...MAIN_THREAD_ANIMATION_ARGUMENTS, ...wslArguments] } }) spaceWindow = window diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 18d0d2a384c1..7c58e5e9bda2 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -2189,7 +2189,7 @@ html.native-shell .app-layout { grid-template-rows: 1fr; } -/* Keep rotation on the compositor: JS style writes caused typing stalls (#12359). */ +/* Keep rotation in CSS: JS style writes caused typing stalls (#12359). */ /* One day per iteration avoids per-second React animation events; still 12 steps/second. */ @keyframes agent-spinner-rotate { to { @@ -2198,7 +2198,44 @@ html.native-shell .app-layout { } .agent-working-spinner { - animation: agent-spinner-rotate 86400s steps(1036800, end) infinite; + animation: none; + + &[data-animation-running] { + animation: agent-spinner-rotate 86400s steps(1036800, end) infinite; + } +} + +@utility visible-animate-spin { + animation: var(--animate-spin); + animation-play-state: paused; + + &[data-animation-running] { + animation-play-state: running; + } +} + +@utility visible-animate-pulse { + animation: var(--animate-pulse); + animation-play-state: paused; + + &[data-animation-running] { + animation-play-state: running; + } +} + +/* Retained hidden surfaces keep guest paint but need no CSS animation frames; pseudo-elements don't inherit play state. */ +[data-retained-animation-paused], +[data-retained-animation-paused]::before, +[data-retained-animation-paused]::after, +[data-retained-animation-paused] *, +[data-retained-animation-paused] *::before, +[data-retained-animation-paused] *::after { + animation-play-state: paused !important; +} + +/* Rings drop their animation instead of pausing so the restart re-anchors the shared phase. */ +[data-retained-animation-paused] .agent-working-spinner { + animation: none !important; } /* Offscreen subtrees pause their loops; the agent ring drops its animation instead so reveal re-anchors phase. */ @@ -2212,7 +2249,8 @@ html.native-shell .app-layout { } @media (prefers-reduced-motion: reduce) { - .agent-working-spinner { + .agent-working-spinner, + .agent-working-spinner[data-animation-running] { animation: none; } } @@ -4255,6 +4293,63 @@ body:has([data-contextual-tour-target='tab-create-menu'][data-state='open']) opacity: 0; } +/* Electron reports no load percentage, so the line eases toward 90% and the real stop finishes it. + CSS rather than script animation so retained hidden pages pause it like every other loop. */ +@keyframes browser-load-trickle { + 0% { + transform: scaleX(0); + opacity: 0; + animation-timing-function: ease-out; + } + 1% { + transform: scaleX(0.15); + opacity: 1; + animation-timing-function: ease-out; + } + 6.667% { + transform: scaleX(0.45); + opacity: 1; + animation-timing-function: ease-out; + } + 20% { + transform: scaleX(0.7); + opacity: 1; + animation-timing-function: ease-out; + } + 50% { + transform: scaleX(0.85); + opacity: 1; + animation-timing-function: ease-out; + } + 100% { + transform: scaleX(0.9); + opacity: 1; + } +} + +/* Reduced motion: a still, dimmed full-width line that still reads as "working". */ +@keyframes browser-load-still { + from { + transform: scaleX(1); + opacity: 0; + } + to { + transform: scaleX(1); + opacity: 0.5; + } +} + +/* The delay keeps fast loads (most local dev servers) from showing anything. */ +.browser-load-progress[data-browser-load-progress='loading'] { + animation: browser-load-trickle 30s linear 200ms forwards; +} + +@media (prefers-reduced-motion: reduce) { + .browser-load-progress[data-browser-load-progress='loading'] { + animation: browser-load-still 150ms linear 200ms forwards; + } +} + /* While an agent drives the page, a soft inner glow breathes at its edge. */ .browser-agent-cursor-layer::before { content: ''; diff --git a/src/renderer/src/components/activity/terminal-portal/activity-thread-detail-pane.tsx b/src/renderer/src/components/activity/terminal-portal/activity-thread-detail-pane.tsx index 3d67b470cc3b..84f5ee743bf0 100644 --- a/src/renderer/src/components/activity/terminal-portal/activity-thread-detail-pane.tsx +++ b/src/renderer/src/components/activity/terminal-portal/activity-thread-detail-pane.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { MessageSquareText, TerminalSquare } from 'lucide-react' import { AgentTypeIcon } from '@/components/agent/icons/agent-type-icon' @@ -123,7 +124,10 @@ export function ActivityThreadDetailPane({ ) : showTerminalLoadingLabel ? (
- + {t( 'auto.components.activity.ActivityPrototypePage.1b633f5c1e', diff --git a/src/renderer/src/components/agent-cli-update/AgentCliUpdateButton.tsx b/src/renderer/src/components/agent-cli-update/AgentCliUpdateButton.tsx index 6b10cc8978f1..79a65415f341 100644 --- a/src/renderer/src/components/agent-cli-update/AgentCliUpdateButton.tsx +++ b/src/renderer/src/components/agent-cli-update/AgentCliUpdateButton.tsx @@ -7,6 +7,7 @@ import { useTranslate } from '@/i18n/use-translate' import type { AgentDetectionTarget } from '@/lib/agent-session/launch/inventory/useDetectedAgents' import { agentCliUpdateHostTarget } from '@/store/slices/runtime-host-updates/agent-cli-updates' import { useAgentCliUpdate } from './use-agent-cli-update' +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { AgentCliUpdateFailedChip } from './AgentCliUpdateFailedChip' // WSL distros and direct SSH hosts aren't checked; Orca's own server there would run the update. @@ -64,7 +65,9 @@ export function AgentCliUpdateButton({ disabled={running} onClick={() => void start()} > - {running ? : null} + {running ? ( + + ) : null} {running ? t('agentCliUpdate.updating', 'Updating…') : t('agentCliUpdate.update', 'Update')} diff --git a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx index 4dfc1bfe99c4..d1644a546e02 100644 --- a/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx +++ b/src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useAgentPickerDraftScope } from '../agent/AgentLaunchSetupButton' import { agentsOfferedForLaunch } from '@/lib/agent-session/launch/inventory/host-chat-program' import { worktreeLaunchWorkspace } from '@/lib/agent-session/launch/routing/agent-launch-route-input' @@ -377,7 +378,9 @@ export function AgentSessionContinuationDialog({ disabled={startDisabled} onClick={() => void handleStart()} > - {showStarting ? : null} + {showStarting ? ( + + ) : null} {starting ? t('components.agentSessionContinuation.starting', 'Starting…') : t('components.agentSessionContinuation.startSessionSentence', 'Start session')} diff --git a/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx b/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx index 56ce94ad0e53..866b13335c35 100644 --- a/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx +++ b/src/renderer/src/components/agent/status/AgentWorkingSpinner.tsx @@ -1,6 +1,9 @@ import React from 'react' import { cn } from '@/lib/class-names' -import { observeOffscreenAnimation } from '@/lib/window-activity/offscreen-animation-pause' +import { + observeOffscreenAnimation, + observeVisibleAnimation +} from '@/lib/window-activity/offscreen-animation-pause' const SPINNER_ANIMATION_NAME = 'agent-spinner-rotate' @@ -17,7 +20,11 @@ function syncSpinnerPhase(el: HTMLSpanElement | null): void { 'animationName' in candidate && candidate.animationName === SPINNER_ANIMATION_NAME ) if (animation !== undefined) { - animation.startTime = 0 + if (animation.playState === 'paused') { + animation.currentTime = animation.timeline?.currentTime ?? 0 + } else { + animation.startTime = 0 + } } } @@ -27,12 +34,17 @@ function handleSpinnerAnimationStart(event: React.AnimationEvent void { - return observeOffscreenAnimation(el) + const stopOffscreen = observeOffscreenAnimation(el) + const stopVisible = observeVisibleAnimation(el) + return () => { + stopOffscreen() + stopVisible() + } } -// CSS compositor rotation avoids JS input-thread work; callers provide size. +// CSS rotation avoids JS style writes; callers provide size. export function AgentWorkingSpinner({ className }: { className?: string }): React.JSX.Element { return ( - {deleting ? : } + {deleting ? ( + + ) : ( + + )} diff --git a/src/renderer/src/components/artifacts/ArtifactCollection.tsx b/src/renderer/src/components/artifacts/ArtifactCollection.tsx index 564400b5542a..663501c0ecba 100644 --- a/src/renderer/src/components/artifacts/ArtifactCollection.tsx +++ b/src/renderer/src/components/artifacts/ArtifactCollection.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useMemo, useState } from 'react' import { Loader2 } from 'lucide-react' import type { ArtifactListItem } from '../../../../shared/artifacts/artifacts' @@ -81,7 +82,9 @@ export function ArtifactCollection({ disabled={loadingMore} onClick={loadMore} > - {loadingMore ? : null} + {loadingMore ? ( + + ) : null} {t('auto.components.artifacts.ArtifactCollection.loadMore', 'Load more')}
diff --git a/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx b/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx index 85680aac4ff0..54c7eb3c7ebc 100644 --- a/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx +++ b/src/renderer/src/components/artifacts/ArtifactListToolbar.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' @@ -36,7 +37,10 @@ export function ArtifactListToolbar({ disabled={isRefreshing} className="shrink-0 border border-border bg-background shadow-none hover:bg-muted/50" > - + diff --git a/src/renderer/src/components/artifacts/ArtifactPreview.tsx b/src/renderer/src/components/artifacts/ArtifactPreview.tsx index 02c52a5923b6..6e18e35f89d3 100644 --- a/src/renderer/src/components/artifacts/ArtifactPreview.tsx +++ b/src/renderer/src/components/artifacts/ArtifactPreview.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useEffect, useRef, useState } from 'react' import { AlertCircle, Loader2 } from 'lucide-react' import { ORCA_BROWSER_GUEST_WEB_PREFERENCES_ATTRIBUTE } from '../../../../shared/browser/guest-lifecycle/browser-guest-web-preferences' @@ -146,7 +147,10 @@ export function ArtifactPreview({ shareUrl }: { shareUrl: string }): React.JSX.E > {state === 'loading' ? (
- +
) : null} {state === 'unavailable' ? ( diff --git a/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx b/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx index 40880cab485f..d245a4b66c7f 100644 --- a/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx +++ b/src/renderer/src/components/artifacts/ArtifactPublishButton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useEffect, useRef, useState, type RefObject } from 'react' import { ArrowRight, Loader2, Share2 } from 'lucide-react' import type { ArtifactWriteRequest } from '../../../../shared/artifacts/artifacts' @@ -143,7 +144,11 @@ export function ArtifactPublishButton({ disabled={blocked} aria-label={label} > - {publishing ? : } + {publishing ? ( + + ) : ( + + )} @@ -255,7 +260,7 @@ export function ArtifactPublishButton({ {checkingLink ? (
- + {t( 'auto.components.artifacts.ArtifactPublishButton.checkingLink', 'Checking for an existing link…' @@ -295,7 +300,11 @@ export function ArtifactPublishButton({ disabled={!signedIn || !sharingEnabled || busy} onClick={() => void publish()} > - {publishing ? : } + {publishing ? ( + + ) : ( + + )} {publishing ? t('auto.components.artifacts.ArtifactPublishButton.sharing', 'Sharing…') : t( diff --git a/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx b/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx index a37b18b1aa37..b46e9dce5451 100644 --- a/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx +++ b/src/renderer/src/components/artifacts/ArtifactPublishedLinkPanel.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { useCallback, useRef, useState } from 'react' import { Check, Copy, ExternalLink, Loader2, RefreshCw } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -136,7 +137,10 @@ export function ArtifactPublishedLinkPanel({ )} aria-hidden={!publishing} > - + {t('auto.components.artifacts.ArtifactPublishedLinkPanel.updating', 'Updating…')} diff --git a/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx b/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx index 663f3299a9ab..16d5c828ec8f 100644 --- a/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx +++ b/src/renderer/src/components/artifacts/ArtifactsPageSkeleton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { cn } from '@/lib/class-names' import { useTranslate } from '@/i18n/use-translate' import { ARTIFACTS_TABLE_GRID_CLASS } from './artifacts-table-layout' @@ -7,7 +8,12 @@ import { } from '@/lib/list-interaction/list-table-layout' function SkeletonBar({ className }: { className?: string }): React.JSX.Element { - return
+ return ( +
+ ) } const TABLE_ROW_SKELETONS = [ diff --git a/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx b/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx index b063593256c6..77ffcbe13945 100644 --- a/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx +++ b/src/renderer/src/components/artifacts/ArtifactsPageStates.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import { ArrowRight, Files, Loader2 } from 'lucide-react' import { Button } from '@/components/ui/button' import { useTranslate } from '@/i18n/use-translate' @@ -153,7 +154,9 @@ export function ArtifactsPageEmptyState({ disabled={loadingMore} onClick={onLoadMore} > - {loadingMore ? : null} + {loadingMore ? ( + + ) : null} {t('auto.components.artifacts.ArtifactCollection.loadMore', 'Load more')} ) : null} diff --git a/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx b/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx index 4007f7a5c2fb..ecfa91412695 100644 --- a/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx +++ b/src/renderer/src/components/automations/AutomationsPageSkeleton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { cn } from '@/lib/class-names' import { automationsTableGridClass } from './listing/automations-table-layout' @@ -10,7 +11,12 @@ import { import { useTranslate } from '@/i18n/use-translate' function SkeletonBar({ className }: { className?: string }): React.JSX.Element { - return
+ return ( +
+ ) } const TABLE_ROW_SKELETONS = [ diff --git a/src/renderer/src/components/automations/details/AutomationDetailActions.tsx b/src/renderer/src/components/automations/details/AutomationDetailActions.tsx index 4b3f0bdd492c..0714fb9dd70c 100644 --- a/src/renderer/src/components/automations/details/AutomationDetailActions.tsx +++ b/src/renderer/src/components/automations/details/AutomationDetailActions.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { Loader2, MoreHorizontal, Pause, Pencil, Play, Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -70,7 +71,7 @@ export function AutomationDetailActions({ aria-busy={isRunNowPending || undefined} > {isRunNowPending ? ( - + ) : ( )} diff --git a/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx b/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx index 33dd629245e3..ea66c05b07d9 100644 --- a/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx +++ b/src/renderer/src/components/automations/details/AutomationDetailHealth.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { cn } from '@/lib/class-names' import type { Automation } from '../../../../../shared/automations/automation-definition' @@ -38,6 +39,7 @@ function HealthCell({ > {showDot ? (
{loading && entries.length === 0 ? (
- + {t('auto.components.automations.AutomationRunsDashboard.loading', 'Loading runs…')}
) : entries.length === 0 ? ( diff --git a/src/renderer/src/components/bots/BotAvatar.tsx b/src/renderer/src/components/bots/BotAvatar.tsx index 9c0dc8629dae..d8dfd0d44bc4 100644 --- a/src/renderer/src/components/bots/BotAvatar.tsx +++ b/src/renderer/src/components/bots/BotAvatar.tsx @@ -10,14 +10,17 @@ import { BOT_MASCOT_URLS } from './bot-mascots' export function BotAvatar({ bot, className, - style + style, + ref }: { bot: Pick & BotOnHost className?: string style?: React.CSSProperties + ref?: React.Ref }): React.JSX.Element { return ( }): React.JSX.Element { return ( + return ( + + ) } return ( diff --git a/src/renderer/src/components/bots/BotConnectorsHostNotice.tsx b/src/renderer/src/components/bots/BotConnectorsHostNotice.tsx index a501c89fef11..58b33081ce1b 100644 --- a/src/renderer/src/components/bots/BotConnectorsHostNotice.tsx +++ b/src/renderer/src/components/bots/BotConnectorsHostNotice.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // The one notice above a server bot's connectors: why Slack, Linear and GitHub aren't reaching it // and how to fix that from here. A bot on this computer keeps its own sign-in notice. import React from 'react' @@ -121,7 +122,10 @@ function SignInWaiting({ return (

- + {firstSignIn ? t( diff --git a/src/renderer/src/components/bots/BotCreateButton.tsx b/src/renderer/src/components/bots/BotCreateButton.tsx index 87073a2a7320..00a47193711c 100644 --- a/src/renderer/src/components/bots/BotCreateButton.tsx +++ b/src/renderer/src/components/bots/BotCreateButton.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // New bot's primary action, drawn like Create worktree's: spinner while busy, label, ⌘↩ hint. import React from 'react' import { LoaderCircle } from 'lucide-react' @@ -14,7 +15,9 @@ export function BotCreateButton({ }): React.JSX.Element { return ( ) : ( - + {label} ) diff --git a/src/renderer/src/components/bots/BotUpcomingRows.tsx b/src/renderer/src/components/bots/BotUpcomingRows.tsx index cf76e3598fbf..af3055635138 100644 --- a/src/renderer/src/components/bots/BotUpcomingRows.tsx +++ b/src/renderer/src/components/bots/BotUpcomingRows.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // The Automations card's rows: Look around, Tidy memory, automations and waits, each with its switch // (waits: Cancel) and how its newest run went. import { useMemo, useState } from 'react' @@ -159,7 +160,11 @@ function LookAroundRow({ disabled={looking} onClick={lookNowClicked} > - {looking ? : } + {looking ? ( + + ) : ( + + )} ) : null} diff --git a/src/renderer/src/components/bots/BotWhoCanAskInsetList.tsx b/src/renderer/src/components/bots/BotWhoCanAskInsetList.tsx index 8d1c2dd70fef..e0125da879db 100644 --- a/src/renderer/src/components/bots/BotWhoCanAskInsetList.tsx +++ b/src/renderer/src/components/bots/BotWhoCanAskInsetList.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // Who can ask, as one list of real people: requests waiting first (their actions under the full // name), the owner, the people added (✕ on hover), and Add people last. import React from 'react' @@ -119,7 +120,11 @@ export function BotWhoCanAskInsetList({ )} > - {saving ? : } + {saving ? ( + + ) : ( + + )} {t('bots.whoCanAsk.addPeople', 'Add people')} diff --git a/src/renderer/src/components/bots/BotWhoCanAskList.tsx b/src/renderer/src/components/bots/BotWhoCanAskList.tsx index d59edbf301f8..f78a589856cd 100644 --- a/src/renderer/src/components/bots/BotWhoCanAskList.tsx +++ b/src/renderer/src/components/bots/BotWhoCanAskList.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { Loader2, Plus, TriangleAlert, Undo2 } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -158,7 +159,11 @@ export function BotWhoCanAskList({ : undefined } > - {saving ? : } + {saving ? ( + + ) : ( + + )} {t('bots.whoCanAsk.add', 'Add')} diff --git a/src/renderer/src/components/bots/apps/BotAppComposio.tsx b/src/renderer/src/components/bots/apps/BotAppComposio.tsx index 5de736e86321..dbf2d060f9a9 100644 --- a/src/renderer/src/components/bots/apps/BotAppComposio.tsx +++ b/src/renderer/src/components/bots/apps/BotAppComposio.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // Add to 's Composio parts: the curated section under All apps, the full catalog behind // "Browse all Composio apps" (read with the owner's key), and the With Composio search group. import React from 'react' @@ -70,7 +71,7 @@ function ComposioAppItem({ } else if (pending) { action = ( ) diff --git a/src/renderer/src/components/bots/apps/BotAppStepParts.tsx b/src/renderer/src/components/bots/apps/BotAppStepParts.tsx index 5a30fc510af6..d91747c090d9 100644 --- a/src/renderer/src/components/bots/apps/BotAppStepParts.tsx +++ b/src/renderer/src/components/bots/apps/BotAppStepParts.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // The pieces every Add to step is drawn from: its header, a form's heading, and the centred // outcome screens (finish in your browser, couldn't sign in, added). import React from 'react' @@ -80,7 +81,10 @@ export function BotAppLogoBadge({ )} > {kind === 'waiting' ? ( - + ) : ( - + {line} } diff --git a/src/renderer/src/components/bots/connector-connect-parts.tsx b/src/renderer/src/components/bots/connector-connect-parts.tsx index a57dc68fb4f5..8fee81d24307 100644 --- a/src/renderer/src/components/bots/connector-connect-parts.tsx +++ b/src/renderer/src/components/bots/connector-connect-parts.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React, { useEffect, useId, useState } from 'react' import { ExternalLink, Loader2, Plus } from 'lucide-react' import { Badge } from '@/components/ui/badge' @@ -42,7 +43,7 @@ export function ConnectWaiting({ role="status" className="flex min-w-0 flex-1 items-center gap-2 text-sm text-muted-foreground" > - + {label}

{action ?? ( diff --git a/src/renderer/src/components/bots/github/BotGitHubSetupDialog.tsx b/src/renderer/src/components/bots/github/BotGitHubSetupDialog.tsx index 5d7825750821..ad5239d439c7 100644 --- a/src/renderer/src/components/bots/github/BotGitHubSetupDialog.tsx +++ b/src/renderer/src/components/bots/github/BotGitHubSetupDialog.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React, { useEffect, useState } from 'react' import { ExternalLink, Loader2, Lock } from 'lucide-react' import { toast } from 'sonner' @@ -230,7 +231,7 @@ function BotGitHubSetupFlow({ case 'checking': return (

- + {t('bots.github.setup.checking', 'Checking GitHub…')}

) @@ -308,7 +309,7 @@ function BotGitHubSetupFlow({ ) : awaiting ? (

- + {t( 'bots.github.setup.installing', 'Waiting for the install, or for an owner of the organization to approve…' diff --git a/src/renderer/src/components/bots/github/github-install-trip.tsx b/src/renderer/src/components/bots/github/github-install-trip.tsx index 28809a347482..b43162caa251 100644 --- a/src/renderer/src/components/bots/github/github-install-trip.tsx +++ b/src/renderer/src/components/bots/github/github-install-trip.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' import React from 'react' import { BookMarked, Check, ExternalLink, Loader2 } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -175,7 +176,7 @@ export function GitHubInstalledRepositories({ ) : githubAwait === 'checking' ? (

- + {t('bots.github.setup.checkingInstalls', 'Checking GitHub for changes…')}

) : githubAwait === 'unchanged' ? ( diff --git a/src/renderer/src/components/bots/google/setup-cards/GoogleSetupProgressCards.tsx b/src/renderer/src/components/bots/google/setup-cards/GoogleSetupProgressCards.tsx index dcd21943aae2..0d7296269a58 100644 --- a/src/renderer/src/components/bots/google/setup-cards/GoogleSetupProgressCards.tsx +++ b/src/renderer/src/components/bots/google/setup-cards/GoogleSetupProgressCards.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // The live step list, and the card for a step the person does. Neither posts a chat message: Done, // "Take over from here" and "Let me do this one" are card answers the bot reads. import React, { useCallback, useState } from 'react' @@ -171,7 +172,11 @@ export function GoogleSetupProgressCard({ state ? ( {state === working ? ( - + ) : null} {state} @@ -299,7 +304,11 @@ export function GoogleSetupStepCard({ trailing={ watching ? ( - + {t('bots.googleSetup.step.watching', 'Watching the page')} ) : null diff --git a/src/renderer/src/components/bots/linear/BotLinearSetupFlow.tsx b/src/renderer/src/components/bots/linear/BotLinearSetupFlow.tsx index 3b2908be08f2..116a196b5c88 100644 --- a/src/renderer/src/components/bots/linear/BotLinearSetupFlow.tsx +++ b/src/renderer/src/components/bots/linear/BotLinearSetupFlow.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // @protected-copy: drawn inside the security-surface setup dialog // The steps of "Add to Linear" inside its dialog: sign in, pick a workspace, install, turn on. import React, { useEffect, useState } from 'react' @@ -214,7 +215,7 @@ export function BotLinearSetupFlow({ case 'checking': return (

- + {t('bots.linear.setup.checking', 'Checking Linear…')}

) @@ -307,7 +308,7 @@ export function BotLinearSetupFlow({

{linearAwait === 'checking' ? (

- + {t('bots.linear.setup.installing', 'Waiting for the install…')}

) : linearAwait === 'unchanged' ? ( diff --git a/src/renderer/src/components/bots/orca-cloud-sign-in.tsx b/src/renderer/src/components/bots/orca-cloud-sign-in.tsx index 393b2017e882..88c06b0a9b85 100644 --- a/src/renderer/src/components/bots/orca-cloud-sign-in.tsx +++ b/src/renderer/src/components/bots/orca-cloud-sign-in.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // The one way a bot surface asks for Orca sign-in before an Orca Cloud feature: a reason, Sign in that // opens the browser right away, then the action the owner started carries on in the same place. import React, { useState } from 'react' @@ -51,7 +52,7 @@ function SignInButton({
@@ -233,7 +236,11 @@ export function Footer({ ) primary = ( ) @@ -246,7 +253,11 @@ export function Footer({ ) primary = ( diff --git a/src/renderer/src/components/bots/slack/BotSlackSetupDialog.tsx b/src/renderer/src/components/bots/slack/BotSlackSetupDialog.tsx index 408587580f28..1863b21625e9 100644 --- a/src/renderer/src/components/bots/slack/BotSlackSetupDialog.tsx +++ b/src/renderer/src/components/bots/slack/BotSlackSetupDialog.tsx @@ -1,3 +1,4 @@ +import { observeVisibleAnimation } from '@/lib/window-activity/offscreen-animation-pause' // @protected-copy: drawn inside the security-surface setup dialog import React, { useEffect, useId, useState } from 'react' import { Loader2 } from 'lucide-react' @@ -111,7 +112,7 @@ function BotSlackSetupFlow({ case 'setting-up': { const status = (

- + {step.kind === 'checking' ? t('bots.slack.setup.checking', 'Checking Slack…') : t('bots.slack.setup.settingUp', 'Setting up your Slack app…')} @@ -217,7 +218,7 @@ function BotSlackSetupFlow({ return (

- + {t('bots.slack.setup.waiting', 'Waiting for Slack…')}

{hostName && step.link ? ( diff --git a/src/renderer/src/components/browser-pane/assemble-chrome/BrowserPaneOverlayLayer.tsx b/src/renderer/src/components/browser-pane/assemble-chrome/BrowserPaneOverlayLayer.tsx index b6838b5c12d5..7dfd18ff0492 100644 --- a/src/renderer/src/components/browser-pane/assemble-chrome/BrowserPaneOverlayLayer.tsx +++ b/src/renderer/src/components/browser-pane/assemble-chrome/BrowserPaneOverlayLayer.tsx @@ -104,6 +104,7 @@ const BrowserOverlaySlot = memo(function BrowserOverlaySlot({ // Clip without scrolling: a squeezed toolbar must neither cover the divider nor slide when a hidden control takes focus. className="relative flex min-h-0 flex-1 flex-col overflow-clip" data-browser-overlay-tab-id={browserTab.id} + data-retained-animation-paused={!isActive ? '' : undefined} onPointerDown={handleFocus} onFocusCapture={handleFocus} > diff --git a/src/renderer/src/components/browser-pane/assemble-chrome/address-bar/browser-load-progress.tsx b/src/renderer/src/components/browser-pane/assemble-chrome/address-bar/browser-load-progress.tsx index 383ed54e6a84..a052c8d3efcf 100644 --- a/src/renderer/src/components/browser-pane/assemble-chrome/address-bar/browser-load-progress.tsx +++ b/src/renderer/src/components/browser-pane/assemble-chrome/address-bar/browser-load-progress.tsx @@ -1,32 +1,7 @@ -import { useEffect, useRef } from 'react' -import { usePrefersReducedMotion } from '@/hooks/theme/usePrefersReducedMotion' +import { useLayoutEffect, useRef } from 'react' -// Why a delay: loads that finish sooner (most local dev servers) should show nothing at all. -const SHOW_DELAY_MS = 200 -const TRICKLE_MS = 30_000 -const TRICKLE_ID = 'browser-load-trickle' -const STILL_ID = 'browser-load-still' - -// Electron reports no load percentage, so the line eases toward 90% and the real stop finishes it. -const TRICKLE_STEPS: [atMs: number, scale: number][] = [ - [0, 0], - [300, 0.15], - [2_000, 0.45], - [6_000, 0.7], - [15_000, 0.85], - [TRICKLE_MS, 0.9] -] -const TRICKLE_KEYFRAMES: Keyframe[] = TRICKLE_STEPS.map(([atMs, scale]) => ({ - offset: atMs / TRICKLE_MS, - transform: `scaleX(${scale})`, - opacity: atMs === 0 ? 0 : 1, - easing: 'ease-out' -})) -// Reduced motion: a still, dimmed full-width line that still reads as "working". -const STILL_KEYFRAMES: Keyframe[] = [ - { transform: 'scaleX(1)', opacity: 0 }, - { transform: 'scaleX(1)', opacity: 0.5 } -] +const LOADING = 'loading' +const IDLE = 'idle' /** A thin line along the bottom edge of the address bar while the page loads. */ export function BrowserLoadProgress({ @@ -37,41 +12,38 @@ export function BrowserLoadProgress({ failed: boolean }): React.JSX.Element { const barRef = useRef(null) - const reducedMotion = usePrefersReducedMotion() - useEffect(() => { + // Why imperative: the finish fade must read the trickle's last frame before its CSS animation is removed. + useLayoutEffect(() => { const bar = barRef.current if (!bar) { return } - const animations = bar.getAnimations() - const running = animations.find(({ id }) => id === TRICKLE_ID || id === STILL_ID) + const wasLoading = bar.dataset.browserLoadProgress === LOADING if (loading) { - const id = reducedMotion ? STILL_ID : TRICKLE_ID - // Why: a navigation that replaces one in flight keeps loading true, so the line carries on. - if (running?.id === id) { - return - } - animations.forEach((animation) => animation.cancel()) - // Hold slow loads at the final frame without ongoing per-frame work, including hidden tabs. - bar.animate(reducedMotion ? STILL_KEYFRAMES : TRICKLE_KEYFRAMES, { - id, - duration: reducedMotion ? 150 : TRICKLE_MS, - // A motion-preference switch mid-load swaps the animation without hiding it again. - delay: running ? 0 : SHOW_DELAY_MS, - fill: 'forwards' + // A finish fade from the previous load gives way to the new trickle. + bar.getAnimations().forEach((animation) => { + if (!(animation instanceof CSSAnimation)) { + animation.cancel() + } }) + bar.dataset.browserLoadProgress = LOADING return } - if (!running) { + if (!wasLoading) { return } const { transform, opacity } = getComputedStyle(bar) - running.cancel() - // Still inside the show delay: the load was fast enough to show nothing. - if (Number(opacity) === 0) { + // Still inside the show delay, or on a retained hidden page: nothing to fade. + const showsFade = + Number(opacity) > 0 && + document.visibilityState === 'visible' && + bar.checkVisibility({ opacityProperty: true, visibilityProperty: true }) + bar.dataset.browserLoadProgress = IDLE + if (!showsFade) { return } + const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches // Why: a failed load fades where it stopped instead of filling up like a success. const end = failed || reducedMotion ? transform : 'scaleX(1)' bar.animate( @@ -82,12 +54,17 @@ export function BrowserLoadProgress({ ], { duration: 450, easing: 'ease-out' } ) - }, [failed, loading, reducedMotion]) + }, [failed, loading]) - useEffect(() => { + useLayoutEffect(() => { const bar = barRef.current - // Why: an animation outlives its removed element and keeps ticking until cancelled. - return () => bar?.getAnimations().forEach((animation) => animation.cancel()) + // Why: a script animation outlives its removed element and keeps ticking until cancelled. + return () => + bar?.getAnimations().forEach((animation) => { + if (!(animation instanceof CSSAnimation)) { + animation.cancel() + } + }) }, []) return ( @@ -97,8 +74,8 @@ export function BrowserLoadProgress({ >
) diff --git a/src/renderer/src/components/browser-pane/assemble-chrome/browser-page-pane.tsx b/src/renderer/src/components/browser-pane/assemble-chrome/browser-page-pane.tsx index d5ed2118dcdf..df1efe1036bd 100644 --- a/src/renderer/src/components/browser-pane/assemble-chrome/browser-page-pane.tsx +++ b/src/renderer/src/components/browser-pane/assemble-chrome/browser-page-pane.tsx @@ -305,6 +305,7 @@ export function BrowserPagePane({ return (