Repository navigation
Add reset mode to preview command - #381
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
--reset discards the page directory but not the page's claim, which lives outside it in state_home()/claims/. On the ordinary path that is invisible — prepare() runs page init, and _commit_layer unlinks the claim when it creates the directory fresh ("Recreating a deleted path creates a new page, so it must not inherit the deleted page's owner").
On the --automation path it is not, because watch_preview's claim check runs before the rebuild: if automation and PageTransaction(page).active_claim is not None. So the remedy the two new messages advertise dead-ends. Concretely, the scenario test_automation_preview_records_real_gestures_outside_the_task already sets up — a running reader preview whose claim is the live session's, per assert claim is not None and claim["id"] == os.environ["CLAUDE_CODE_SESSION_ID"] — then --automation on that slot, which the test asserts refuses with choose a new --slot, now also says "or rerun with --reset to replace it". Following that: reset stops the watcher and deletes the directory, then the restarted watcher reads the surviving claim, pid_alive is still true for the same session, and it raises has an active task claim; choose a new --slot to preserve it, or rerun with --reset to replace it — the same advice again, with nothing left to reset.
Unlinking the claim alongside the directory keeps the discard whole and matches the invariant _commit_layer already states. Suggestions inline.
Preview slots preserve reader feedback, which previously meant a changed fixture seed could only be opened under a new slot. Add
--resetto stop the selected watcher, discard all of its page state—including the external task claim—under the existing lifecycle locks, rebuild it from the current fixture, and start watching again. Conflict diagnostics and the developer workflow now point to the reset path.The integration tests exercise a real reader decision, reset both background and automation previews, and verify that a fresh page and watcher replace the old state.