Repository navigation
fix(cli): a preview inside a host app's run no longer takes the project's history - #6493
Conversation
Edit accuracy: accurate 271 (base branch 271), smooth 151 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (2)
|
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 0 nits · head 47c34dff
Scope
The adapter's history is the only place that calls projectHistory(). The watcher's noteChange goes through histories.peek, which never opens a history, so a preview inside the host's run takes no lock at all. I also checked the env var across hyperframes-internal: the desktop app sets HYPERFRAMES_DESKTOP_PROJECT only on child envs (agent runs in runLaunch.mjs, the render CLI in render.mjs), and it opens its own history in the main process (projectHistory.mjs). So the host's own history is unaffected. The first set of workflow runs on this head is all green; a second CI run was still running at review time.
What
A
hyperframes previewstarted inside a host app's agent run (HYPERFRAMES_DESKTOP_PROJECTset) no longer opens the project's history, so it never takes the history's owner lock. The host app owns that history.Why
An agent's shell commands each run in their own process group, so a preview an agent starts during a run can outlive that run when the host stops the run's process group, and even outlive the host app. While it holds the history lock, the host can't open the project's history. Every later run waits for the lock, is refused ("Another HyperFrames preview is using this project's history"), and Undo, history steps and project renames fail the same way, until the leftover preview is killed by hand.
#5852 already refuses
--backgroundinside a host app's run. A--foregroundpreview, which that error message suggests and which skills use, still took the lock.How
createStudioServerasksinsideHostApp()once. Inside a host app's run, the adapter'shistoryanswersnulland never callsopenProjectHistory. Studio already handles a history that's off, the same path it takes today when another process holds the lock. The host app's own watcher still records the run's file changes in its history.Why under 100 lines
It is one decision with one owner: inside a host app's run, the preview leaves the history to the host. That is a single check in
createStudioServerplus its test. It ships alone because it depends on no other open change, and every release without it leaves later runs refused until someone kills the leftover preview by hand.Test plan
studioServer.test.ts: withHYPERFRAMES_DESKTOP_PROJECTset, the history route answers 404 andopenProjectHistoryis never called. It fails with the check removed: the history is opened. 43 pass, three runs in a row.tscshows only two errors, both in files this PR doesn't touch (checkFindingInspect.ts, andcheckTypes.ts, which needs the unbuilt inspector package).