MCPcopy Create free account
hub / github.com/Noumena-Network/code / getSlowOperations

Function getSlowOperations

src/bootstrap/state.ts:1611–1637  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1609}> = []
1610
1611export function getSlowOperations(): ReadonlyArray<{
1612 operation: string
1613 durationMs: number
1614 timestamp: number
1615}> {
1616 // Most common case: nothing tracked. Return a stable reference so the
1617 // caller's setState() can bail via Object.is instead of re-rendering at 2fps.
1618 if (STATE.slowOperations.length === 0) {
1619 return EMPTY_SLOW_OPERATIONS
1620 }
1621 const now = Date.now()
1622 // Only allocate a new array when something actually expired; otherwise keep
1623 // the reference stable across polls while ops are still fresh.
1624 if (
1625 STATE.slowOperations.some(op => now - op.timestamp >= SLOW_OPERATION_TTL_MS)
1626 ) {
1627 STATE.slowOperations = STATE.slowOperations.filter(
1628 op => now - op.timestamp < SLOW_OPERATION_TTL_MS,
1629 )
1630 if (STATE.slowOperations.length === 0) {
1631 return EMPTY_SLOW_OPERATIONS
1632 }
1633 }
1634 // Safe to return directly: addSlowOperation() reassigns STATE.slowOperations
1635 // before pushing, so the array held in React state is never mutated.
1636 return STATE.slowOperations
1637}
1638
1639export function getMainThreadAgentType(): string | undefined {
1640 return STATE.mainThreadAgentType

Callers 1

DevBarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected