Skip to content

Add reset mode to preview command - #381

Merged
max-sixty merged 3 commits into
mainfrom
codex/reset-preview-state
Sep 7, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/reset-preview-state

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 7, 2026 •

Copy link
Copy Markdown
Owner

Preview slots preserve reader feedback, which previously meant a changed fixture seed could only be opened under a new slot. Add --reset to 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.

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--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.

Comment thread scripts/preview.py Resolved
Comment thread scripts/preview.py Resolved
@max-sixty
max-sixty merged commit f873d5a into main Sep 7, 2026
6 of 7 checks passed
@max-sixty
max-sixty deleted the codex/reset-preview-state branch September 7, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants