fix(cli): keep Ctrl+D no-op when only attachments pending

Follow-up to @iRonin's Ctrl+D EOF fix. If the input text is empty but
the user has pending attached images, do nothing rather than exiting —
otherwise a stray Ctrl+D silently discards the attachments.
This commit is contained in:
Teknium 2026-04-24 15:15:41 -07:00 committed by Teknium
parent 08d5c9c539
commit ed91b79b7e

7
cli.py
View file

@ -9558,11 +9558,16 @@ class HermesCLI:
@kb.add('c-d') @kb.add('c-d')
def handle_ctrl_d(event): def handle_ctrl_d(event):
"""Ctrl+D: delete char under cursor (standard readline behaviour). """Ctrl+D: delete char under cursor (standard readline behaviour).
Only exit when the input is empty same as bash/zsh. Only exit when the input is empty same as bash/zsh. Pending
attached images count as input and block the EOF-exit so the
user doesn't lose them silently.
""" """
buf = event.app.current_buffer buf = event.app.current_buffer
if buf.text: if buf.text:
buf.delete() buf.delete()
elif self._attached_images:
# Empty text but pending attachments — no-op, don't exit.
return
else: else:
self._should_exit = True self._should_exit = True
event.app.exit() event.app.exit()