Skip to content

fix(shell-hook): pass the cd target through a file so prompts keep the TTY - #42

Open
amustafa wants to merge 1 commit into
am/init-adopt-remote-metafrom
am/shell-hook-cd-file
Open

fix(shell-hook): pass the cd target through a file so prompts keep the TTY#42
amustafa wants to merge 1 commit into
am/init-adopt-remote-metafrom
am/shell-hook-cd-file

Conversation

@amustafa

Copy link
Copy Markdown
Owner

What

The shell hook no longer captures sr's stdout. The cd target for worktree navigation now travels through a scratch file (SR_CD_FILE) instead of a __sr_cd: sentinel parsed out of captured output.

Why

The old hook ran output="$(command sr "$@")". Command substitution turns stdout into a pipe, root's TTY check then classifies the run as non-interactive, and every interactive prompt (submit's PR creation, preflight decisions, navigation choices) silently takes its scripted branch. In other words: installing the hook — the documented setup step — disabled half the CLI.

How

  • The hook mktemps a scratch file, exports it as SR_CD_FILE, and runs sr with stdin/stdout attached to the terminal. Afterwards it reads the cd target from the file, cds, and cleans up.
  • handleNavigateResult writes the target into SR_CD_FILE when set; the __sr_cd: stdout sentinel remains as the fallback for hooks eval'd before this change (and when the file write fails).
  • If mktemp fails, the hook degrades to running sr directly with no cd.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 31c79c88-612b-4ca5-971c-89e9e6821867

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@amustafa
amustafa force-pushed the am/shell-hook-cd-file branch from 009ac14 to 34e9a12 Compare August 18, 2026 18:34
@amustafa amustafa closed this Aug 19, 2026
@amustafa
amustafa force-pushed the am/shell-hook-cd-file branch from 34e9a12 to 0d57b0d Compare August 19, 2026 14:56
@amustafa amustafa reopened this Aug 19, 2026
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