Conversation
`daft shell-init` is sourced from `~/.bashrc`, `~/.zshrc`, etc. via `eval "$(daft shell-init …)"` on every interactive shell startup, so its codepath must stay lean. Previously it unconditionally ran a `git config --global` subprocess, read the update-check cache from disk, and (when stale) spawned `daft __check-update` which then forks `curl`. The version-upgrade banner is also written to stderr, which `eval` does not capture, so it leaked straight into the user's terminal at shell startup. Generalise the existing `is_background_task` gate in `src/main.rs` into a pure helper `daft::skip_startup_tasks_for` that also matches `shell-init`, and route both `maybe_check_for_update` and `maybe_prune_trust` through it. Document the hot-path constraint in CLAUDE.md so future commands with similar requirements are added to the same gate rather than introducing a parallel one. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`daft completions <shell>` emits shell code to stdout that some users `eval` from their rc files (when they don't go through `shell-init`, which already bundles completions). That makes it the same hot path as `shell-init`: subprocess calls, file IO, and background spawns add latency to every new shell, and any stderr output (e.g., the update banner) leaks past `eval`'s stdout capture into the user's terminal. Extend `daft::skip_startup_tasks_for` to also match `completions`, and update the CLAUDE.md note to cover both shell-eval'd commands plus the `__complete` tab-completion helper that is already gated via the `__` prefix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 27, 2026
Merged
Closed
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
daft shell-initanddaft completions <shell>both emit shell code that usersevalfrom their rc files (~/.bashrc,~/.zshrc, …), so they run on every interactive shell startup. Two problems on this codepath:src/main.rsrun agit config --globalsubprocess, read~/.config/daft/update-check.json, and (when stale) fork-spawndaft __check-updatewhich itself forkscurlto GitHub.print_notificationwrites to stderr;evalonly captures stdout, so when a newer release is cached and the 24h-per-version throttle has elapsed, the banner leaks straight into the user's terminal at shell startup.This PR:
is_background_taskgate insrc/main.rsinto a small pure helperdaft::skip_startup_tasks_for(src/lib.rs) that matches__*background tasks plus the two shell-eval'd commandsshell-initandcompletions.maybe_check_for_updateandmaybe_prune_trustthrough the helper.CLAUDE.md(covers shell-init, completions, and the__completetab-completion helper that is already gated via the__prefix) so future commands with similar requirements are added to the same gate rather than introducing a parallel one.Test plan
mise run fmtmise run clippy— zero warningscargo test --lib skip_startup_tasks— 11/11 helper tests pass (covers empty argv, no subcommand,daft shell-init,git-daft shell-init,daft completions,git-daft completions,__check-update,__prune-trust,daft clone …,daft list, no-substring-match guard)target/release/daft, seeded~/.config/daft/update-check.jsonwithlatest_version: 999.0.0, randaft shell-init bash— no banner on stderr,pgrepconfirmed no__check-update/__prune-trustbackground processes spawned🤖 Generated with Claude Code