Skip to content

fix(picker): show the resolved config path in disabled-summary hints - #3290

Merged
max-sixty merged 3 commits into
mainfrom
picker-summary-hint-resolved-path
Jun 28, 2026
Merged

max-sixty merged 3 commits into
mainfrom
picker-summary-hint-resolved-path

Conversation

@max-sixty

@max-sixty max-sixty commented Jun 28, 2026 •

Copy link
Copy Markdown
Owner

When LLM summaries are disabled, the wt switch picker's Summary tab is seeded with one of two hints — "Summaries not configured" when there's no [commit.generation] command, or "Summaries off" when [list] summary = false. Both previously told the user to edit a hardcoded ~/.config/worktrunk/config.toml, which is wrong whenever wt loads config from elsewhere: a --config flag, the WORKTRUNK_CONFIG_PATH env var, or a non-default $XDG_CONFIG_HOME. A user following the hint would edit a file wt never reads.

Both hints now show the path wt actually loads from, resolved once at picker startup via worktrunk::config::config_path() (priority: --config → WORKTRUNK_CONFIG_PATH → platform default) and rendered through format_path_for_display so it shows ~/…. When no location can be determined, it falls back to the canonical literal. This mirrors the resolved-path idiom already in src/commands/worktree/resolve.rs.

The hints are also reshaped into the gutter house style — a bold H4-subject first line and a fenced ```toml config block — structured so the PTY snapshot is platform-stable. render_summary word-wraps prose to the preview width, which is one column narrower under Windows' PTY, so any prose body long enough to wrap breaks on a different word there and a single cross-platform snapshot can't match. To avoid that, the only prose is a short lead line that can't wrap, the resolved path sits alone on its own line (one unbreakable token, so there's no wrap boundary to shift), and the config block is never wrapped (code blocks aren't). The H4 subject is never wrapped either.

Tests

test_switch_picker_preview_panel_summary_disabled is added to cover the "configured but summary = false" arm, which had no test before (the existing summary test only exercises the not-configured arm) — closing a codecov/patch gap. Both arms' PTY snapshots render the resolved path; under the tests' WORKTRUNK_CONFIG_PATH isolation that path is a per-run temp file, which the existing snapshot filter redacts to a stable [TEST_CONFIG] placeholder, so the snapshots stay host-independent and test_no_host_specific_paths_in_snapshots is satisfied.

This was written by Claude Code on behalf of max

The picker's Summary tab seeds two static hints when LLM summaries are
disabled (commit.generation not configured, or [list] summary = false).
Both hardcoded ~/.config/worktrunk/config.toml, which is wrong whenever
wt loads config from elsewhere — a --config flag, WORKTRUNK_CONFIG_PATH,
or a non-default $XDG_CONFIG_HOME.

Resolve the path once at picker startup via config_path() (the same
resolver wt uses to load config) and render it with
format_path_for_display, mirroring the resolved-path guidance already in
src/output/commit_generation.rs. When no location can be determined,
fall back to the canonical literal so the guidance stays useful.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
worktrunk-bot
worktrunk-bot previously approved these changes Jun 28, 2026

@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 — resolving config_path() once at picker startup (where config is already loaded) and falling back to the canonical literal on None is the right shape, and the [TEST_CONFIG] redaction keeps the snapshot host-independent.

One same-pattern-elsewhere note, not blocking: the PR body says this "mirrors the resolved-path guidance already in src/output/commit_generation.rs", but that file's "Would add to …" prompt (the info_message in the prompt_yes_no_preview closure inside prompt_commit_generation) actually hardcodes ~/.config/worktrunk/config.toml, while the accepted/declined branches write through require_config_path(). So it has the very divergence this PR fixes — under --config / WORKTRUNK_CONFIG_PATH / non-default $XDG_CONFIG_HOME the prompt names one path and the write lands in another. Happy to push a follow-up resolving that message through config_path() too (or it can be a separate PR — it's an unrelated file).

@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.

codecov/patch is failing on one uncovered added line — the else-branch format! that builds the "Enable summaries in {config_path}" hint (the case where [commit.generation] is configured but [list] summary = false). The not-configured branch above it is covered by test_switch_picker_preview_panel_summary (which waits for "Configure"), but nothing exercises this branch. Converting it from a plain string literal to format! turned it into a counted patch line, so the gap surfaced now.

Per CLAUDE.md (Coverage), codecov/patch gates merge even though GitHub marks it non-required — so I'm dismissing my approval until it's green.

The fix is a sibling test next to test_switch_picker_preview_panel_summary that seeds [commit.generation] so the configured-but-disabled branch fires. [list] summary already defaults to false, so only the command needs writing — e.g. before launching the picker:

std::fs::write(
    repo.test_config_path(),
    "[commit.generation]\ncommand = \"llm -m haiku\"\n",
)
.unwrap();

then drive Alt-5 waiting for "Enable summaries" (mirroring the existing test's ("\x1b5", Some("Configure"))) and snapshot the panel. The [TEST_CONFIG] redaction will keep the resolved-path line host-independent in the new snapshot, same as the one this PR already updated.

Happy to push that test to the branch if you'd like — just say the word.

@worktrunk-bot
worktrunk-bot dismissed their stale review June 28, 2026 19:11

codecov/patch failing — the else-branch "Enable summaries" hint (configured but [list] summary=false) is uncovered; a sibling test of test_switch_picker_preview_panel_summary covers it. Per CLAUDE.md, codecov/patch gates merge.

Rewrite the two disabled-summary hints into the gutter house style: a
short H4-subject first line ("Summaries not configured" / "Summaries
off") that render_summary promotes without wrapping, a wrapping body
sentence carrying the resolved config path, and a fenced ```toml block
so the config snippet renders in the gutter rather than as loose prose.
Both still interpolate the resolved config path from config_path().

Add test_switch_picker_preview_panel_summary_disabled, exercising the
"commit.generation configured but [list] summary = false" arm. That arm
was never covered (the existing summary test only hits the
not-configured arm), so turning it into a format! made codecov/patch
flag it. The new PTY snapshot asserts the hint points at the resolved
config path, redacted to [TEST_CONFIG] under the test's
WORKTRUNK_CONFIG_PATH isolation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
worktrunk-bot
worktrunk-bot previously approved these changes Jun 28, 2026

@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.

The required test (windows) check is failing on this PR's own snapshot — test (macos) passed, so this is a Unix-vs-Windows rendering divergence, not a flake. Dismissing the approval until it's green; the rest of the change (the codecov-covering test_switch_picker_preview_panel_summary_disabled, the H4-subject + fenced-toml rework) looks good.

The reworded hint body is now long enough to wrap, and the wrap boundary lands one column earlier on Windows than on the host the snapshot was regenerated on. From the failing run:

4  4 │ Summaries not configured
6  6 │ LLM branch summaries need a [commit.generation] command. Ad
7    │- one in [TEST_CONFIG], then enable summaries:
   7 │+ one in [TEST_CONFIG], then enable
9 10 │   [commit.generation]

On Windows summaries: wraps to its own line (the body fits one word fewer per line), so the committed switch_picker_preview_summary_preview.snap — a single cross-platform file regenerated on macOS/Linux — can't match. The new switch_picker_preview_summary_disabled_preview.snap has the same wrapping-prose shape (…Enable\nsummaries in [TEST_CONFIG]:) and may trip the same boundary once Windows gets past this first failure.

I can't reproduce Windows PTY wrap width from CI, so I'm not pushing a snapshot fix blind. Two paths: regenerate the snapshot(s) on a Windows host, or shorten the wrapping body lines so they clear the pane width with a margin and stop sitting on the per-platform off-by-one boundary. Happy to push a reworded-shorter-body attempt if you'd like, but I'd flag it as unverified on Windows.

@worktrunk-bot
worktrunk-bot dismissed their stale review June 28, 2026 19:40

CI failed — required test (windows) red on this PR's own snapshot (switch_picker_preview_summary_preview): the reworded hint body wraps one column earlier on Windows. macOS passed. See review comment.

The reworded hints had a prose body long enough to soft-wrap, and
render_summary word-wraps to the preview width — which is one column
narrower under Windows' PTY. So the body broke on a different word
there ("summaries:" fell to its own line), and the single
cross-platform PTY snapshot couldn't match: required test (windows)
failed while linux/macOS passed.

Restructure both hints so nothing platform-divergent renders: a short
lead line that can't wrap, the resolved config path alone on its own
line (one unbreakable token, so there's no wrap boundary to shift), and
the config in a fenced ```toml block (code blocks are never wrapped).
The H4 subject is never wrapped. Both snapshots keep the resolved path,
redacted to [TEST_CONFIG].

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 14c79c1 into main Jun 28, 2026
37 checks passed
@max-sixty
max-sixty deleted the picker-summary-hint-resolved-path branch June 28, 2026 20:21
max-sixty added a commit that referenced this pull request Jun 28, 2026
…3298)

The first-time commit-generation setup prompt (`wt step commit` / `wt
merge` / `wt step squash` with no `[commit.generation]` configured)
hardcoded `~/.config/worktrunk/config.toml` in two user-facing hints —
the `?`-preview ("Would add to …") and the save-failure hint ("add
manually to …") — while the actual save resolves the path via
`require_config_path()`. So the displayed path was wrong whenever
`--config`, `WORKTRUNK_CONFIG_PATH`, or `$XDG_CONFIG_HOME` redirected
the real config location. Same bug class as #3290 (the picker's
disabled-summary hint).

Rather than add a third inline copy of the `config_path() →
format_path_for_display → fallback-literal` dance — the picker and the
bare-repo `resolve.rs` warning each already carried one — this extracts
a single helper, `config_path_for_display()`, the display-only
counterpart of `config_path()`. The `--config` / `WORKTRUNK_CONFIG_PATH`
/ `$XDG_CONFIG_HOME` resolution and the one canonical fallback literal
now live in one place, and all three sites route through it (the inline
at `resolve.rs` also dropped a redundant `.to_string()`). The helper's
doc points callers at `require_config_path()` for the actual mutation.

## Testing

The helper is covered three ways over by existing integration tests (the
picker summary-preview PTY snapshot, the bare-repo prompt snapshot, and
the commit-generation prompt PTY tests). The commit-gen prompt's preview
line was already covered by `test_user_requests_preview`; this PR adds
`test_user_accepts_but_save_fails_shows_manual_hint` to cover the
save-failure hint — it points `WORKTRUNK_CONFIG_PATH` at a path whose
parent is a regular file, so the write fails with `ENOTDIR` (root-proof,
unlike a chmod). No snapshot drift: the picker/resolve conversions emit
byte-identical output.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.63.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

- **`[list] columns` can force a column on past `--full`**: Listing a column now overrides the `--full` / `[list] summary` presets — `columns = ["branch", "ci"]` shows the CI column without `--full`. Hard data-source prerequisites still apply: a listed `summary` with no `[commit.generation]` command, or `url` with no template, stays hidden, since listing can't conjure data that isn't configured. ([#3295](max-sixty/worktrunk#3295))

- **`Alt-r` in the picker refreshes the preview panes, not just the rows**: `Alt-r` re-collected the rows but kept serving cached preview content, so editing a tracked file and refreshing still showed the pre-edit diff. It now clears the preview cache too, recomputing the working-tree / log / branch-diff / upstream / summary tabs and re-fetching `pr` / `comments`. Unchanged branches re-read from the content-keyed on-disk cache, so only genuinely changed content pays a recompute. ([#3293](max-sixty/worktrunk#3293))

- **A narrowed `wt list` is now actually faster**: A narrowed `[list] columns` selection (e.g. `["branch", "path"]`) now runs only the git work its columns need. It previously ran every per-worktree `git status`, diff, and ahead/behind walk regardless, then discarded the unselected results — so a trimmed view was no faster than the full table, and on a repo with many dirty worktrees that discarded work was the bulk of the wall-clock cost. ([#3274](max-sixty/worktrunk#3274), thanks @jtaby for reporting)

- **Fewer duplicate git calls in `wt list --full`**: The two integration probes per row (the conflict bit for `main-state` and the clean-merge tree for the integration column) issued a byte-identical `git merge-tree`, and the shared default-branch tip was peeled to its tree once per row. Both are now deduplicated through the in-memory cache, so each resolves once per run instead of once per worktree. ([#3288](max-sixty/worktrunk#3288), [#3289](max-sixty/worktrunk#3289))

- **Picker `comments` tab avoids redundant forge fetches**: The picker's `comments` preview tab gained an on-disk cache keyed by the PR's `updatedAt` (which rides for free on the CI fetch the picker already makes), so a repeat `wt switch` skips the per-row `gh pr view --json comments` fetch when the thread is unchanged and paints the tab instantly instead of showing "Loading comments…". The cache is also primed from the `gh pr list` call the picker already makes, so the tab skips its own fetch even on a session's first open (including PRs with no comments). GitHub only. ([#3294](max-sixty/worktrunk#3294), [#3299](max-sixty/worktrunk#3299))

- **Statusline width comes from `COLUMNS`, not a parent-process walk**: `wt list statusline` used to spawn up to 10 `ps` calls plus `stty` per render to recover a terminal width, because Claude Code piped the subprocess with no inherited TTY. Claude Code now sets `COLUMNS`/`LINES` to the terminal dimensions before running the script (since v2.1.153), so the width comes straight from there — less a fixed 5-column margin for Claude Code's own UI — and the `ps`/`stty` walk is gone. On an older Claude Code that doesn't set `COLUMNS`, the line renders untruncated rather than walking the process tree. ([#3286](max-sixty/worktrunk#3286), closes [#2950](max-sixty/worktrunk#2950))

### Fixed

- **`wt list` diff and ahead/behind columns use the upstream default tip**: The `main↕` (ahead/behind) and `main…±` (diff) columns measured every branch against the *local* default-branch tip, so in a fork whose local `main` lagged its upstream they reported inflated counts — one fork branch showed `↑44` and `+∞ / -5K` when it was ~2 commits past the real upstream tip. They now diff against the same upstream-aware base the integration column already uses. ([#3280](max-sixty/worktrunk#3280))

- **Integrated branches no longer flash `✗` in `wt list`**: A squash-merged branch whose default branch later re-edited the same lines showed `✗` (would-conflict), even though `wt step prune` classified it as `⊂` (fully integrated) and removed it. The list now ranks the integration verdict above the downstream conflict, matching prune; a genuinely un-integrated conflict still shows `✗`. ([#3278](max-sixty/worktrunk#3278))

- **`wt list` divergence-overflow marker uses one emphasis level**: When an ahead/behind count overflows its digit budget, the `main↕` column's compact `C`/`K`/`∞` marker rendered the "behind" subcolumn as dim + bold (reading as bold red) instead of a clean one-level step. It now steps exactly one level — dim red → normal red — matching the "ahead" subcolumn, across `wt list` and the picker. ([#3303](max-sixty/worktrunk#3303))

- **Branch deletion on removal is atomic**: `wt remove` and prune now delete a branch with a compare-and-swap (`git update-ref -d <ref> <expected-sha>`) against the SHA the integration check already read, closing the window where a branch whose tip moved in between (e.g. a hook landing a commit) could be deleted. Such a branch is now retained with a clear message and a `wt remove -D <branch>` recovery hint. This also unifies the previously divergent safe-delete paths; explicit force-delete still uses `git branch -D`. ([#2903](max-sixty/worktrunk#2903))

- **`wt list` and picker Age/Message columns paint as soon as the commit batch lands**: These columns carry no async task — their data arrives with the initial `git log` batch — but stayed on the `·` placeholder until some slower task happened to redraw the row, so the commit message lagged behind a cache-warm Summary preview. They now paint the moment the batch lands. ([#3287](max-sixty/worktrunk#3287))

- **Picker `Alt-x` removal: no cursor flash, `--prs` rows preserved**: Removing a row with `Alt-x` flashed the `>` pointer to the top of the list for a frame, and in `--prs` mode made the streamed PR/MR rows vanish until the next `Alt-r`. Removal is now a synchronous in-place pool resync: the cursor lands on the row that slid up with no flash, and the PR/MR rows survive. ([#3268](max-sixty/worktrunk#3268), [#3275](max-sixty/worktrunk#3275))

- **Removable rows stay gray when selected in the picker**: A safe-to-delete worktree (integrated, or clean and even with the default branch) renders its row gray, but the gray vanished under the selection highlight — exactly when you're about to act on it. The gray now survives selection (selected row only; `wt list` and unselected rows are unchanged). ([#3267](max-sixty/worktrunk#3267))

- **Picker preview keeps its scroll when CI status arrives**: Scrolling down a diff and waiting a couple of seconds snapped it back to the top when the live CI fetch landed and re-rendered the pane. The re-render is now precise — a tab re-runs only when its own content would actually change — so a CI update no longer throws away the scroll position of an unrelated tab. ([#3292](max-sixty/worktrunk#3292))

- **Picker summary tab dims when there's nothing to summarize**: The summary preview tab (`5`) stayed lit on a clean branch with no commits ahead, unlike the diff tabs (1/3/4), which dim once their diff is known empty. It now dims in concert with them once both the branch diff and working tree are known empty. ([#3291](max-sixty/worktrunk#3291))

- **Picker default view keeps collect order**: With no query typed, the `wt switch` picker reordered rows by where each name's last `/` falls, so slash-bearing branches (`feature/…`, `perf/…`) sank toward the bottom and intermixed with other row kinds. The default view now preserves collect order. ([#3301](max-sixty/worktrunk#3301))

- **Picker branch-diff preview and summary use the upstream-aware base**: Like the `wt list` columns above, the picker's branch-diff preview pane and the LLM branch summary diffed against the raw local default branch, so a fork whose local default lagged upstream made them describe dozens of already-merged commits. They now use the same upstream-aware comparison base. ([#3305](max-sixty/worktrunk#3305))

- **Picker comment previews render fenced code blocks cleanly**: A fenced code block inside a PR/MR comment rendered as a garbled double gutter in the `wt switch` comments preview — alternating bar/no-bar lines with broken alignment. The code block now renders without the nested gutter. ([#3306](max-sixty/worktrunk#3306))

- **First-run hints show the config path wt actually loads from**: The picker's disabled-summary tab and the commit-generation setup prompt hardcoded `~/.config/worktrunk/config.toml`, so a user with `--config`, `WORKTRUNK_CONFIG_PATH`, or a non-default `$XDG_CONFIG_HOME` was told to edit a file wt never reads. Both now show the resolved path. ([#3290](max-sixty/worktrunk#3290), [#3298](max-sixty/worktrunk#3298))

### Internal

- **`-vv` trace and profiler accuracy**: `trace.log` is now purely human-readable, with the machine-parseable `[wt-trace]` fields living only in `trace.jsonl`; and the performance profile's cache analysis no longer reports stdin-driven commands (LLM `claude -p` calls, `git patch-id`) as duplicate re-runs, since their real input isn't captured in the command string. ([#3296](max-sixty/worktrunk#3296), [#3297](max-sixty/worktrunk#3297))

## Install worktrunk 0.63.0

### Install prebuilt binaries via shell script

`

See merge request: Harmonybrew/homebrew-core!13092
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants