Repository navigation
fix(config): distinguish "not configured" from "not active" in shell status - #2572
Conversation
…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]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
codecov/patch failed at 78.12% (25/32 lines covered on src/commands/config/show.rs). Seven uncovered lines, all in render_shell_status:
- Lines 711-717 —
Errarm ofmatch scan_shell_configs(None, true, &cmd). Same block existed before the PR (originally at the post-warning location, now hoisted above it) and was already uncovered onmain.scan_shell_configsonly returnsErrwhenShell::config_paths()fails (home dir lookup), which no test currently exercises. Codecov treats relocated lines as part of the patch — see CLAUDE.md "Renames and moves". - Line 765 — closing
)?;of the new under-warningwriteln!(out, ..., hint_message(cformat!(...)))?. The 35 fresh-user snapshots all hit this writeln, so the body is covered, but?onwriteln!to a&mut Stringsynthesizes an error path that can never fire (fmt::WriteforStringis infallible). The other lines of the samewriteln!(758, 759, 762) report as covered; only the line where?lands is reported missed.
Per CLAUDE.md "NEVER merge a PR with failing codecov/patch without explicit user approval", I'm dismissing my approval. If you read this as a relocation false positive + an unreachable ? path and want to merge as-is, re-approve. Otherwise, the simplest remediation for line 765 is collapsing the writeln! to a single line so the ? shares a region with the rest of the call.
codecov/patch failed — see follow-up comment for analysis
…egion `writeln!(...)?` reports the closing `)?;` line as a missed branch on codecov when the `?` lands on its own line — the error path is unreachable for `fmt::Write` on `&mut String`, but codecov instruments it anyway. Extracting the hint into a let binding shrinks the writeln to a single line so the `?` shares a region with the rest of the call. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The writeln collapse worked — line 762 is now covered, and the latest-commit diff shows 100% coverage (2/2 lines). The codecov/patch failure is now down to the 6 lines I previously flagged as a relocation false positive: the Err(e) arm of match scan_shell_configs(None, true, &cmd) at lines 711-717.
711 Err(e) => {
712 writeln!(
713 out,
715 hint_message(format!("Could not determine shell status: {e}"))
716 )?;
717 return Ok(());
This block existed before the PR (originally at the post-warning location, now hoisted above) and was already uncovered on main — scan_shell_configs only returns Err when Shell::config_paths() fails (home-dir lookup), which no test currently exercises. Per CLAUDE.md "Renames and moves", codecov treats relocated lines as part of the patch, so the FP persists until a test exercises that branch or the lines move out of the diff.
Per CLAUDE.md "NEVER merge a PR with failing codecov/patch without explicit user approval", I'm dismissing my approval. Two paths:
- Re-approve to merge as-is if you read the remaining miss as an FP (lines unchanged, only their location moved). Approving accepts the FP and unblocks merge.
- Add a test for the
Errarm (e.g., a unit test that injects aShell::config_paths()failure) — then codecov clears on its own.
codecov/patch failed — see follow-up comment for analysis
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](https://claude.com/claude-code) --------- Co-authored-by: Claude <[email protected]>
Follow-up to #2562.
wt config shownow reads▲ Shell integration not configuredwhen no working integration exists in any shell (fresh user, container, CI sandbox), and keeps▲ Shell integration not activefor the case where it's installed but not loaded in this session. The install hint also moves directly under the warning when nothing is configured anywhere, so cause and remedy stay adjacent instead of being separated by fourSkippedrows.The "configured somewhere" signal accepts
AlreadyExistsrc-file matches, wrapper-based shells with their wrapper present (even if outdated content), and fish at the legacyconf.dpath — anything less reads as "not configured." The trailing summary hint still fires for partial-config (e.g., zshAlreadyExists+ bash needs init line) and for fish-legacy.Fresh-user output:
35
config_showsnapshots updated for the warning text and hint position. Active, partial-config, fish-outdated/nushell-outdated, and fish-legacy snapshots are unchanged.