Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

2.1 KB
Raw Blame
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
    }
  })
}