fix(cache): replay a control that leads its row in that row, not by its place

JA
2d ago
+201-25

What and why

  • A control that shares its name with other rows' controls and is the first text in its row (an Archive button in a table's first column) was recorded as tap button "Archive" (2 of 5). The row's first text was the button's own name, so containerKey keyed nothing, and a replay on a list of the same length in another order pressed another row's button. A glyph button (<button aria-label="Archive">×</button>) did the same with in "×" (2 of 5).
  • containerKey takes pastOwn and then reads the row's first text outside the control. The recorder uses that key only when the control has twins and the text tells it from all of them. Relocation accepts either key.
  • No REPLAY_POLICY_VERSION bump, as in #998: entries recorded on main match the same nodes as before. The cost is that an entry already recorded by place replays by place until the step is recorded again. I can bump it if you would rather cold-start.
  • The row's next text can be data (Archive | $500 | Acme). The key is then $500, and a changed price hands off where main replayed by place. I did not skip volatile text, since containerKey matches no patterns today.
  • Still by place, as on main: rows whose next text is the same in every row ([Archive] [Edit] Acme, a status column).

Issue

Fixes #2052

Verified

Ran it locally: yes

Real CLI and Chromium, the repro from the issue (sh run.sh, a scripted executor, no model): five rows a page, one new record on top before the second run.

second runmain (0.24.0 and 0.25.0-nightly-20261121030204)this branch
recordedtap button "Suspend" (2 of 5)tap button "Suspend" in "Acme Corp"
cache1 replayed · 1 handed off2 replayed
invoices archivedGlobex, then Acme CorpAcme Corp
account suspendedGlobex, and the test passesAcme Corp
  • --strict-cache: main fails the archive test with REPLAY_STALE after archiving Globex and still passes the suspend test on Globex. The branch replays both on Acme Corp.
  • The new tests: 5 failed | 27 passed on main's sources, 32 passed here.
  • main against this branch over 20,000 generated lists, recorded and then replayed after a reorder, a new row, a removed row, or changed data: 2,858 wrong-row replays become right, 1,050 become hand-offs, and no hand-off becomes a wrong row. 175 right replays become hand-offs and 2 land on a wrong row, all keyed by row data that changed. Entries recorded on main relocate to the same node in all 296,229 cases.
  • Web benchmark recordings, CI=1, test:agent --strict-cache, no model key: 26 replayed · 3 handed off · 6 missed on main and here, every step the same. The 8 tests that call the model fail on both.
  • Not run: the mobile benchmark recordings (no emulator), bench:ab and a recording made by a real model (no key). A target that is itself a row or group, as many mobile targets are, takes the old path.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.