feat(cli): preview lifecycle — idle timeout and owner-pid for background servers#2132
Open
WaterrrForever wants to merge 1 commit into
Open
feat(cli): preview lifecycle — idle timeout and owner-pid for background servers#2132WaterrrForever wants to merge 1 commit into
WaterrrForever wants to merge 1 commit into
Conversation
…und servers Rework of the original `preview --detach` PR on top of the `--background/--status/--stop` lifecycle that landed in #2384: instead of a parallel detached-server implementation (state files, launch nonces, a --detached-child internal mode), the two capabilities main lacks become first-class preview flags that ride the existing argv forwarding into the background child. - `--idle-timeout <minutes>`: the server shuts itself down after this long with no requests. An open Studio tab counts as activity (it polls the project signature), so "idle" means nobody — human or agent — is looking. `--background` children default to 60 minutes (injected by buildBackgroundPreviewArgs unless the caller pinned a value; `--idle-timeout 0` opts out), so background servers no longer outlive their usefulness. Foreground default stays disabled. - `--owner-pid <pid>`: the server exits when that process does — an agent session can tie the preview to its own lifetime instead of leaking servers when it is killed. The watcher checks both conditions every 30s and SIGTERMs itself, reusing the exact Ctrl+C shutdown path (browser-pool drain, ffmpeg kill, hard deadline). Flags parse and fail loudly in the launching process, not inside a detached child's log file. Vite dev/local-studio modes warn that lifecycle flags apply to the embedded server only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
83acf70 to
02166da
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--idle-timeout <minutes>tohyperframes preview: the server shuts itself down after that long without a request;--backgroundchildren default to 60 minutes (injected bybuildBackgroundPreviewArgsunless the caller pins a value;--idle-timeout 0opts out), foreground stays disabled by default--owner-pid <pid>: the server exits when that process does, so an agent session can tie the preview to its own lifetime instead of leaking servers when it is killed--background/--status/--stop+ the new lifecycle flags in thehyperframes-cliskill (they were undocumented there)History
This PR originally shipped a standalone
preview --detachimplementation (state files, launch nonces, an internal--detached-childmode). #2384 landed--background/--status/--stopon main in the meantime, which covers the detachment itself — so this was reworked from scratch on top ofpreviewLifecycle: only the two capabilities main lacks remain, as plain preview flags that ride the existing argv forwarding into the background child. The branch was reset; the old implementation is gone.Design notes
--backgrounderrors there).Verification
previewLifecycle.test.ts: 18 passed — including default idle-timeout injection, explicit-value preservation (both--idle-timeout 0and=forms), owner-pid forwarding, and the ported shutdown-reason / processAlive suitescli.commands.test.ts+ lifecycle suite: 22 passed