Skip to content

fix: Atuin hangs when attempting to spawn daemon from Ctrl+R invocation - #3502

Merged
ellie merged 4 commits into
mainfrom
mkt/fix-daemon-crash
May 27, 2026
Merged

fix: Atuin hangs when attempting to spawn daemon from Ctrl+R invocation#3502
ellie merged 4 commits into
mainfrom
mkt/fix-daemon-crash

Conversation

@BinaryMuse

@BinaryMuse BinaryMuse commented May 26, 2026

Copy link
Copy Markdown
Member

This PR fixes a shell hang when daemon autostart happens from the interactive search widget.

The bash/zsh/fish integrations run atuin search -i under command substitution and swap stdout/stderr so the TUI can draw to the terminal while the selected command is captured:

3>&1 1>&2 2>&3

This leaves fd 3 open in the atuin search process. If search autostarts the daemon, the spawned long-running atuin daemon start --daemonize inherits fd 3, the command-substitution pipe, so the shell keeps waiting for EOF until the daemon is killed.

The fix: close fd 3 after the swap in the non-tmux bash/zsh/fish paths:

3>&1 1>&2 2>&3 3>&-

Tested on zsh; I still need to confirm for bash and fish. Near as I can tell, the other shell integrations don't need this change.

Fixes #3499

Comment thread crates/atuin/src/command/client/search/interactive.rs Outdated
Comment thread crates/atuin/src/shell/atuin.zsh
@BinaryMuse
BinaryMuse marked this pull request as ready for review May 26, 2026 23:47
@greptile-apps

greptile-apps Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the interactive search daemon autostart hang. The main changes are:

  • Closes fd 3 after stdout/stderr swapping in bash, zsh, and fish non-tmux search paths.
  • Preserves and handles failed atuin search -i exits in shell widgets.
  • Logs terminal cleanup failures from interactive search teardown instead of ignoring them.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The fd close is limited to the command-substitution paths that create the extra descriptor.
  • The error-handling changes avoid treating failure output as a selected command.

Important Files Changed

Filename Overview
crates/atuin/src/shell/atuin.bash Closes the extra command-substitution fd and avoids inserting captured error output.
crates/atuin/src/shell/atuin.zsh Closes the extra command-substitution fd and returns early on failed search.
crates/atuin/src/shell/atuin.fish Closes the extra fd in non-tmux paths and propagates search or popup failures.
crates/atuin/src/command/client/search/interactive.rs Reports terminal cleanup errors through tracing during TUI teardown.

Reviews (1): Last reviewed commit: "clippy" | Re-trigger Greptile

@BinaryMuse
BinaryMuse requested a review from ellie May 27, 2026 16:49
@ellie
ellie merged commit 4475e17 into main May 27, 2026
25 checks passed
@ellie
ellie deleted the mkt/fix-daemon-crash branch May 27, 2026 21:42
taylordotfish pushed a commit that referenced this pull request Jul 9, 2026
### Bug Fixes

- *(ai)* Dispatch skills registered in the slash command registry
([#3593](#3593))
- *(ci)* Fossier install in scan workflow
([#3485](#3485))
- *(i18n)* Fix typos in Russian localization
([#3575](#3575))
- *(nu)* Use `char -u 1b` for ESC in OSC 133 sequences
([#3530](#3530))
- *(nu)* Suppress error when `ATUIN_HISTORY_ID` is missing in
`pre_prompt` hook
([#3587](#3587))
- *(pi)* Observe tool events instead of registering a bash tool
([#3557](#3557))
- *(pty-proxy)* Set `$SHELL` to the spawned shell
([#3548](#3548))
- *(search)* Fix terminal clearing with latest Ratatui
([#3578](#3578))
- *(sync)* Skip records that fail to decrypt or decode instead of
failing the whole store
([#3569](#3569))
- Atuin hangs when attempting to spawn daemon from Ctrl+R invocation
([#3502](#3502))
- Capture session ID from stream headers rather than final event
([#3531](#3531))
- Doctor resiliency fo runknown platforms + openbsd warning
([#3551](#3551))
- Double input on arrow keys in AI setup prompt on Windows
([#3552](#3552))
- Exclude AI agent commands from zsh-autosuggestions
([#3567](#3567))
- Silence shellcheck SC2016 on literal `$all-user` author filter
- Respect `store_failed` when using daemon
([#3571](#3571))


### Documentation

- Highlight `Ctrl-r` keybinding on docs page
([#3489](#3489))
- Document store purge workflow
([#3544](#3544))
- Fix command example typo in documentation
([#3536](#3536))
- Make commented-out lines in `config.toml` match real defaults
([#3583](#3583))
- Add fish shell cleanup step to uninstall instructions
([#3582](#3582))


### Features

- *(doctor)* Add whether daemon is enabled to `doctor` output
([#3572](#3572))
- *(pty-proxy)* Add `--shell` flag to override the spawned shell
([#3327](#3327))
- Setup fossier to stop bot slop prs
([#3482](#3482))
- Capture command output + expose to new `atuin_output` tool
([#3510](#3510))
- Cache user contexts on load until `/reload`
([#3525](#3525))
- Create database integration tests for atuin-server
([#3514](#3514))
- Add `/model` slash command for changing models
([#3576](#3576))
- Add mcp server for history tools and expand search filters
([#3581](#3581))
- Add status bar with model and usage information
([#3591](#3591))


### Miscellaneous Tasks

- *(rustdoc)* Fix Rustdoc warnings
([#3585](#3585))
- *(warnings)* Fix compile warnings with latest dependencies
([#3586](#3586))
- Vouch for all existing contributors
([#3486](#3486))
- Update GitHub app token format
- Update to Rust 1.96.1
([#3568](#3568))
- Adopt `derive_more` to reduce boilerplate across the codebase
([#3573](#3573))


### Performance

- *(search)* Scan history by recency until N unique
([#3553](#3553))
- Add `synchronous(Normal)` + `optimize_on_close` to record store SQLite
([#3577](#3577))
- Remove unnecessary clones in a hot path
([#3580](#3580))


### Refactor

- Implement `From<sqlx::Error>` and clean up `fix_error`
([#3484](#3484))
- Pull `fn into_utc` into `atuin-server-database` crate
([#3487](#3487))
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.

[Bug]: Ctrl+R -> Tab -> Ctrl+R -> Esc causes Atuin to freeze indefinitely if the daemon is enabled but not running

2 participants