Branch markers outlive their worktree and branch, so a reused branch name inherits a stale 🤖/💬
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
The marker is written in src/commands/config/state.rs around lines 932-933, and the only unset calls for worktrunk.state.* keys are the clear paths in that same file. Start by reading the wt remove code path and the helpers in src/git/repository/config.rs to see where branch deletion could clean up those keys. Done means a reproduction of the issue's steps no longer shows the old marker on a reused branch name, or wt list ignores markers whose branch is gone, with tests covering both.
Written by the indexing model from the issue text.
Description
Follow-up to #1733.
wt config state marker set stores the marker as worktrunk.state.<branch>.marker in the shared git config. Nothing removes that key when the worktree or the branch goes away, so a marker left behind by a session that never cleared it stays for good. #1733 was closed on the premise that "this goes away as soon as we remove the worktree, and even if we start a worktree with the same name, it gets reset". On 0.81.0 the key outlives both the worktree and the branch, and a new worktree on the same branch name shows the old marker.
Repro (0.81.0, macOS):
git init -q -b main /tmp/m && cd /tmp/m && git commit -q --allow-empty -m init
git worktree add -q -b feature ../m.feature
wt -C ../m.feature config state marker set 🤖
git worktree remove ../m.feature && git branch -D feature
git config --get-regexp '^worktrunk\.state\.'
# worktrunk.state.feature.marker {"marker":"🤖","set_at":...} <- still there
git worktree add -q -b feature ../m.feature
wt list
# + feature _ 🤖 <- the new worktree shows the old marker
This repro removes the worktree with plain git. I did not run wt remove. Reading the v0.81.0 source, though, nothing appears to unset the key on that path either. The marker is written at src/commands/config/state.rs:932-933. Every unset_config call on a worktrunk.state.* key is in src/commands/config/state.rs and runs only from wt config state ... clear (lines 1003, 1020, 1157, 1745, 1759, 1787, 1806). The other callers in src/git/repository/config.rs touch only worktrunk.history*, worktrunk.hints.* and worktrunk.default-branch.
In one repository that uses Claude Code worktrees heavily, git config --get-regexp 'worktrunk\.state\..*\.marker' listed 75 keys, and none of their branches still had a worktree. Its worktree branch names are deterministic (worktree-issue-<n>-<slug>), so a reopened issue inherits whatever marker the last session left.
How markers get stranded in the first place: a Claude Code session whose working directory moves during a turn (EnterWorktree / ExitWorktree) can set 🤖 on one branch at UserPromptSubmit, then send Stop and SessionEnd to another branch. The plugin avoids that by pinning to CLAUDE_PROJECT_DIR (#3956). Hook setups that follow the payload's cwd do not, and killed sessions (#1733) do not either.
Suggestions, smallest first:
- Unset
worktrunk.state.<branch>.marker(and arguably the wholeworktrunk.state.<branch>section) whenwt removedeletes the branch, or when it removes the branch's last worktree. - Have
wt listskip a marker whose branch no longer exists, or documentwt config state marker clear --branch <b>/--allas the cleanup for this case. - Optionally, a
wt config state prunethat removesworktrunk.state.*sections for branches that no longer exist.
- Dominant language
- Rust
- Stars
- 8.8k
- Forks
- 315
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 204
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from max-sixty/worktrunk
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
max-sixty/worktrunk#4727 · 7 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
max-sixty/worktrunk#4260 · 5 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
max-sixty/worktrunk#3847 · 1 comment ·
Maintainers usually reply within 1 day
-
`wt step` confusionOpen
Difficulty 5/5 Over a week Newbie friendliness 28/100
max-sixty/worktrunk#4728 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
max-sixty/worktrunk#4718 · 1 comment ·
Maintainers usually reply within 1 day
All issues in max-sixty/worktrunk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
n0-computer/iroh#4669 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rubys/roundhouse#1950 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
cloudflare/workers-rs#1130 ·
Maintainers usually reply within 11 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
vfarcic/dot-agent-deck#2160 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
RustCrypto/utils#1597 ·
Maintainers usually reply within 1 day