claw: shell readline — history, cursor editing, Ctrl-C#103
Merged
Conversation
Add a shared ring-buffer history module (shell_history.c) that
stores up to 16 recent inputs with duplicate suppression.
All three shell implementations now support:
- Up/Down arrows to cycle through command history
- History covers both AI messages and /commands
- Current unsaved input is preserved as scratch when
navigating, restored on down-past-newest
Linux shell additionally gains:
- Left/Right arrow cursor movement with insert mode
- Home/End keys
- Delete key
- Proper redraw on mid-line insert and backspace
(ESP and Zynq shells already had cursor editing; this commit
adds only history navigation to them.)
Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
Line editing (all platforms):
- Ctrl-C prints ^C and discards current input, returns to
a fresh prompt without exiting.
AI chat interruption (all platforms):
- Animation thread polls console for Ctrl-C during thinking.
- On detection, sets cancel flag, stops animation, and
discards the AI response when ai_chat() completes.
Linux-specific:
- Double Ctrl-C within 1 second exits the program (replaces
the old single Ctrl-C exit behavior).
- Ctrl-D still exits immediately.
- Keep raw mode during AI chat so animation thread can poll
stdin for Ctrl-C.
Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add interactive shell improvements across all three platforms (ESP, Zynq, Linux).
Command history (Up/Down arrows)
shell_history.c) stores up to 16 recent inputs/commandsCursor editing (Linux — new; ESP/Zynq — already had)
Ctrl-C support (all platforms)
^Cdiscards current input and returns to fresh promptChanges (2 commits)
claw: add shell history and cursor editing across all platformsclaw: add Ctrl-C to cancel input and interrupt AI chatNew files
include/claw/shell/shell_history.h— history APIclaw/shell/shell_history.c— ring buffer implementationTest plan
make build-linux— zero warningsmake build-zynq-a9-qemu— zero warningsmake test-unit-zynq— all suites passmake build-esp32c3-qemu+ smoke tests (CI)