fix(cache): replay a recorded step that types an empty value

Merged
RA
2mo ago
+49-2

Fixes #789.

  • The recorder writes a type or typeText action with value "" (clearing a field), and the reader rejected it. readInputText returns undefined for "" (packages/e2e/src/cache/trace.ts), so the entry was invalid-entry: the step called the model on every run and failed with REPLAY_STALE under --strict-cache.
  • New readTypedValue allows "" for the type and typeText value only. select, text, url, and upload paths still reject it, and a unit case pins select.
  • Replay already handles it: the dispatcher only checks typeof value === 'string', and the unique() templating passes "" through.
  • Adds a /clear-field fixture page and a clears a field flow in the trace cache replay suite: type a draft, then type "".

Verified

Ran it locally: yes

  • Built dist, round-trip of a type entry through JSON (buildTraceEntry then readTraceEntry).
  • tests/integration/trace-cache-replay.test.ts against a dist built from main's reader and from this branch.
mainthis branch
value: "nonempty" reads back: truetrue
value: "" reads back: falsetrue
replay suite: × replays every step on the second run with zero model calls (AssertionError: expected [ Array(2) ] to have a length of +0 but got 2)Tests 20 passed (20)

Also green locally: pnpm check, e2e unit suite (2521 passed), and the other trace cache integration files (42 passed).

Not run: the web benchmark, and a live agent.act against a real model recording a field clear.

apps/testbed tests/speed.e2e.ts (forty taps each cost no more than a few locator reads) failed 3 of 6 runs on this branch at about 102.7 ms against its 100 ms budget, and passed on the others. I ran it twice on main and both passed. That test taps and never reads the trace cache, but two runs is not enough to call it unrelated.