Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Clicking Cancel on the "Delete the worktree too?" dialog still permanently deletes the thread #48310

OpenSmithLabsLLC(GitHub profile, opens in a new tab) opened this issue 0 comments

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

  1. Keep Delete worktrees with deleted threads (worktreeOnDelete) off (the default).
  2. Create a thread attached to a Git worktree so that it is the only thread linked to that worktree.
  3. 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).
  4. When the warning popup appears:

    Delete the worktree too? This thread is the only one linked to this worktree: <worktree path>

    with buttons Cancel and Confirm, click Cancel (or press Escape or click outside the dialog) intending to abort the deletion.

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:

  1. 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.
  2. Alternative (if keeping the worktree prompt separate or when confirmThreadDelete is off): Replace the 2-button boolean Cancel / Confirm dialog 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 boolean localApi.dialogs.confirm(...) call to set shouldDeleteWorktree = confirmationResult.value and then unconditionally proceeds to deleteThreadMutation(...) even when confirmationResult.value is false.
  • ConfirmDialogHost.tsx (lines 70–105) hardcodes the two buttons to Cancel and Confirm, and maps Cancel, Escape, and backdrop dismiss to false.

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.

  1. tanstack-source added labelsbug

Sign in to join this conversation.