]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : Webui - change setText command from parent window to also send the message...
authorigardev <redacted>
Mon, 5 May 2025 14:03:31 +0000 (17:03 +0300)
committerGitHub <redacted>
Mon, 5 May 2025 14:03:31 +0000 (16:03 +0200)
* setText command from parent window for llama-vscode now sends the message automatically.

* Upgrade packages versions to fix vulnerabilities with "npm audit fix" command.

* Fix code formatting.

* Add index.html.gz changes.

* Revert "Upgrade packages versions to fix vulnerabilities with "npm audit fix" command."

This reverts commit 67687b7fda8a293724ba92ea30bb151677406bc8.

* easier approach

* add setTimeout

---------

Co-authored-by: igardev <redacted>
Co-authored-by: Xuan Son Nguyen <redacted>
tools/server/public/index.html.gz
tools/server/webui/src/components/ChatScreen.tsx
tools/server/webui/src/components/useChatTextarea.ts
tools/server/webui/src/utils/llama-vscode.ts

index 6f760c39f44c0ed88f0319fd72971f94168dee7a..82d2e3b97ba383b64a88656086fc26849706326b 100644 (file)
Binary files a/tools/server/public/index.html.gz and b/tools/server/public/index.html.gz differ
index 29ab5ea64f76fb7e4c987838c6984b37ebb86595..a2e3ee997583427c2d4faada7f040f244535ef3d 100644 (file)
@@ -157,6 +157,9 @@ export default function ChatScreen() {
     clearExtraContext();
   };
 
+  // for vscode context
+  textarea.refOnSubmit.current = sendNewMessage;
+
   const handleEditMessage = async (msg: Message, content: string) => {
     if (!viewingChat) return;
     setCurrNodeId(msg.id);
index 42b128194646f1dffd5c4caeb59558e512049474..a3223f4fd64da4307173d0c82012573b5b8d6cea 100644 (file)
@@ -37,6 +37,7 @@ export interface ChatTextareaApi {
   setValue: (value: string) => void;
   focus: () => void;
   ref: React.RefObject<HTMLTextAreaElement>;
+  refOnSubmit: React.MutableRefObject<(() => void) | null>; // Submit handler
   onInput: (event: React.FormEvent<HTMLTextAreaElement>) => void; // Input handler
 }
 
@@ -46,6 +47,7 @@ export interface ChatTextareaApi {
 export function useChatTextarea(initValue: string): ChatTextareaApi {
   const [savedInitValue, setSavedInitValue] = useState<string>(initValue);
   const textareaRef = useRef<HTMLTextAreaElement>(null);
+  const onSubmitRef = useRef<(() => void) | null>(null);
 
   // Effect to set initial value and height on mount or when initValue changes
   useEffect(() => {
@@ -91,6 +93,7 @@ export function useChatTextarea(initValue: string): ChatTextareaApi {
       }
     },
     ref: textareaRef,
+    refOnSubmit: onSubmitRef,
     onInput: handleInput,
   };
 }
index c45b0d3973c2ce339ea8c21af4be60f7f92557d5..55ebdcffc420e779632171afaf79810c84e232a8 100644 (file)
@@ -33,6 +33,9 @@ export const useVSCodeContext = (textarea: ChatTextareaApi) => {
           });
         }
         textarea.focus();
+        setTimeout(() => {
+          textarea.refOnSubmit.current?.();
+        }, 10); // wait for setExtraContext to finish
       }
     };