Skip to content

Add JSON streaming to Function replay watch mode - #9056

Draft
isaacroldan wants to merge 3 commits into
mainfrom
codex/function-replay-json
Draft

isaacroldan wants to merge 3 commits into
mainfrom
codex/function-replay-json

Conversation

@isaacroldan

@isaacroldan isaacroldan commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Function replay watches by default, but rejects --json unless --no-watch is set.

WHAT is this pull request doing?

Add typed JSONL records for watch status, rebuilds, and Function results. Keep diagnostics on stderr and preserve native runner fields and numeric tokens. Keep the finite JSON result and existing text presentation.

Use one replay loop for watching files, running the Function, and handling rebuilds. The JSON writer and React hook consume its events instead of maintaining separate watch logic.

Wait for the file watcher's initial scan before reporting watching, so an immediate edit is not missed.

This is the JSON portion of #9007, which remains unchanged. Shared build and process shutdown behavior stays unchanged here; the second PR in this stack adds those fixes.

How to manually test your changes?

Use an app with a Function and a saved Function log.

  1. Run pnpm shopify app function replay --path <function-directory> --log <log-id> --json --no-input > replay.jsonl 2> replay.stderr.
  2. Edit the Function, introduce a build error, then fix it. Check that stdout contains separate JSON records, diagnostics use stderr, and replay keeps watching. A completed Function failure must also keep watching.
  3. When replay is idle, press Ctrl-C. Check the final cancelled record and exit code 130.
  4. Repeat without --json. Check the input, output, logs, and instruction statistics. Repeat the build error and recovery steps, then press q to quit.
  5. Repeat with --no-watch --json. Check that stdout contains one native runner result, not a watch record.
  6. Run pnpm shopify app function replay --json-schema. Check that it describes both finite results and watch records without starting replay.

Validation

  • Tested this PR on its own: 251 Function, replay, and file-watcher tests passed. Coverage includes real file events, immediate edits after watching, execution ordering, updated extensions, callback cancellation, and React effect cleanup.
  • App build and type-check passed. ESLint passed; the Nx module-boundary rule was skipped because the isolated checkout has no cached project graph.
  • Replay help, manifest, and schemas are unchanged by the shared-loop refactor.
  • A full CLI flow with a controlled Node runner passed: build failure, Function failure, recovery, and Ctrl-C with exit code 130.
  • Text replay passed the same recovery flow in a real terminal, including logs, instruction statistics, and the q shortcut.
  • Native WASM execution remains unverified: Function runner 9.2.2 receives SIGKILL on this machine even for --version.

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing and has a minor changeset.

@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Nov 2, 2026
@isaacroldan
isaacroldan added this pull request to stack #9058 November 2, 2026 13:19

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant