[Bug]: Clicking Cancel on the "Delete the worktree too?" dialog still permanently deletes the thread #48310
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/web
Steps to reproduce#
- Keep Delete worktrees with deleted threads (
worktreeOnDelete) off (the default). - Create a thread attached to a Git worktree so that it is the only thread linked to that worktree.
- Delete the thread from the sidebar (if Confirm thread delete is enabled, confirm the first dialog; if it is disabled, the worktree dialog is the first and only dialog shown).
- When the warning popup appears:
with buttons Cancel and Confirm, click Cancel (or press Escape or click outside the dialog) intending to abort the deletion.Delete the worktree too? This thread is the only one linked to this worktree:
<worktree path>
Expected behavior#
Clicking Cancel (or pressing Escape / dismissing the dialog) should never permanently delete the thread. Learning that a thread is the only one linked to a worktree is material information that commonly makes a user reconsider deleting the thread at all, so there should be a clear way to back out without losing the thread.
Suggested fixes:
- Preferred — combine into a single confirmation dialog: Check for an orphaned worktree before prompting and show one dialog: "Delete thread
<title>?" with the sole-worktree note and a checkbox (unchecked by default) "Also delete the linked worktree folder", plus explicit Cancel (aborts everything) and Delete thread / Delete thread & worktree buttons. This eliminates back-to-back modals and ensures Cancel / Escape always aborts cleanly. - Alternative (if keeping the worktree prompt separate or when
confirmThreadDeleteis off): Replace the 2-button booleanCancel/Confirmdialog with a 3-choice dialog:- Cancel (and Escape / backdrop click) — aborts the deletion entirely (keeps both thread and worktree)
- Delete thread only — deletes the thread, keeps the worktree
- Delete thread & worktree — deletes both
Actual behavior#
Clicking Cancel (or pressing Escape / clicking outside) permanently deletes the thread anyway with no undo, leaving only the worktree behind.
Root cause in apps/web:
useThreadActions.ts(lines 594–644) uses a booleanlocalApi.dialogs.confirm(...)call to setshouldDeleteWorktree = confirmationResult.valueand then unconditionally proceeds todeleteThreadMutation(...)even whenconfirmationResult.valueisfalse.ConfirmDialogHost.tsx(lines 70–105) hardcodes the two buttons to Cancel and Confirm, and maps Cancel, Escape, and backdrop dismiss tofalse.
Once this dialog appears, there is no way for the user to abort deleting the thread.
Impact#
Major degradation or frequent failure
Version or commit#
t3 v0.1.13 (also verified present on main @ 85b15b92e0f529154677801e072b1e0c3b007433)
Environment#
Linux (Ubuntu), T3 Code web UI, t3 v0.1.13
Workaround#
None once the worktree dialog appears (any choice or dismissal deletes the thread). Keeping Confirm thread delete enabled helps catch mistakes on the first dialog, before the worktree warning is shown.
tanstack-source added labelsbug
Sign in to join this conversation.