Repository navigation
fix(config): iterate PowerShell uniformly with other shells - #2581
Conversation
Before: PowerShell was excluded from `default_shells` unless we detected a PS session (PSModulePath set, or SHELL absent on Windows). This made PS invisible in `wt config show` and `wt config shell install` output for users who have pwsh installed but aren't currently in a PS shell — even when they have a configured profile. Now: PowerShell is iterated alongside bash/zsh/fish/nushell, and the same `is_installed()` filter that hides "Skipped fish" on a stock zsh-only Mac hides "Skipped pwsh" on a host without pwsh. The PS-session signal (`should_auto_configure_powershell()`) still gates `allow_create` so we don't write a profile for users who installed pwsh once and never opened it (issue #885 unchanged). Net visible changes: - pwsh on PATH, profile exists, not in PS session: shown as `configured` (was: invisible). - pwsh on PATH, no profile, not in PS session: shown as `Skipped pwsh; profile not found` (was: invisible). - pwsh absent: invisible via `is_installed()` (was: invisible via iteration gate). Same outcome, different mechanism. - in PS session: auto-creates profile if missing. Unchanged. Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
The change reads cleanly: is_installed() (added in #2574) was always going to be the right place to filter pwsh on hosts without it, so removing the iteration gate is the natural follow-up. Behavior table matches what I traced through scan_shell_configs.
One drive-by: the comment for WORKTRUNK_TEST_POWERSHELL_ENV in src/testing/mod.rs (lines 266–269) is now stale — after this PR it no longer "gates whether PS is iterated at all in scan_shell_configs"; iteration is unconditional and the env var only controls allow_create via should_auto_configure_powershell(). Happy to push a one-line comment fix as a follow-up if you'd like.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Windows CI failed on the test this PR modified — test_configure_shell_skipped_lists_only_installed_shells. The new "Skipped powershell" line includes the platform-specific profile path, which the snapshot assumes is the Unix ~/.config/powershell/... form:
- Skipped powershell; ~/.config/powershell/Microsoft.PowerShell_profile.ps1 not found
+ Skipped powershell; _PARENT_/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 not found
Same root cause as the Windows-ignore on test_powershell_env_detection — dirs::document_dir() can't be overridden via HOME/set_temp_home_env. Three options:
- Mirror the sibling test and add
#[cfg_attr(windows, ignore = "Windows uses Documents folder which can't be easily overridden")]— simplest, loses Windows coverage for the new assertion. - Drop
assert_cmd_snapshot!and assert on substrings (Skipped+powershell) so the path is irrelevant — keeps Windows coverage. - Add an insta path filter that normalizes the Documents prefix.
Option 2 is probably best since the test's belief is "pwsh appears as Skipped when installed but profile missing" — the exact path is incidental. Happy to push that fix if you'd like.
CI failed — Windows snapshot assertion in the modified test
The previous attempt extended `test_configure_shell_skipped_lists_only_installed_shells` to also flag pwsh as installed, but that test runs cross-platform and the PowerShell profile path differs on Windows (`~/Documents/PowerShell/...` vs `~/.config/powershell/...`), so the inline snapshot mismatched on Windows CI. Restore the cross-platform test to its original bash+fish form and add `test_powershell_skipped_when_installed_no_profile`, gated on `cfg(unix)`, to cover the new uniform PowerShell behavior with the Unix profile path. Co-Authored-By: Claude <[email protected]>
…ELL_ENV (#2585) ## Summary After #2581, PowerShell iterates unconditionally in `scan_shell_configs` alongside the other shells. The comment for `WORKTRUNK_TEST_POWERSHELL_ENV` in `src/testing/mod.rs` still claimed the var "gates whether PS is iterated at all" — that's now stale. Updated to reflect that the var only controls `allow_create` via `should_auto_configure_powershell()`. Caught by the auto-reviewer on #2581. ## Test plan - [x] No code changes; comment-only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
…#2586) The test wrote `tracked.txt` as `"original"` then `"modified"` — both 8 bytes. `wt step commit --dry-run --stage=tracked` runs `git add -u` against a copy of the index, so the only signal git has for the modification is mtime. On Linux/ext4 the recorded entry mtime and the post-modification mtime can be indistinguishable at the kernel's resolution; git treats the file as unchanged, the temp index keeps the old blob hash, and `git diff --staged` returns nothing. The rendered prompt then has empty `<diffstat>` / `<diff>` blocks and the assertion on `"tracked.txt"` / `"modified"` fires. Reproduces 0/200 locally on macOS APFS and passes on `test (linux)`, but flaked on the `affected (linux, advisory)` job for PR #2581 ([logs](https://github.com/max-sixty/worktrunk/actions/runs/25306727293/job/74184225239)) — that PR only touched PowerShell shell config and has no plausible effect on this code path. Switching the modification to `"modified content"` makes the new size differ from the committed blob, so git's DATA_CHANGED check fires unconditionally and the test no longer depends on mtime resolution. This mirrors the adjacent `test_step_commit_with_stage_tracked_flag` (`merge.rs:2113`) which uses `"initial"` → `"modified"` (different sizes) for the same reason. PR #2433 fixed an analogous mtime-tick collision in the picker/summary tests. The `stdout.contains("modified")` assertion still passes since `"modified"` is a prefix of the new content. > _This was written by Claude Code on behalf of @max-sixty_ Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Summary
default_shellsunconditionally; theShell::is_installed()filter (added in fix(config): clean up wt config show shell-integration section #2574) now hidesSkipped pwshon hosts without pwsh, the same waySkipped fishis hidden on a stock zsh-only Macshould_auto_configure_powershell()still gatesallow_create, so users who have pwsh installed but never opened it don't get an unsolicited profile written (issue PowerShell shell integration is not working #885 behavior unchanged)wt config showfor users who configured a profile but aren't currently in a PS sessionVisible changes
configuredSkipped pwsh; profile not foundis_installed()filter)Test plan
cargo test --test integration(1622 passed)pre-commit run --all-filestest_configure_shell_skipped_lists_only_installed_shellsto flag pwsh installed and assert it appears asSkipped🤖 Generated with Claude Code