Skip to content

feat: add confirmation dialog to archive & delete workspace action#23150

Open
johnstcn wants to merge 7 commits intomainfrom
cj/archive-delete-confirm
Open

feat: add confirmation dialog to archive & delete workspace action#23150
johnstcn wants to merge 7 commits intomainfrom
cj/archive-delete-confirm

Conversation

@johnstcn
Copy link
Member

@johnstcn johnstcn commented Mar 17, 2026

Re-creation of #23016 but with the correct branch name

  • Adds a "molly-guard" to require users to type the workspace name before the 'Archive & delete workspace' action fires. This prevents accidental deletion of 'pet' workspaces.
  • This is only shown for workspaces created before the chat was created. The logic here is that any workspace that existed previous to the chat cannot have been created by the chat.

@johnstcn johnstcn self-assigned this Mar 17, 2026
@johnstcn johnstcn marked this pull request as ready for review March 18, 2026 13:25
Copy link
Contributor

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

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 DeleteDialog from AgentsPageView and wires it via a new deleteDialog prop.

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.

@johnstcn johnstcn removed the request for review from DanielleMaywood March 18, 2026 13:54
@DanielleMaywood
Copy link
Contributor

Could we make sure we have a story covering this change

Copy link
Member Author

$Addressed in 7706cb9 — added DeleteConfirmationDialog and DeleteConfirmationDialogLoading stories.\n\n> 🤖 This response was generated by Coder Agents.

@johnstcn johnstcn force-pushed the cj/archive-delete-confirm branch from b8988c9 to 55423b1 Compare March 18, 2026 17:56
archiveAndDeleteMutation.mutate(pendingArchiveAndDelete, {
onSettled: () => {
setPendingArchiveAndDelete(null);
navigate("/agents");
Copy link
Member Author

Choose a reason for hiding this comment

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

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.
@johnstcn johnstcn force-pushed the cj/archive-delete-confirm branch from 4f30652 to 8af5a0d Compare March 18, 2026 19:01
Use a stateful render function so onConfirm flips isLoading to true,
then assert the button disables. Removes the separate
DeleteConfirmationDialogLoading story.
@johnstcn johnstcn force-pushed the cj/archive-delete-confirm branch from 8af5a0d to 99a84e5 Compare March 18, 2026 19:08
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
@johnstcn johnstcn removed the request for review from DanielleMaywood March 18, 2026 19:43
@johnstcn johnstcn marked this pull request as draft March 18, 2026 19:43
@johnstcn johnstcn force-pushed the cj/archive-delete-confirm branch 2 times, most recently from 8716789 to 5b0bd17 Compare March 18, 2026 20:19
…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.
@johnstcn johnstcn force-pushed the cj/archive-delete-confirm branch from 5b0bd17 to 4fbf317 Compare March 18, 2026 20:34
@johnstcn johnstcn marked this pull request as ready for review March 18, 2026 21:37
Comment on lines +420 to +422
const isAutoCreatedWorkspace =
hasWorkspace &&
new Date(workspaceQuery.data.created_at) >= new Date(chat.created_at);
Copy link
Member Author

Choose a reason for hiding this comment

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

review: this controls whether we consider a workspace "auto-created" or not and whether we show the molly-guard.

@johnstcn
Copy link
Member Author

smoke-tested ✅

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