Skip to content

fix: use temp file for shell wrapper CD communication#219

Merged
avihut merged 2 commits intomasterfrom
daft-218/non-blocking-io
Feb 17, 2026
Merged

fix: use temp file for shell wrapper CD communication#219
avihut merged 2 commits intomasterfrom
daft-218/non-blocking-io

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Feb 17, 2026

Summary

  • Replace stdout capture (output=$(...) + grep for __DAFT_CD__: markers) with a temp file mechanism (DAFT_CD_FILE env var) for shell wrapper CD communication
  • Stdout now flows directly to the terminal, enabling real-time output during hook execution and command progress
  • Removes CLICOLOR_FORCE workaround and stderr routing for result() messages since stdout is no longer captured

What changed

Rust core: New CD_FILE_ENV constant replaces CD_PATH_MARKER, SHELL_WRAPPER_ENV, and output_cd_path(). cd_path() writes to the temp file instead of printing a marker. result() always prints to stdout.

Shell wrappers: __daft_wrapper() (bash/zsh/fish) creates a temp file via mktemp, passes it as DAFT_CD_FILE, runs the command with stdout flowing directly to the terminal, then reads the cd target from the file after the command finishes.

Breaking change: Old shell wrappers won't work with the new binary. Users must re-source shell config after updating (eval "$(daft shell-init bash)").

Fixes #218

Test plan

  • mise run clippy — zero warnings
  • mise run test-unit — 335 tests pass
  • mise run test-integration — 175 tests pass (default + gitoxide)
  • mise run verify-man — man pages up-to-date
  • Manual test: real-time stdout streaming confirmed during hook execution

🤖 Generated with Claude Code

avihut and others added 2 commits February 17, 2026 08:14
…out capture

The shell wrapper previously captured all stdout via $() to grep for
__DAFT_CD__:/path markers. This blocked real-time output and required
workarounds like CLICOLOR_FORCE and routing result() to stderr.

Now the wrapper creates a temp file via mktemp, passes its path via
DAFT_CD_FILE env var, and daft writes the cd target there. Stdout flows
directly to the terminal, enabling real-time output during hooks and
commands.

Fixes #218

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@avihut avihut added this to the v1.1.0 milestone Feb 17, 2026
@avihut avihut added the fix Bug fix label Feb 17, 2026
@avihut avihut self-assigned this Feb 17, 2026
@avihut avihut changed the title feat: use temp file for shell wrapper CD communication fix: use temp file for shell wrapper CD communication Feb 17, 2026
@avihut avihut merged commit aea0eea into master Feb 17, 2026
4 checks passed
@avihut avihut deleted the daft-218/non-blocking-io branch February 17, 2026 06:49
This was referenced Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-blocking IO

1 participant