Skip to content

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Jan 7, 2026

Related issues

Proposed Changes

  • Add cli-site-editor.ts module to invoke the CLI's studio site set command
  • Update IPC handler updateSite() to delegate to CLI for site changes (domain, HTTPS, PHP version, WP version)
  • Simplify edit-site-details.tsx - UI now just calls updateSite() and lets CLI handle restart logic
  • Simplify site-server.ts updateSiteDetails() since CLI handles hosts file, SSL certs, and WP updates
  • Create shared utility siteNeedsRestart() in common/lib/ so CLI and Studio UI share the same restart logic

Testing Instructions

  1. Create a site in Studio
  2. Start the site
  3. Open Edit Site modal and change:
    • Site name (no restart needed)
    • PHP version (should restart)
    • WordPress version (should restart and update WP)
    • Add custom domain (should restart)
    • Enable HTTPS (should restart)
  4. Verify each change works correctly and server restarts when needed
  5. Test editing while site is stopped (should update without restart)

Pre-merge Checklist

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

@bcotrim bcotrim self-assigned this Jan 7, 2026
@bcotrim bcotrim requested a review from fredrikekelund January 7, 2026 17:33
@bcotrim bcotrim force-pushed the stu-1149-check-edit-site-details-from-studio branch from 5ad33ba to 52dbfca Compare January 8, 2026 15:54
@bcotrim bcotrim marked this pull request as ready for review January 8, 2026 17:45
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.

LGTM 👍 Sensible and manageable diff. Nice work!

const loggerError = new LoggerError( __( 'Failed to configure site' ), error );
logger.reportError( loggerError );
}
process.exit( 1 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch 👍

Comment on lines +235 to +244
processEventHandler = ( event: unknown ) => {
const result = pm2ProcessEventSchema.safeParse( event );
if ( ! result.success ) {
return;
}

if ( result.data.process.name === processName && result.data.event === 'exit' ) {
reject( new Error( 'WordPress server process exited unexpectedly' ) );
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems sensible. Out of curiosity, did you add this because of something related to the core purpose of this PR, or was it just something that happened to come up here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This came up during testing this PR. When changing WP version to an incompatible one (e.g., 6.4.7 with Twenty Twenty-Five theme which requires WP 6.5+), the CLI would hang forever instead of reporting the error.

}
}

export async function updateSite(
Copy link
Contributor

Choose a reason for hiding this comment

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

Aside from being exposed as an IPC function, this function is also called in from multiple places in this file. It seems like the old purpose was to:

  1. Write changes to the appdata file.
  2. Update the SiteServer instance itself (which might have been entirely redundant, given that we pass SiteServer.details to this function already).

I'm curious if we really need to keep calling this function from startServer, stopServer, etc..?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, I think it deserves a closer look. I added a note on STU-1193 and will tackle it in that PR if you agree.

Comment on lines +354 to +372
// Check for WordPress critical error in HTML output
const wpDieMatch = message.match( /<div class="wp-die-message"[^>]*>([\s\S]*?)<\/div>/ );
if ( wpDieMatch ) {
// Extract text from HTML, removing tags
const htmlContent = wpDieMatch[ 1 ];
const textContent = htmlContent
.replace( /<[^>]+>/g, ' ' )
.replace( /\s+/g, ' ' )
.trim();
if ( textContent ) {
return `WordPress error: ${ textContent }`;
}
}

// Check for PHP fatal error pattern
const fatalMatch = message.match( /PHP Fatal error:\s*(.+?)(?:\sin\s|$)/i );
if ( fatalMatch ) {
return `PHP Fatal error: ${ fatalMatch[ 1 ].trim() }`;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious what these two conditions are based on. XDebug errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also related to the WordPress issue I came across during testing.
I just tried to clean the errors a bit so it's more UI friendly.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a small thing, but I still love the changes to this file. This is the kind of business logic consolidation that I think will do Studio a lot of good 👍

Comment on lines +201 to +202
tlsKey: site.tlsKey,
tlsCert: site.tlsCert,
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for the future: we don't need to load these details in the Studio app anymore

} );

emitter.on( 'success', () => {
console.log( `[CLI Site Editor] Command completed successfully` );
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

@bcotrim bcotrim merged commit f1f0731 into dev/studio-cli-i2 Jan 9, 2026
3 of 4 checks passed
@bcotrim bcotrim deleted the stu-1149-check-edit-site-details-from-studio branch January 9, 2026 16:26
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