Repository navigation
fix: give each detached worktree its own summary cache directory - #4840
Conversation
The summary cache directory was keyed by the branch string, so every detached worktree wrote to summary/(detached)/. Each write trims that directory to one entry, so two detached rows with changes evicted each other and every `wt list --full` or picker Summary tab re-ran the LLM for both. A detached row's key now adds a hash of its worktree path; named branches keep their existing directories, so no cached summary is invalidated. Two worktrees on the same branch (`git worktree add --force`) still share a directory. Refs #4838
|
@worktrunk-bot The new per-worktree key leaves a cached detached summary in the legacy shared directory. After that checkout’s diff changes and a new summary is generated,
|
Before per-worktree keys, every detached worktree cached its summary under summary/(detached)/. After upgrading, that entry stayed listed by wt config state get next to the current per-worktree one indefinitely. A detached write now removes the legacy directory, unless a local branch named (detached) exists — Git permits that name, and its summaries live in the same directory. Co-Authored-By: Claude <[email protected]>
|
Handled in 920cf24. After a detached summary is written under its per-worktree key, the legacy New tests, both starting with a pre-upgrade entry in the legacy directory:
|
Every detached worktree wrote its LLM summary to the same cache directory,
summary/(detached)/, because the directory was keyed by the branch string and bothwt list --fulland the picker pass(detached)for a row without a branch.CachedSummary::writetrims that directory to one entry after each write, so two detached worktrees with changes evicted each other, and the next run called the LLM for both again. A detached row's directory key now includes a hash of its worktree path. Named branches keep their existing directories, so no cached summary has to be regenerated. The JSONbranchfield still reads(detached), sowt config state getdisplays these rows the same way, with one row per detached worktree instead of one shared row.test_detached_worktrees_keep_separate_cached_summariescreates two detached worktrees with different uncommitted changes and summarizes each one twice. On the old code, the second summary of the first worktree re-ran the LLM command (left: "regenerated",right: "Summary A"). It passes with the fix.Detached summaries cached by earlier releases sit in the shared
summary/(detached)/directory. A detached write now removes that directory, sowt config state getdoesn't keep listing the pre-upgrade summary beside the current one. It is kept when a local branch named(detached)exists, because Git allows that name and its summaries use the same directory.test_detached_summary_prunes_legacy_shared_entryandtest_detached_summary_keeps_real_detached_named_branchstart with that directory populated and cover both cases.The callers now pass
Option<&str>for the branch instead of the"(detached)"sentinel, andsummary.rsmapsNoneto the display name.Not covered: two worktrees on the same branch (
git worktree add --force) still share a directory and can still evict each other. Fixing that means putting the worktree path in every row's key, which forces a one-time regeneration of every cached summary. The issue leaves that trade-off to a maintainer.Refs #4838 — automated triage