[Website] Add error notices and delete confirmation modal to site management#3454
[Website] Add error notices and delete confirmation modal to site management#3454
Conversation
…umers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves site-management UX by surfacing API errors inside modals and replacing blocking window.confirm deletion with a dedicated modal flow.
Changes:
- Add inline error notices to rename/save/delete site modals so API errors aren’t silently swallowed.
- Replace
window.confirmwith a newDeleteSiteModaland Redux UI state to track which site is being deleted. - Add JSDoc (
@param,@returns,@throws) documentation across thePlaygroundSitesAPIinterface.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/playground/website/src/lib/state/redux/slice-ui.ts | Adds DELETE_SITE modal slug and siteSlugToDelete UI state/action to support delete modal flow. |
| packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts | Adds API JSDoc and updates error/guard behavior for active-site operations and deletion messaging. |
| packages/playground/website/src/lib/state/redux/persist-temporary-site.ts | Lets directory picker errors propagate so callers can show cancellation/errors in UI. |
| packages/playground/website/src/components/site-manager/site-info-panel/index.tsx | Switches delete action from window.confirm + API call to opening the delete modal with selected slug. |
| packages/playground/website/src/components/saved-playgrounds-overlay/index.tsx | Switches delete action to open delete modal (instead of confirming + calling API directly). |
| packages/playground/website/src/components/save-site-modal/index.tsx | Displays real error messages via <Notice> and moves error notice above action buttons. |
| packages/playground/website/src/components/rename-site-modal/index.tsx | Shows rename errors inline via <Notice> and unifies form layout via shared modal form CSS. |
| packages/playground/website/src/components/modal/style.module.css | Adds shared .modal-form styling for consistent modal form layout. |
| packages/playground/website/src/components/layout/index.tsx | Wires DELETE_SITE slug to render the new DeleteSiteModal. |
| packages/playground/website/src/components/delete-site-modal/index.tsx | Introduces a delete confirmation modal with inline error handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const handleDeleteSite = (site: SiteInfo, closeMenu: () => void) => { | ||
| dispatch(setSiteSlugToDelete(site.slug)); | ||
| modalDispatch(setActiveModal(modalSlugs.DELETE_SITE)); | ||
| closeMenu(); | ||
| }; |
There was a problem hiding this comment.
Deletion modal state is being split across two dispatchers (dispatch vs modalDispatch). If these target different Redux stores/providers, the modal can open without ui.siteSlugToDelete set (or vice versa), causing the UI to render no modal content and leaving activeModal stuck. Use the same dispatcher for both setSiteSlugToDelete(...) and setActiveModal(...) so the slug and modal state are always updated atomically in the same store.
There was a problem hiding this comment.
@bgrgicak Valid point for consideration? Thoughts? Not a blocker of course.
There was a problem hiding this comment.
If these target different Redux stores/providers, the modal can open without ui.siteSlugToDelete set (or vice versa)
Both dispatches use the same store.
| if (!site || site.metadata.storage === 'none') { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
When activeModal is DELETE_SITE but the selected site is missing (e.g., stale slug, deleted elsewhere, or store mismatch), returning null renders no modal while leaving the modal route/state active. This can strand users with modal=delete-site in the URL and no visible way to close it. Instead of returning null, proactively close/reset the modal state (e.g., via an effect) or render a minimal modal that explains the issue and offers a close button.
There was a problem hiding this comment.
When the DELETE_SITE modal is active but the target site no longer exists (e.g. stale URL), dispatch closeModal actions so the URL param is cleaned up. Also remove the storage === 'none' guard since both callers already prevent temporary sites from reaching this modal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These modals require Redux state (siteSlugToDelete / siteSlugToRename) that is not persisted in the URL, so restoring them from a stale URL param would silently show nothing. Exclude them like save-site and remove the now-unnecessary cleanup effect from DeleteSiteModal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ashfame
left a comment
There was a problem hiding this comment.
Changeset looks good. I haven't personally tested it yet. Plan to do tomorrow, but just in case if this falls off the radar, feel free to merge. Hence, approving!
Motivation for the change, related issues
Follow-up to PR feedback on #3401. The
PlaygroundSitesAPImethods throw descriptive errors for MCP consumers, but UI components were silently swallowing them. Additionally, site deletion usedwindow.confirm, which is inconsistent with the rest of the modal-based UI and blocks the main thread.Implementation details
Error notices in modals
sitesAPI.rename()and displays them in a<Notice>component.sitesAPI.delete()and displays them inline.Delete confirmation modal
window.confirmwith a newDeleteSiteModalcomponent, consistent with the existing rename/save modal pattern.DELETE_SITEmodal slug andsiteSlugToDeleteUI state to the Redux store.window.confirm.API documentation
@param,@returns, and@throwstags to every method on thePlaygroundSitesAPIinterface.Minor cleanups
getActiveSiteOrThrow— each call site now checks and throws with a context-specific message ("No active site selected").persistTemporarySitenow letsshowDirectoryPickererrors propagate instead of silently returning, so callers can handle cancellation.storage === 'none'safety-net checks that are no longer needed.Testing Instructions
Testing Instructions
save-site-modal/index.tsx, addthrow new Error('test')before thepersistTemporarySitecall inhandleSubmitrename-site-modal/index.tsx(beforesitesAPI.rename()) anddelete-site-modal/index.tsx(beforesitesAPI.delete())throwstatements