Skip to content

Merge changes from dev/studio-cli-i2 branch, 2nd try#2404

Merged
fredrikekelund merged 30 commits intotrunkfrom
dev/studio-cli-i2
Jan 16, 2026
Merged

Merge changes from dev/studio-cli-i2 branch, 2nd try#2404
fredrikekelund merged 30 commits intotrunkfrom
dev/studio-cli-i2

Conversation

@fredrikekelund
Copy link
Contributor

@fredrikekelund fredrikekelund commented Jan 16, 2026

Related issues

N/A

Proposed Changes

We've been using dev/studio-cli-i2 as a base branch for the Studio CLI i2 project since ~Dec 8. This PR merges all changes from that branch to trunk.

Testing Instructions

This branch contains almost exclusively PR merge commits, each of which has been tested individually. Our main confidence indicator here is that CI should pass.

If you want to run some sanity tests locally, do this:

  1. npm install in the root directory and in ./cli
  2. npm start to build the CLI and start the app
  3. Run some simple smoke tests to ensure that things work as expected
  4. Keep the app open
  5. Run node dist/cli/main.js to execute CLI commands
  6. Try creating, starting, and stopping sites to ensure the status is synced with Studio

Warning

Running node dist/cli/main.js site stop --all will break the sync with Studio. We are working on a fix in #2398.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

bcotrim and others added 29 commits December 18, 2025 15:50
* Abort async operations on SIGTERM/SIGINT

* Also send abort message to child server

* Only create AbortController when topic is not `abort`

* Fix

* More fixes

* Tweaks

* Fix unit tests

* Fix types
* Studio CLI: Fix miscellaneous issues raised in CfT

* Remove version field altogether

* Unused variable

* Only log `adminPassword` if defined

* Bring back `showHelpOnFail`

* Always use ellipses

* Exclude "Finished running the Blueprint" message

* Trash files instead of removing them
- Add `updateDomainInHosts()` function to `cli/lib/hosts-file.ts` that handles removing the old domain and adding the new domain in a single hosts file write operation (single admin privilege request)
- Add `skipHostsUpdate` option to `setupCustomDomain()` in `cli/lib/site-utils.ts` to avoid duplicate hosts file updates
- Refactor `cli/commands/site/set-domain.ts` to use the new combined operation
- Add `logPrefix` option to `executeCliCommand` to identify which site the logs belong to
- Capture stdout from CLI child processes and log in real-time with `[CLI - {siteId}]` prefix
- Add logging for site create operations via CLI (`cli-site-creator.ts`)
- Add logging for site start operations via CLI (`cli-server-process.ts`)
- Add logging for WP-CLI command execution (`site-server.ts`)
* add bundled node

* change node download script

* Fix cli/node_modules copy pattern for Windows compatibility

* fix node command on Windows

* hide windows on child processes

* ensure nvrm version is used

* logs

* fix lint and tests

* attempt to fix windows hide

* trigger tests

* Refine download-node-binary script

- ESM instead of CommonJS
- Use npm modules instead of shell commands to extract archives
- Linux isn't supported
- fetch API instead of https module

* Use bundled node binary in ./bin scripts

* Flip the logic for distinguishing node environments

* process.env is already the default

* Use system-level node binary in development

* Use Electron node binary in unit tests

---------

Co-authored-by: Fredrik Rombach Ekelund <fredrik.rombach.ekelund@automattic.com>
* Statically import `runCommand` functions in CLI tests

* auth tests, too
* add new site from CLI to Studio runtime

* Fix external site changes not reflecting in UI (STU-1163)

* Fix TypeScript error: handle url property for stopped sites

* Fix tests

* add comments for site changes watch workflow

---------

Co-authored-by: Antonio Sejas <antonio@sejas.es>
* Update studio-cli.bat so we can read from stdin

* Don't silence chcp warnings
…2364)

* Use bundled latest WP version in online mode

* Fix unit tests

* Fix code formatting in site create test

* Refactor `createPathExistsMock` to set mock implementation internally
* stop sites on exit dialog

* cancel option, consistent message and e2e check

* conditional dialog when studio cli is installed
* Moved logic inside stop command and added flag

* Simplify `site stop --all` implementation

* Use `site stop --all` from Studio

* Fix tests

* Address review comments

---------

Co-authored-by: Volodymyr Makukha <nei.css@gmail.com>
* Miscellaneous translation tweaks

* Capitalize "Blueprint" where applicable

* Fix interpolation
* Abort async operations on SIGTERM/SIGINT

* Also send abort message to child server

* Only create AbortController when topic is not `abort`

* Fix

* More fixes

* Tweaks

* Fix unit tests

* Fix types

* Remove `this.sessionPath` files individually

To help us diagnose which specific files or directories are causing trouble

* Stop running servers in a detached process

* Revert "Remove `this.sessionPath` files individually"

This reverts commit 8786163.

* Retry

* Increase timeouts

* Fix deprecated blueprint syntax

* Increase timeout

* Try adding a small delay

* Kill `site list --watch` on SIGINT

* Create main window after creating site watcher

* Try using async fs method for cleanup

* Try rimraf (which has advanced retry strategies)

* New approach: don't remove `sessionPath` dir

* Unused import

* Force close app

* disconnect from pm2 in response to SIGTERM

* Revert user data watcher changes from #2313

* Wait for running button

* Use Electron's will-quit event in `execute-command.ts`

* SIGINT and SIGTERM listeners in `wp` command

* More SIGINT and SIGTERM listeners in `wp` command

* Temporarily skip blueprints test

* Revert "Temporarily skip blueprints test"

This reverts commit 0d16ae5.

* Try with force kill again

* Logging

* New approach to waiting for app close

* Logging again

* Try to make all child processes detached

* Experiment

* Revert "Experiment"

This reverts commit 3596bac.

* Revert "Try to make all child processes detached"

This reverts commit f99f4b0.

* Try a 5s timeout for closing the app

* Experiment with removing stopAllServersOnQuit

* shutdown message

* Revert "shutdown message"

This reverts commit 9d56d0c.

* Revert E2ESession::closeApp implementation

* Temporarily skip app.test.ts

* Temporarily skip blueprints.test.ts

* Revert "Temporarily skip app.test.ts"

This reverts commit 8307750.

* Revert "Temporarily skip blueprints.test.ts"

This reverts commit 9d78492.

* Add logging to Playwright source code

* pidtree

* More playwright logging

* More logging and await pidtree

* pidtree after close

* Remove stdio listeners

* Fix pidtree logging after close

* destroy stdio streams on exit

* Disconnect IPC

* Try teardown workaround

* Log pid and result in will-quit handler

* Unregister will-quit handlers

* Bring back logging

* Stop all servers on quit

* Undo all Windows hacks in E2ESession

* Bring back tree-kill

* Log stop-all pid and pidtree

* Catch errors from tree-kill

* Remove pidtree

* No IPC channel in stopAllServersOnQuit

* Update playwright-core patch to test theory

* Fix patch

* `spawn` over `fork`

* Temporarily remove `stopAllServersOnQuit`

* Never call `electronApp.close` on Windows

* Restore `e2e/e2e-helpers.ts`

* Reinstate `stopAllServersOnQuit`

* Revert `spawn` and IPC channel theory

* Fix unit tests

* Remove playwright-core patch

* Remove tree-kill dependency

* Remove `started` event

* More lenient child process cleanup

* Revert "Remove `started` event"

This reverts commit b42fa0b.

* Destroy stdio streams again

* Explicitly disconnect IPC

* Clean up `E2ESession`

* Always call `killRemainingProcesses`

* Reset test timeouts

* No `detached` option

* Reset more test timings

* Only prevent `will-quit` when applicable

* fix e2e test

* Children connect to pm2 daemon in sequence

* Fix unit tests

* Kill pm2 daemon in `site stop --all` command

* Fix stop command unit test, async disconnect, `process.exit`

* Remove stray `console.info` calls

* Undo all hacks in `E2ESession`

* Restore `E2ESession`, but don't kill children

* Increase timeout

* Don't log child pids

* Experimental: detach `site stop --all` again

* Clean up session files again

* Let's give rimraf one more try

* Experiment with removing `child.disconnect()` call

* Don't destroy stdio streams on exit

* Always run `site stop --all` command if pending update

* Notify Studio if user runs `site stop --all`

* Fix `package-lock.json` diff

* Fix and document "stop sites on exit" logic

* Speed up `site stop --all`

* Fix logic

* Revert "Experimental: detach `site stop --all` again"

This reverts commit 01ae1c4.

* String tweaks

---------

Co-authored-by: bcotrim <bernardo.cotrim@a8c.com>
* Use raw PHP-WASM to run WP-CLI commands

* Use php.cli to run WP CLI commands

* Remove PHP.exit

* Cleanup

* Disable help output for `wp` command

* No translate domain

---------

Co-authored-by: Bero <berislav.grgicak@gmail.com>
* different approach

* code cleanup

* Add PM2 kill event handling to _events command

* Improve events subscriber with async startup and proper cleanup

* trigger e2e

* Simplify _events signal handlers to match old pattern

* Fix index.test.ts to use isolateModulesAsync for async test

* trigger e2e retry

* Fix duplicate sites by debouncing events and restricting site creation to CREATED events

* fix lint

* Make event debouncing smarter: preserve CREATED events, send DELETE immediately

* Stop events relay process on cleanup

* fix issue with relay pmId

* address pr feedback

* fix unit test
@fredrikekelund fredrikekelund requested a review from a team January 16, 2026 07:30
@fredrikekelund fredrikekelund self-assigned this Jan 16, 2026
@wojtekn
Copy link
Contributor

wojtekn commented Jan 16, 2026

Looks good. The only glitch I found after running rough tests is that it reloads thumbnails and buttons each time I activate Studio window:

^[[A[CLI - pid 53534 - site ID 0f0f4892-c854-443a-ad5b-fafe0a5c9485] {"name":"Twenty Twenty-Five","path":"\/wordpress\/wp-content\/themes\/twentytwentyfive","slug":"twentytwentyfive","isBlockTheme":true,"supportsWidgets":false,"supportsMenus":false}

We can adjust that after the merge, though.

We can also merge #2399 to the branch after it's merged as it fixes the metrics tests' flakiness.

@fredrikekelund fredrikekelund merged commit 5e1182d into trunk Jan 16, 2026
10 of 11 checks passed
@fredrikekelund fredrikekelund deleted the dev/studio-cli-i2 branch January 16, 2026 10:35
@ivan-ottinger
Copy link
Contributor

ivan-ottinger commented Jan 16, 2026

Glad to see this coming in! I did not observe any obvious issues (apart from that refresh that Wojtek mentioned above already). If there's something, we should be able to catch it when smoke testing for the release.

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.

4 participants