Skip to content

feat(switch): add AI summary preview tab - #1049

Merged
max-sixty merged 31 commits into
mainfrom
summary
Feb 16, 2026
Merged

max-sixty merged 31 commits into
mainfrom
summary

Conversation

@max-sixty

@max-sixty max-sixty commented Feb 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add tab 5 (summary) to wt switch picker showing AI-generated branch summaries using the configured [commit.generation] LLM command
  • Gated behind [list] summary = true (default: false) to avoid surprise LLM calls — both [list] summary and [commit.generation] command must be configured
  • Summaries generated in parallel across all worktrees at picker open; cached in .git/wt-cache/summaries/ with hash-based invalidation
  • Graceful fallback: config hint when LLM not configured or summaries disabled, dim "no changes" for default branch
  • Documentation: updated switch help (tab 5, keybindings), FAQ (commands we run), llm-commits page (new "Picker summaries" section)

Test plan

  • All 530 unit tests pass
  • All 1036 integration tests pass
  • 6 switch_picker snapshot tests updated for new tab labels
  • 3 help snapshots updated for tab 5 and config line
  • Interactive testing: verified summary generation, default branch handling, word wrapping, markdown rendering
  • Verify CI passes

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

Add a fifth preview mode to `wt switch` that shows AI-generated branch
summaries using the configured [commit.generation] LLM command. Summaries
use commit-message format (imperative subject + body) and render through
the standard markdown help renderer for consistent styling.

- Background thread generates summaries in parallel for all branches
- Disk cache in .git/wt-cache/summaries/ with hash-based invalidation
- Graceful fallback: config hint when LLM not configured, dim "no changes"
  for default branch
- Shortened tab labels to fit 5 tabs: 1:diff | 2:log | 3:main | 4:upstream | 5:summary

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty added the feedback-requested Looking for user feedback on this feature label Feb 16, 2026
max-sixty and others added 2 commits February 15, 2026 20:28
After merging main (which reverted jj support), fix two issues:
- Resolve config to access commit_generation (handle_select no longer
  receives resolved config directly)
- Restore pub(crate) visibility on execute_llm_command

Co-Authored-By: Claude <[email protected]>
# Conflicts:
#	src/commands/select/mod.rs
@github-actions

Copy link
Copy Markdown
Contributor

Review: feat(switch): add AI summary preview tab

Well-structured PR. The caching design, graceful fallback for unconfigured LLM, and parallel generation are all well thought out. A few observations worth considering:

Design observations (4 items)

1. Thread-per-branch scaling in generate_all_summaries

std::thread::scope spawns one OS thread per item (summary.rs:257-267). The rationale is sound for I/O-bound LLM calls with <100 branches, but each thread allocates ~2MB of stack space. At 500+ branches this could consume 1GB+ of memory, and at OS thread limits it would fail. Consider a bounded thread pool or semaphore if large-repo support matters.

2. DefaultHasher for cache invalidation

DefaultHasher is not guaranteed stable across Rust versions (summary.rs:139-143). This means cache files from one Rust build may not match another, causing unnecessary LLM regeneration. The impact is low since it just means a cache miss (not stale data), but it's worth noting. If cross-version cache stability ever matters, a deterministic hasher would be the fix.

3. Tab label renaming is a quiet UX change

The tab labels changed from "1: HEAD±" / "2: log" / "3: main…±" / "4: remote⇅" to "1:diff" / "2:log" / "3:main" / "4:upstream" / "5:summary". The new labels are more compact (needed to fit 5 tabs), but lose some information density — the old unicode symbols (±, …, ⇅) conveyed the tab's purpose at a glance. This seems intentional to accommodate the 5th tab, just noting it as a visible UI change for existing users.

4. render_markdown_in_help_with_width for summary rendering

render_summary (summary.rs:69-83) routes through the markdown help renderer, which was designed for --help pages. It handles headers, bold, code blocks, and prose wrapping, which aligns well with the commit-message format. It does strip markdown links and has limited list support, but that's unlikely to matter for LLM-generated summaries.

Minor code observations (3 items)

compute_combined_diff silently returns None when default_branch() is None

At summary.rs:150, repo.default_branch()? uses ? on Option, so if there's no default branch (unusual, but possible), the function returns None and the user sees "No changes to summarize." A debug log here could help troubleshoot this edge case, but it's not a bug.

Hint text formatting

The config hint (mod.rs:274-277) uses leading whitespace from the string continuation (\n\ at line endings), which may render oddly. The \n\ continuation strips indentation in the source but the content itself has proper alignment, so it should be fine.

items_for_precompute.clone() naming

summary_items is a clone of items_for_precompute (mod.rs:235). Since cloning Vec<Arc<ListItem>> only copies Arc pointers (not data), this is cheap and correct.

Overall this is clean, well-documented code that integrates naturally into the existing preview tab system. The caching with hash-based invalidation and atomic writes is a solid approach, and the fallback UX (config hint when LLM isn't configured, "Generating..." placeholder, dim "no changes" for default branch) handles all the states gracefully.

Add tests for cache round-trip, hash invalidation, file path
sanitization, directory structure, and pre-styled text rendering
to improve codecov/patch coverage.

Co-Authored-By: Claude <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: feat(switch): add AI summary preview tab

Well-structured feature. The architecture (background thread + disk cache + in-memory preview cache) is sound, and the code integrates cleanly with the existing preview tab system. A few observations below.

Design observations (3 items)

1. DefaultHasher for cache invalidation

hash_diff uses std::collections::hash_map::DefaultHasher, which is documented as potentially varying across Rust versions. Since this hash is persisted to disk in CachedSummary.diff_hash, upgrading the Rust toolchain could silently invalidate all cached summaries — which is actually fine here (worst case: one extra LLM call per branch). But it's worth documenting this choice so future readers don't wonder whether a stable hash was intended. The rest of the codebase uses DefaultHasher similarly, so this is consistent.

2. Thread-per-branch concurrency

generate_all_summaries spawns one thread per item via thread::scope. The comment explains the reasoning (I/O-bound LLM calls), but for repos with many branches this could spawn dozens of threads simultaneously. In practice this is bounded by the number of worktrees shown in the picker (typically <20), so it's fine. If this ever scales to include remote branches, a bounded semaphore or channel would be worth considering.

3. Graceful degradation path

The fallback when LLM isn't configured inserts a config hint into the preview cache for all items — this means users always see something useful on tab 5 rather than a stuck "Generating..." message. The compute_summary_preview synchronous fallback for when the background thread hasn't finished is also a nice touch.

Suggestions (2 items)

1. compute_combined_diff returns None when default_branch() is None

In summary.rs:150, if repo.default_branch() returns None (e.g., a freshly initialized repo without a remote), the function returns None and the summary shows "No changes to summarize on {branch}" even for feature branches that have commits. This is a rare edge case but the message could be confusing — something like "Could not determine default branch" might be clearer. Not a blocker.

2. Tab label change is a minor UX shift

The tab labels changed from descriptive (1: HEAD±, 3: main…±, 4: remote⇅) to terse (1:diff, 3:main, 4:upstream). This trades discoverability for horizontal space to fit tab 5. The controls line still explains the keys. Worth noting for the changelog since existing users will notice the change.

Code quality notes
  • The visibility changes to llm.rs (pub(crate) for PreparedDiff, prepare_diff, execute_llm_command) are minimal and appropriate — these were previously private and are now shared with the summary module.
  • write_cache correctly uses atomic write (temp file + rename) with a Windows fallback for the non-atomic rename-over-existing limitation.
  • The render_summary function's ANSI-detection heuristic (text.contains('\x1b')) for distinguishing pre-styled text from raw LLM output is pragmatic. It could theoretically misfire if an LLM returns text containing escape characters, but that's highly unlikely in practice.
  • Tests are thorough — cache roundtrip, hash determinism, rendering, prompt template validation, and snapshot updates for the tab label changes.

Overall this is a clean, well-thought-out addition. The caching strategy and background generation are well-engineered for the interactive preview use case.

- Add PTY test for tab 5 showing config hint when LLM not configured
- Add cache round-trip, invalidation, sanitized path, and dir tests
- Add pre-styled text rendering test for dim "no changes" messages

Co-Authored-By: Claude <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review: feat(switch): add AI summary preview tab

Well-structured feature addition. The caching design, background thread strategy, and graceful fallbacks are all well thought out. A few observations below.

Detailed findings (5 items)

1. DefaultHasher is not stable across Rust versions (issue)

summary.rs:7 uses std::collections::hash_map::DefaultHasher for cache invalidation. The Rust docs explicitly state that DefaultHasher is not guaranteed to produce the same output across Rust versions. This means upgrading the Rust toolchain could silently invalidate all cached summaries, triggering unnecessary LLM re-generation for every branch on the first run after an update.

This is a minor concern since cache invalidation only costs an extra LLM call (no data corruption), but it's worth noting. If stability matters, a fixed hasher like fnv, xxhash, or even a simple CRC could be used instead. The project already depends on dashmap which pulls in ahash — though that has the same instability guarantee.

2. compute_combined_diff returns None when default_branch() is None (suggestion)

At summary.rs:151, if repo.default_branch() returns None (e.g. a bare repo with no default branch configured), the function returns None, which causes generate_summary to render the "No changes to summarize" message — even for feature branches that do have commits. Consider whether this should fall back to showing just the working tree diff, or produce a different message indicating the default branch couldn't be determined.

3. One thread per branch for LLM calls (observation)

generate_all_summaries spawns one OS thread per item via thread::scope. The comment explains this is intentional for I/O-bound LLM calls. For repos with many branches (50+), this could create a lot of threads. In practice this is probably fine since:

  • wt list with --branches could surface many branches, but most users have fewer
  • The threads are short-lived and I/O-bound
  • thread::scope handles cleanup properly

Just noting it — a semaphore or bounded thread pool would be a more defensive choice if branch counts grow, but it's not necessary now.

4. Tab label changes are a minor external interface change (observation)

The tab labels changed from 1: HEAD± / 2: log / 3: main…± / 4: remote⇅ to 1:diff / 2:log / 3:main / 4:upstream / 5:summary. The old labels were more informative (e.g., HEAD± immediately conveyed "uncommitted changes", remote⇅ showed sync direction). The new labels are more compact, which is needed to fit a 5th tab, but users who remember the old labels might need to re-orient. This is internal UI, not a protected external interface, so it's fine — just a trade-off worth being aware of.

5. Test uses std::process::Command instead of Cmd (suggestion)

summary.rs:278-288 (in temp_repo()) uses std::process::Command::new("git") directly. Per CLAUDE.md, all external commands should go through shell_exec::Cmd for consistent logging/tracing. However, since this is test-only code and other test files use the same pattern (TestRepo uses its own helpers), this is consistent with existing test conventions and fine to leave as-is.

Overall: clean implementation with good separation of concerns. The caching strategy (hash-based invalidation, atomic writes) is solid. The graceful degradation when LLM isn't configured (showing a config hint) is a nice touch.

Repository owner deleted a comment from github-actions Bot Feb 16, 2026
Repository owner deleted a comment from github-actions Bot Feb 16, 2026
Add 10 new unit tests covering `compute_combined_diff`,
`generate_summary`, `generate_all_summaries`, and the single-line
`render_summary` path. Uses real temp git repos with shell-stub LLM
commands (following existing patterns from merge integration tests).

Also refactors test helpers to share git command setup and repo
initialization, eliminating duplication between test cases.

Co-authored-by: Claude <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clean implementation. The caching strategy, background generation, and graceful fallbacks are well done. One observation below about an edge case.

Comment thread src/commands/select/items.rs Resolved
- compute_combined_diff no longer bails when default_branch() returns
  None — wraps branch diff in if-let, preserving working tree diff
- Fix test to use exotic branch name so default_branch() actually
  returns None (infer_default_branch_locally checks "main"/"master"/etc)
- Add unit tests for items.rs Summary tab paths (main worktree, feature
  branch, cache hit/miss, compute_preview delegation)
- Add error path tests for write_cache (unwritable path, permission
  failure)

Co-Authored-By: Claude <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good feature — clean design with disk caching, background generation, and graceful fallbacks. A few observations:

Comment thread src/commands/select/items.rs Resolved
Comment thread src/commands/select/summary.rs Resolved
Comment thread src/commands/select/items.rs Resolved

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall this is well-structured — the architecture (background thread for I/O-bound LLM calls, hash-based disk cache, graceful fallbacks) is clean and integrates naturally with the existing preview system. A few observations:

Thread-per-branch scaling (summary.rs:260)

std::thread::scope spawns one OS thread per item. With typical worktree counts this is fine, but users with many visible branches (50+) would create that many concurrent LLM calls simultaneously. A bounded concurrency limit would be more robust, though this may be premature for v1.

is_main() vs default branch in the synchronous fallback (items.rs:425)

compute_summary_preview uses item.is_main() (checks WorktreeData.is_main — the main worktree) to short-circuit with "No changes to summarize". But compute_combined_diff uses repo.default_branch() to decide what to diff against. These are usually the same, but not always (bare repos, non-standard setups). The mismatch only affects the brief synchronous placeholder before the background thread completes, so it's low-impact — just something to be aware of.

Minor: clone before config check (mod.rs:235)

items_for_precompute.clone() happens unconditionally at line 235, but the config check for commit_generation.is_configured() is at line 259. Moving the clone inside the if block (or at least next to its first use) would avoid the Vec<Arc<_>> allocation when LLM is not configured. The Arc clones themselves are cheap, so this is a minor nit.

None of these are blockers — the implementation handles the expected use cases well. The test coverage is thorough (cache roundtrip, hash invalidation, error paths, integration PTY test for the config hint).

- Remove is_main() shortcut from compute_summary_preview — was checking
  main worktree (git concept) not default branch (different concept)
- Add unicode visual cues to tab labels: 1:diff±, 3:main↕, 4:upstream⇅
- Move summary_items clone closer to its consumer in mod.rs

Co-Authored-By: Claude <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review feedback addressed cleanly — tab labels restored with unicode symbols, is_main/default_branch mismatch removed, clone moved to point of use. No new issues.

Characters ±, ↕, ⇅ have East Asian Width "Ambiguous" which skim
renders as double-width on CI, shifting [N/M] alignment by 3 chars.
Revert to plain labels for cross-platform consistency.

Co-Authored-By: Claude <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Clean fix for the unicode tab cue issue. Reverting the ambiguous East Asian Width characters is the right approach for cross-platform consistency with skim.

Restore ±, ↕, ⇅ symbols to tab labels (1:diff±, 3:main↕, 4:upstream⇅).
These characters are used throughout the codebase and haven't shown
width issues in practice.

Co-authored-by: Maximilian Roos <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment thread src/commands/select/items.rs Outdated
assert!(output.contains("2:log"));
assert!(output.contains("3:main"));
assert!(output.contains("4:upstream"));
assert!(output.contains("5:summary"));

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@claude revert these changes to the tab titles

@worktrunk-bot worktrunk-bot Feb 16, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Claude finished @max-sixty's task in 3m 2s —— View job


Restored original tab titles for tabs 1-4 and added 5: summary as the new 5th tab.

  • Identify original tab titles from origin/main
  • Revert tab titles in src/commands/select/items.rs: "1: HEAD±", "2: log", "3: main…±", "4: remote⇅" + new "5: summary"
  • Update 7 snapshot files with restored labels
  • Update unit test assertions (11 tests passing)
  • Commit and push

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@claude iterate with CI untill it passes

@worktrunk-bot worktrunk-bot Feb 16, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Claude finished @max-sixty's task in 19m 7s —— View job


CI is green across all platforms.

  • Diagnose failures — skim's width_cjk() treats ±, …, ⇅ as double-width, so the restored 5-tab header overflows the preview panel width, causing the count indicator to overlap with or truncate "summary" (e.g., summary1/4, summar1/28)
  • Fix snapshot normalization — added regex summary?\w*\s*\d+/\d+\s*$ → summary [N/M] to handle the overlap before the generic count filter (b2448ca)
  • Fix typos lint — used summary? (optional y) to avoid spell checker flagging partial word (9ed322b)
  • CI passing — lint, tests (Linux, macOS, Windows), code-coverage, codecov/patch all green

Revert tab labels 1-4 to their original format ("1: HEAD±", "2: log",
"3: main…±", "4: remote⇅") and add "5: summary" as a new 5th tab.

Co-authored-by: Maximilian Roos <[email protected]>
When the 5 restored tab labels use ambiguous-width unicode symbols (±, …, ⇅),
skim's width_cjk() treats them as double-width, leaving insufficient space for
the count indicator. This causes the count to overlap with "summary" (e.g.,
"summary1/4") or truncate it ("summar1/28"). Add a targeted regex filter that
normalizes this overlap before the generic whitespace-padded count filter runs.

Co-authored-by: Maximilian Roos <[email protected]>
Use `summary?` (optional `y`) instead of `summar` to avoid the typos
spell checker flagging the partial word.

Co-authored-by: Maximilian Roos <[email protected]>
max-sixty and others added 6 commits February 16, 2026 11:56
#1056)

- Reorder as explicit numbered workflow: pre-flight checks before
  expensive diff analysis to avoid redundant work
- Remove redundant "read CLAUDE.md" (already in system prompt)
- Filter dedup check by bot identity so human approvals don't
  cause the bot to skip its review
- Accept brief approval bodies (matches actual bot behavior)
- Replace {owner}/{repo} placeholders with derived $REPO variable
- Add --paginate on comment fetching for large PRs
- Remove sticky comment references from skill (bot puts feedback
  in review bodies, not stdout — sticky comment stopped working
  after PAT switch in #1052)
- Add TODO on use_sticky_comment in workflow
- Restore gh pr comment prohibition with correct justification

Co-authored-by: Claude <[email protected]>
* fix(shell): harden nushell wrapper and improve diagnostics

- Move LAST_EXIT_CODE capture inside do{} block so it reflects the
  actual command exit code, not a subsequent operation
- Wrap directive processing in try/catch to ensure temp file cleanup
  on error
- Include nushell vendor autoload paths in scan_for_detection_details
  so `wt config show` reports nushell integration status
- Add "nu" to the supported shells hint shown on unsupported shells
- Fix detection tests to use actual nushell config line patterns
- Document why non-cd directives delegate to sh -c

Co-Authored-By: Claude <[email protected]>

* refactor(shell): remove try/catch from nushell directive cleanup

Drop error-path cleanup for the temp directive file. On error, the file
persists in /tmp as a useful debugging artifact (the OS cleans it up).
This matches bash and fish which already use a single rm on the happy
path with no error wrapping.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
* fix(shell): PowerShell wrapper swallows -D flag as -Debug (#885)

The `[Parameter(ValueFromRemainingArguments)]` attribute promoted the
wrapper to an "advanced function", which adds common parameters like
-Debug and -Verbose. PowerShell then consumed `-D` as `-Debug` instead
of passing it to wt.exe — so `wt remove -D` silently lost the flag.

Replace with `$args` (automatic variable for simple functions) which
passes all arguments through unchanged.

Co-Authored-By: Claude <[email protected]>

* fix(test): use .ps1 mock for cross-platform PowerShell test

The shell script mock (#!/bin/sh) doesn't work on Windows. Use a .ps1
script instead — pwsh can invoke it directly with &, and pwsh is already
required for this test.

Co-Authored-By: Claude <[email protected]>

* style: apply cargo fmt to PowerShell test

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
The review bot was generating summary prose like "Clean hardening of
the nushell wrapper..." when it had no issues to raise. An empty
approval is less noisy — the thumbs-up reaction is sufficient signal.

Co-authored-by: Claude <[email protected]>
* fix(list): handle empty repos (no commits) gracefully

Skip commit-dependent tasks for unborn branches (null OID) using a
COMMIT_TASKS constant, following the existing EXPENSIVE_TASKS pattern.
Filter null OIDs from timestamp batching, accept unborn default branch
in validation, and render empty commit/age cells instead of garbage.

Closes #885

Co-Authored-By: Claude <[email protected]>

* fix: address codecov/patch coverage gaps

- Remove unreachable COMMIT_TASKS check from work_items_for_branch (null
  OIDs only appear in worktree HEAD, never in git for-each-ref)
- Restructure json_output null OID handling to eliminate dead branch
- Pre-set default branch config in test to exercise is_unborn_head_branch path

Co-Authored-By: Claude <[email protected]>

* fix: remove unused BranchRef::has_commits() (dead code)

Only WorktreeInfo::has_commits() is called in the dispatch code.
BranchRef::has_commits() was never referenced, causing a codecov gap.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
All 5 preview modes now follow the same cache → compute → post-process
path in preview_for_mode, eliminating the Summary early-return special
case. Summary precomputation uses rayon (queued after tabs 1-4) instead
of a separate std::thread::spawn + thread::scope wrapper.

Threading simplified from:
  rayon::spawn × (N × 4)      ← tabs 1-4
  std::thread::spawn           ← wrapper
    └── std::thread::scope     ← N scoped threads
        └── LLM_SEMAPHORE      ← rate limit

To:
  rayon::spawn × (N × 4)      ← tabs 1-4 (queued first)
  rayon::spawn × N             ← summaries (queued last, semaphore inside)

Co-Authored-By: Claude <[email protected]>
max-sixty and others added 2 commits February 16, 2026 13:53
Summary generation is opt-in via `[list] summary = true` (default: false)
to avoid surprise LLM calls for users who have `[commit.generation]`
configured. Both settings are required for summaries to fire.

Adds documentation for the feature in switch help, FAQ (commands we run),
and llm-commits page (new "Picker summaries" section).

Co-Authored-By: Claude <[email protected]>
max-sixty and others added 2 commits February 16, 2026 14:48
The merge with main changed handle_select to receive ResolvedConfig
instead of UserConfig, so the .resolved() call is no longer needed.

Co-Authored-By: Claude <[email protected]>
The hint text now includes [list] summary = true in addition to the
[commit.generation] example.

Co-Authored-By: Claude <[email protected]>
max-sixty and others added 2 commits February 16, 2026 15:02
The shlex removal in #1065 missed one call site in the switch suggestion
context builder. Replace with shell_escape::escape to match the rest of
the codebase.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 74e3d6b into main Feb 16, 2026
19 checks passed
@max-sixty
max-sixty deleted the summary branch February 16, 2026 23:16
max-sixty added a commit to goodtune/worktrunk that referenced this pull request Feb 17, 2026
* feat(switch): add AI summary preview tab (tab 5)

Add a fifth preview mode to `wt switch` that shows AI-generated branch
summaries using the configured [commit.generation] LLM command. Summaries
use commit-message format (imperative subject + body) and render through
the standard markdown help renderer for consistent styling.

- Background thread generates summaries in parallel for all branches
- Disk cache in .git/wt-cache/summaries/ with hash-based invalidation
- Graceful fallback: config hint when LLM not configured, dim "no changes"
  for default branch
- Shortened tab labels to fit 5 tabs: 1:diff | 2:log | 3:main | 4:upstream | 5:summary

Co-Authored-By: Claude <[email protected]>

* fix: resolve merge conflicts from jj revert

After merging main (which reverted jj support), fix two issues:
- Resolve config to access commit_generation (handle_select no longer
  receives resolved config directly)
- Restore pub(crate) visibility on execute_llm_command

Co-Authored-By: Claude <[email protected]>

* test: add cache and rendering tests for summary module

Add tests for cache round-trip, hash invalidation, file path
sanitization, directory structure, and pre-styled text rendering
to improve codecov/patch coverage.

Co-Authored-By: Claude <[email protected]>

* test: add integration test for summary tab and expand cache tests

- Add PTY test for tab 5 showing config hint when LLM not configured
- Add cache round-trip, invalidation, sanitized path, and dir tests
- Add pre-styled text rendering test for dim "no changes" messages

Co-Authored-By: Claude <[email protected]>

* test(summary): add coverage for diff computation and LLM generation

Add 10 new unit tests covering `compute_combined_diff`,
`generate_summary`, `generate_all_summaries`, and the single-line
`render_summary` path. Uses real temp git repos with shell-stub LLM
commands (following existing patterns from merge integration tests).

Also refactors test helpers to share git command setup and repo
initialization, eliminating duplication between test cases.

Co-authored-by: Claude <[email protected]>

* fix(summary): handle missing default branch + add coverage tests

- compute_combined_diff no longer bails when default_branch() returns
  None — wraps branch diff in if-let, preserving working tree diff
- Fix test to use exotic branch name so default_branch() actually
  returns None (infer_default_branch_locally checks "main"/"master"/etc)
- Add unit tests for items.rs Summary tab paths (main worktree, feature
  branch, cache hit/miss, compute_preview delegation)
- Add error path tests for write_cache (unwritable path, permission
  failure)

Co-Authored-By: Claude <[email protected]>

* fix(summary): address PR review feedback

- Remove is_main() shortcut from compute_summary_preview — was checking
  main worktree (git concept) not default branch (different concept)
- Add unicode visual cues to tab labels: 1:diff±, 3:main↕, 4:upstream⇅
- Move summary_items clone closer to its consumer in mod.rs

Co-Authored-By: Claude <[email protected]>

* fix(ci): revert unicode tab cues — ambiguous East Asian Width

Characters ±, ↕, ⇅ have East Asian Width "Ambiguous" which skim
renders as double-width on CI, shifting [N/M] alignment by 3 chars.
Revert to plain labels for cross-platform consistency.

Co-Authored-By: Claude <[email protected]>

* fix(switch): restore unicode symbols in tab labels

Restore ±, ↕, ⇅ symbols to tab labels (1:diff±, 3:main↕, 4:upstream⇅).
These characters are used throughout the codebase and haven't shown
width issues in practice.

Co-authored-by: Maximilian Roos <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor(summary): bound concurrent LLM calls with Semaphore

Use the project's existing Semaphore (from src/sync.rs) to limit
concurrent LLM calls to 8 — same pattern as HEAVY_OPS_SEMAPHORE
and CMD_SEMAPHORE.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(switch): adjust snapshot spacing for unicode tab symbols

skim-tuikit uses width_cjk() for header layout, which treats
East Asian Width "Ambiguous" characters (±, ↕) as double-width.
This shifts [N/M] left by 3 columns. Update snapshots to match.

Co-authored-by: Maximilian Roos <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(test): normalize tab bar padding for cross-platform unicode widths

Skim right-aligns the [N/M] count indicator with padding that varies
depending on whether unicode chars (±, ↕, ⇅) are rendered as single
or double width. Normalize this padding in the snapshot filter so
tests pass regardless of the terminal's East Asian Width handling.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(switch): restore original tab titles, add 5th summary tab

Revert tab labels 1-4 to their original format ("1: HEAD±", "2: log",
"3: main…±", "4: remote⇅") and add "5: summary" as a new 5th tab.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(test): handle skim count overlap with summary tab label

When the 5 restored tab labels use ambiguous-width unicode symbols (±, …, ⇅),
skim's width_cjk() treats them as double-width, leaving insufficient space for
the count indicator. This causes the count to overlap with "summary" (e.g.,
"summary1/4") or truncate it ("summar1/28"). Add a targeted regex filter that
normalizes this overlap before the generic whitespace-padded count filter runs.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(test): avoid typos lint on truncated word in snapshot regex

Use `summary?` (optional `y`) instead of `summar` to avoid the typos
spell checker flagging the partial word.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(ci): restructure review skill workflow and fix dead sticky comment (max-sixty#1056)

- Reorder as explicit numbered workflow: pre-flight checks before
  expensive diff analysis to avoid redundant work
- Remove redundant "read CLAUDE.md" (already in system prompt)
- Filter dedup check by bot identity so human approvals don't
  cause the bot to skip its review
- Accept brief approval bodies (matches actual bot behavior)
- Replace {owner}/{repo} placeholders with derived $REPO variable
- Add --paginate on comment fetching for large PRs
- Remove sticky comment references from skill (bot puts feedback
  in review bodies, not stdout — sticky comment stopped working
  after PAT switch in max-sixty#1052)
- Add TODO on use_sticky_comment in workflow
- Restore gh pr comment prohibition with correct justification

Co-authored-by: Claude <[email protected]>

* fix(shell): harden nushell wrapper and improve diagnostics (max-sixty#1059)

* fix(shell): harden nushell wrapper and improve diagnostics

- Move LAST_EXIT_CODE capture inside do{} block so it reflects the
  actual command exit code, not a subsequent operation
- Wrap directive processing in try/catch to ensure temp file cleanup
  on error
- Include nushell vendor autoload paths in scan_for_detection_details
  so `wt config show` reports nushell integration status
- Add "nu" to the supported shells hint shown on unsupported shells
- Fix detection tests to use actual nushell config line patterns
- Document why non-cd directives delegate to sh -c

Co-Authored-By: Claude <[email protected]>

* refactor(shell): remove try/catch from nushell directive cleanup

Drop error-path cleanup for the temp directive file. On error, the file
persists in /tmp as a useful debugging artifact (the OS cleans it up).
This matches bash and fish which already use a single rm on the happy
path with no error wrapping.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* fix(shell): PowerShell wrapper swallows -D flag as -Debug (max-sixty#1057)

* fix(shell): PowerShell wrapper swallows -D flag as -Debug (max-sixty#885)

The `[Parameter(ValueFromRemainingArguments)]` attribute promoted the
wrapper to an "advanced function", which adds common parameters like
-Debug and -Verbose. PowerShell then consumed `-D` as `-Debug` instead
of passing it to wt.exe — so `wt remove -D` silently lost the flag.

Replace with `$args` (automatic variable for simple functions) which
passes all arguments through unchanged.

Co-Authored-By: Claude <[email protected]>

* fix(test): use .ps1 mock for cross-platform PowerShell test

The shell script mock (#!/bin/sh) doesn't work on Windows. Use a .ps1
script instead — pwsh can invoke it directly with &, and pwsh is already
required for this test.

Co-Authored-By: Claude <[email protected]>

* style: apply cargo fmt to PowerShell test

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* fix(ci): use empty body for LGTM approvals instead of fluff (max-sixty#1060)

The review bot was generating summary prose like "Clean hardening of
the nushell wrapper..." when it had no issues to raise. An empty
approval is less noisy — the thumbs-up reaction is sufficient signal.

Co-authored-by: Claude <[email protected]>

* fix(list): handle empty repos (no commits) gracefully (max-sixty#1058)

* fix(list): handle empty repos (no commits) gracefully

Skip commit-dependent tasks for unborn branches (null OID) using a
COMMIT_TASKS constant, following the existing EXPENSIVE_TASKS pattern.
Filter null OIDs from timestamp batching, accept unborn default branch
in validation, and render empty commit/age cells instead of garbage.

Closes max-sixty#885

Co-Authored-By: Claude <[email protected]>

* fix: address codecov/patch coverage gaps

- Remove unreachable COMMIT_TASKS check from work_items_for_branch (null
  OIDs only appear in worktree HEAD, never in git for-each-ref)
- Restructure json_output null OID handling to eliminate dead branch
- Pre-set default branch config in test to exercise is_unborn_head_branch path

Co-Authored-By: Claude <[email protected]>

* fix: remove unused BranchRef::has_commits() (dead code)

Only WorktreeInfo::has_commits() is called in the dispatch code.
BranchRef::has_commits() was never referenced, causing a codecov gap.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* refactor(switch): unify preview mode handling

All 5 preview modes now follow the same cache → compute → post-process
path in preview_for_mode, eliminating the Summary early-return special
case. Summary precomputation uses rayon (queued after tabs 1-4) instead
of a separate std::thread::spawn + thread::scope wrapper.

Threading simplified from:
  rayon::spawn × (N × 4)      ← tabs 1-4
  std::thread::spawn           ← wrapper
    └── std::thread::scope     ← N scoped threads
        └── LLM_SEMAPHORE      ← rate limit

To:
  rayon::spawn × (N × 4)      ← tabs 1-4 (queued first)
  rayon::spawn × N             ← summaries (queued last, semaphore inside)

Co-Authored-By: Claude <[email protected]>

* feat(switch): gate summary tab behind [list] summary config

Summary generation is opt-in via `[list] summary = true` (default: false)
to avoid surprise LLM calls for users who have `[commit.generation]`
configured. Both settings are required for summaries to fire.

Adds documentation for the feature in switch help, FAQ (commands we run),
and llm-commits page (new "Picker summaries" section).

Co-Authored-By: Claude <[email protected]>

* fix: use ResolvedConfig directly after main merge

The merge with main changed handle_select to receive ResolvedConfig
instead of UserConfig, so the .resolved() call is no longer needed.

Co-Authored-By: Claude <[email protected]>

* test: update summary preview snapshot for config hint

The hint text now includes [list] summary = true in addition to the
[commit.generation] example.

Co-Authored-By: Claude <[email protected]>

* fix: replace missed shlex::try_quote with shell_escape

The shlex removal in max-sixty#1065 missed one call site in the switch suggestion
context builder. Replace with shell_escape::escape to match the rest of
the codebase.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Roos <[email protected]>
max-sixty added a commit that referenced this pull request Feb 17, 2026
* feat: add system-wide config file support

Load organization-wide defaults from a system config file before user
config, allowing companies to distribute shared preferences via
configuration management.

Config loading order (later overrides earlier):
1. System config (organization defaults)
2. User config (personal preferences)
3. Environment variables

System config search locations:
- $WORKTRUNK_SYSTEM_CONFIG_PATH (explicit override)
- $XDG_CONFIG_DIRS directories (colon-separated)
- Linux: /etc/xdg/worktrunk/config.toml
- macOS: /Library/Application Support/worktrunk/config.toml
- Windows: %PROGRAMDATA%\worktrunk\config.toml

Uses the same format as user config. Visible in `wt config show`.

https://claude.ai/code/session_01FeQXY5Hu8STpn5DZPvkxWC

* fix: apply cargo fmt formatting

Apply rustfmt formatting to fix CI lint failures:
- Split long `pub use` statement across multiple lines in `mod.rs`
- Condense multi-line path building to single line in `path.rs`
- Format long string assignment in `tests.rs`
- Improve method chaining formatting in integration tests

* fix: ensure consistent system config path in tests across platforms

Add `WORKTRUNK_SYSTEM_CONFIG_PATH` to test environment setup to prevent
platform-specific system config paths from appearing in snapshots.

Changes:
- Set `WORKTRUNK_SYSTEM_CONFIG_PATH=/etc/xdg/worktrunk/config.toml` in `configure_wt_cmd()` (TestRepo)
- Set `WORKTRUNK_SYSTEM_CONFIG_PATH=/etc/xdg/worktrunk/config.toml` in `configure_cli_command()` (standalone tests)
- Add filter for non-canonicalized macOS temp paths (`/var/folders/...`)

This ensures tests show consistent "Not found (optional)" for system config
across Linux, macOS, and Windows, preventing snapshot mismatches.

* style: apply cargo fmt to tests/common/mod.rs

https://claude.ai/code/session_01FeQXY5Hu8STpn5DZPvkxWC

* fix: add WORKTRUNK_SYSTEM_CONFIG_PATH to PTY test environment

Add `WORKTRUNK_SYSTEM_CONFIG_PATH` to `test_env_vars()` to ensure PTY-based
tests (like switch picker) have consistent system config behavior across platforms.

Without this, PTY tests would fall back to platform-specific system config
paths, causing test output to vary between Linux, macOS, and Windows.

* refactor: remove #[cfg(test)] guards from config path resolution

Eliminate all test/non-test cfg annotations from path.rs. Both user
config and system config now use the same pattern: env var check first,
then platform default. Test isolation relies on env vars set by
TestRepo (WORKTRUNK_CONFIG_PATH, WORKTRUNK_SYSTEM_CONFIG_PATH), which
already covered integration tests.

Delete system_config_search_dirs() (fragile double-.parent() hack),
replace with default_system_config_path() that returns the env var
or first platform default.

Co-authored-by: Claude <[email protected]>

* test: add integration tests for XDG_CONFIG_DIRS and platform default paths

Cover the system config resolution paths that were previously behind
#[cfg(not(test))] and never tested: XDG_CONFIG_DIRS lookup (found and
not-found cases), and platform default display path fallback.

Co-authored-by: Claude <[email protected]>

* test: add coverage for system config edge cases in config show

Add tests for empty system config (hint message), invalid system config
(TOML parse error display), and unknown keys warning during config loading.
These exercise the render_system_config() and config loading paths.

Co-Authored-By: Claude <[email protected]>

* docs: reduce system config prominence in config page

System config is a niche feature for organizations. Replace the dedicated
section, TOML example, and table row with a single sentence pointing to
`wt config show`. Env vars remain in the table for discoverability.

Co-Authored-By: Claude <[email protected]>

* fix: update powershell test snapshot for system config section

Test from main needed its snapshot updated to include the new
SYSTEM CONFIG section in config show output.

Co-Authored-By: Claude <[email protected]>

* fix(config): resolve list timeout from per-project config (#1063)

* refactor(list): move timeout resolution into collect

Move raw_timeout extraction from handle_list into the collect function's
config resolution phase. This simplifies the public API by removing an
unused field from ShowConfig::DeferredToParallel and consolidates timeout
logic (including the --full override) into a single location where it can
access the merged project-specific config.

* refactor(config): add repo.config() for resolved config access

Add Repository::config() -> &ResolvedConfig and
Repository::user_config() -> &UserConfig, both lazily loaded and cached
in RepoCache. This makes correct config resolution the default path —
callers use repo.config() and get project-specific overrides applied
automatically.

Migrate wt list / wt select to use repo.config() instead of receiving
&UserConfig as a parameter. This removes the manual config resolution
that led to the timeout_ms bug (reading global config instead of merged
project-specific config).

Co-Authored-By: Claude <[email protected]>

* refactor(select): move config resolution into handle_select

Move CLI flag + config resolution from callers into handle_select(),
which already creates a Repository. This simplifies main.rs callers
and improves coverage on changed lines (callers in untestable
terminal paths now have minimal code).

Also switch select's post-selection switch to repo.user_config()
instead of UserConfig::load().

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* feat(switch): enrich error hints with --execute context (#1064)

* feat(switch): enrich error hints with --execute and trailing args context

When `wt switch --execute=<cmd> -- <args>` fails (branch not found, already
exists, path exists), error hints now include the full command context so
users can copy-paste the suggested fix directly.

Also fixes `suggest_command()` to place flags before positional args (and
before any `--` separator), preventing flags from being treated as positional
args when dash-prefixed branches are involved.

Co-Authored-By: Claude <[email protected]>

* fix(coverage): remove unreachable -- separator branch in apply()

Clap's `#[arg(last = true)]` on execute_args means `--` always routes
to execute_args, so a dash-prefixed branch can't coexist with --execute
via the CLI. The suggested command never has a pre-existing `--`
separator when SwitchSuggestionCtx is applied, making this branch
dead code.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* Refactor approvals into separate file with deprecation migration (#1042)

* Refactor approvals into separate file

Approved commands are now stored in `~/.config/worktrunk/approvals.toml`,
independent of user config. This enables dotfile management of
`config.toml` without exposing machine-local trust state.

The `Approvals` type provides the same mutation interface as
`UserConfig` (approve/revoke commands, file locking) but stores
exclusively approval data. For backward compatibility, approvals
are silently read from `config.toml` if `approvals.toml` doesn't exist.

All command approval code now uses `Approvals::load()` and passes
`&approvals` to `approve_command_batch()`. Tests use isolated
`test_approvals_path()` to prevent pollution of user approvals.

* Add deprecation warning for approved-commands in config.toml

Approved commands moved to approvals.toml in the previous commit but
stale entries in config.toml were silently ignored. Now `wt config show`
detects them, generates a migration file that removes the entries, and
shows a diff + mv command. Other commands show a brief warning.

Also updates all CLI help text, docs, and FAQ to reference
approvals.toml as the storage location, and migrates all test configs
to use write_test_approvals() for approved-commands content.

Co-Authored-By: Claude <[email protected]>

* fix: document fallback path asymmetry and add config.toml fallback tests

Address PR review feedback:
- Document why `load_from_config_fallback()` uses `get_config_path()` while
  `reload_from()` uses sibling derivation, and why both converge in production
- Add `test_load_from_config_file` testing the extraction logic
- Add `test_mutation_picks_up_config_toml_fallback` testing the full mutation
  path with config.toml fallback (no approvals.toml → reads config.toml →
  preserves existing commands alongside new one)
- Inline `get_config_path` import (only used in `#[cfg(not(test))]` block)

Co-Authored-By: Claude <[email protected]>

* refactor: single fallback path for config.toml approvals

Replace two separate fallback implementations (load_from_config_fallback
via get_config_path, and reload_from via sibling derivation) with a
single load_with_fallback(path) that both load() and reload_from() use.

The shared helper derives config.toml as a sibling of the approvals
file, which is always correct since get_approvals_path() derives
approvals.toml as a sibling of config.toml.

Co-Authored-By: Claude <[email protected]>

* fix(tests): pass WORKTRUNK_APPROVALS_PATH in shell wrapper tests

Shell wrapper tests only passed WORKTRUNK_CONFIG_PATH to the binary,
so it derived the approvals path from config and found approved-commands
in config.toml, triggering the new deprecation warnings. This broke
4 snapshot tests and likely caused 6 timeouts on CI.

Fix: pass WORKTRUNK_APPROVALS_PATH alongside WORKTRUNK_CONFIG_PATH in
all shell wrapper test environments (build_shell_script, build_test_env_vars,
and custom script builders for all shell types). Migrate all approved-commands
writes from test_config_path() to write_test_approvals().

Co-Authored-By: Claude <[email protected]>

* fix(docs): escape brackets in doc comments for rustdoc

Rustdoc interprets `[projects]` as a broken intra-doc link.
Escape with `\[...\]` to treat as literal text.

Co-Authored-By: Claude <[email protected]>

* fix(tests): migrate approvals in e2e_shell_post_start and approval_pty tests

- e2e_shell_post_start: write approved-commands to approvals.toml
  instead of config.toml (fixes 5 timeout failures from unanswered
  approval prompts)
- approval_pty permission test: use a subdirectory for the read-only
  approvals path so the temp root stays writable for .zshrc and other
  test files

Co-Authored-By: Claude <[email protected]>

* test: improve coverage for approvals and deprecation modules

Add tests covering error paths, edge cases, and new deprecation features:
- approvals.rs: load_from_file parse errors, load_from_config_file parse
  errors, load_from_path nonexistent, revoke on nonexistent projects,
  clear_all when empty, save_to with empty project, revoke_project with
  empty commands
- deprecation.rs: remove_approved_commands with invalid TOML,
  format_deprecation_details with approved_commands flag,
  write_migration_file with approved_commands

Co-Authored-By: Claude <[email protected]>

* refactor: remove unused revoke_command from Approvals

Adversarial review found a normalization bug: revoke_command used exact
string matching while is_command_approved normalizes template variables.
Rather than fix a method with no production callers, remove it entirely.
Production code uses revoke_project (removes all approvals for a project)
and clear_all.

Rewrote test_concurrent_revoke_preserves_all_changes to use revoke_project.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* refactor: consolidate shell escaping on shell_escape, drop shlex (#1065)

Both `shell_escape` and `shlex` were used for shell quoting. `shell_escape`
is the project standard (~10 files); `shlex` was only used in 2 call sites
for `try_quote()`. Consolidate on the single crate.

Co-authored-by: Claude <[email protected]>

* fix(test): wait for item content in switch picker PTY tests (#1066)

* fix(test): wait for item content in switch picker PTY tests

On macOS CI under heavy load, skim may render the prompt and header
line before item rows, causing wait_for_stable (500ms threshold) to
capture the screen too early — before branch entries appear.

Fix by passing expected content to the pre-abort wait, ensuring the
test waits until items are actually rendered. This matches the pattern
already used by test_switch_picker_respects_list_config.

Also harden test_switch_picker_with_multiple_worktrees with the same
pattern as a preventive measure.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(switch): replace remaining shlex reference with shell_escape

Commit 8ba5cd8 dropped the shlex dependency but missed one call site
at handle_switch.rs:154 (the suggestion context builder). Also update
the stale comment in error.rs.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <[email protected]>

* feat(switch): add AI summary preview tab (#1049)

* feat(switch): add AI summary preview tab (tab 5)

Add a fifth preview mode to `wt switch` that shows AI-generated branch
summaries using the configured [commit.generation] LLM command. Summaries
use commit-message format (imperative subject + body) and render through
the standard markdown help renderer for consistent styling.

- Background thread generates summaries in parallel for all branches
- Disk cache in .git/wt-cache/summaries/ with hash-based invalidation
- Graceful fallback: config hint when LLM not configured, dim "no changes"
  for default branch
- Shortened tab labels to fit 5 tabs: 1:diff | 2:log | 3:main | 4:upstream | 5:summary

Co-Authored-By: Claude <[email protected]>

* fix: resolve merge conflicts from jj revert

After merging main (which reverted jj support), fix two issues:
- Resolve config to access commit_generation (handle_select no longer
  receives resolved config directly)
- Restore pub(crate) visibility on execute_llm_command

Co-Authored-By: Claude <[email protected]>

* test: add cache and rendering tests for summary module

Add tests for cache round-trip, hash invalidation, file path
sanitization, directory structure, and pre-styled text rendering
to improve codecov/patch coverage.

Co-Authored-By: Claude <[email protected]>

* test: add integration test for summary tab and expand cache tests

- Add PTY test for tab 5 showing config hint when LLM not configured
- Add cache round-trip, invalidation, sanitized path, and dir tests
- Add pre-styled text rendering test for dim "no changes" messages

Co-Authored-By: Claude <[email protected]>

* test(summary): add coverage for diff computation and LLM generation

Add 10 new unit tests covering `compute_combined_diff`,
`generate_summary`, `generate_all_summaries`, and the single-line
`render_summary` path. Uses real temp git repos with shell-stub LLM
commands (following existing patterns from merge integration tests).

Also refactors test helpers to share git command setup and repo
initialization, eliminating duplication between test cases.

Co-authored-by: Claude <[email protected]>

* fix(summary): handle missing default branch + add coverage tests

- compute_combined_diff no longer bails when default_branch() returns
  None — wraps branch diff in if-let, preserving working tree diff
- Fix test to use exotic branch name so default_branch() actually
  returns None (infer_default_branch_locally checks "main"/"master"/etc)
- Add unit tests for items.rs Summary tab paths (main worktree, feature
  branch, cache hit/miss, compute_preview delegation)
- Add error path tests for write_cache (unwritable path, permission
  failure)

Co-Authored-By: Claude <[email protected]>

* fix(summary): address PR review feedback

- Remove is_main() shortcut from compute_summary_preview — was checking
  main worktree (git concept) not default branch (different concept)
- Add unicode visual cues to tab labels: 1:diff±, 3:main↕, 4:upstream⇅
- Move summary_items clone closer to its consumer in mod.rs

Co-Authored-By: Claude <[email protected]>

* fix(ci): revert unicode tab cues — ambiguous East Asian Width

Characters ±, ↕, ⇅ have East Asian Width "Ambiguous" which skim
renders as double-width on CI, shifting [N/M] alignment by 3 chars.
Revert to plain labels for cross-platform consistency.

Co-Authored-By: Claude <[email protected]>

* fix(switch): restore unicode symbols in tab labels

Restore ±, ↕, ⇅ symbols to tab labels (1:diff±, 3:main↕, 4:upstream⇅).
These characters are used throughout the codebase and haven't shown
width issues in practice.

Co-authored-by: Maximilian Roos <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor(summary): bound concurrent LLM calls with Semaphore

Use the project's existing Semaphore (from src/sync.rs) to limit
concurrent LLM calls to 8 — same pattern as HEAVY_OPS_SEMAPHORE
and CMD_SEMAPHORE.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(switch): adjust snapshot spacing for unicode tab symbols

skim-tuikit uses width_cjk() for header layout, which treats
East Asian Width "Ambiguous" characters (±, ↕) as double-width.
This shifts [N/M] left by 3 columns. Update snapshots to match.

Co-authored-by: Maximilian Roos <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(test): normalize tab bar padding for cross-platform unicode widths

Skim right-aligns the [N/M] count indicator with padding that varies
depending on whether unicode chars (±, ↕, ⇅) are rendered as single
or double width. Normalize this padding in the snapshot filter so
tests pass regardless of the terminal's East Asian Width handling.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(switch): restore original tab titles, add 5th summary tab

Revert tab labels 1-4 to their original format ("1: HEAD±", "2: log",
"3: main…±", "4: remote⇅") and add "5: summary" as a new 5th tab.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(test): handle skim count overlap with summary tab label

When the 5 restored tab labels use ambiguous-width unicode symbols (±, …, ⇅),
skim's width_cjk() treats them as double-width, leaving insufficient space for
the count indicator. This causes the count to overlap with "summary" (e.g.,
"summary1/4") or truncate it ("summar1/28"). Add a targeted regex filter that
normalizes this overlap before the generic whitespace-padded count filter runs.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(test): avoid typos lint on truncated word in snapshot regex

Use `summary?` (optional `y`) instead of `summar` to avoid the typos
spell checker flagging the partial word.

Co-authored-by: Maximilian Roos <[email protected]>

* fix(ci): restructure review skill workflow and fix dead sticky comment (#1056)

- Reorder as explicit numbered workflow: pre-flight checks before
  expensive diff analysis to avoid redundant work
- Remove redundant "read CLAUDE.md" (already in system prompt)
- Filter dedup check by bot identity so human approvals don't
  cause the bot to skip its review
- Accept brief approval bodies (matches actual bot behavior)
- Replace {owner}/{repo} placeholders with derived $REPO variable
- Add --paginate on comment fetching for large PRs
- Remove sticky comment references from skill (bot puts feedback
  in review bodies, not stdout — sticky comment stopped working
  after PAT switch in #1052)
- Add TODO on use_sticky_comment in workflow
- Restore gh pr comment prohibition with correct justification

Co-authored-by: Claude <[email protected]>

* fix(shell): harden nushell wrapper and improve diagnostics (#1059)

* fix(shell): harden nushell wrapper and improve diagnostics

- Move LAST_EXIT_CODE capture inside do{} block so it reflects the
  actual command exit code, not a subsequent operation
- Wrap directive processing in try/catch to ensure temp file cleanup
  on error
- Include nushell vendor autoload paths in scan_for_detection_details
  so `wt config show` reports nushell integration status
- Add "nu" to the supported shells hint shown on unsupported shells
- Fix detection tests to use actual nushell config line patterns
- Document why non-cd directives delegate to sh -c

Co-Authored-By: Claude <[email protected]>

* refactor(shell): remove try/catch from nushell directive cleanup

Drop error-path cleanup for the temp directive file. On error, the file
persists in /tmp as a useful debugging artifact (the OS cleans it up).
This matches bash and fish which already use a single rm on the happy
path with no error wrapping.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* fix(shell): PowerShell wrapper swallows -D flag as -Debug (#1057)

* fix(shell): PowerShell wrapper swallows -D flag as -Debug (#885)

The `[Parameter(ValueFromRemainingArguments)]` attribute promoted the
wrapper to an "advanced function", which adds common parameters like
-Debug and -Verbose. PowerShell then consumed `-D` as `-Debug` instead
of passing it to wt.exe — so `wt remove -D` silently lost the flag.

Replace with `$args` (automatic variable for simple functions) which
passes all arguments through unchanged.

Co-Authored-By: Claude <[email protected]>

* fix(test): use .ps1 mock for cross-platform PowerShell test

The shell script mock (#!/bin/sh) doesn't work on Windows. Use a .ps1
script instead — pwsh can invoke it directly with &, and pwsh is already
required for this test.

Co-Authored-By: Claude <[email protected]>

* style: apply cargo fmt to PowerShell test

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* fix(ci): use empty body for LGTM approvals instead of fluff (#1060)

The review bot was generating summary prose like "Clean hardening of
the nushell wrapper..." when it had no issues to raise. An empty
approval is less noisy — the thumbs-up reaction is sufficient signal.

Co-authored-by: Claude <[email protected]>

* fix(list): handle empty repos (no commits) gracefully (#1058)

* fix(list): handle empty repos (no commits) gracefully

Skip commit-dependent tasks for unborn branches (null OID) using a
COMMIT_TASKS constant, following the existing EXPENSIVE_TASKS pattern.
Filter null OIDs from timestamp batching, accept unborn default branch
in validation, and render empty commit/age cells instead of garbage.

Closes #885

Co-Authored-By: Claude <[email protected]>

* fix: address codecov/patch coverage gaps

- Remove unreachable COMMIT_TASKS check from work_items_for_branch (null
  OIDs only appear in worktree HEAD, never in git for-each-ref)
- Restructure json_output null OID handling to eliminate dead branch
- Pre-set default branch config in test to exercise is_unborn_head_branch path

Co-Authored-By: Claude <[email protected]>

* fix: remove unused BranchRef::has_commits() (dead code)

Only WorktreeInfo::has_commits() is called in the dispatch code.
BranchRef::has_commits() was never referenced, causing a codecov gap.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>

* refactor(switch): unify preview mode handling

All 5 preview modes now follow the same cache → compute → post-process
path in preview_for_mode, eliminating the Summary early-return special
case. Summary precomputation uses rayon (queued after tabs 1-4) instead
of a separate std::thread::spawn + thread::scope wrapper.

Threading simplified from:
  rayon::spawn × (N × 4)      ← tabs 1-4
  std::thread::spawn           ← wrapper
    └── std::thread::scope     ← N scoped threads
        └── LLM_SEMAPHORE      ← rate limit

To:
  rayon::spawn × (N × 4)      ← tabs 1-4 (queued first)
  rayon::spawn × N             ← summaries (queued last, semaphore inside)

Co-Authored-By: Claude <[email protected]>

* feat(switch): gate summary tab behind [list] summary config

Summary generation is opt-in via `[list] summary = true` (default: false)
to avoid surprise LLM calls for users who have `[commit.generation]`
configured. Both settings are required for summaries to fire.

Adds documentation for the feature in switch help, FAQ (commands we run),
and llm-commits page (new "Picker summaries" section).

Co-Authored-By: Claude <[email protected]>

* fix: use ResolvedConfig directly after main merge

The merge with main changed handle_select to receive ResolvedConfig
instead of UserConfig, so the .resolved() call is no longer needed.

Co-Authored-By: Claude <[email protected]>

* test: update summary preview snapshot for config hint

The hint text now includes [list] summary = true in addition to the
[commit.generation] example.

Co-Authored-By: Claude <[email protected]>

* fix: replace missed shlex::try_quote with shell_escape

The shlex removal in #1065 missed one call site in the switch suggestion
context builder. Replace with shell_escape::escape to match the rest of
the codebase.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Roos <[email protected]>

* fix: replace missed shlex::try_quote call with shell_escape (#1067)

The shlex crate removal in #1065 missed one call site in
handle_switch.rs that still used shlex::try_quote for escaping
--execute flag values in error suggestions.

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <[email protected]>

* Improve CI reviewer: resolve threads, skip trivial re-approval, default to suggestions (#1068)

Three changes to the worktrunk-review skill:

- Resolve handled suggestions: after review, check unresolved bot threads via
  GraphQL and resolve any where the issue was addressed
- Skip re-approval for trivial changes: when bot already approved a prior
  revision and new changes are under ~20 lines with no new logic, the existing
  approval stands — skip to thread resolution and exit
- Default to code suggestions: reframe GitHub suggestion format as the default
  for specific fixes, not just an option

Co-authored-by: Claude <[email protected]>

* fix: update snapshots and PTY tests after merge from main

Update config_show snapshots to include new env vars from main
(WORKTRUNK_APPROVALS_PATH, WORKTRUNK_TEST_NUSHELL_ENV, etc.) and
system config section in output.

Add write_test_config("") to PTY merge tests to suppress the commit
generation prompt that fires when claude is on PATH.

Co-Authored-By: Claude <[email protected]>

* Refactor system config handling to only show section when found

When no system config file exists, `config show` now displays an optional
system config hint under USER CONFIG instead of a separate empty SYSTEM
CONFIG section. This improves UX by reducing visual clutter while still
informing users where to place a system config file if desired.

Also consolidates system config directory lookup logic into a single
`system_config_dirs()` function that properly handles XDG_CONFIG_DIRS
environment variable precedence per XDG spec.

* fix: improve review findings and add hooks merge semantics tests

- Simplify system_config_dirs() return type (remove unused xdg_was_set bool)
- Fix two integration tests with empty assertion loops (wrong field name,
  no linked worktrees)
- Add end-to-end tests for system/user hooks merge behavior:
  - Deep merge preserves differently-named hooks from both configs
  - Same-named hooks: user replaces system
  - Untouched hook types from system config are preserved
- Rename misleading unit test to clarify Merge trait scope (global→project only)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Roos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feedback-requested Looking for user feedback on this feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants