Repository navigation
Move a worktree thread (and its changes) to the current checkout #16570
Replies: 2 comments
|
Julius closed my #19295 as a duplicate of this, so adding my points here. My case is a bit wider, Docker is set up in only one of my worktrees and that is not always the main checkout, so I think the target should be any existing worktree, not only the project checkout. For a dirty target I would refuse with a clear message that lists the changed files, your Commit/Stash/Discard dialog works for me too. If the target is on another branch, switching it to the thread's branch automatically and remembering the old one would save a step. When the source is another worktree and not the main one, I would rather keep it detached than remove it. Also, a worktree change detaches the Claude session and kills background agents (#16000), so I think this move should reuse the same background-work guard. +1 on opening the PR, I would use this daily. |
|
Thanks @LAlex14, these all made sense, so I reworked the implementation around them. The action is now Move to worktree…:
Updated answers to my original questions:
The implementation, with tests against real Git repositories, is on my fork: https://github.com/EduardoDadalt/t3code Could a maintainer confirm whether this direction and scope are OK for a PR? Proposed scope: web and desktop, one server service method behind |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
T3 Code makes it easy to start work in a worktree, and agents can hand a thread from the
current checkout into a new worktree (
t3_worktree_handoff). There is no way back.When work started in a worktree should continue in the project's own folder (to run the
real dev environment, use a tool that is only set up there, or just stop juggling a
second checkout), today you have to do it by hand:
Step 4 has no manual workaround: the thread stays bound to the worktree.
Proposal
A thread action, Move to current checkout, available for idle threads that work in
a worktree (sidebar right-click menu and the chat header's thread menu on web/desktop).
It:
worktree was detached), so commits made in the worktree come along;
files — as ordinary unstaged edits;
worktreePath: null), so the next turnruns there;
Files ignored by Git (
.env,node_modules) are not moved, and the dialog says so.Never overwrite local work
picks Commit (with a message), Stash, or Discard in the dialog.
before anything changes, so a failure can't lose the work being moved.
git read-tree -m -u, which refuses to overwrite files thatdiffer from what it expects.
metadata update), leaving the worktree on its branch with its changes and the
checkout on its original branch.
same worktree.
Shape
git.moveThreadToLocalCheckoutRPC), so the samecapability could later be exposed as an MCP tool, the reverse of
t3_worktree_handoff.if wanted.
I have a working implementation with tests against real Git repositories (full move,
dirty-checkout refusal, stash, rollback on failure) and would be happy to open a PR if
the direction and scope sound right.
Questions for maintainers
existing worktree cleanup to handle?
move simply refuse and let the user clean up first?
All reactions