mirror of
https://github.com/instructkr/claw-code.git
synced 2026-11-18 00:00:00 +08:00
feat(cli): press Esc to interrupt a running turn
While a turn runs the main thread is blocked in the conversation loop, so nothing reads the keyboard. Add an EscapeInterruptMonitor that, for the duration of a turn on an interactive terminal, switches stdin to a minimal non-canonical mode (echo/line-buffering off; ISIG and output processing untouched, unlike full raw mode) and polls for a lone ESC byte. Escape sequences such as arrow keys are recognized and swallowed. On Esc it trips the TurnInterruptSignal: the in-flight request is aborted and control returns to the REPL prompt with the session intact. Permission prompts read whole lines from stdin mid-turn, so stdin ownership is coordinated through a StdinPromptGate: while a prompt holds a lease the listener restores canonical mode and stops consuming bytes. Also: - spinner shows '(esc to interrupt)' and the banner/help mention Esc - WorkerStatus/WorkerEventKind gain an 'interrupted' lifecycle state - non-terminal stdin and non-unix platforms skip the listener; Ctrl+C interruption still works there Closes the Esc-to-interrupt feature request (#3196).
This commit is contained in:
1 parent
1efa72099d
commit
d4578586eb
5 files changed
+356
-24
No files matched your search
Generated
+1
@@ -2268,6 +2268,7 @@ dependencies = [
|
||||
"crossterm",
|
||||
"log",
|
||||
"mock-anthropic-service",
|
||||
"nix",
|
||||
"plugins",
|
||||
"pulldown-cmark",
|
||||
"runtime",
|
||||
|
||||
Reference in new issue
Block a user