@@ -282,11 +296,7 @@ export default function ChatView({
handleSubmit={handleSubmit}
isLoading={isLoading}
onStop={onStopGoose}
- commandHistory={filteredMessages
- .filter((m) => isUserMessage(m))
- .map((m) => m.content.find((c) => c.type === 'text')?.text || '')
- .filter((text) => text.trim())
- .reverse()}
+ commandHistory={commandHistory}
/>
diff --git a/ui/desktop/src/components/Input.tsx b/ui/desktop/src/components/Input.tsx
index d163cead92ef..e82bb942989a 100644
--- a/ui/desktop/src/components/Input.tsx
+++ b/ui/desktop/src/components/Input.tsx
@@ -57,38 +57,42 @@ export default function Input({
setIsComposing(false);
};
- const handleKeyDown = (evt: React.KeyboardEvent
) => {
- // Handle command history navigation
- if ((evt.metaKey || evt.ctrlKey) && (evt.key === 'ArrowUp' || evt.key === 'ArrowDown')) {
- evt.preventDefault();
+ const handleHistoryNavigation = (evt: React.KeyboardEvent) => {
+ evt.preventDefault();
- // Save current input if we're just starting to navigate history
- if (historyIndex === -1) {
- setSavedInput(value);
- }
+ // Save current input if we're just starting to navigate history
+ if (historyIndex === -1) {
+ setSavedInput(value);
+ }
- // Calculate new history index
- let newIndex = historyIndex;
- if (evt.key === 'ArrowUp') {
- // Move backwards through history
- if (historyIndex < commandHistory.length - 1) {
- newIndex = historyIndex + 1;
- }
- } else {
- // Move forwards through history
- if (historyIndex > -1) {
- newIndex = historyIndex - 1;
- }
+ // Calculate new history index
+ let newIndex = historyIndex;
+ if (evt.key === 'ArrowUp') {
+ // Move backwards through history
+ if (historyIndex < commandHistory.length - 1) {
+ newIndex = historyIndex + 1;
}
-
- // Update index and value
- setHistoryIndex(newIndex);
- if (newIndex === -1) {
- // Restore saved input when going past the end of history
- setValue(savedInput);
- } else {
- setValue(commandHistory[newIndex] || '');
+ } else {
+ // Move forwards through history
+ if (historyIndex > -1) {
+ newIndex = historyIndex - 1;
}
+ }
+
+ // Update index and value
+ setHistoryIndex(newIndex);
+ if (newIndex === -1) {
+ // Restore saved input when going past the end of history
+ setValue(savedInput);
+ } else {
+ setValue(commandHistory[newIndex] || '');
+ }
+ };
+
+ const handleKeyDown = (evt: React.KeyboardEvent) => {
+ // Handle command history navigation
+ if ((evt.metaKey || evt.ctrlKey) && (evt.key === 'ArrowUp' || evt.key === 'ArrowDown')) {
+ handleHistoryNavigation(evt);
return;
}
From 26c80e158ea3f2902364a1bcf334df336c94b3ad Mon Sep 17 00:00:00 2001
From: kang-square <112981282+kang-square@users.noreply.github.com>
Date: Tue, 4 Mar 2025 15:53:06 -0500
Subject: [PATCH 3/3] add back comment
---
ui/desktop/src/components/Input.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/ui/desktop/src/components/Input.tsx b/ui/desktop/src/components/Input.tsx
index e82bb942989a..3d3a33247799 100644
--- a/ui/desktop/src/components/Input.tsx
+++ b/ui/desktop/src/components/Input.tsx
@@ -17,6 +17,7 @@ export default function Input({
commandHistory = [],
}: InputProps) {
const [value, setValue] = useState('');
+ // State to track if the IME is composing (i.e., in the middle of Japanese IME input)
const [isComposing, setIsComposing] = useState(false);
const [historyIndex, setHistoryIndex] = useState(-1);
const [savedInput, setSavedInput] = useState('');