feat(agent,dom): recorder follow-ups — auto screenshots, nav-abort, durable pending buffer (#148) - #194
Conversation
…ort, durable pending buffer (#148) Per-edit screenshot auto-capture (src/agent/edit-shots.ts): the BEFORE viewport shot arms ahead of the first unrecorded mutation (the SW dispatch is the one point that still precedes the page change), recordEdit's drain consumes it and captures the AFTER — one pair per Edit, two capture-lock rides, never per mutation. Best-effort by contract (a failed capture never fails the edit) and size-guarded (per-image ceiling + whole-changeset budget) so the record can't blow the chrome.storage.session quota it lives in. Mid-turn navigation aborts the turn (src/agent/nav-abort.ts + onCommitted): a cross-document commit of the running turn's tab stops it with session-stop's clears and a turn-stamped error — except the agent's own nav (runNav now marks its tab for the commit window), which keeps the turn alive while the turn's persistChangeset refuses to write a record whose URL no longer matches the committed URL (the in-flight re-persist #148 names). Same-document navigations never commit and never abort. The pending-mutations buffer survives SW eviction (pending-persist.ts): mirrored per tab beside the changeset record — appends debounced, shrinking ops written through so a drained/reverted event can't resurrect — and re-seeded on wake, so a resumed turn's recordEdit folds real ground truth instead of falling back to model-supplied values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 19 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
Warning
|
Implements all three residuals from #9, with the behavioral decisions the issue left open taken as follows.
1. Per-edit before/after screenshot auto-capture — on the
recordEditdrain, not per mutationDecision: the cheap cadence. One before/after pair per recorded Edit (2 capture-lock rides, ~200ms settle each) instead of 2 rides per mutation — per-mutation fidelity isn't worth 400ms added to every
setStyle.Mechanics (
src/agent/edit-shots.ts, wired inbackground.ts+src/agent/tools/session.ts):recordEdit's drain consumes the slot and captures the AFTER. Interleaved multi-element work degrades honestly to an after-only pair rather than a fabricated before.chrome.storage.sessiontwice, so the budget bounds the worst case at ~5MB of the ~10MB quota; an oversized capture is skipped, never stored.screenshotspair wins; auto-capture stands down. The turn-end auto-finalize does not capture (nothing new to illustrate at that point; the slot dies with the buffer).Schema (
Edit.screenshots) and Diff-tab rendering pre-existed — this only produces the data.2. Mid-turn navigation — ABORT the turn
Decision: abort, not rebase ("abort is safer; rebase preserves work" — work the new document cannot carry anyway).
webNavigation.onCommitted(cross-document commits only — hash/pushState never fire it) now aborts a turn RUNNING on the committed tab with the same clearssession-stopuses, a turn-stamped error to the panel ("The page navigated away mid-turn, so the turn was stopped"), a debug-log entry, and asession-statepush. User reload included: it's a cross-document commit and the live edits died with it.navigate/back/reloadnever aborts:runNavnow marks its tab inagentNavTabsinside its capture-lock ride (commit lands before the load-complete wait settles, so the window covers it). Decision table is the puresrc/agent/nav-abort.ts, unit-pinned.persistChangesetnow refuses to write a record whose URL no longer matches the tab's committed URL (same comparison chain as the turn-start guard: persisted stamp → in-memory stamp → turn tab.url). The turn stays alive, the wipe stands, and the next turn re-seeds clean — pinned end-to-end inchangeset-record.test.ts.3. Persist the pending-mutations buffer
The SW's recorder buffer now mirrors to
chrome.storage.session(pendingMutations:<tabId>, besidechangeset:<tabId>) viasrc/changeset/pending-persist.tsand re-seeds on SW wake, so an eviction mid-turn no longer dropsrecordEditback to model-supplied values (pre-#9 behavior).drain/remove/clear) write through, because losing one to eviction would resurrect events arecordEditalready folded (double-recorded deltas) or a revert already retracted (a phantom).pendingReadygate so pre-hydration events can neither be clobbered by the seed nor resurrect a cleared buffer; live events beat the mirror.Tests
DZ_TEST_WORKERS=2 bun run verifyfully clean — 196 files, 2696 tests (was 2634), lint + typecheck green. New:edit-shots(12),nav-abort(5),pending-persist(7),pending-restoreintegration (5, the eviction round-trip through realcreateSessionTools),changeset-record#148 item 2block (2), plusonChange/seedcoverage inpending-mutationsand the capture contract insession-tools.Closes #148
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.