perf(agent): stop re-waiting for a lost list on every repeat of a replayed scroll
Merged
OK
2mo ago+51+51+01234567890123456789-17-17-01234567890123456789
A replayed folded scroll (one recorded scroll with times: N) on a list that filled the screen re-ran the full relocation backoff before every repeat when the list could not be found. pollSettled (packages/e2e/src/agent/replay.ts) waits about 14s per relocation, so a recorded 4x scroll spent about 56s before falling back to the viewport each time.
scrollOncenow reports whether it scrolled the list, scrolled the viewport (list lost,spans >= MAIN_LIST_SHARE), or failed. Once a list is judged lost, the rest of the repeats in that scroll go through the viewport path: a settledheld-stilllook, then a scroll, with no new relocation.- The list and viewport repeats share one loop now.
- Unchanged: a smaller region (
spansbelow the share) still hands off on the first miss, the count of repeats done before a miss is kept, and the cache key and recordings are untouched.
flowchart LR
A[repeat i] --> B{list still tracked?}
B -- yes --> C[relocate, up to 14s]
C -- found --> D[scroll list]
C -- lost, fills screen --> E[scroll viewport, stop tracking list]
C -- lost, small region --> F[hand off]
B -- no --> G[held-still look, scroll viewport]
Verified
Ran it locally: yes
- Unit: new test in
tests/unit/trace-replay.test.tsuses fake timers to replay a 4x scroll whose list is gone. It asserts the elapsed clock (14000ms) and the looks: one backoff of 9, then oneheld-stilllook per later repeat. On main it fails withexpected 56000 to be 14000. - Runner: a scratch integration test (not committed) runs the built runner through the fake engine on an
iostarget withcache: 'read-write'. The first run records an executor that scrollslist "Feed"(97% of the viewport) four times, folded to one action withtimes: 4. Before the second run the list is renamed (Feed, row 13 of 40, the way a device renames a scroll view) and the step replays:
| main | this branch | |
|---|---|---|
replayed agent.act step | 56369 ms | 14324 ms |
| cache | self-finalized, 1/1 | self-finalized, 1/1 |
| swipes / test | 4 / passed | 4 / passed |