Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Deleting a thread offers to force-remove a worktree that T3 didn't create #48176

OpensQVe(GitHub profile, opens in a new tab) opened this issue 1 comment

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" off (the default).
  2. Create a worktree outside T3 and leave a change uncommitted:
    git init -b main myproj && cd myproj
    echo hello > README.md && git add . && git commit -m init
    git worktree add ../myproj-feature -b feature-x
    echo wip >> ../myproj-feature/README.md
  3. Add myproj as a project, start a thread, and pick feature-x in the branch picker. The thread now points at myproj-feature.
  4. Delete the thread and confirm "Delete the worktree too?".

Expected behavior

T3 offers to delete only worktrees it created. Automatic cleanup already does this: it skips anything "outside the managed worktree folder" (storageCleanup.ts).

Actual behavior

myproj-feature is force-removed, along with its uncommitted change. getOrphanedWorktreePathForThread only checks whether another thread uses the path, and useThreadActions.ts then removes it with force: true.

This hits hardest with a bare repository and one worktree per branch, where any existing branch you pick is one of your own worktrees. Unlike #37769, which asks for a dirty check, this is about ownership.

Reproduced in the T3 Code desktop app (v0.1.13, Linux). With automatic cleanup on, the worktree was kept and no prompt appeared.

Impact

Major degradation or frequent failure (data loss)

Version or commit

v0.1.13 (code links: main at 23fad9519a)

Environment

Linux, T3 Code desktop

Workaround

Turn on "Delete worktrees with deleted threads", or click Cancel on "Delete the worktree too?" for any worktree you created yourself.

  1. tanstack-source added labelsbug

  2. A fix for this was proposed in #48219, but when the reported steps were run in the real app the problem did not appear.

    What was run on 7b7ca65f9a, the commit before this change:

    Created a git project with README.md, added a sibling feature-x worktree with an uncommitted wip line, started a thread selecting feature-x, opened Thread actions > Delete, confirmed deletion, and observed the worktree-delete prompt and filesystem state on both commits.

    How: Web app via the repository e2e runner, fresh T3CODE_DEV_SEED=0 database per checkout, Replay (dev) provider, same viewport.

    Could you share the exact steps, what you see, and the version and platform you are on? The pull request is closed for now; the fix is picked up again once the problem can be shown.

  3. juliusmarminge added labelsneeds more info

Sign in to join this conversation.