The open source coding agent.
TypeScript
fix(desktop): prompt history nav
Adamf07d4b933c01
diff --git a/packages/desktop/src/components/prompt-input.tsx b/packages/desktop/src/components/prompt-input.tsxindex b152ff0f522..aea9f4e2349 100644--- a/packages/desktop/src/components/prompt-input.tsx+++ b/packages/desktop/src/components/prompt-input.tsx@@ -598,19 +598,24 @@ export const PromptInput: Component<PromptInputProps> = (props) => {const cursorPosition = getCursorPosition(editorRef)const textLength = promptLength(prompt.current())+ const textContent = editorRef.textContent ?? ""+ const isEmpty = textContent.trim() === "" || textLength <= 1+ const hasNewlines = textContent.includes("\n")const inHistory = store.historyIndex >= 0- const atStart = cursorPosition <= 0- const atEnd = cursorPosition >= textLength+ const atStart = cursorPosition <= (isEmpty ? 1 : 0)+ const atEnd = cursorPosition >= (isEmpty ? textLength - 1 : textLength)+ const allowUp = isEmpty || atStart || (!hasNewlines && !inHistory) || (inHistory && atEnd)+ const allowDown = isEmpty || atEnd || (!hasNewlines && !inHistory) || (inHistory && atStart)if (event.key === "ArrowUp") {- if (!atStart && !(inHistory && atEnd)) return+ if (!allowUp) returnif (navigateHistory("up")) {event.preventDefault()}return}- if (!atEnd && !(inHistory && atStart)) return+ if (!allowDown) returnif (navigateHistory("down")) {event.preventDefault()}