From fc1be2baac830acf782f8484aebff7a61bc4e3b3 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 10 Feb 2026 16:14:11 -0800 Subject: [PATCH] add more shortcuts to help output (#9204) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add more shortcuts to help output * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Max Paulus 🥪 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- cli/src/components/HelpPanelContent.tsx | 24 ++++++++++++++++++++++++ cli/src/hooks/useTextInput.ts | 14 +++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/cli/src/components/HelpPanelContent.tsx b/cli/src/components/HelpPanelContent.tsx index c7bbd98fd0..71bbb5c58b 100644 --- a/cli/src/components/HelpPanelContent.tsx +++ b/cli/src/components/HelpPanelContent.tsx @@ -43,6 +43,30 @@ export const HelpPanelContent: React.FC = ({ onClose }) = + + Keyboard Shortcuts + + {" "} + Ctrl+U - Clear entire input (delete to start) + + + {" "} + Ctrl+K - Delete from cursor to end + + + {" "} + Ctrl+W - Delete word backwards + + + {" "} + Ctrl+A / Ctrl+E - Jump to start / end of input + + + {" "} + Alt/Option+←/→ - Move by word + + + Slash Commands diff --git a/cli/src/hooks/useTextInput.ts b/cli/src/hooks/useTextInput.ts index c1fd05b617..dbcd35a058 100644 --- a/cli/src/hooks/useTextInput.ts +++ b/cli/src/hooks/useTextInput.ts @@ -6,6 +6,7 @@ * - Ctrl+A/E: start/end of line * - Ctrl+W: delete word backwards * - Ctrl+U: delete to start of line + * - Ctrl+K: delete to end of line * * Note: Home/End keys are handled by useHomeEndKeys hook because Ink doesn't * expose them in useInput (it sets input='' for these keys). @@ -152,6 +153,14 @@ export function useTextInput(): UseTextInputReturn { } }, []) + const deleteToEnd = useCallback(() => { + const pos = cursorRef.current + if (pos < textRef.current.length) { + setTextState((prev) => prev.slice(0, pos)) + // Cursor stays at same position (now at end of text) + } + }, []) + // Cursor movement (internal, used by handlers) const moveToStart = useCallback(() => setCursorPosState(0), []) const moveToEnd = useCallback(() => setCursorPosState(textRef.current.length), []) @@ -190,6 +199,9 @@ export function useTextInput(): UseTextInputReturn { case "u": // Ctrl+U - delete to start deleteToStart() return true + case "k": // Ctrl+K - delete to end + deleteToEnd() + return true case "w": // Ctrl+W - delete word backwards deleteWordBefore() return true @@ -197,7 +209,7 @@ export function useTextInput(): UseTextInputReturn { return false } }, - [moveToStart, moveToEnd, deleteToStart, deleteWordBefore], + [moveToStart, moveToEnd, deleteToStart, deleteToEnd, deleteWordBefore], ) return {