Skip to content

Conversation

@katinthehatsite
Copy link
Contributor

@katinthehatsite katinthehatsite commented Dec 23, 2025

Related issues

Closes STU-1099

Proposed Changes

This PR refactors CreateSiteForm to take features prop and an onSubmit prop instead of all the value and setter props that it currently does.

Testing Instructions

  • Pull the changes from this branch
  • Start the app with npm start
  • Click on the Add site in the sidebar
  • Try all the options for creating sites and test those extensively e.g. for errors, using custom domain, renaming sites etc. to ensure it works as the current site creation process

Pre-merge Checklist

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

@katinthehatsite katinthehatsite self-assigned this Dec 23, 2025
@katinthehatsite katinthehatsite marked this pull request as draft December 23, 2025 10:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the CreateSiteForm component to manage its own state internally instead of receiving numerous value and setter props, reducing props drilling. The form now accepts defaultValues for initialization and an onSubmit callback that receives all form values, simplifying the component hierarchy and data flow.

Key Changes

  • The CreateSiteForm now owns its form state internally (site name, path, PHP/WP versions, custom domain settings) instead of relying on lifted state
  • The useAddSite hook has been restructured to expose path validation functions (selectPath, generateProposedPath) and a site creation function (handleCreateSite) instead of managing form state
  • The form submission mechanism now uses native form submission with a form ID, allowing the stepper's "Add site" button to submit the form via the form attribute

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/modules/add-site/index.tsx Refactored to pass defaultValues and callback functions to CreateSite instead of managing form state; added logic to build default values with blueprint preferred versions
src/modules/add-site/components/create-site.tsx Updated props interface to accept defaultValues and callbacks instead of individual state values and setters
src/modules/add-site/components/create-site-form.tsx Major refactor to internalize form state management; now accepts defaultValues for initialization and onSubmit callback that receives complete form values
src/modules/add-site/components/stepper.tsx Modified action button to use native form submission with createFormId for create paths instead of onClick handler
src/modules/add-site/hooks/use-stepper.ts Added isCreatePath boolean to identify when the form is on a create path
src/modules/add-site/components/index.ts Added exports for new types: CreateSiteFormValues, CreateSiteFormProps, and PathValidationResult
src/hooks/use-add-site.ts Significantly refactored to remove form state management and expose path validation and site creation functions instead; added type definitions for CreateSiteFormValues and PathValidationResult
src/hooks/tests/use-add-site.test.tsx Updated tests to work with new API that uses handleCreateSite with form values instead of individual setters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@katinthehatsite katinthehatsite requested a review from a team December 29, 2025 14:59
@katinthehatsite katinthehatsite marked this pull request as ready for review December 29, 2025 14:59
@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

📊 Performance Test Results

Comparing 36511c7 vs trunk

site-editor

Metric trunk 36511c7 Diff Change
load 6292.00 ms 5112.00 ms -1180.00 ms 🟢 -18.8%

site-startup

Metric trunk 36511c7 Diff Change
siteCreation 9067.00 ms 9086.00 ms +19.00 ms 🔴 0.2%
siteStartup 3954.00 ms 3954.00 ms 0.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@katinthehatsite katinthehatsite mentioned this pull request Dec 31, 2025
1 task
*/
const generateProposedPath = useCallback(
async ( siteName: string ): Promise< PathValidationResult > => {
const { path, isEmpty, isWordPress } = await getIpcApi().generateProposedSitePath( siteName );
Copy link
Contributor

@gcsecsey gcsecsey Jan 6, 2026

Choose a reason for hiding this comment

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

I think we'll need to destructure the isNameTooLong prop here as well. When I tested with a long path, I get the "directory is not empty" error.

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I missed this when I was resolving conflicts, I will make some updates to this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made changes in 7196c0e

Copy link
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

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

This is looking good overall, I found that I don't get the "The site name is too long" error anymore with these changes. I found no other regressions.

Copy link
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

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

Thanks for iterating on the changes and fixing the tests @katinthehatsite! This works great now, I found no regressions. 👍

@katinthehatsite katinthehatsite merged commit dfb5503 into trunk Jan 9, 2026
9 checks passed
@katinthehatsite katinthehatsite deleted the fix/refactor-create-site-form branch January 9, 2026 11:55
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