fix(cli): Ctrl+C clears input buffer before exiting
Previously, pressing Ctrl+C while text was typed in the input prompt would immediately exit Hermes. Now follows standard shell behavior: - Text in buffer → Ctrl+C clears the line (like bash) - Empty buffer → Ctrl+C exits This means accidentally hitting Ctrl+C while composing a message just clears the input instead of killing the session. A second Ctrl+C on the empty prompt still exits as expected.
This commit is contained in:
9
cli.py
9
cli.py
@@ -2490,8 +2490,13 @@ class HermesCLI:
|
|||||||
print("\n⚡ Interrupting agent... (press Ctrl+C again to force exit)")
|
print("\n⚡ Interrupting agent... (press Ctrl+C again to force exit)")
|
||||||
self.agent.interrupt()
|
self.agent.interrupt()
|
||||||
else:
|
else:
|
||||||
self._should_exit = True
|
# If there's text in the input buffer, clear it (like bash).
|
||||||
event.app.exit()
|
# If the buffer is already empty, exit.
|
||||||
|
if event.app.current_buffer.text:
|
||||||
|
event.app.current_buffer.reset()
|
||||||
|
else:
|
||||||
|
self._should_exit = True
|
||||||
|
event.app.exit()
|
||||||
|
|
||||||
@kb.add('c-d')
|
@kb.add('c-d')
|
||||||
def handle_ctrl_d(event):
|
def handle_ctrl_d(event):
|
||||||
|
|||||||
Reference in New Issue
Block a user