Repository navigation
fix(alias): inherit stdin so interactive children keep the tty - #2380
Merged
Merged
Conversation
Alias execution piped the template context JSON into each child's stdin, displacing the controlling terminal. Interactive children like `wt switch` then saw a pipe and failed the `stdin().is_terminal()` guard with "Interactive picker requires an interactive terminal". Hooks still get the documented JSON-on-stdin contract; aliases now leave stdin alone. The hook/alias split already exists as `CommandOrigin` at the single call site, so no subcommand sniffing is needed. Fixes #406 follow-up reported by @KieranP. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Closed
This was referenced Apr 22, 2026
max-sixty
added a commit
that referenced
this pull request
May 2, 2026
The comparison table in `extending.md` covered invocation, positional handling, approval flags, source filters, and template-context extras — but never said anything about stdin. Hooks have always received the template context as JSON on stdin (documented in `hook.md`), and since #2380 aliases inherit the parent's stdin so pipes pass through and interactive TUIs (`wt switch`) keep the tty. Adding a row makes the contract discoverable from the aliases page rather than only from the CHANGELOG. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Alias execution piped the template context JSON into each child's stdin, displacing the controlling terminal. Interactive children like
wt switchthen saw a pipe and bailed withInteractive picker requires an interactive terminal. See #406 follow-up for the reproduction.The fix is scoped to the single call site in
run_one_command(src/commands/command_executor.rs) whereCommandOriginalready distinguishes hooks from aliases:CommandOrigin::Hook { .. }→ keep pipingcontext_jsonon stdin (documented contract, covered bytest_post_create_json_stdin/test_post_start_json_stdin).CommandOrigin::Alias { .. }→ passNone;execute_shell_commandnow treatsNoneasStdio::inherit()so the child keeps the parent's tty.No subcommand sniffing, no new configs, no change to
for_each(which still opts into JSON-on-stdin).Test plan
test_alias_inherits_stdinintests/integration_tests/step_alias.rs— pipes a sentinel intowt, runs an alias ofcat, asserts the sentinel (not the context JSON) reaches the alias body.cargo test --test integration -- step_alias— all 67 tests pass, including the new one.cargo test --test integration -- test_post_create_json_stdin test_post_start_json_stdin— hook JSON-on-stdin still works.cargo test --test integration -- post_start post_create for_each— 70 tests pass.cargo clippy --all-targets— clean.🤖 Generated with Claude Code