feat: add confirmation dialog to archive & delete workspace action#23150
feat: add confirmation dialog to archive & delete workspace action#23150
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a “type the workspace name to confirm” guard (“molly-guard”) before the Archive & delete workspace action executes in the Agents UI, reducing accidental destructive actions.
Changes:
- Introduces a pending “archive & delete” state so the mutation only runs after confirmation.
- Fetches the target workspace name (by ID) to drive name-typed confirmation.
- Renders the shared
DeleteDialogfromAgentsPageViewand wires it via a newdeleteDialogprop.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| site/src/pages/AgentsPage/AgentsPageView.tsx | Adds DeleteDialog rendering and a new deleteDialog prop contract for controlling it. |
| site/src/pages/AgentsPage/AgentsPageView.stories.tsx | Updates story args to satisfy the new props and provide deleteDialog defaults. |
| site/src/pages/AgentsPage/AgentsPage.tsx | Defers the destructive mutation behind pending state + workspace name lookup, then passes dialog controls to the view. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Could we make sure we have a story covering this change |
|
$Addressed in 7706cb9 — added |
b8988c9 to
55423b1
Compare
| archiveAndDeleteMutation.mutate(pendingArchiveAndDelete, { | ||
| onSettled: () => { | ||
| setPendingArchiveAndDelete(null); | ||
| navigate("/agents"); |
There was a problem hiding this comment.
review: added this so after you archive and delete you go back to the "New Agent" page.
Require users to type the workspace name before the 'Archive & delete workspace' action fires. This prevents accidental deletion of workspaces (particularly pre-existing ones that were linked to a chat rather than auto-created by the agent). Uses the existing DeleteDialog component. The dialog is rendered in AgentsPage where the mutation lives, so both the sidebar and the top-bar action go through the same confirmation flow. The workspace name is fetched via workspaceById (usually already cached from the agent detail view).
- Navigate to /agents after archive-and-delete settles so the deleted chat no longer stays focused (johnstcn) - Add error handling for workspace name lookup failure via useEffect; toast error and clear pending state (Copilot) - Add key prop to DeleteDialog to reset typed confirmation text when targeting a different workspace (Copilot) - Override title/verb on DeleteDialog to say 'Archive agent & delete workspace' matching the actual action (Copilot) - Add DeleteConfirmationDialog and DeleteConfirmationDialogLoading stories (DanielleMaywood)
Extend the play function to type the workspace name, assert the confirm button enables, click it, and check onConfirm was called.
4f30652 to
8af5a0d
Compare
Use a stateful render function so onConfirm flips isLoading to true, then assert the button disables. Removes the separate DeleteConfirmationDialogLoading story.
8af5a0d to
99a84e5
Compare
Gate the menu item on whether the workspace was created after the chat (autocreated by the createworkspace tool) vs linked by the user at chat creation time. - Sidebar: fetch workspace per ChatTreeNode via useQuery, compare workspace.created_at >= chat.created_at - TopBar: use existing workspace query data in AgentDetail.tsx, pass canDeleteWorkspace boolean down - Rename hasWorkspace → canDeleteWorkspace in TopBar path
- AutocreatedWorkspaceShowsDelete: workspace created after chat, menu item appears - LinkedWorkspaceHidesDelete: workspace created before chat, menu item hidden
8716789 to
5b0bd17
Compare
…firmation The 'Archive & delete workspace' context menu item is now always shown when a workspace is associated with a chat. The delete confirmation dialog is only shown when the workspace was created *before* the chat (a 'pet' workspace that the user likely does not want to accidentally delete). Auto-created workspaces (created after the chat started) skip the confirmation dialog and proceed directly.
5b0bd17 to
4fbf317
Compare
| const isAutoCreatedWorkspace = | ||
| hasWorkspace && | ||
| new Date(workspaceQuery.data.created_at) >= new Date(chat.created_at); |
There was a problem hiding this comment.
review: this controls whether we consider a workspace "auto-created" or not and whether we show the molly-guard.
|
smoke-tested ✅ |
Re-creation of #23016 but with the correct branch name