Skip to content

fix(config): clean up wt config show shell-integration section - #2574

Merged
max-sixty merged 4 commits into
mainfrom
shell-detect-installed
May 4, 2026
Merged

max-sixty merged 4 commits into
mainfrom
shell-detect-installed

Conversation

@max-sixty

@max-sixty max-sixty commented May 4, 2026 •

Copy link
Copy Markdown
Owner

On a stock zsh-only macOS, wt config show listed bash, fish, and nu as Skipped; ~/.foorc not found — clutter for shells the user doesn't have installed. The block was the loudest thing in the SHELL INTEGRATION section for users who'd never touch those shells.

After this PR, that fresh-user case shows just the warning + install hint with no per-shell clutter. Together with #2572 (which renamed the warning to "not configured" in this state), the section reads:

SHELL INTEGRATION
▲ Shell integration not configured
↳ To configure, run wt config shell install
  Invoked as: …
  $SHELL: /bin/zsh

What changed

Adds Shell::is_installed() (PATH lookup with WORKTRUNK_TEST_<SHELL>_INSTALLED env override) and gates the skipped.push in scan_shell_configs. Shells with rc files still render normally — the filter only affects the "binary absent AND no rc file" case, which is exactly when the entry has no useful information. nu and pwsh are filtered cleanly because neither ships with macOS/Linux. bash and zsh on macOS still report (/bin/bash and /bin/zsh are preinstalled), but that's the honest answer.

Side fixes:

  • Removed a redundant Err("No shell config files found") from scan_shell_configs. The install command's main.rs handler already covered this case.
  • Made the blank line between header status and the per-shell list conditional, so the trailing ↳ To configure… hint stays attached to its subject when no shells render.
  • Replaced the standalone is_nushell_available() helper with Shell::Nushell.is_installed() — same semantics, one fewer function. The historical WORKTRUNK_TEST_NUSHELL_ENV env-var name is preserved to avoid churning hundreds of recorded snapshots.

Tests

  • New test_configure_shell_skipped_lists_only_installed_shells pairs with test_configure_shell_no_files to cover both arms of the install guard (binary on PATH + rc absent → Skipped; binary absent + rc absent → drop entirely).
  • Test defaults moved into STATIC_TEST_ENV_VARS so PTY tests inherit them through TestRepo::test_env_vars.
  • 50+ snapshot files updated to reflect the merged behavior.

Coverage caveat: the which::which fallback in is_installed() is not exercised by tests (every test sets the env override). Same shape as the prior is_nushell_available() helper, documented inline.

🤖 Generated with Claude Code

max-sixty and others added 3 commits May 3, 2026 22:24
…status

`wt config show` now reads "▲ Shell integration not configured" when no
working integration exists in any shell (fresh user, container, CI sandbox),
and keeps "▲ Shell integration not active" for the case where it's installed
but not loaded in this session. The install hint also moves directly under
the warning when nothing is installed anywhere, so cause and remedy stay
adjacent instead of being separated by four "Skipped" rows.

The "configured somewhere" signal includes `AlreadyExists` rc-file lines,
wrapper-based shells with their wrapper file present (even if outdated), and
fish at the legacy `conf.d` path — anything less reads as "not configured."
The trailing summary hint still fires for partial-config and fish-legacy.

Co-Authored-By: Claude <[email protected]>
On a stock zsh-only macOS, `wt config show` listed `bash`, `fish`, and
`nu` as `Skipped; ~/.foorc not found` — clutter for shells the user
doesn't have installed. The four-line block was the loudest thing in
the SHELL INTEGRATION section for users who'd never touch those shells.

Adds `Shell::is_installed()` (PATH lookup with
`WORKTRUNK_TEST_<SHELL>_INSTALLED` env override) and gates the
`skipped.push` in `scan_shell_configs` on it. Shells with rc files
still render normally — the filter only affects the "binary absent
AND no rc file" case, which is exactly when the entry carries no
useful information. `nu` and `pwsh` are filtered cleanly because
neither ships with macOS/Linux. `bash` and `zsh` on macOS still
report (`/bin/bash` and `/bin/zsh` are preinstalled), but that's the
honest answer — they're installed, the user just hasn't configured a
shell extension. The cost is ~150–500µs of `which::which` lookups,
invisible against the existing ~290 ms config-show baseline.

Side fixes pulled in:

- Removed a redundant `Err("No shell config files found")` from
  `scan_shell_configs`. The install command's `main.rs:536` handler
  already produces the same error after rendering skipped shells, so
  the early-exit was dead in practice. Now `scan_shell_configs`
  returns an empty `ScanResult` and lets callers decide.
- Made the blank line between the active/not-active status and the
  per-shell list conditional on having shells to render, so the
  trailing `↳ To configure, run wt config shell install` hint stays
  attached to its subject when no shells remain after filtering.
- Replaced the standalone `is_nushell_available()` helper with the
  new `Shell::Nushell.is_installed()`. Same semantics, one fewer
  function. The historical `WORKTRUNK_TEST_NUSHELL_ENV` env-var name
  is preserved to avoid churning hundreds of recorded snapshots.

### Tests

- New `test_configure_shell_skipped_lists_only_installed_shells`
  pairs with `test_configure_shell_no_files` to cover both arms of
  the install guard (binary on PATH + rc absent → Skipped; binary
  absent + rc absent → drop entirely).
- Test defaults moved into `STATIC_TEST_ENV_VARS` so PTY tests
  inherit them through `TestRepo::test_env_vars`. One PTY test
  (`exec_install_in_pty`) bypasses that path and gets explicit
  per-test env overrides.
- 50 snapshot files updated to drop the now-filtered Skipped lines.
  All test runs pass (3465/3465) and lints are clean.

Coverage caveat: the `which::which` fallback in `is_installed()` is
not exercised by tests (every test sets the env override). Same
shape as the prior `is_nushell_available()` helper, documented
inline.

Co-authored-by: Claude <[email protected]>
# Conflicts:
#	src/commands/config/show.rs
#	tests/snapshots/integration__integration_tests__config_show__config_show_claude_available_plugin_not_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_no_cd_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_no_ff_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_pre_hook_table_form_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_select_section_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_empty_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_empty_system_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_update_available.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_version_check_unavailable.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_invalid_project_toml.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_invalid_system_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_invalid_user_toml.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_no_user_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_opencode_available_plugin_not_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_opencode_plugin_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_opencode_plugin_outdated.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_plugin_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_statusline_configured.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_suggests_project_config_for_ci.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_warning.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_whitespace_only_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_with_system_config.snap

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

Logic reads cleanly, snapshots updated consistently, and the new Shell::is_installed filter pairs with the warning-text branch to give the documented fresh-user output.

Two notes on the failing codecov/patch (70.9%) — both look like accept-as-is rather than gaps to plug:

  • src/shell/mod.rs (50%): the which::which fallback in is_installed() is unexercised because every test sets WORKTRUNK_TEST_*_INSTALLED. Acknowledged in the PR description and inherits the prior is_nushell_available() pattern.
  • src/commands/config/show.rs (80%): the lines codecov flags — the scan_shell_configs error arm (711–717), the Running from: divergence check (779–781), and the GIT_EXEC_PATH git-subcommand line (794) — exist verbatim in main (ce66d9cf:src/commands/config/show.rs, lower in the same function). The reorder hoisted them above the warning so codecov treats the moved code as new (CLAUDE.md "Renames and moves" pattern). codecov/project is green.

Heads-up: #2572 becomes a strict subset of this PR after the merge of shell-warning-text here, so it can be closed once 2574 lands.

# Conflicts:
#	src/commands/config/show.rs
#	tests/snapshots/integration__integration_tests__config_show__config_show_claude_available_plugin_not_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_deprecation_details.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_no_cd_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_no_ff_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_pre_hook_table_form_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_project_commit_generation_deprecations.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_displays_select_section_deprecation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_empty_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_empty_system_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_from_linked_worktree_shows_main_worktree_hint.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_update_available.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_full_version_check_unavailable.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_invalid_project_toml.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_invalid_system_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_invalid_user_toml.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_no_user_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_opencode_available_plugin_not_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_opencode_plugin_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_opencode_plugin_outdated.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_plugin_installed.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_statusline_configured.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_suggests_project_config_for_ci.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_suggests_user_config_for_commit_generation.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_unmatched_candidate_warning.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_whitespace_only_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
#	tests/snapshots/integration__integration_tests__config_show__config_show_with_system_config.snap
@max-sixty
max-sixty merged commit c2e38f6 into main May 4, 2026
24 of 25 checks passed
@max-sixty
max-sixty deleted the shell-detect-installed branch May 4, 2026 06:36
max-sixty added a commit that referenced this pull request May 4, 2026
Adds `test_config_show_skipped_with_installed_binary` — bash flagged
installed via test override with no `.bashrc`, so the entry survives
#2574's `is_installed()` filter and renders as a Skipped row. Locks in
the bold-name + dim-body styling on the previously-uncovered code path
in `render_shell_status` (line 1022).

Co-Authored-By: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 4, 2026
)

Aligns the `Skipped` per-shell row with every other status row in the
SHELL INTEGRATION section — bold shell name, then `: `, then the body.
Previously the entire row was wrapped in `<dim>` so the shell name lost
its bold treatment and the row didn't visually scan the same as `Already
configured` / `Outdated` / `Not configured`.

The bold-name and dim-body spans are sequential (`<bold>foo</>:
<dim>bar</>`), not nested — that avoids the SGR-22 reset trap the
writing-user-outputs skill warns about (closing `</bold>` would
otherwise also clear an outer `<dim>`).

The Skipped row only renders when a shell binary is installed but has no
rc file — #2574's `is_installed()` filter suppresses the more common "no
binary, no rc file" case. New
`test_config_show_skipped_with_installed_binary` flags
`WORKTRUNK_TEST_BASH_INSTALLED=1` with no `.bashrc` to lock in the
styling on that path.

> _This was written by Claude Code on behalf of @max-sixty_

---------

Co-authored-by: Claude <[email protected]>
max-sixty added a commit that referenced this pull request May 4, 2026
## Summary

- Adds PowerShell to `default_shells` unconditionally; the
`Shell::is_installed()` filter (added in #2574) now hides `Skipped pwsh`
on hosts without pwsh, the same way `Skipped fish` is hidden on a stock
zsh-only Mac
- `should_auto_configure_powershell()` still gates `allow_create`, so
users who have pwsh installed but never opened it don't get an
unsolicited profile written (issue #885 behavior unchanged)
- Removes the iteration asymmetry that left PowerShell invisible in `wt
config show` for users who configured a profile but aren't currently in
a PS session

## Visible changes

| Host state | Before | After |
|---|---|---|
| pwsh on PATH, profile exists, not in PS session | invisible | shown as
`configured` |
| pwsh on PATH, no profile, not in PS session | invisible | `Skipped
pwsh; profile not found` |
| pwsh absent | invisible (iteration gate) | invisible (`is_installed()`
filter) |
| in PS session, no profile | auto-creates | auto-creates (unchanged) |

## Test plan

- [x] `cargo test --test integration` (1622 passed)
- [x] `pre-commit run --all-files`
- [x] Extended
`test_configure_shell_skipped_lists_only_installed_shells` to flag pwsh
installed and assert it appears as `Skipped`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <[email protected]>
@worktrunk-bot worktrunk-bot mentioned this pull request May 6, 2026
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