From 7787685f125ddaca521cdac525e5c233dcf4f4ce Mon Sep 17 00:00:00 2001 From: TomIsion Date: Fri, 21 Nov 2025 02:19:20 +0800 Subject: [PATCH] fix: HOTFIX useHistory currentIndex more than MAX_HISTORY_LENGTH cause replace fail (#8819) fix: useHistory currentIndex more than MAX_HISTORY_LENGTH cause replace fail --- gui/src/hooks/useInputHistory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/hooks/useInputHistory.ts b/gui/src/hooks/useInputHistory.ts index 3d63886fe..a2b2ed9aa 100644 --- a/gui/src/hooks/useInputHistory.ts +++ b/gui/src/hooks/useInputHistory.ts @@ -54,7 +54,7 @@ export function useInputHistory(historyKey: string) { return; } - setCurrentIndex(inputHistory.length + 1); + setCurrentIndex(Math.min(inputHistory.length + 1, MAX_HISTORY_LENGTH)); setInputHistory((prev) => { return [...prev, inputValue].slice(-MAX_HISTORY_LENGTH); });