Skip to content

fix: force direct tty prompts for zsh hook#184

Merged
kaplanelad merged 1 commit into
kaplanelad:mainfrom
donbeave:codex/zsh-direct-tty-pre-command
May 15, 2026
Merged

fix: force direct tty prompts for zsh hook#184
kaplanelad merged 1 commit into
kaplanelad:mainfrom
donbeave:codex/zsh-direct-tty-pre-command

Conversation

@donbeave

Copy link
Copy Markdown
Contributor

Summary

Fixes the zsh hook path so it explicitly uses Shellfirm's direct /dev/tty prompter instead of relying on stdin().is_terminal() to infer whether requestty/crossterm is safe.

Root Cause

pre-command already has a DirectTtyPrompter fallback for zsh zle contexts, but it is selected only when stdin is not a terminal. In some zsh hook environments stdin still reports as a terminal, so Shellfirm selects TerminalPrompter, enters requestty/crossterm, emits a cursor-position query, and can hang without showing a usable prompt.

Changes

  • Adds a hidden pre-command --direct-tty flag that forces DirectTtyPrompter on Unix.
  • Updates the generated zsh hook to call shellfirm pre-command --direct-tty -c "${BUFFER}".
  • Adds a regression test asserting the generated zsh hook keeps the direct-tty flag.

Fixes #183.

Verification

  • cargo test -p shellfirm zsh_hook_uses_direct_tty_prompt
  • cargo test -p shellfirm command
  • Runtime smoke test with target/debug/shellfirm pre-command --direct-tty -c 'rm -rf /private/tmp/shellfirm-pr-runtime-test', confirming it shows Type 'yes' to continue instead of entering the hanging cursor-query path.

@donbeave donbeave marked this pull request as ready for review May 10, 2026 18:31
@kaplanelad kaplanelad merged commit 7ebf869 into kaplanelad:main May 15, 2026
7 checks passed
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.

zsh pre-command hook can hang with no visible prompt because TerminalPrompter is selected

2 participants