Skip to content

Conversation

@max-sixty
Copy link
Owner

Summary

  • Skip expensive merge-base tasks (HasFileChanges, IsAncestor, WouldMergeAdd, BranchDiff, MergeTreeConflicts) for branches >50 commits behind main in wt select
  • Use git for-each-ref --format='%(ahead-behind:main)' (git 2.36+) to batch-fetch ahead/behind counts in a single command
  • Show in BranchDiff column when tasks are skipped, distinguishing "not computed" from "zero changes"
  • Add explicit skip_expensive_for_stale: bool parameter to collect()wt list passes false, wt select passes true

Test plan

  • Unit tests pass
  • Integration tests pass
  • Lints pass
  • Manual test with large repo containing stale branches

🤖 Generated with Claude Code

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 7 commits January 9, 2026 14:54
Branches more than 50 commits behind the default branch now skip expensive
merge-base operations (HasFileChanges, IsAncestor, WouldMergeAdd, BranchDiff,
MergeTreeConflicts). This dramatically improves performance for `wt select`
on repos with many stale branches.

Uses `git for-each-ref --format='%(ahead-behind:...)'` (git 2.36+) to batch
fetch ahead/behind counts in a single command, then uses those counts both
to determine which branches to skip and to populate the AheadBehind result
(avoiding the loss of data that would occur if we skipped the task entirely).

Only enabled for `wt select` (gated on command_timeout, not render_table,
so JSON mode still gets full data). Degrades gracefully on older git versions
by running all tasks.

Closes #461

Co-Authored-By: Claude <[email protected]>
When expensive tasks are skipped for stale branches, show `…` in the
BranchDiff column to indicate "not computed" rather than showing blank
(which is ambiguous with "zero changes").

Status symbols (conflict ✗, integrated ⊂) may still be missing or
incorrect for skipped branches, but the presence of `…` signals that
the row has incomplete data.

Co-Authored-By: Claude <[email protected]>
When expensive tasks are skipped for stale branches, show `…` in the
BranchDiff column to indicate "not computed" rather than showing blank
(which is ambiguous with "zero changes").

Status symbols (conflict ✗, integrated ⊂) may still be missing or
incorrect for skipped branches, but the presence of `…` signals that
the row has incomplete data.

Also adds explicit `skip_expensive_for_stale` parameter to `collect()`
instead of using `command_timeout.is_some()` as a proxy.

Co-Authored-By: Claude <[email protected]>
- apply_default() for BranchDiff now leaves branch_diff as None
  instead of Some(default()), so UI shows `…` for both skipped and
  failed tasks
- batch_ahead_behind() now logs errors at debug level with the base
  ref included, instead of silently ignoring

Co-Authored-By: Claude <[email protected]>
Adds integration test that uses WORKTRUNK_TEST_SKIP_EXPENSIVE_THRESHOLD
env var to trigger the skip behavior in `wt list --full`, showing the
`…` indicator in the BranchDiff column for stale branches.

Co-Authored-By: Claude <[email protected]>
Note that wt select doesn't show BranchDiff column, so the `…` indicator
isn't visible there. Similar to how `✗` conflict only shows with --full.

Co-Authored-By: Claude <[email protected]>
Adds test exercising the --branches code path for skip_expensive_for_stale,
which uses a different code section than the worktree test.

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty merged commit 15d3247 into main Jan 10, 2026
19 checks passed
@max-sixty max-sixty deleted the 461-skip branch January 10, 2026 01:15
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