Skip to content

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Dec 2, 2025

Related issues

Proposed Changes

  • Add --watch to studio site list
  • Add watcher to Studio to listen to site status changes
  • Implemented createCliServerProcess so Studio can start and stop sites using Studio CLI

Testing Instructions

  • npm install
  • npm start
  • Start a new site using Studio
  • Confirm site is running
  • Stop site using Studio
  • Confirm site is not running
  • Confirm studio site list returns the correct status for the site
  • Start site using Studio CLI
  • Confirm Studio shows the site as running
  • Stop the site using Studio CLI
  • Confirm Studio shows the site as stopped

Pre-merge Checklist

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

@bcotrim bcotrim self-assigned this Dec 2, 2025
@bcotrim bcotrim force-pushed the stu-1019-studio-refactor-studio-to-depend-on-the-cli-for-starting branch from 034011f to e882445 Compare December 3, 2025 19:25
@bcotrim bcotrim requested a review from a team December 3, 2025 19:28
@bcotrim bcotrim marked this pull request as ready for review December 3, 2025 19:31
@bcotrim bcotrim force-pushed the stu-1019-studio-refactor-studio-to-depend-on-the-cli-for-starting branch from e882445 to d0e4359 Compare December 4, 2025 14:47
Copy link
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @bcotrim! 👍 Very satisfying to see this come together. It's working nicely in my testing so far.

I left a couple of smaller comments.

I'd also be interested to hear your perspective of this site list --watch approach vs watching the config file for changes and using some mechanism (a version of the studio site status command, perhaps) to check the site status when latestCliPid changes. I don't really have a strong opinion there, but it would be good to have a documented reason for going one way or the other.

Comment on lines 153 to 165
choices: [ 'table', 'json' ],
default: 'table',
description: __( 'Output format' ),
} )
.option( 'watch', {
type: 'boolean',
default: false,
description: __( 'Watch for site status changes and update the list in real-time' ),
} );
},
handler: async ( argv ) => {
try {
await runCommand( argv.format as 'table' | 'json' );
await runCommand( argv.format as 'table' | 'json', argv.watch as boolean );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

					choices: [ 'table', 'json' ] as const,
					default: 'table' as const,
					description: __( 'Output format' ),
				} )
				.option( 'watch', {
					type: 'boolean',
					default: false,
					description: __( 'Watch for site status changes and update the list in real-time' ),
				} );
		},
		handler: async ( argv ) => {
			try {
				await runCommand( argv.format, argv.watch );

Kind of a nitpick, but that's how we get yargs to provide the correct types for the options.

} );

app.on( 'quit', () => {
void stopAllServersOnQuit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will kill all running processes, regardless of whether they were started from the CLI or from the app. We could just accept this behavior, but @nightnei also had a pretty good idea to display a simple modal before quitting the app that says "Do you want to stop the running sites? Yes / Leave them runing"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea! I would add a "remember my decision" checkbox. I think that provides enough tools for our users to adjust their experience as it work best for them. We can always revisit in the future.
Should I handle that change in this PR or as part of STU-1078 ?

Comment on lines +727 to +731
// CLI-managed sites don't have PHP instance, return cached theme details for Now
// ToDo: Implement logic to fetch theme details using mu-plugin?
if ( ! server.server.php ) {
return server.details.themeDetails;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we have WP-CLI support, we might also consider using the wp eval command

export function executeCliCommand(
args: string[],
options: ExecuteCliCommandOptions = {}
): CliCommandEventEmitter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
): CliCommandEventEmitter {
): [CliCommandEventEmitter, ChildProcess] {

Optional, but we could return the child process instance from this function, too. It would save us from the dance of having to set the kill function on the EventEmitter

@bcotrim bcotrim changed the base branch from trunk to dev/studio-cli-i2 December 5, 2025 12:25
@bcotrim bcotrim force-pushed the stu-1019-studio-refactor-studio-to-depend-on-the-cli-for-starting branch from 5a0ae52 to dd0994d Compare December 5, 2025 19:04
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.

3 participants