fix Ctrl-C swallowing the next line

readline only redraws the prompt on Ctrl-C: the half-typed text
stays in its buffer and the interrupt flag outlives the prompt,
so the line typed next was silently discarded. Register a signal
event hook that empties the line, the way bash does, and clear
the flag around readline instead of eating the line: a Ctrl-C
during a command still aborts the turn, and one during a
multi-line task still abandons it. Two pty-based regression
tests cover the idle-prompt and mid-line cases.
This commit is contained in:
Luxferre
2026-10-04 21:32:50 +03:00
parent 141c6cc414
commit fdd389e452
3 changed files with 84 additions and 6 deletions
+6 -5
View File
@@ -416,12 +416,13 @@ where you are when you press it:
| -------------------- | ------------------------------------------------------------------- |
| Running a command | The process group is killed, exit 130 is reported, the turn ends. |
| Waiting on the API | The request is abandoned and the turn ends. |
| Part way through a line | The half-typed line is thrown away. |
| Sitting at the prompt | Solo survives and stays usable, but the flag lingers, so the next line you type is silently discarded. |
| Part way through a line | The half-typed line is cleared; the next line runs normally. |
| Mid way through a multi-line task | The whole task is abandoned. |
| Sitting at the prompt | Solo survives and stays usable; the next line runs normally. |
That last case is the one wart: press Ctrl-C once at an idle prompt and your
next command vanishes without a word. Press it twice and the second one goes
through, so it is self-correcting in practice.
The half-typed line is cleared by Solo itself: readline only redraws the
prompt on Ctrl-C and leaves the text in its buffer, so Solo registers a
signal hook that empties the line, the way bash does.
## Example session