Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
de3e222
test: Fix snapshot platform incompatibility for test_list_maximum_sta…
max-sixty Nov 20, 2025
6b9b4f0
fix: Normalize platform-specific git behavior in test_list_maximum_st…
max-sixty Nov 20, 2025
77e29e3
Merge branch 'main' into ci
max-sixty Nov 20, 2025
8517be3
test: simplify maximum_status_symbols test with dir-to-dir clone
max-sixty Nov 20, 2025
bca2ad3
Merge branch 'ci'
max-sixty Nov 20, 2025
080556d
fix: Update snapshot for consolidated status symbols and add normaliz…
max-sixty Nov 20, 2025
600b54a
fix: Account for ANSI codes in upstream divergence filter
max-sixty Nov 20, 2025
2f54c7b
Refactor status symbols for better JSON querying
max-sixty Nov 20, 2025
0a86ed7
Merge branch 'main' into ci
max-sixty Nov 20, 2025
455247b
Make maximum status symbols test deterministic
Nov 20, 2025
1d16c4f
chore: trigger CI for max status test
Nov 20, 2025
d5ea564
ci: allow manual dispatch for troubleshooting
Nov 20, 2025
087222d
Stabilize upstream divergence test and fix clippy
Nov 20, 2025
26a8da3
Document deterministic upstream setup and passing CI
Nov 20, 2025
8acdda7
Merge main into ci
Nov 20, 2025
531694a
fix: gate status render on unix
Nov 20, 2025
ae07465
Merge branch 'main' into ci
max-sixty Nov 20, 2025
726420a
docs: tidy list json help
Nov 20, 2025
62cffe2
revert: keep list help unchanged
Nov 20, 2025
e154d69
Remove ISSUE.md
max-sixty Nov 20, 2025
bcf10db
Merge branch 'main' into ci
max-sixty Nov 20, 2025
1bdc13e
tests: revert init help snapshots
Nov 20, 2025
7200cff
tests: harden post-start background wait
Nov 20, 2025
5f8d9fe
Merge remote-tracking branch 'origin/main' into ci
Nov 20, 2025
7e36883
chore: sync skill README
Nov 20, 2025
805c225
chore: fmt after wait helper
Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions .claude-plugin/skills/worktrunk/reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ everything — standard `git worktree` commands continue working fine.

### LLM-Authored Commit Messages

Worktrunk can invoke an external commands during merge operations to generate
Worktrunk can invoke external commands during merge operations to generate
commit messages. Simon Willison's [llm](https://llm.datasette.io/) tool reads
the diff and a configurable prompt, then returns a formatted commit message.

Expand Down Expand Up @@ -831,17 +831,15 @@ The custom emoji appears directly after the git status symbols.

Claude Code can automatically set/clear emoji status when coding sessions start and end. This shows which branches have active AI sessions.

**Easy setup:** The Worktrunk repository includes a `.claude-plugin` directory with pre-configured hooks. When working in this repository, the hooks are automatically available.

**Manual setup for other repositories:** Copy the hooks from [`.claude-plugin/hooks/hooks.json`](.claude-plugin/hooks/hooks.json) to `~/.claude/settings.json`.
**Easy setup:** The Worktrunk repository includes a `.claude-plugin` directory with pre-configured hooks.

When using Claude:

- Sets status to `🤖` for the current branch when submitting a prompt (working)
- Changes to `💬` when Claude needs input (waiting for permission or idle)
- Clears the status completely when the session ends

**Status from other terminal:**
**Status from another terminal:**

<!-- Output from: tests/snapshots/integration__integration_tests__list__with_user_status.snap -->

Expand All @@ -862,7 +860,6 @@ dirty-with-status ≡?🤖 ./dirty-with-status b8346
- Status is stored as `worktrunk.status.<branch>` in `.git/config`
- Each branch can have its own status emoji
- The hooks automatically detect the current branch and set/clear its status
- Status is shared across all worktrees on the same branch (by design)
- Works with any git repository, no special configuration needed

</details>
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tier-2-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
Expand Down
6 changes: 4 additions & 2 deletions src/commands/list/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,10 @@ pub struct StatusSymbols {
impl StatusSymbols {
/// Render symbols with full alignment (all positions)
///
/// This is used for the display fields in JSON output.
/// For table rendering with selective positions, use `render_with_mask()`.
/// This is used for the display fields in JSON output. Skipped on Windows
/// to avoid an unused/dead-code warning in clippy (the interactive selector
/// that calls this exists only on Unix).
#[cfg(unix)]
pub fn render(&self) -> String {
self.render_with_mask(&PositionMask::FULL)
}
Expand Down
43 changes: 31 additions & 12 deletions tests/integration_tests/e2e_shell_post_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ use crate::common::{
use rstest::rstest;
use std::fs;
use std::thread;
use std::time::Duration;
use std::time::{Duration, Instant};

fn wait_for_file(path: &std::path::Path, timeout: Duration) {
let start = Instant::now();
while start.elapsed() < timeout {
if path.exists() {
return;
}
thread::sleep(Duration::from_millis(50));
}
panic!(
"File was not created within {:?}: {}",
timeout,
path.display()
);
}

/// Test that post-start background commands work with shell integration
#[rstest]
Expand Down Expand Up @@ -71,9 +86,6 @@ approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt"
output
);

// Wait for background command to complete (command has sleep 0.05 + margin)
thread::sleep(Duration::from_millis(150));

// Verify background command actually ran
let worktree_path = repo
.root_path()
Expand Down Expand Up @@ -105,14 +117,13 @@ approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt"
log_files
);

let marker_file = worktree_path.join("bg_marker.txt");
assert!(
marker_file.exists(),
"Background command should have created bg_marker.txt in {} (logs: {:?})",
worktree_path.display(),
log_files
// Wait for background command to complete (allow plenty of margin on CI)
wait_for_file(
worktree_path.join("bg_marker.txt").as_path(),
Duration::from_secs(1),
);

let marker_file = worktree_path.join("bg_marker.txt");
let content = fs::read_to_string(&marker_file).expect("Failed to read marker file");
assert!(
content.contains("Background task done"),
Expand Down Expand Up @@ -321,8 +332,16 @@ approved-commands = ["sleep 0.05 && echo 'Fish background done' > fish_bg.txt"]
output
);

// Wait for background command (command has sleep 0.05 + margin)
thread::sleep(Duration::from_millis(150));
// Wait for background command (allow plenty of margin on CI)
wait_for_file(
repo.root_path()
.parent()
.unwrap()
.join("test-repo.fish-bg-test")
.join("fish_bg.txt")
.as_path(),
Duration::from_secs(1),
);

// Verify background command ran
let worktree_path = repo
Expand Down
96 changes: 36 additions & 60 deletions tests/integration_tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,75 +1611,61 @@ fn test_list_maximum_status_symbols() {
.output()
.unwrap();

// Create a remote repo by cloning to a separate directory
let remote_dir = repo.root_path().parent().unwrap().join("remote-repo");
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args([
"clone",
repo.root_path().to_str().unwrap(),
remote_dir.to_str().unwrap(),
])
.output()
.unwrap();
// Create a real bare remote so upstream exists, but keep all graph crafting local for determinism
repo.setup_remote("main");

// In the remote repo, check out feature branch and make a commit
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["checkout", "feature"])
.current_dir(&remote_dir)
.output()
.unwrap();
// Remember the shared base (Feature work)
let base_sha = {
let output = repo
.git_command(&["rev-parse", "HEAD"])
.current_dir(&feature)
.output()
.unwrap();
String::from_utf8_lossy(&output.stdout).trim().to_string()
};

std::fs::write(remote_dir.join("remote-file.txt"), "remote content").unwrap();
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["add", "remote-file.txt"])
.current_dir(&remote_dir)
// Remote-only commit
std::fs::write(feature.join("remote-file.txt"), "remote content").unwrap();
repo.git_command(&["add", "remote-file.txt"])
.current_dir(&feature)
.output()
.unwrap();
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["commit", "-m", "Remote commit"])
.current_dir(&remote_dir)
repo.git_command(&["commit", "-m", "Remote commit"])
.current_dir(&feature)
.output()
.unwrap();
let remote_sha = {
let output = repo
.git_command(&["rev-parse", "HEAD"])
.current_dir(&feature)
.output()
.unwrap();
String::from_utf8_lossy(&output.stdout).trim().to_string()
};

// In the local feature worktree, make a different commit (creates divergence)
std::fs::write(feature.join("local-file.txt"), "local content").unwrap();
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["add", "local-file.txt"])
// Reset back to base so the remote commit is not in the local branch history
repo.git_command(&["reset", "--hard", &base_sha])
.current_dir(&feature)
.output()
.unwrap();
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["commit", "-m", "Local commit"])

// Local-only commit (divergence on the local side)
std::fs::write(feature.join("local-file.txt"), "local content").unwrap();
repo.git_command(&["add", "local-file.txt"])
.current_dir(&feature)
.output()
.unwrap();

// Set up the remote repo as origin for the feature worktree
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["remote", "add", "origin", remote_dir.to_str().unwrap()])
repo.git_command(&["commit", "-m", "Local commit"])
.current_dir(&feature)
.output()
.unwrap();

// Fetch from the remote to establish tracking
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["fetch", "origin"])
// Wire up upstream tracking deterministically: point origin/feature at the remote-only commit
repo.git_command(&["update-ref", "refs/remotes/origin/feature", &remote_sha])
.current_dir(&feature)
.output()
.unwrap();

// Set up branch tracking
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
cmd.args(["branch", "--set-upstream-to=origin/feature", "feature"])
repo.git_command(&["branch", "--set-upstream-to=origin/feature", "feature"])
.current_dir(&feature)
.output()
.unwrap();
Expand Down Expand Up @@ -1749,17 +1735,7 @@ fn test_list_maximum_status_symbols() {
.unwrap();

// Result should show 11 chars: ?!+»✘=⊠↕⇅🤖
//
// Note: Git's ahead/behind calculation for clone-based remotes is platform-dependent:
// - Ubuntu: reports behind=0, shows ⇡ (ahead only)
// - macOS: reports behind=1, shows ⇅ (diverged)
// We normalize the flaky upstream divergence symbol and behind count to accept either.
let mut settings = list_snapshots::standard_settings(&repo);
// Normalize upstream divergence: accept both ⇡ (ahead) and ⇅ (diverged)
// Note: Yellow ANSI code (\x1b[33m) appears before the ⊠ symbol
settings.add_filter(r"↕[⇡⇅]\x1b\[33m⊠", "↕[UPSTREAM]\x1b[33m⊠");
// Normalize remote behind count: accept both ↓0 and ↓1
settings.add_filter(r"↓[01]", "↓[N]");
let settings = list_snapshots::standard_settings(&repo);
settings.bind(|| {
let mut cmd = list_snapshots::command(&repo, repo.root_path());
cmd.arg("--full");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpLJgbF4/test-config.toml
WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpoGHFYx/test-config.toml
---
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
main ./test-repo 85ed6d3d 10 months ago Main advances
feature ?!+»✘= ↕[UPSTREAM]⊠🤖 +2 -2 ↑2 ↓[N] +3 -1 ./feature ↑1 ↓[N] 4afb2b9e 10 months ago Local commit
main ⇡ ./test-repo ↑1 ↓0 85ed6d3d 10 months ago Main advances
feature ?!+»✘= ↕⇅⊠🤖 +2 -2 ↑2 ↓1 +3 -1 ./feature ↑1 ↓1 4afb2b9e 10 months ago Local commit

⚪ Showing 2 worktrees, 1 with changes, 1 ahead