perf(agent): wait 1 s, not 2 s, after a caret key in a focused text field
Ā
KD
6d ago+268+268+012345678901234567890123456789-12-12-01234567890123456789
- After
pressorpressKey, a settled look waits up to 2 s (FULL_CHANGE_WAIT_MS) for the tree to change shape. A caret key (ArrowLeft, ArrowRight, Home, End, Control/Meta+a, with Shift or Control) in atextboxorsearchboxthat already holds the focus usually changes nothing the tree records, so the whole window was spent. - That wait is now 1 s (
HELD_STILL_MS) for those keys:changeWaitAfterinpackages/e2e/src/agent/settle-policy.ts. The first version used 150 ms; review showed aselectionchangehandler that reveals a toolbar 700 ms later was missed, so the window now covers it. - Kept at 2 s: taps, the first key or tap that gives a field the focus,
combobox, Alt chords, Tab and the vertical keys, and every other action. armChange(observation-feed.ts) keeps the later deadline when a window is still pending. Without it,tap(Save)thenpressKey('End')in one turn would cut the tap's 2 s window.focusedNode()returns a node only when exactly one node has the focus.- Known limit: a handler that updates the tree more than 1 s after the key is read on the next look, as after any action with a window shorter than its delay.
Verified
Ran it locally: yes
- Surface: the web benchmark's
tests-agent/replay with--strict-cache, throughpnpm bench:ab --config e2e.agent.config.tsagainst the merge base (e27f492c), 6 pairs in random order. - The 7 tests that call the model on a replay (3 planted-bug judgments, 4
act completes ā¦scenarios) are left out ofbench:abwith--grep-invert, since their model calls differ between runs. They ran once on the 150 ms version of this branch with a key (CI=1 e2e run --config e2e.agent.config.ts --ai-trace, recordings read-only): 33 tests passed, noREPLAY_STALE. On this head CI'sweb agentjob ran them with a key: 33 passed, 20 model calls. The--no-cachepath was not run. - Behavior: every test ran the same steps with the same outcome (status, cache mode, replayed actions) on every run of both builds.
| Metric | main | this branch | change (95% CI) |
|---|---|---|---|
| wall (process) | 68.71 s | 62.86 s | -9.0% (-11.4% to -5.8%) |
| suite (sum of attempts) | 67.52 s | 61.67 s | -9.2% (-11.6% to -5.9%) |
| observe (events) | 38.70 s | 32.78 s | -15.3% (-15.6% to -15.0%) |
| action (events) | 25.89 s | 25.64 s | same (-7.8% to +6.4%) |
act completes rich-text-editor | 20.49 s | 14.58 s | -28.9% (-29.3% to -28.4%) |
- Review regression test:
tests/integration/agent-caret-settle.test.tshas a fake-engine popup that opens 700 ms afterpressand afterpressKeyon a focused field. Both cases fail at the 150 ms window and pass at 1 s. The same file keeps a first tap, a tap on the focused field, a caret key before the field held the focus, and a batched tap then key at the full window. - e2e unit 3514 pass, agent integration 203 pass,
pnpm checkexit 0. The iOS and Android agent and deterministic suites passed in CI on an earlier head, sincesettle-policy.tsis shared with mobile. - The replay suite cannot catch a delayed effect: every changing look in it ends within about 120 ms, which is why the fake-engine file exists.
At 150 ms the replay took 59.75 s (-16.1%) and the rich-text step 9.40 s. Taps stay at 2 s for the same reason: a click can open a panel that renders late. Five dead looks of about 2.1 s (10.7 s) remain: right clicks in the context-menu trap, the upload tap, the gift-card amount tap, and the editor's bold tap.
š¤ Generated with Claude Code