Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(signals): drop the hidden label node from each scout run box (#109281)

posthog[bot]14a4e555396d
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx
index 129a3b20a5b2..b15753e25df1 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.test.tsx
@@ -39,7 +39,9 @@ describe('ScoutRunBoxes', () => {
/>
)
- const labels = Array.from(container.querySelectorAll('.sr-only')).map((node) => node.textContent ?? '')
+ const labels = Array.from(container.querySelectorAll('[aria-label]')).map(
+ (node) => node.getAttribute('aria-label') ?? ''
+ )
expect(labels.filter((label) => label.includes('$4.03'))).toHaveLength(1)
expect(labels.filter((label) => label.includes('$'))).toHaveLength(1)
})
@@ -66,7 +68,9 @@ describe('ScoutRunBoxes', () => {
)
expect(container.querySelectorAll('.bg-brand-yellow')).toHaveLength(2)
- const labels = Array.from(container.querySelectorAll('.sr-only')).map((node) => node.textContent ?? '')
+ const labels = Array.from(container.querySelectorAll('[aria-label]')).map(
+ (node) => node.getAttribute('aria-label') ?? ''
+ )
expect(labels.filter((label) => label.includes('top 10% of runs by cost'))).toHaveLength(2)
})
@@ -88,6 +92,16 @@ describe('ScoutRunBoxes', () => {
expect(link?.querySelector('.bg-brand-yellow')).not.toBeNull()
})
+ it('renders two elements per plain run, so a large fleet stays a small DOM', () => {
+ // The roster renders one strip per scout. An extra node per box multiplies by every run on
+ // every card, and a filter change discards the whole set at once.
+ const runs = Array.from({ length: 24 }, (_, i) => makeRun({ run_id: `run-${i}` }))
+ const { container } = render(<ScoutRunBoxes runs={runs} />)
+
+ const strip = container.firstElementChild as HTMLElement
+ expect(strip.querySelectorAll('*')).toHaveLength(runs.length * 2)
+ })
+
it('marks nothing while the fleet has too few priced runs to rank', () => {
const { container } = render(
<ScoutRunBoxes runs={[makeRun()]} costs={new Map([['run-1', 3.19]])} costThreshold={null} />
@@ -99,6 +113,6 @@ describe('ScoutRunBoxes', () => {
it('leaves every run unpriced when no costs are given', () => {
const { container } = render(<ScoutRunBoxes runs={[makeRun()]} />)
- expect(container.querySelector('.sr-only')?.textContent).not.toContain('$')
+ expect(container.querySelector('[aria-label]')?.getAttribute('aria-label')).not.toContain('$')
})
})
diff --git a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx
index 809b8676ce8a..ec5a847a4f76 100644
--- a/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx
+++ b/products/signals/frontend/inbox/components/config/scouts/ScoutRunBoxes.tsx
@@ -110,11 +110,13 @@ export function ScoutRunBoxes({
{newestFirst.map(({ run, outcome, expensive, tooltip }) => {
const boxClass = `${BOX_CLASS} ${OUTCOME_BOX_CLASS[outcome]}`
const boxTooltip = run.task_url ? `${tooltip} · open task run` : tooltip
- const label = <span className="sr-only">Run {boxTooltip}</span>
+ // The label is an attribute, not an `sr-only` child: the roster renders a strip per
+ // scout, so one more node per box adds thousands of nodes to a large fleet.
+ const label = `Run ${boxTooltip}`
const column = (
<>
{expensive ? <span className={MARKER_CLASS} /> : null}
- <span className={boxClass}>{label}</span>
+ <span className={boxClass} role="img" aria-label={label} />
</>
)
// The whole column links, not only the box, because the tooltip spans the column