Repository navigation
Commit 8bbc86a
Fix readline EOF: tcflush stdin before each Readline() call (#334)
Root cause (confirmed by research): ergochat/readline sends \033[6n
(cursor position query) before each prompt. During long LLM calls,
the terminal response \033[row;colR arrives late and sits in stdin.
On the next Readline(), these stale bytes cause io.EOF.
Same bug exists in Node.js readline (nodejs/node#57602) and Ruby
reline (ruby/reline#674).
Fix: call POSIX tcflush(TCIFLUSH) via TIOCFLUSH ioctl after each
agent Run() completes, before the next Readline(). Discards any
stale cursor position responses from stdin.
Also kept EOF retry as safety net (1 retry with 300ms pause).
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>1 parent 6e4f3e0 commit 8bbc86a
2 files changed
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
299 | 305 | | |
300 | 306 | | |
301 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
0 commit comments