Skip to content

fix(picker): skip disk cache write when git log fails - #2651

Merged
max-sixty merged 3 commits into
mainfrom
tend/picker-log-cache-fix
May 9, 2026
Merged

max-sixty merged 3 commits into
mainfrom
tend/picker-log-cache-fix

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

The Log-preview cache hit/miss split in #2646 replaced an explicit return String::new() on git log failure with unwrap_or_default(), which writes an empty LogCacheEntry to disk via preview_cache::write_log. Because the disk cache is SHA-keyed, that empty entry then suppresses the preview on every subsequent visit until the cache is cleared by hand.

This restores the prior contract: when git log fails, return an empty preview without writing through. The orchestrator already protects the in-memory DashMap against the same poisoning during the refresh path (preview_orchestrator.rs:99-104) — this brings the disk path in line.

Also fixes the run-on docstring on compute_log_preview: the two paragraphs added by #2646 lacked the /// blank-line separator and rendered as one paragraph in cargo doc.

Test plan

  • Picker module tests pass locally (cargo test --bin wt commands::picker — 102 passed)
  • Clippy clean
  • CI green

The git log failure branch is, per the existing inline comment, "effectively unreachable" because merge-base already validated head. A regression test for the no-write-on-failure property would require fault injection at the Cmd::run() layer, which the codebase doesn't currently support — so none is added here. The fix is a structural restoration of the pre-refactor branch in #2646.

Found during nightly tend sweep.

worktrunk-bot and others added 2 commits May 9, 2026 07:17
The Log-preview cache hit/miss split (#2646) replaced an explicit
`return String::new()` on `compute_log_raw_and_stats` failure with
`unwrap_or_default()`, which writes a default `LogCacheEntry` (empty
`raw_log`, empty `stats`) to disk via `preview_cache::write_log`. Once
written, the SHA-keyed disk entry suppresses the preview on every
subsequent visit until the cache is cleared.

Restore the prior contract: if `git log` fails, return an empty preview
without persisting. The orchestrator already protects the in-memory
DashMap against the same poisoning during the refresh path
(`preview_orchestrator.rs:99-104`); this brings the disk path in line.

Also fix the run-on docstring on `compute_log_preview` — the two
paragraphs added by #2646 lacked the `///` blank-line separator and
rendered as one paragraph in `cargo doc`.

The git-log-failure branch is, per the existing comment, "effectively
unreachable" because merge-base already validated `head`. A regression
test would require fault injection at the git command layer that the
codebase doesn't currently support, so none is added here.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov/patch fails on line 560 — the new None => return (String::new(), false), arm is unreachable in tests, and the explicit match exposes it as a separate basic block (the prior unwrap_or_default() form folded the unreachable case into a single line so coverage didn't see it).

Per CLAUDE.md: "specialized error handlers for rare cases when falling through to a more general handler is sufficient" — the pre-#2646 path renders an empty preview just fine via process_log_with_dimming("") + format_log_output("", {}), so the fix can keep the original fall-through shape and just gate the disk write. Suggested form below; happy to push it as a follow-up commit if you'd rather.

Comment thread src/commands/picker/items.rs Resolved
The explicit `match` arm with `return (String::new(), false)` exposed an
unreachable basic block to coverage. Restore the prior `unwrap_or_else`
fall-through (the empty `LogCacheEntry` renders as empty output via
`process_log_with_dimming` + `format_log_output`) and just gate the
disk write on a `Some(fresh)`. Same no-poison guarantee, no extra
unreachable branch for codecov to flag.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@max-sixty
max-sixty merged commit 777070f into main May 9, 2026
33 checks passed
@max-sixty
max-sixty deleted the tend/picker-log-cache-fix branch May 9, 2026 14:28
@max-sixty max-sixty mentioned this pull request May 10, 2026
3 tasks done
max-sixty added a commit that referenced this pull request May 10, 2026
Bump worktrunk to **0.49.0** — minor bump (semver-checks reports a
breaking change in `GitError::UncommittedChanges`, which gained a
`dirty_files: Vec<String>` field).

## Highlights

**Improved**
- New `codename(n)` template filter — deterministic friendly worktree
names from a ~1.26M-combo pool (`{{ branch | codename(2) }}` →
`malleable-opah`).
[#2641](#2641), thanks
@endigma
- Picker preview disk cache for Log / BranchDiff / UpstreamDiff, with
background refresh for stale Log decorations.
[#2628](#2628),
[#2646](#2646)
- Picker shares one `default_branch_sha` lookup across BranchDiff items
instead of forking N rev-parse subprocesses.
[#2658](#2658)
- "X has uncommitted changes" errors now list the dirty files inline.
[#2653](#2653)

**Fixed**
- `wt switch` integrates with `cd` aliases like zoxide (uses `builtin
cd`). [#2644](#2644), thanks
@xkumiyu for reporting
- Empty hook tables no longer panic during `wt switch --create`.
[#2635](#2635), thanks @topit
for reporting
- `Repository::current_worktree()` and five sibling helpers no longer
silently leak the process CWD when called via `Repository::at(p)`.
[#2652](#2652)
- `WorkingTree::is_linked` tolerates non-git CWDs (e.g. Nix sandbox).
[#2625](#2625), thanks
@DArtagan for reporting
- Picker no longer overlays `collect` warnings on the active TUI; clears
its frame on exit in inline mode.
[#2627](#2627),
[#2626](#2626)
- Failed `git log` no longer poisons the picker's preview disk cache.
[#2651](#2651)
- `wt step prune` says "removing branch" for branch-only candidates.
[#2619](#2619)
- Claude Code Windows integration uses a `wt.sh` wrapper to avoid
colliding with Windows Terminal's `wt.exe`.
[#1754](#1754), thanks
@lucaspimentel

**Documentation**
- cmux workspace integration recipe.
[#1907](#1907), thanks
@alvistar

See
[CHANGELOG.md](https://github.com/max-sixty/worktrunk/blob/release/CHANGELOG.md)
for the full list including internal CI / test-isolation changes.

## Test plan

- [x] `cargo run -- hook pre-merge --yes` (tests + lints clean)
- [x] `cargo semver-checks check-release -p worktrunk` (one breaking
change confirmed → minor bump)
- [x] CHANGELOG entries verified by subagent against actual diffs

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants