Skip to content

fix: Pressing 'enter' after a suggested command inserts instead of runs in bash#3592

Draft
BinaryMuse wants to merge 1 commit into
mainfrom
mkt/ai-bash-enter
Draft

fix: Pressing 'enter' after a suggested command inserts instead of runs in bash#3592
BinaryMuse wants to merge 1 commit into
mainfrom
mkt/ai-bash-enter

Conversation

@BinaryMuse

Copy link
Copy Markdown
Member

The bash integration's __atuin_ai_execute__ branch set READLINE_LINE and then bound two key sequences that nothing ever invoked, so "execute" behaved identically to "insert": accepting an AI suggestion with enter just placed it in the buffer.

Readline provides no way to call accept-line from a shell function, so this uses the same string-macro trick as atuin.bash's enter_accept support: "?" is bound to a two-part macro where the first keyseq runs the widget via bind -x and the trailing keyseq is dynamically rebound to accept-line (execute) or a no-op (everything else). Under ble.sh the widget calls ble/widget/accept-line directly. Bash <= 4.2 can't bind -x multi-byte key sequences, so it keeps the direct binding and execute still degrades to insert there.

Also removes the dead __atuin_ai_accept_line /
_atuin_ai_question_mark_wrapper scaffolding.

The bash integration's __atuin_ai_execute__ branch set READLINE_LINE and
then bound two key sequences that nothing ever invoked, so "execute"
behaved identically to "insert" — accepting an AI suggestion with enter
just placed it in the buffer.

Readline provides no way to call accept-line from a shell function, so
this uses the same string-macro trick as atuin.bash's enter_accept
support: "?" is bound to a two-part macro where the first keyseq runs
the widget via bind -x and the trailing keyseq is dynamically rebound
to accept-line (execute) or a no-op (everything else). Under ble.sh the
widget calls ble/widget/accept-line directly. Bash <= 4.2 can't bind -x
multi-byte key sequences, so it keeps the direct binding and execute
still degrades to insert there.

Also removes the dead __atuin_ai_accept_line /
_atuin_ai_question_mark_wrapper scaffolding.

Verified in interactive bash 5.3 via expect with a stubbed atuin:
execute runs without pressing enter, insert leaves the command in the
buffer (including immediately after an execute, exercising the trailer
reset), mid-line "?" inserts literally, and vi editing mode works.
@BinaryMuse BinaryMuse marked this pull request as ready for review July 13, 2026 19:06
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes bash AI suggestions so execute suggestions can submit the command.

  • Adds a readline macro chain for the ? AI binding.
  • Rebinds the trailing macro key to accept-line only for execute suggestions.
  • Calls ble/widget/accept-line directly when ble.sh is active.
  • Keeps the older Bash fallback as insert-only behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The macro flow matches the existing bash integration pattern.
  • The ble.sh branch follows the existing accept-line handling style.

Important Files Changed

Filename Overview
crates/atuin-ai/src/commands/init.rs Updates the generated bash AI integration to use a macro-based accept-line flow, with a ble.sh-specific execute path and string checks in tests.

Reviews (1): Last reviewed commit: "Fix AI execute mode in bash: enter now r..." | Re-trigger Greptile

@BinaryMuse BinaryMuse marked this pull request as draft July 13, 2026 19:09
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.

1 participant