Repository navigation
Expose app dev session files for agents #8926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
587b14d
Expose app dev session files for agents
isaacroldan 0bde236
Document session identity in the dev status file
isaacroldan 3197d4a
Keep app dev log messages and status transitions aligned with termina…
isaacroldan 003947d
Own app dev sessions in the service
isaacroldan c1eb1bb
Document the 15-second dev stale interval
isaacroldan 4c57c84
Flush app dev output before signal shutdown
isaacroldan f1869f2
Capture Javy diagnostics in dev session logs
isaacroldan 2632d64
Document dev log discovery with identity hashes
isaacroldan 7792233
Run dev shutdown subprocess tests from workspace sources
isaacroldan d445199
Exit non-interactive dev after the postrun hook
isaacroldan 1a87349
Separate complete messages in non-interactive dev output
isaacroldan a3cebb6
Use scoped dev instance ownership in the app service
isaacroldan ade2bbc
Separate source startup and shutdown test deadlines
isaacroldan d632b3f
Remove stale stream options after restacking
isaacroldan 78e2360
Document shared dev sessions and test shutdown on Windows
isaacroldan 349478a
Preserve the root process during Windows dev shutdown
isaacroldan 0405cff
Trace Windows subprocess shutdown in CI
isaacroldan 479c9f2
Trace native Windows signal redelivery
isaacroldan 567898b
Let dev shutdown handlers drain output before Windows exit
isaacroldan dce1186
Restore the standard manual test workflow
isaacroldan 83d5e5c
Allow Windows child cleanup its postrun startup budget
isaacroldan b7d103f
Merge branch 'main' into make-dev-agentic
isaacroldan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/app': minor | ||
| --- | ||
|
|
||
| Record `app dev` sessions, preview status, and JSONL logs so agents can reuse a running session. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@shopify/cli-kit': patch | ||
| '@shopify/cli': patch | ||
| --- | ||
|
|
||
| Preserve graceful shutdown and child-process cleanup on Windows. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Dev Instance files | ||
|
|
||
| Long-running dev commands write an instance JSON file and a JSONL log under | ||
| `<project>/.shopify/dev/`. Agents can read these files when dev was started in | ||
| another terminal. There is no IPC endpoint or extra command. | ||
|
|
||
| The instance JSON includes the command, project directory, PID, `sessionId`, | ||
| `status`, `logFile`, and command-specific `details`. `status` is `starting` or | ||
| `running`. Use `logFile` to find the log; filenames include an identity hash. | ||
| A saved instance file alone does not prove that the process is alive. Check its | ||
| PID and lock heartbeat before reusing the session. | ||
|
|
||
| ## Read new output | ||
|
|
||
| Each complete JSONL line contains `timestamp` and `message`, with `source` and | ||
| `level` where available. Terminal colors, spinners, and screen redraws are excluded. | ||
| Keep a byte offset to read new lines. Wait for an incomplete final line to finish. | ||
| If `sessionId` in the instance JSON changes, reset the offset: each new run clears | ||
| the log. Logs have no size limit or rotation. | ||
|
|
||
| ## Agent workflow | ||
|
|
||
| 1. Find the instance JSON for the intended command and configuration. Check its | ||
| identity details, PID, and lock heartbeat. | ||
| 2. Reuse an existing session. If none is available, start the dev command through | ||
| the agent's background terminal facility. Supply the required configuration and | ||
| store flags and use `--no-input` when setup and authentication are available. | ||
| 3. If a second start reports `dev_instance_already_running`, read the reported | ||
| instance and log. Do not stop a session started by the developer. | ||
| 4. Make the change, read new output, inspect the command-specific status, and test | ||
| the result. Use a bounded wait and report errors or timeouts. | ||
|
|
||
| Reported status is a snapshot of the CLI's state, not a health check or proof that | ||
| an edit has reached the store. Web-server and browser health require their own checks. | ||
|
|
||
| ## Shutdown and recovery | ||
|
|
||
| Normal shutdown removes the instance JSON and lock, and retains the log until the | ||
| next run. Ctrl+C cancels dev work and waits for queued log writes. On Unix, | ||
| SIGINT and SIGTERM use the same shutdown path. Sending these signals through | ||
| `process.kill()` on Windows forces termination and does not drain queued writes. | ||
|
|
||
| A live PID blocks takeover, including after the fixed 15-second stale interval. | ||
| Stop an unresponsive owner before starting another instance. Crashes after | ||
| startup recover automatically on the next start. If the CLI is killed during the | ||
| short lock-acquisition step, a `.lock.acquire` directory can remain. The next | ||
| start reports its path. Confirm that no other startup is running before removing | ||
| that directory and trying again. | ||
|
|
||
| A crash can leave stale metadata or an incomplete log. Keep these local files out | ||
| of commits and external reports; output and local URLs can contain secrets. | ||
|
|
||
| ## App dev | ||
|
|
||
| `shopify app dev` owns one session per app configuration. The instance details | ||
| include the app configuration, app identity, store, URLs, and `preview`: | ||
|
|
||
| - `state`: `starting`, `updating`, `ready`, or `error`. | ||
| - `message`: the current CLI status message, or `null` before one is available. | ||
| - `errors`: the current reported errors. Errors remain during retries and clear | ||
| when the CLI reports success. | ||
|
|
||
| Process messages keep their terminal source, including extension handles. | ||
| Changes to the status message also produce a log record with source `app dev`. |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.