Repository navigation
fix(bare-repo): UX fixes for worktree-path prompt and wt config create --project in bare repos - #2951
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Reviewing as a draft — flagging anything that looks worth a quick fix. Mark ready for a full review.
Test failures from the migration
Three PTY snapshots in tests/integration_tests/bare_repository.rs (bare_repo_prompt_accept, bare_repo_prompt_decline, bare_repo_prompt_preview) still reference the old messaging (feature-auth, Would add to [TEMP]/test-config.toml, [projects."..."] TOML), so affected tests (linux, advisory) is red. They need the same treatment as the two non-PTY snapshots that were updated — cargo insta test --accept against the bare_repo_prompt_pty module should regenerate them.
The accept-PTY test also still verifies that the user config gained a worktree-path line, which the new code no longer writes there. The post-snapshot assertion at tests/integration_tests/bare_repository.rs:1595-1600 reads test.config_path() (the user config); after this PR the value lands in .git/config. Easiest fix is to mirror the pattern the decline_pty test already uses for worktrunk.skip-bare-repo-prompt:
// Verify config was written to git config (not user config).
let git_config_output = Cmd::new("git")
.args(["config", "worktrunk.worktree-path"])
.current_dir(&main_worktree)
.env("GIT_CONFIG_GLOBAL", test.git_config_path())
.run()
.unwrap();
let value = String::from_utf8_lossy(&git_config_output.stdout);
assert!(
value.trim().contains("{{ branch | sanitize }}"),
"worktrunk.worktree-path should be set in git config, got: {value}"
);The PR description mentions "1 pre-existing failure" — note that code-coverage and the linux/macos advisory legs are failing on this commit, and I think they're caused by the missing snapshot updates rather than pre-existing.
Symbolic branch forms
offer_bare_repo_worktree_path_fix(repo, config, identifier) is called from SwitchPipeline::run before plan_switch resolves symbolic forms, so branch can still be -, @, pr:123, mr:456. The example messages then read worktrees will be at project/.git.- or place worktrees at project/pr:123, which is confusing — the user input isn't what the resolved path will look like. The git config value written is a template constant so it's correct either way, but the displayed example is misleading.
Two options: skip the prompt when identifier looks symbolic (starts_with('-') || starts_with('@') || contains(':')), or resolve the identifier to a real branch name before formatting the messages.
Doc gap
worktrunk.worktree-path is now an officially recognized git config key, on par with worktrunk.default-branch. The configuration docs (docs/content/config.md, around the "Worktrunk cache" section that documents worktrunk.default-branch) don't mention it, and the new tips-patterns prose still tells users to set the path in the user-config TOML — only the interactive prompt actually steers them to git config. Worth a sentence under "Configure the worktree path" naming the git-config alternative, so users who skip the prompt can still find the per-clone scope.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Reviewing as a draft — flagging anything that looks worth a quick fix. Mark ready for a full review.
Spurious "customize worktree locations" hint after accept
The updated bare_repo_prompt_accept snapshot now ends with:
✓ Created branch feature and worktree @ project/feature
↳ To customize worktree locations, run wt config create
That second line is new in this PR — on main the accept path didn't show it. The user just customized the worktree path via the prompt, so telling them to customize it again is confusing.
The cause is in maybe_print_worktree_path_hint in src/output/handlers.rs:
let has_custom_config = UserConfig::load()
.map(|c| {
c.has_custom_worktree_path()
|| repo
.project_identifier()
.ok()
.is_some_and(|p| c.has_project_worktree_path(&p))
})
.unwrap_or(false);
if !has_custom_config && !repo.has_shown_hint("worktree-path") {The check only inspects UserConfig, not the git config. Before this PR the prompt wrote to user config, so has_custom_worktree_path() returned true and the hint was suppressed. Now the prompt writes worktrunk.worktree-path to git config, the user-config check still returns false, and the hint fires. The same hint also nags anyone who set worktrunk.worktree-path manually via git config.
The same format_path already treats git config as a first-class source (accessors.rs:218 reads repo.config_value("worktrunk.worktree-path") before falling back to user config), so the hint check should mirror that. Roughly:
let has_git_config = repo
.config_value("worktrunk.worktree-path")
.ok()
.flatten()
.is_some();
if !has_custom_config && !has_git_config && !repo.has_shown_hint("worktree-path") {Once that's fixed, the bare_repo_prompt_accept snapshot should drop the new line.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Reviewing as a draft — flagging anything that looks worth a quick fix. Mark ready for a full review.
Hint suppression doesn't actually suppress
The new has_git_config check in maybe_print_worktree_path_hint calls Repository::current(), which constructs a fresh Repository whose cache.all_config is populated from GIT_CONFIG_PRELOAD — a process-global map filled once by Repository::prewarm() at main() startup, before the prompt writes worktrunk.worktree-path. set_config_value updates the in-memory map on the caller's Repository instance but never invalidates the preload, and Repository::at() clones the (stale) preload entry into each new instance's cache. So config_value("worktrunk.worktree-path") from the fresh Repository::current() returns None and the hint fires anyway.
Evidence: 749f473 only regenerated the two help snapshots; the bare_repo_prompt_accept PTY snapshot still ends with ↳ To customize worktree locations, run wt config create, and test (linux) passes — that job runs cargo insta test ... --check --features shell-integration-tests, so a stale snapshot would fail. Snapshot matching reality means the suppression didn't fire.
The cleanest fix is to plumb the existing Repository (whose set_config_value kept its own cache.all_config coherent — see src/git/repository/config.rs:51) into maybe_print_worktree_path_hint rather than calling Repository::current() again. Alternatively, have set_config_value invalidate GIT_CONFIG_PRELOAD.get(&self.discovery_path) so future Repository::at(same_path) calls re-fork.
Once the suppression actually fires, the bare_repo_prompt_accept snapshot will need to drop the trailing hint line.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Coming back from draft — one more symbolic-form case worth catching alongside -, @, and pr:/mr:.
The earlier thread on src/output/handlers.rs (hint suppression after acceptance) is still unresolved — leaving the verdict as a comment until that lands or gets a response.
worktrunk-bot
left a comment
There was a problem hiding this comment.
CI is failing on this commit from changes the latest push introduced — flagging before this lands. The two failures share root causes I can sketch:
lint(cargo fmt) — the newhandle_switch_output(repo, ...)call insrc/commands/worktree/switch.rs:1670exceeds rustfmt's line-length budget. Inline suggestion below.test (linux),test (macos),code-coverage— all the sametest_docs_are_in_syncfailure —docs/content/config.mdwas hand-edited at line 857, but perCLAUDE.md(## Documentation) that file is a generated mirror — the primary source is theafter_long_helpblock for thedefault-branchsubcommand insrc/cli/config.rs(around line 719). Move the sentence to the primary source and the test will regenerate the mirror.
The cli/config.rs edit isn't in this diff so I can't drop an inline suggestion on it, but the change is:
// src/cli/config.rs, in the DefaultBranch after_long_help, replace the
// "Once detected..." line with:
Once detected, the result is cached in `worktrunk.default-branch` for fast access. Similarly, `worktrunk.worktree-path` can be set in git config to override the worktree path template for a specific clone — see [Scope options](@/config.md#scope-options).Then cargo insta test --accept -- --test integration test_docs_are_in_sync regenerates docs/content/config.md, and the manual edit at line 857 should be dropped (see inline).
Happy to push both fixes if that's easier — just say the word. Dismissing the approval until CI is green.
CI failed — cargo fmt + test_docs_are_in_sync (docs/content/config.md is generated from src/cli/config.rs)
4651e71 to
9fe7bb0
Compare
|
Some of this is great, thank you @ammachado ! Can we split out the "new config location" part though? that's a much bigger change I'd want to think about (and I'd be a bit bearish on; it would be a single excpetion to our whole config system) @worktrunk-bot can help split it out if you're ok with that, @ammachado |
|
Ready to help with the split when you give the word, @ammachado. To make sure I'd do the right thing — the plan I'd execute:
That keeps the bare-repo UX wins separate from the config-system change @max-sixty wants to think about. Just say go and I'll prepare it. |
|
@worktrunk-bot go on, split the PR. |
cf561d6 to
a0a17a9
Compare
wt config create --project in bare repos
|
Force-pushed the split, @ammachado @max-sixty. This PR (#2951) keeps the UX-only fixes:
The accepting-the-prompt behavior reverts to the pre-PR Follow-up PR (stacked) carries the new
See the new PR #2953 for the stacked half. Reviewing as a pair is probably easiest. Each branch passes |
worktrunk-bot
left a comment
There was a problem hiding this comment.
The split landed cleanly — the UX fixes look correct in isolation, prior threads are addressed, and CI test/lint legs that already finished are green. One small consistency suggestion inline.
| let example_bad = format!("{parent_name}/{repo_name}.feature-auth"); | ||
| let example_good = format!("{parent_name}/feature-auth"); | ||
| // Use the actual branch being switched to in example paths. | ||
| let sanitized = branch.replace(['/', '\\'], "-"); |
There was a problem hiding this comment.
Worth calling worktrunk::config::sanitize_branch_name(branch) here so the displayed example tracks the actual sanitize Jinja filter — the filter is literally a wrapper around this function (src/config/expansion.rs registers env.add_filter("sanitize", |v| sanitize_branch_name(...))), so duplicating the replace(['/', '\\'], "-") body inline means the example could silently drift if the filter ever gains another substitution.
| let sanitized = branch.replace(['/', '\\'], "-"); | |
| let sanitized = worktrunk::config::sanitize_branch_name(branch); |
There was a problem hiding this comment.
Applied — switched to worktrunk::config::sanitize_branch_name(branch) in src/commands/worktree/resolve.rs and added a one-line comment recording why. Mirrored the same change in #2953 so it doesn't drift back on the stacked PR.
| Configure worktrunk: | ||
| ### Configure the worktree path | ||
|
|
||
| When you run `wt switch` for the first time in a bare repo at a hidden path (`.git`, `.bare`), worktrunk detects that the default template would produce broken paths like `myproject/.git.main` and offers to fix it automatically: |
There was a problem hiding this comment.
@worktrunk-bot review a of this in the context of our doc guidelines: e.g. avoid 2nd person
There was a problem hiding this comment.
Scanned the new bare-repo subsections for guideline misses. Two 2nd-person phrasings; the rest is imperative or 3rd person.
Line 442 — When you run wt switch for the first time…
On first `wt switch` in a bare repo at a hidden path (`.git`, `.bare`), worktrunk detects that the default template would produce broken paths like `myproject/.git.main` and offers a fix:
Line 449 — Accepting writes a project-scoped entry to your user config:
Accepting writes a project-scoped entry to user config:
These match the voice in worktrunk.md, extending.md, hook.md, and the rest of this same section ("Run wt config show…", "The project config must live inside a worktree…", "Commit the file and it will appear in every worktree automatically"). Explicit "you/your" elsewhere in tips-patterns.md (lines 149 and 277) all predates this PR.
Nothing else stood out: links resolve, fences are right, and Identifier: / PROJECT CONFIG match the labels in src/commands/config/show.rs (lines 754 and 763).
Happy to push these two edits if it's easier — just say the word.
There was a problem hiding this comment.
Pushed in ec376e6 — line 442 now opens with On first wt switch in a bare repo… and line 449 drops "your" before "user config". Sorry for the lag.
The bare-repo `worktree-path` prompt previously hardcoded `feature-auth` in
the example paths regardless of the branch being switched to, which produced
a confusing mismatch (switching to `main` showed `project/.git.feature-auth`).
Use the branch identifier instead so the example matches reality.
Symbolic identifiers (`-`, `@`, `^`, `pr:N`, `mr:N`) aren't real branch
names yet — the prompt would show the literal symbol in the example path.
Skip the prompt for those; it surfaces on the next switch with a concrete
branch.
Also fix `wt config create --project` in a bare repo with no linked
worktrees yet: instead of the bare "Cannot determine project config
location — no worktree found" error, point the user at the right next
step ("run `wt switch <branch>` to create a worktree first").
Restructure the Tips & Patterns bare-repo section to walk through the
automatic prompt, the project-scoped config it writes, and the
`wt config create --project` follow-up.
Co-Authored-By: Adriano Machado <[email protected]>
Co-Authored-By: Claude Opus 4.7 <[email protected]>
a0a17a9 to
dd9bf3b
Compare
Imperative/3rd-person voice matches the rest of the section (`worktrunk.md`, `extending.md`, `hook.md`). Co-Authored-By: Claude Opus 4.7 <[email protected]>
Resolve conflicts after #2951 landed. All conflicts kept the PR-side (this-clone git-config) approach since that is the PR's purpose; main's remaining changes here were the older user-config behavior that this PR replaces. Co-Authored-By: Claude Opus 4.7 <[email protected]>
v0.56.0. `cargo semver-checks` reports a breaking library API change: the config-deprecation refactor (#2946) replaced the public `Deprecations` struct with a `Vec<DeprecationKind>` alias, removing the struct shape. Not intentional public API, but it forces a minor bump pre-1.0. ## CHANGELOG ### Improved - **`wt list` JSON output includes `repo_url`**: Each item now carries `repo_url`, the repository's web URL derived from the primary remote (absent when there's no parseable forge remote). It's the local checkout's repo — distinct from `ci.repo_url`, which is the repo a PR/MR targets. ([#2941](#2941), thanks @bendrucker) ### Fixed - **Bare-repo prompts**: Two UX fixes. `wt config create --project` run in a bare repo with no linked worktrees now explains the next step (`wt switch <branch>` first, then create from inside the worktree) instead of failing with a generic "no worktree found". And the bare-repo worktree-path prompt no longer fires for symbolic identifiers (`-`, `@`, `^`, `pr:`/`mr:`), where the example paths would be misleading — it waits for the next switch to a concrete branch name. ([#2951](#2951), thanks @ammachado) - **Context gauge spacing in the Claude Code statusline**: The context-gauge moon emoji rendered flush against the percent (`🌕42%`). Most terminals draw the emoji double-width and bleed it into the next cell, so the moon collided with the digits; it now carries a trailing space (`🌕 42%`). ([#2944](#2944)) - **Console storm on Windows**: Detached background hook processes were created with `DETACHED_PROCESS`, which could flash a burst of console windows. They now use `CREATE_NO_WINDOW` and spawn fully hidden. ([#2959](#2959), thanks @nathanbabcock) ### Documentation - **Codex commit-generation model bumped to `gpt-5.4-mini`**: The recommended `[commit.generation]` command for Codex — shown by `wt config create` and in the LLM-commits docs — now uses `gpt-5.4-mini` (was `gpt-5.1-codex-mini`). ([#2949](#2949)) ### Internal - **Config-deprecation layer refactor**: The deprecation detector now returns a `Vec<DeprecationKind>` instead of a struct of per-field flags, and the per-section config-table walks collapse into two combinators. Behavior-neutral — warning text and migration output are byte-for-byte unchanged. ([#2946](#2946)) > _This was written by Claude Code on behalf of max_
worktrunk 0.56.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **`wt list` JSON output includes `repo_url`**: Each item now carries `repo_url`, the repository's web URL derived from the primary remote (absent when there's no parseable forge remote). It's the local checkout's repo — distinct from `ci.repo_url`, which is the repo a PR/MR targets. ([#2941](max-sixty/worktrunk#2941), thanks @bendrucker) ### Fixed - **Bare-repo prompts**: Two UX fixes. `wt config create --project` run in a bare repo with no linked worktrees now explains the next step (`wt switch <branch>` first, then create from inside the worktree) instead of failing with a generic "no worktree found". And the bare-repo worktree-path prompt no longer fires for symbolic identifiers (`-`, `@`, `^`, `pr:`/`mr:`), where the example paths would be misleading — it waits for the next switch to a concrete branch name. ([#2951](max-sixty/worktrunk#2951), thanks @ammachado) - **Context gauge spacing in the Claude Code statusline**: The context-gauge moon emoji rendered flush against the percent (`🌕42%`). Most terminals draw the emoji double-width and bleed it into the next cell, so the moon collided with the digits; it now carries a trailing space (`🌕 42%`). ([#2944](max-sixty/worktrunk#2944)) - **Console storm on Windows**: Detached background hook processes were created with `DETACHED_PROCESS`, which could flash a burst of console windows. They now use `CREATE_NO_WINDOW` and spawn fully hidden. ([#2959](max-sixty/worktrunk#2959), thanks @nathanbabcock) ### Documentation - **Codex commit-generation model bumped to `gpt-5.4-mini`**: The recommended `[commit.generation]` command for Codex — shown by `wt config create` and in the LLM-commits docs — now uses `gpt-5.4-mini` (was `gpt-5.1-codex-mini`). ([#2949](max-sixty/worktrunk#2949)) ### Internal - **Config-deprecation layer refactor**: The deprecation detector now returns a `Vec<DeprecationKind>` instead of a struct of per-field flags, and the per-section config-table walks collapse into two combinators. Behavior-neutral — warning text and migration output are byte-for-byte unchanged. ([#2946](max-sixty/worktrunk#2946)) ## Install worktrunk 0.56.0 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-installer.sh | sh && wt config shell install ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-installer.ps1 | iex"; git-wt config shell install ``` ### Install prebuilt binaries via Homebrew ```sh brew install worktrunk && wt config shell install ``` ## Download worktrunk 0.56.0 | File | Platform | Checksum | |--------|----------|----------| | [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) | | [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) | | [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.56.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) | ### Install via Cargo ```sh cargo install worktrunk && wt config shell install ``` ### Install via Winget (Windows) ```sh winget install max-sixty.worktrunk && git-wt config shell install ``` ### Install via AUR (Arch Linux) ```sh paru worktrunk-bin && wt config shell install ``` </pre> <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.56.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.56.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!10277
Problem
Three UX issues in the bare-repository workflow documented in Tips & Patterns.
Bug 1: Example paths use a hardcoded placeholder branch
When
wt switchdetects a bare repo at a hidden path (.git,.bare), the warning and prompt previously showed:The
feature-authplaceholder was hardcoded regardless of the branch being switched to. Switching tomainproduced a confusing mismatch between what was shown and what would actually happen.Bug 2: Symbolic identifiers showed unresolved input in the prompt
Switching with
wt switch @,wt switch -,wt switch ^, orwt switch pr:123triggered the prompt with the literal symbol in the example path (camel/.git.@, etc.), which is meaningless. The symbol isn't a branch name — it gets resolved later. Skip the prompt for those; it surfaces on the next switch with a concrete branch.Bug 3:
wt config create --projectgives an unhelpful error in bare repos with no worktreesRunning
wt config create --projectfrom a bare repo root with no linked worktrees yet failed with:No indication of why this happened or what to do next.
Bug 4: Docs are vague about the bare-repo setup order
The Tips & Patterns bare-repo section told users to set
worktree-pathglobally in user config, affecting all repos. It didn't mention the per-project[projects."..."]override, didn't clarify thatwt switch main(without--create) works for existing branches on a freshly cloned bare repo, and didn't explain that the project config must be created from inside a worktree.Solution
offer_bare_repo_worktree_path_fixand use it (with/and\sanitized to-) in the warning and preview messages.-,@,^,pr:N,mr:N).wt config create --project— points the user atwt switch <branch>as the next step.[projects."..."]scope, when--createis needed, and the chicken-and-egg constraint on.config/wt.toml.Out of scope
The original PR also added a per-clone
worktrunk.worktree-pathgit-config key as a third scope alongside per-remote and global user-config. That's a more invasive change (new exception in the config-resolution chain) and is split out into a follow-up PR — see #2953.Testing
test_bare_repo_worktree_path_prompt_auto_accept/..._non_interactive_warning— snapshots now show the actual branch name (feature) instead of hardcodedfeature-auth.test_bare_repo_worktree_path_prompt_skipped_for_symbolic_identifier— new test confirmingwt switch @skips the prompt in an unconfigured bare repo.test_config_create_project_from_git_dir_errors— new test confirming the generic error fires from a non-bare repo's.gitdirectory (the bare-repo-specific message only fires for bare repos).test_docs_are_in_syncpasses.Co-authored with @ammachado from the original PR.