fix(cache): replay a multi-line unique() value the screen shows on one line
Merged
SA
17d ago+23+23+01234567890123456789-5-5-0123456789
What and why
- The cache writes end anchors on one line (
collapseTextinpackages/e2e/src/cache/anchors.ts). So a multi-lineunique()value, such as an address typed into a textarea, is recorded on one line. templateTextlooked for the value as given and in its URL spellings (uri,form,slug) only. The one-line spelling stayed the recording run's literal text. The next run typed a new value, and the end check missed:REPLAY_STALE (end-mismatch)with--strict-cache, a hand-off to the agent without it.ENCODERSinpackages/e2e/src/cache/template.tsgets aflatspelling,normalizeText: every whitespace run,\rincluded, becomes one space, then the result is trimmed. The anchors record as{{param:/address|flat}}, and replay fills in this run's value on one line.normalizeText, notcollapseText:collapseTextturns a\rinto U+FFFD, but a textarea stores\r\nas\n, so a value joined with\r\nwould still miss.- Older runners: an entry recorded with
|flatreads asinvalid-entryon a runner without this fix (stated in the changeset). Cache keys do not change, becausetemplateParamswrites placeholders with no encoding. A value with no whitespace run has noflatspelling, so no other recording changes.
The issue author, @amoscicki, proposed this fix and the flat name in #1359.
Issue
Fixes #1359
Verified
Ran it locally: yes
- The issue's reproduction as a scratch project on the built packages. A scripted executor (no model) types
unique(address)into a textarea and taps Save. Steps:npx e2e runto record, thennpx e2e run --strict-cache. - Same steps with the value joined by
\r\ninstead of\n. It failed on this branch before thenormalizeTextchange and passes now. - The new unit test in
tests/unit/trace-template.test.tsfails on main.
| main | this branch | |
|---|---|---|
| Recorded end anchors | "value":"Ada Lovelace 12 Example Street E2E 1793336967299" | "value":"{{param:/address|flat}}" |
--strict-cache replay, \n value | REPLAY_STALE (end-mismatch), 15.30s, Cache 1 handed off | passed, 1.21s, Cache 1 replayed |
--strict-cache replay, \r\n value | not run | passed, 1.17s and 1.11s, Cache 1 replayed |
main:
Ć saves a multi-line address > agent.act "save the address {address}" 14.37s failed
REPLAY_STALE: the recording of this step no longer replays (end-mismatch), and cache.strict hands no step to the agent; re-record it with a read-write run without --strict-cache and commit the changed entry under .e2e/cache
Cache 1 handed off
this branch:
ā saves a multi-line address > agent.act "save the address {address}" 304ms
Tests 1 passed (1)
Cache 1 replayed
Duration 1.21s
Reviewed with sol-loop: 2 rounds with gpt-6.1-sol on high. Sol verdict: approved
š¤ Generated with Claude Code