From 138548ad45b593f099f0f1f4554f20f0c4d11367 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Mon, 5 Feb 2024 22:10:02 +0700 Subject: [PATCH] Feat [Terminal] [Chats] enhance local storage - [+] feat(chat.tsx): enhance local storage handling for chat input --- app/components/chat.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 5fe350a0b..8df75b44b 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1052,8 +1052,12 @@ function _Chat() { // Save the current input to local storage only if it is not a command. // Use the captured value from the input reference. const currentInputValue = currentInputRef?.value ?? ""; - if (!currentInputValue.startsWith(ChatCommandPrefix)) { + // Save the input to local storage only if it's not empty and not a command. + if (currentInputValue && !currentInputValue.startsWith(ChatCommandPrefix)) { localStorage.setItem(key, currentInputValue); + } else { + // If there's no value, ensure we don't create an empty key in local storage. + localStorage.removeItem(key); } }; // The effect should depend on the session ID to ensure it runs when the session changes.