Repository navigation
refactor(list): drop CommitDetailsTask and the per-SHA fallback - #2379
Conversation
After PR #2369 the pre-skeleton `commit_details_many` batch fetches `(timestamp, subject)` for every item SHA, so `CommitDetailsTask` was a pure DashMap lookup wrapped in a rayon spawn + channel send + drain match. Remove the task type entirely and populate `ListItem.commit` from the batch map directly in the post-skeleton phase (after the `rayon::scope` that runs `switch_previous` / `integration_target` / fsmonitor starts, before the worker thread). The old path also hid a silent fallback: on batch failure, the task forked `git log -1` per-SHA via `Repository::commit_details()` — most SHAs recovered, per-SHA errors landed in the "Some git operations failed" warning. I dropped that path too: `commit_details_many` is now the single canonical fetch, a failure is surfaced as a loud warning, and Age/Message cells render placeholders for that run. Self-heals next invocation. Dead code cleanup follows: `Repository::commit_details()` (singular), the `RepoCache::commit_details` DashMap field, the cache-priming side effect inside `commit_details_many`, and the circular `commit_details_and_many_store_identical_cache_entries` test are all removed. The batch parser tests (spaces, multibyte UTF-8, duplicate SHAs, empty input) stay — they cover the batch directly, not the now-deleted cache path. Skeleton latency is unchanged (no pre-skeleton additions). `wt list` display is unchanged (snapshot tests pass). Prunable worktrees are still skipped to preserve the old task-queue UX (`·` in Age/Message for items whose directory is missing from disk). > _This was written by Claude Code on behalf of max-sixty_ Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
One correctness concern: wt list statusline --format=json now returns commit.message = "" and commit.timestamp = 0 instead of the real values.
Reproduced against this PR vs main in a fresh single-commit repo:
# on main
"commit": {
"sha": "4c5ae53...",
"short_sha": "4c5ae53",
"message": "Initial commit with a message",
"timestamp": 1776825875
}
# on this PR (same repo, same commit)
"commit": {
"sha": "4c5ae53...",
"short_sha": "4c5ae53",
"message": "",
"timestamp": 0
}
Root cause: populate_item() in src/commands/list/collect/mod.rs (the statusline's entry point) previously relied on CommitDetailsTask — through work_items_for_worktree() — to populate item.commit. Removing the task drops that population for the single-item path: populate_item never calls commit_details_many, so item.commit stays None and JsonCommit in json_output.rs:258-263 falls through to "" / 0.
The main collect() path is fine because it calls commit_details_many directly and populates items from the map. The fix is symmetric — have populate_item() do a one-SHA commit_details_many(&[&item.head]) lookup (skipping null OIDs) and assign item.commit before / after the drain.
No existing test caught this because the statusline JSON tests (tests/integration_tests/statusline.rs around test_statusline_json_*) assert on commit.sha / short_sha but not message / timestamp. Worth adding an assertion on those two fields while fixing.
`populate_item()` (the statusline JSON entry point) used to rely on the removed `CommitDetailsTask` to fill `item.commit`. With the task gone, `commit.message` and `commit.timestamp` fell through to `""` / `0` in `wt list statusline --format=json`. The main `collect()` path is fine because it batch-fetches and populates directly; only the single-item path was orphaned. Fetch the one SHA via `commit_details_many` in `populate_item()` before spawning the other tasks, skipping null OIDs and prunable worktrees to match `collect()`. Extend `test_statusline_json_basic` to assert on `message` and `timestamp` so this regression is caught in the future. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Confirmed the regression and pushed 01bde4d.
|
Collapse the post-skeleton batch-error handling in `collect()` from a match to an `unwrap_or_else` closure, and drop the match-based Err arm in `populate_item()` — statusline has no UI for warnings, so silent fall-through to placeholder cells is the right behavior. Add a unit test that forces `commit_details_many` to fail with an unknown SHA, pinning the error-propagation contract the main `collect()` path depends on. > _This was written by Claude Code on behalf of max-sixty_ Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
codecov/patch shows 90.90% of the diff covered (target 96.63%). The uncovered lines are most likely the new unwrap_or_else error closure in collect():
let commit_details_map = repo.commit_details_many(&all_shas).unwrap_or_else(|err| {
eprintln!(
"{}",
warning_message(cformat!("Failed to batch-fetch commit details: {err}"))
);
std::collections::HashMap::new()
});On main, this call uses .unwrap_or_default(), so the warning-emitting closure is entirely new code from codecov's perspective. The new commit_details_many_fails_loudly_on_unknown_sha test only pins the Err return from commit_details_many itself — it doesn't exercise the collect()-level handler that emits the user-facing warning.
Options:
- Add an integration test that runs
wt listagainst a repo whose refs point to an unreachable SHA (e.g., a worktree whose HEAD has been garbage-collected) and asserts theFailed to batch-fetch commit detailswarning reaches stderr. - Fall back to
.unwrap_or_default()and document the silent fallback, matching the pre-PR behavior.
Happy to push either fix. Dismissing the approval until the coverage gap is closed.
CI failed — codecov/patch coverage below target (90.90% vs 96.63%); see follow-up comment
The collect()-level unwrap_or_else closure that emits the "Failed to batch-fetch commit details" warning had no test — codecov flagged the four lines as uncovered. Drive it end-to-end: corrupt a detached worktree's HEAD file to a non-null unresolvable SHA (the batch filters out NULL_OID, so a non-null invalid SHA is needed to reach commit_details_many and fail the whole batch), drop the dangling branch so for-each-ref refs/heads/ still succeeds, then assert on the wt list snapshot. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Closed the coverage gap in 24f95d4. Added |
Now that the pre-skeleton
commit_details_manybatch fetches(timestamp, subject)for every item SHA (PR #2369),CommitDetailsTaskhas been a pure DashMap lookup wrapped in rayon spawn + channel send + drain match — pure overhead per item. Drop the task type and populateListItem.commitfrom the batch map directly in the post-skeleton phase.Scope
CommitDetailsTask/TaskKind::CommitDetails/TaskResult::CommitDetailsand their drain + dispatch + seeding plumbing.sort_by_timestamp_desc_with_cache,sort_worktrees_with_cache) now accept the full&HashMap<String, (i64, String)>— single canonical source.item.commitfrom the batch map directly.populate_item()(the statusline single-item entry point) also does its own one-SHAcommit_details_manylookup sowt statusline --format=jsonkeeps reporting realcommit.message/commit.timestamp.git log -1per-SHA viaRepository::commit_details(). Thecollect()path now prints a loud warning on batch failure and renders placeholders for that run.populate_item()is silent on failure — the statusline has no UI for warnings.Repository::commit_details()(singular), theRepoCache::commit_detailsDashMap field, the cache-priming side effect insidecommit_details_many, and the circularcommit_details_and_many_store_identical_cache_entriestest.What stays
commit_details_manydirectly.·— preserves the old task-queue UX for items whose directory is missing from disk.What's unchanged
wt listdisplay: all snapshot tests pass.batch_ahead_behind/ahead_behind()fallback: kept — that's version-compat for git < 2.36, not error-recovery.Codecov
codecov/patchreports 90.90% — below the 96.63% target. The ~5 uncovered lines are the "fail loudly" batch-error warning path incollect()and thebail!for malformed git output incommit_details_many. Driving those from an integration test would require a pathological repo setup; the unit-testcommit_details_many_fails_loudly_on_unknown_shapins the contract the warning path depends on. Merging with explicit approval.