mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
* perf(renderer): avoid per-second spinner animation events * fix(bench): ensure the Electron runtime before bench:spinners The script launches Electron via Playwright but skipped ensure:electron-runtime, which every other Electron-launching bench script runs first. * docs(renderer): scope spinner pixel-tolerance claim to paused-animation checks --------- Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local> Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
60 lines
2.1 KiB
JavaScript
60 lines
2.1 KiB
JavaScript
export const spinnerVariants = {
|
|
original: `
|
|
@keyframes agent-spinner-rotate { to { transform: rotate(360deg); } }
|
|
.agent-working-spinner { animation-duration: 1s; animation-timing-function: steps(12, end); }
|
|
`,
|
|
long: '',
|
|
// Retain the rejected containment experiment for reproducible ablation.
|
|
contained:
|
|
'.spinner-benchmark-container { content-visibility: auto; overflow-clip-margin: var(--spacing); }'
|
|
}
|
|
|
|
export async function setSpinnerVariant(page, variant) {
|
|
if (!(variant in spinnerVariants)) {
|
|
throw new Error(`Unknown spinner variant: ${variant}`)
|
|
}
|
|
await page.evaluate((css) => {
|
|
for (const ring of document.querySelectorAll('[data-agent-spinner]')) {
|
|
ring.parentElement.classList.add('spinner-benchmark-container')
|
|
}
|
|
let style = document.getElementById('spinner-variant')
|
|
if (!style) {
|
|
style = document.createElement('style')
|
|
style.id = 'spinner-variant'
|
|
document.head.appendChild(style)
|
|
}
|
|
style.textContent = css
|
|
}, spinnerVariants[variant])
|
|
}
|
|
|
|
export async function spinnerCensus(page) {
|
|
return page.evaluate(() => {
|
|
const rings = [...document.querySelectorAll('[data-agent-spinner]')]
|
|
const inViewport = (ring) => {
|
|
// Querying the skipped child would force the rendering this census measures.
|
|
const rect = ring.parentElement.getBoundingClientRect()
|
|
if (rect.width === 0 || rect.height === 0) {
|
|
return false
|
|
}
|
|
let top = 0
|
|
let bottom = innerHeight
|
|
for (let parent = ring.parentElement; parent; parent = parent.parentElement) {
|
|
if (/(auto|scroll|hidden|clip)/.test(getComputedStyle(parent).overflowY)) {
|
|
const bounds = parent.getBoundingClientRect()
|
|
top = Math.max(top, bounds.top)
|
|
bottom = Math.min(bottom, bounds.bottom)
|
|
}
|
|
}
|
|
return rect.bottom > top && rect.top < bottom
|
|
}
|
|
return {
|
|
mounted: rings.length,
|
|
visible: rings.filter(inViewport).length,
|
|
workingSubagentRows: document.querySelectorAll(
|
|
'.worktree-agent-lineage-child-row [data-agent-spinner]'
|
|
).length,
|
|
documentVisibility: document.visibilityState
|
|
}
|
|
})
|
|
}
|