Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

chore: correct stale comments and make the orphan-branch prune test keep an unmerged orphan (#4490)

Worktrunk Bot2d10b78242b9
diff --git a/src/commands/hooks.rs b/src/commands/hooks.rs
index 079f2f9ec..d0d70a043 100644
--- a/src/commands/hooks.rs
+++ b/src/commands/hooks.rs
@@ -29,7 +29,7 @@
//!
//! | Plan-backed hook | Runs in (the anchor) | Gate |
//! |---|---|---|
-//! | `pre-merge`, `pre-remove`, `post-remove` | the feature/removed worktree | `merge::approve_merge_plan`, `remove::handle_remove_command`'s `approve_remove`, `step::prune::approve_prune_hooks` |
+//! | `pre-merge`, `pre-remove`, `post-remove` | the feature/removed worktree | `merge::approve_merge_plan`, `remove::handle_remove_command`'s `approve_remove`, `step::prune::step_prune`'s `build_pessimistic_plan` approval |
//! | `post-merge`, `post-switch` (after a removal) | the merge/removal destination | the same gates |
//! | `pre-start`, `post-start`, `post-switch` (on switch) | the new/destination worktree | `worktree::switch::approve_switch_hooks` |
//!
diff --git a/src/commands/list/collect/execution.rs b/src/commands/list/collect/execution.rs
index 6b9ff95cf..de87a87a4 100644
--- a/src/commands/list/collect/execution.rs
+++ b/src/commands/list/collect/execution.rs
@@ -2,7 +2,7 @@
//!
//! Contains the flat parallelism infrastructure:
//! - `WorkItem` - unit of work for the thread pool
-//! - `TaskKind::compute()` - route each task to its computation
+//! - `TaskKind::compute()` (in `tasks.rs`) - route each task to its computation
//! - `work_items_for_worktree()` / `work_items_for_branch()` - generate work items
//! - `ExpectedResults` - track expected results for timeout diagnostics
//! - `seed_skipped_task_defaults()` - conservative sentinels for skipped tasks
@@ -93,7 +93,7 @@ pub(crate) struct ExpectedResults {
impl ExpectedResults {
/// Record that we expect a result of the given kind for the given item.
- /// Called internally by `TaskSpawner::spawn()`.
+ /// Called by `work_items_for_worktree()` / `work_items_for_branch()`.
pub fn expect(&self, item_idx: usize, kind: TaskKind) {
let mut inner = self.inner.lock().unwrap();
if inner.len() <= item_idx {
@@ -127,7 +127,7 @@ impl ExpectedResults {
/// `refresh_status_symbols` keeps gates at `None` while their inputs are
/// unloaded, which renders as the `·` placeholder. For tasks that will
/// *never* run (a task no rendered column needs, unborn item missing
-/// commit-dependent tasks, prunable worktree), seeding a conservative
+/// commit-dependent tasks), seeding a conservative
/// default up front lets the gate resolve normally instead of showing `·`
/// forever.
///
@@ -247,9 +247,7 @@ pub(super) fn seed_unborn_main_state(item: &mut ListItem) {
///
/// Prunable worktrees have lost their directory or its `.git`, so no task
/// can run for them. Without this seeding, every gate would stay `None`
-/// forever and the cell would render as seven `·` placeholders. This
-/// helper replaces the runtime fallback in `refresh_status_symbols`
-/// (introduced as a shim in step 4) with spawn-time seeding.
+/// forever and the cell would render as seven `·` placeholders.
pub(super) fn seed_prunable_item(item: &mut ListItem) {
use super::super::model::{
Divergence, MainState, OperationState, StatusSymbols, WorktreeState,
@@ -405,7 +403,7 @@ pub fn work_items_for_worktree(
// URL status health check task (if we have a URL). Only this single
// work item is queued per item — the immediate `UrlStatus` placeholder
// was already sent through the drain channel above (never written to
- // `item.url` directly; see the module docstring), so this task needs no
+ // `item.url` directly; see the `work_items_for_worktree` docstring), so this task needs no
// additional placeholder send.
if include_url && ctx.item_url.is_some() {
expected_results.expect(item_idx, TaskKind::UrlStatus);
diff --git a/src/commands/list/collect/results.rs b/src/commands/list/collect/results.rs
index 2d47bf51f..9dbd2b51d 100644
--- a/src/commands/list/collect/results.rs
+++ b/src/commands/list/collect/results.rs
@@ -345,10 +345,9 @@ pub(super) fn drain_results_with_timings(
item.pr_status = Some(pr_status);
}
TaskResult::UrlStatus { url, active, .. } => {
- // The synchronous URL write in `work_items_for_worktree`
- // already set `item.url`; this result only carries the
- // health-check outcome. Still guard for older call sites
- // that may send `url=Some`.
+ // `work_items_for_worktree` sends the URL itself as an
+ // immediate `url: Some, active: None` result; the later
+ // health check sends `url: None` with the outcome.
if url.is_some() {
item.url = url;
}
diff --git a/src/commands/picker/preview_notify.rs b/src/commands/picker/preview_notify.rs
index 4e50ae463..8d8b12812 100644
--- a/src/commands/picker/preview_notify.rs
+++ b/src/commands/picker/preview_notify.rs
@@ -37,9 +37,9 @@
//! re-dims the diff tabs' tab-bar number — chrome the user can wait a keystroke
//! for, never worth a scroll reset.
//! - **`pr` tab** — body renders every shown `PrStatus` field, so it re-runs on
-//! any real change. The collect handler excludes `is_priming` (a list-cell dim
-//! hint the pane never draws — see `items::pr_status_pane_eq`) so a
-//! cache-prime→live flip that only clears it doesn't reset scroll.
+//! any real change. The collect handler excludes `is_priming` and `updated_at`
+//! (fields the pane never draws — see `items::pr_status_pane_eq`) so a
+//! cache-prime→live flip that only changes them doesn't reset scroll.
//! - **`comments` tab** — body is the row-keyed thread (surfaced by
//! `notify_filled`), invariant to `PrStatus` fields once a PR exists, so it
//! re-runs only on a [`PrPresence`](super::items::PrPresence) change
@@ -73,8 +73,8 @@ use super::preview::PreviewMode;
#[derive(Debug, Clone, Copy)]
pub(super) struct PrStatusDelta {
/// The rendered `pr` pane would differ — any shown field changed (CI badge,
- /// title, body, review, …), ignoring the `is_priming` dim hint the pane
- /// never draws. Gates the `pr` tab. See `items::pr_status_pane_eq`.
+ /// title, body, review, …), ignoring the `is_priming` and `updated_at`
+ /// fields the pane never draws. Gates the `pr` tab. See `items::pr_status_pane_eq`.
pub(super) pane_changed: bool,
/// The [`PrPresence`](super::items::PrPresence) (Loading/NoPr/HasPr) changed.
/// Gates the `comments` tab, whose body is otherwise the row-keyed thread
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index 05bec7139..3874ebeab 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -2219,7 +2219,7 @@ fn remove_removed_worktree_silently(
/// `redirect_stdout_to_stderr` controls whether the child's stdout is merged
/// onto wt's stderr (`true`) or passed through unchanged (`false`).
///
-/// - Hooks and `for-each` pass `true`: their output is decoration around
+/// - Hooks pass `true`: their output is decoration around
/// wt's own stderr messages, and merging keeps "Running …" / progress lines
/// ordered with the child's own writes.
/// - Aliases pass `false`: `wt <alias>` is a user-defined command and its
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index d21808d25..390775453 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -2199,8 +2199,8 @@ pre-start = "ln -sf {{ repo_root }}/node_modules {{ worktree }}/node_modules"
);
}
-/// With -v flag, the brief deprecation warning includes the mv command hint
-/// and template expansion logs are shown
+/// With -v flag, template expansion logs appear alongside the deprecation
+/// warnings
#[rstest]
fn test_deprecated_template_variables_verbose_shows_content(repo: TestRepo, temp_home: TempDir) {
// Write config with deprecated variables
@@ -2795,7 +2795,7 @@ fn test_config_show_gemini_extension_installed(mut repo: TestRepo, temp_home: Te
/// override the harness sets, so the production `which::which` PATH lookup is
/// otherwise never exercised. `setup_mock_clis_on_path()` drops the overrides
/// and prepends real mock executables, so this single run covers the
-/// PATH-detection path for all five AI CLIs at once.
+/// PATH-detection path for all six AI CLIs at once.
#[rstest]
fn test_config_show_clis_detected_via_path(mut repo: TestRepo, temp_home: TempDir) {
repo.setup_mock_ci_tools_unauthenticated();
@@ -3092,7 +3092,7 @@ fn test_opencode_install_ignores_relative_xdg_config_home(temp_home: TempDir) {
}
/// Install prompt declined (no `--yes`, piped stdin → empty → declined).
-/// Exercises the `return Ok(())` branch at lines 83-84 of opencode.rs.
+/// Exercises the declined-prompt branch of `install_file_plugin` in config/mod.rs.
#[rstest]
fn test_opencode_install_prompt_declined(temp_home: TempDir) {
let settings = setup_home_snapshot_settings(&temp_home);
@@ -3115,7 +3115,7 @@ fn test_opencode_install_prompt_declined(temp_home: TempDir) {
}
/// Uninstall prompt declined (no `--yes`, piped stdin → empty → declined).
-/// Exercises the `return Ok(())` branch at lines 129-130 of opencode.rs.
+/// Exercises the declined-prompt branch of `uninstall_file_plugin` in config/mod.rs.
#[rstest]
fn test_opencode_uninstall_prompt_declined(temp_home: TempDir) {
// Pre-install the plugin so we reach the prompt
@@ -3661,7 +3661,8 @@ fn test_config_show_runs_real_ancestry_walk(mut repo: TestRepo, temp_home: TempD
);
}
-/// Test that deprecated [commit-generation] section shows warning and creates migration file
+/// Test that deprecated [commit-generation] section shows warning and that
+/// `wt config update` migrates it in place
#[rstest]
fn test_deprecated_commit_generation_section_shows_warning(repo: TestRepo, temp_home: TempDir) {
// Write user config with deprecated [commit-generation] section
diff --git a/tests/integration_tests/step_prune.rs b/tests/integration_tests/step_prune.rs
index e580c27ba..f86069cd3 100644
--- a/tests/integration_tests/step_prune.rs
+++ b/tests/integration_tests/step_prune.rs
@@ -422,7 +422,9 @@ fn test_prune_orphan_branches(mut repo: TestRepo) {
repo.create_branch("orphan-b");
// Create an unmerged branch (has a unique commit via worktree, then remove worktree)
- repo.add_worktree_with_commit("unmerged-orphan", "u.txt", "data", "unique commit");
+ let unmerged_path =
+ repo.add_worktree_with_commit("unmerged-orphan", "u.txt", "data", "unique commit");
+ repo.run_git(&["worktree", "remove", unmerged_path.to_str().unwrap()]);
// Far-future epoch: branches appear ~5 years old, passing the default 1d guard
let mut cmd = make_snapshot_cmd(&repo, "step", &["prune", "--yes"], None);
@@ -430,6 +432,9 @@ fn test_prune_orphan_branches(mut repo: TestRepo) {
cmd.env("RAYON_NUM_THREADS", "1"); // deterministic output order
assert_cmd_snapshot!(cmd);
+
+ // The unmerged orphan has a unique commit, so prune keeps it
+ repo.run_git(&["rev-parse", "--verify", "refs/heads/unmerged-orphan"]);
}
/// Orphan branches (no worktree) respect the min-age guard via reflog timestamps.