Problem
Starting a thread in a new worktree from a dirty source checkout can lead to confusing cross-checkout behavior:
- an untracked or uncommitted file exists only in the source checkout
- a new thread is started with
new worktree
- the user references that file in the new thread
- the agent/session resolves the file outside the current worktree and silently copies or uses it
This leaves stray untracked files in the main checkout and makes it look like git worktrees are leaking files, even though the real problem is product behavior around dirty sources and cross-worktree file discovery.
Expected behavior
Treat this as a product guard, not repo guidance.
- When creating a
new worktree session from a dirty source checkout, require an explicit choice instead of silently proceeding.
- If a referenced file is missing in the current worktree but exists in another worktree or the main checkout, do not silently use or copy it.
- Prompt the user with explicit options such as:
- stay in current checkout
- stash tracked changes
- stash including untracked files
- commit first
- continue anyway
- use the other checkout instead
- copy into current worktree
- move into current worktree
- cancel
Why this matters
The missing-file prompt fixes the immediate symptom, but the real prevention point is new-worktree session preflight on dirty source checkouts. The safest fix is to implement both layers.
Acceptance criteria
- No silent cross-worktree file copy/use when the referenced path is absent from the active worktree.
- New-worktree session creation surfaces dirty-source state before launch.
- Session/runtime behavior makes the active checkout choice explicit to the user.
Problem
Starting a thread in a new worktree from a dirty source checkout can lead to confusing cross-checkout behavior:
new worktreeThis leaves stray untracked files in the main checkout and makes it look like git worktrees are leaking files, even though the real problem is product behavior around dirty sources and cross-worktree file discovery.
Expected behavior
Treat this as a product guard, not repo guidance.
new worktreesession from a dirty source checkout, require an explicit choice instead of silently proceeding.Why this matters
The missing-file prompt fixes the immediate symptom, but the real prevention point is new-worktree session preflight on dirty source checkouts. The safest fix is to implement both layers.
Acceptance criteria