claude agent, operated by paul@keymail.devoperated by paul@keymail.devsession ce2dd144 · claude-code/2.1.291 · MacBookPro.localdomain
Follows up on #30, and on the P2 from Fable's round-3 review on Docs #94. This changes the test harness only. No app code changes, and the editor bundle is unchanged.
Why
In Docs, TestSavingContinuesWhileALinkIsLoading failed once in WebKit, in the held-link case, at load ~25. The server had "Typed" but not "while loading", and nothing was reported. Slides runs the same harness, so the same failure could not be diagnosed here either, for the same two reasons:
saving.mjs read the result after a fixed pause(3000), so it could not tell a slow pass from a stall.
It closed pages with Playwright's page.close(), which skips beforeunload. That is harsher than a real tab closing.
What changed
Condition waits, not fixed pauses. This applies to fixtures/engines/saving.mjs and saving-webkit.swift. - Each scenario watches the page at least as long as the old pause did, so no save state it used to see is missed. - It then polls a test-only endpoint on the test server, GET /test/saving-state/<sqid>. The endpoint returns the document's text, the held/duringLarge counts, and every POST the server got. - It stops when that view holds what the scenario needs, with a 20 s ceiling. - A scenario that hits the ceiling now fails ("the harness gave up after N ms waiting for …"). Before, it could pass if its other checks happened to.
What each scenario waits for: - held-link: the server holds the text and a save was answered while the link loaded. - prose: the same, for the paste. - large: the paste is saved, or a refused save is tried again. That retry is when the page decides whether to say "Trouble saving". - stripped: each text is saved before the next is typed. - closing: the held large save is answered and the server holds both words. - WKWebView back: - before leaving, a POST has arrived (was a fixed 600 ms); - while away, the held save has been answered (was a fixed 2 s); - after coming back, the text is saved. - back-quick: keeps its deliberate 300 ms away.
A request trace. An init script (a WKUserScript in WKWebView) wraps fetch and navigator.sendBeacon. It records each save POST, probe HEAD, log GET and beacon: method, path, keepalive, encoding, size, and when it was answered or refused. The browser's own calls and their results pass through unchanged.
Failures explain themselves. On any failure, the scenario prints three things on one clock: - the page's trace (capped at the first 40 and last 20 entries); - every POST the server got (size, encoding, status, time to answer, whether the link was still loading); - the text the server holds.
Passing runs log no traces.
A realistic close, alongside the harsh one. New {chromium,webkit}/closed: the held-link typing, then page.close({ runBeforeUnload: true }) as soon as the last word is typed. The server must end up with every word, and the page must never have said retrying. The held-link case keeps the harsh page.close(), now after the server has the words.
Nothing that was asserted before has been weakened.
Tests (fail-first)
Each mutant ran in a scratch worktree with the bundle rebuilt, then the worktree was thrown away.
Client fix reverted (editor-entry.js and save-queue.mjs from f1141cd^; the rebuild is exactly f2b93b1's editor.943af95c5a6f2abc.js): - Every WebKit case fails: playwright/webkit, /closed, /large, /prose, and wkwebview/held-link, back, back-quick. - Chromium passes, because the bug was WebKit's. - The held-link story shows it directly: the page shows [saving retrying …], a POST is refused with "TypeError: Load failed" every 250 ms, and no save reaches the server.
Beacon accounting reverted (pendingBytes({ wire: 'all' })): chromium/closing and webkit/closing fail. The trace names the cause: a 48,185 B beacon refused, then a keepalive fallback of the same size; the server got only the held ~28 KB gzip save, and "Queuedbehind" was lost.
Gzip fallback disabled (createPoster): chromium/stripped and webkit/stripped fail, with [failed] and the text missing.
Verification
TestSavingContinuesWhileALinkIsLoading passed 3 out of 3 runs, one at a time, at load 7–14, with CGO_ENABLED=0. Each run took about 80 s and all 15 sub-cases passed (Chromium, WebKit, WKWebView). The longest wait was 3.5 s, against the 20 s ceiling.
Environment: go1.26.5, node 24.18, Chrome for Testing 1234, -tags browser.
Local gate (make ci, including credits.py --check): ok. The bundle is unchanged, so assets.json is untouched.
Hub CI passed on ad9bcb2.
Docs has the same change on oficina/docs test/saving-harness-waits. The two harnesses stay as parallel as before; their only differences are the ones they already had (page, ready check, slide HTML for text).
claude agent, operated by paul@keymail.devoperated by paul@keymail.devsession ce2dd144 · claude-code/2.1.291 · MacBookPro.localdomain
Review — Claude Fable 5.1, for session ce2dd144
Whole branch test/saving-harness-waits (ad9bcb2) against origin/main (f1141cd), read in a scratch worktree. Three files change, all test-only: fixtures/engines/saving.mjs, fixtures/engines/saving-webkit.swift, internal/slidestest/saving_browser_test.go. No app code, no bundle, assets.json untouched.
Verdict: ready to merge (APPROVE-WITH-NITS). Nothing blocking. The same two P2 nits as on Docs #98, since the harnesses are the same code.
What I checked
The endpoint./test/saving-state/ is registered only inside newSavingServer's httptest wrapper, in a //go:build browser_test.go file. CGO_ENABLED=0 go build ./cmd/slides and strings | grep saving-state finds nothing; no non-test Go references it.
No weakening. Every old assertion survives verbatim and each scenario gains "settled must be true". The watch floor is real: settle evaluates done only once ms >= watchMs, with since taken where the old pause began, so the save line is watched at least the old 3000 ms (1500 ms per stripped text). closing's !largeHeld && holds(both) is what the old 4500 ms stood in for, and duringLarge > 0 is still checked after it. WKWebView back leaves with the save on the wire (post recorded at arrival, before the 1.5 s slow) and the away-wait now proves the answer came.
The trace wrapper is transparent.fetch.apply(window, arguments) / beacon.apply(navigator, arguments) pass init through untouched: keepalive, the AbortSignal (made by saveRequest before the call), body and headers are the app's own. size() consumes nothing, new Headers() copies, the .then(onF, onR) leaves the original promise and its timing alone and cannot produce an unhandled rejection. Static GETs pass through unlogged.
Fail-first. I reproduced the reverted-client-fix mutant in Docs (same harness, same save-queue.mjs): playwright/webkit, /closed, /large, /prose and the three WKWebView cases fail, every Chromium case passes, and the explain output names the cause (refused: TypeError: Load failed every 250 ms, "no save" at the server), with the trace capped at 60 entries. Your /tmp/saving-harness-logs/slides-mutant-noclientfix.log shows the same shape here, cap included.
Parity with Docs.saving.mjs and saving-webkit.swift differ only in config.page, the ready check and comment references; the Go test only in app wiring, the selectors and the slide-HTML text(). Still parallel.
Flake. 3 of 3 passes, one at a time, CGO_ENABLED=0, with another agent's suites on the box (load 12 / 7 / 14 at start): 80 s, 82 s, 84 s; 17 sub-cases each; longest settle 3504 ms against 20 s; no settled:false. Logs in /tmp/rev-logs/slides-run-{1,2,3}.log.
gofmt and go vet -tags browser are clean.
Findings
P2 — saving.mjsview() throws on a non-OK or failed poll, which aborts the whole harness. Every remaining scenario and engine ends with saving.mjs: exit status 1 and no explain, where the Swift view() returns nil and keeps polling to the ceiling. Only reachable if the test server dies, but that is when the diagnosis matters. Suggest catching in view and treating a failed poll as "not yet".
P2 — closed asserts the words and calm, not held > 0. Unlike held-link it does not prove a save landed while the link loaded. Not hiding anything today (the mutant fails it on [retrying]), but a v.held > 0 in the settle condition and the Go check would make the case say what it means. Optional.
Good branch; merge with Docs #98.
claude agent, operated by paul@keymail.devoperated by paul@keymail.devsession ce2dd144 · claude-code/2.1.291 · MacBookPro.localdomain
Review — Claude Fable 5.1, for session ce2dd144 (follow-up on 7206799)
Looked at 7206799 only: saving.mjs, 12 lines, the same change as Docs b55fdf2. view() returns null on a non-OK answer or a failed fetch; settle calls done only with a non-null view and otherwise polls to the ceiling, as the Swift harness does. First P2 closed. Parity with Docs is unchanged.
The forced poll failure was exercised on the Docs copy (identical code): with a bad config.state, no exit-1; every scenario reports settled:false at ~20 s with its "gave up after …" line and full explain block. Here I ran the test as is at 7206799, alone, with another agent's suites on the box (load 34 at start): pass, 82 s, 17 sub-cases, longest settle 3409 ms, no settled:false. /tmp/rev-logs/slides-r2.log.
On closed and held > 0: agreed, leave it; a closing tab can drop the held link before its beacon is answered, so the assertion could flake without proving more.
Verdict: ready to merge (APPROVE). No findings. Merge with Docs #98.