Skip to content

[codex] refine shell prompt and powershell invocation#2284

Draft
aboimpinto wants to merge 4 commits into
Hmbown:fix/1779-windows-shell-dispatchfrom
aboimpinto:codex/2279-followup
Draft

[codex] refine shell prompt and powershell invocation#2284
aboimpinto wants to merge 4 commits into
Hmbown:fix/1779-windows-shell-dispatchfrom
aboimpinto:codex/2279-followup

Conversation

@aboimpinto
Copy link
Copy Markdown
Contributor

@aboimpinto aboimpinto commented May 27, 2026

Summary

  • refine the Windows shell prompt so it shows a shell stem instead of a full path
  • add -NonInteractive to PowerShell invocation
  • keep the cmd.exe full-path raw-argument handling fix and its regression coverage
  • keep the shell_program_stem helper reusable inside the crate

This is a follow-up branch because I cannot push directly to the maintainer branch from this environment.

Paulo Aboim Pinto

Greptile Summary

This PR refines Windows shell handling in three focused ways: the system-prompt environment block now shows a shell stem (pwsh, cmd) instead of a full executable path; PowerShell invocations gain -NonInteractive; and push_eval_shell_args in eval.rs correctly matches full-path cmd.exe references by routing through shell_program_stem rather than a plain case-insensitive string compare.

  • The removal of the implicit powershell.exe (Windows PowerShell 5.x) auto-detection fallback is intentional and is now documented with a code comment; users can still select it explicitly via the SHELL environment variable.
  • -NonInteractive is added to every powershell_invocation call (both pwsh.exe and explicit powershell.exe via SHELL), preventing PowerShell from waiting for user input in automated contexts.
  • shell_program_stem is promoted to pub(crate) and reused consistently across eval.rs and prompts.rs, eliminating duplicated path-normalisation logic.

Confidence Score: 5/5

Safe to merge; all behaviour changes are intentional, documented, and covered by new tests.

The three changed files make tightly scoped improvements. The powershell.exe auto-detection removal is explicitly documented in a code comment and a new test confirms the correct fallback path. The shell_program_stem refactor produces identical output for all edge cases. The -NonInteractive addition and stem-only prompt display have targeted regression tests. No logic regressions or data-correctness issues were identified.

No files require special attention.

Important Files Changed

Filename Overview
crates/tui/src/shell_invocation.rs Removes powershell_on_path auto-detection (now documented as intentional); adds -NonInteractive to PowerShell invocation; makes shell_program_stem pub(crate); refactors stem extraction to lowercase upfront; adds three new targeted tests.
crates/tui/src/prompts.rs Uses shell_program_stem on the resolved program to emit only the shell stem instead of a full path in the Environment block; adds a Windows-only assertion to the existing environment-block test.
crates/tui/src/eval.rs Imports shell_program_stem and replaces the direct case-insensitive program name check so full-path cmd.exe invocations correctly use raw args; adds a Windows-only regression test.

Comments Outside Diff (1)

  1. crates/tui/src/shell_invocation.rs, line 129-131 (link)

    P1 Silent removal of powershell.exe auto-detection fallback

    The powershell_on_path field and its associated fallback branch were removed, which means Windows users who only have powershell.exe (Windows PowerShell 5.x) installed — but not pwsh (PowerShell 7) — will now silently fall through to cmd.exe. This is a non-trivial behaviour change for any Windows machine that ships PowerShell 5.x exclusively (e.g. Windows Server 2019, unmanaged enterprise desktops). The PR description does not mention this removal, so it is unclear whether it is intentional. If powershell.exe is being deliberately dropped, a short comment or changelog entry would help reviewers and users understand the new minimum requirement.

    Fix in Codex Fix in Claude Code Fix in Cursor

Reviews (3): Last reviewed commit: "test(tui): lock Windows shell fallback b..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors Windows shell invocation logic, adding the -NonInteractive flag to PowerShell commands, simplifying shell_program_stem to handle full paths (such as cmd.exe), and adding corresponding tests. However, the changes also remove the fallback to Windows PowerShell (powershell.exe) when PowerShell Core (pwsh.exe) is missing, which forces standard Windows environments to fall back directly to cmd.exe. The reviewer recommends restoring the powershell_on_path field, its detection, the fallback logic, and the accidentally deleted test windows_falls_back_to_comspec_cmd_with_utf8_prefix to prevent this regression.

Comment thread crates/tui/src/shell_invocation.rs
Comment thread crates/tui/src/shell_invocation.rs
Comment thread crates/tui/src/shell_invocation.rs
Comment thread crates/tui/src/shell_invocation.rs
Comment thread crates/tui/src/shell_invocation.rs
Copy link
Copy Markdown
Contributor Author

@Hmbown I want to confirm the intended direction before I make another change here.

In your #1779 / #2279 comments, you said that if pwsh.exe is not available on PATH, it is safer to fall back to cmd.exe. The current review on #2284 is asking to restore powershell_on_path and bring back a powershell.exe fallback.

Can you confirm which behavior you want for this branch?

  • pwsh.exe -> powershell.exe -> cmd.exe
  • or pwsh.exe -> cmd.exe

I’ll align the branch to your preference.

Paulo Aboim Pinto

Copy link
Copy Markdown
Owner

Hmbown commented May 28, 2026

 pwsh.exe → cmd.exe - thank you so much!

@aboimpinto
Copy link
Copy Markdown
Contributor Author

@Hmbown aligned this with your preference: the default Windows fallback stays pwsh.exe -> cmd.exe; powershell.exe is only used when explicitly selected through SHELL.

I also restored coverage for the COMSPEC full-path cmd.exe branch in shell_invocation.rs, including the UTF-8 prefix and display-command behavior.

Verified locally:

  • cargo fmt --check
  • cargo test -p codewhale-tui --bin codewhale-tui shell_invocation -- --nocapture
  • cargo test -p codewhale-tui --bin codewhale-tui push_eval_shell_args -- --nocapture

Paulo Aboim Pinto

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