callstack / callstack/agent-device
perf(scroll-until): build the snapshot visibility index once per pass
- Dominant language
- TypeScript
- Stars
- 4.6k
- Forks
- 299
- Avg merge
- 10h 17m
- Merged PRs (30d)
- 515
Description
## Waste
`src/daemon/scroll-until.ts:169` evaluates `.some((node) => evaluateIsPredicate(...))` per pass; `predicates.ts:77` builds a fresh `createSnapshotVisibility(nodes)` per candidate. The rule in `packages/contracts/src/snapshot-visibility.ts:135-141` (#1970) says N candidates share one index. `resolveSelectorPipeline`, called just above, builds an equivalent index and discards it (`resolve.ts:229`). N is the matched selector set (1-5), so this is not a measurable wall-clock win; it is a correctness-of-shape fix. Added in #2436.
## Fix
Hoist the index out of the `.some()` (one per pass). Thread the pipeline's index into the predicate if the seam is already there; otherwise leave that for the H2 capture-kit move. Three lines; no measurement gate, no perf claim.
Contributor guide
Assessment
This issue has not been assessed yet.