server : Webui - change setText command from parent window to also send the message. (#13309)
* 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 <ivailo.gardev@akros.ch> Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
This commit is contained in:
parent
9b61acf060
commit
b34c859146
4 changed files with 9 additions and 0 deletions
Binary file not shown.
|
@ -157,6 +157,9 @@ export default function ChatScreen() {
|
||||||
clearExtraContext();
|
clearExtraContext();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// for vscode context
|
||||||
|
textarea.refOnSubmit.current = sendNewMessage;
|
||||||
|
|
||||||
const handleEditMessage = async (msg: Message, content: string) => {
|
const handleEditMessage = async (msg: Message, content: string) => {
|
||||||
if (!viewingChat) return;
|
if (!viewingChat) return;
|
||||||
setCurrNodeId(msg.id);
|
setCurrNodeId(msg.id);
|
||||||
|
|
|
@ -37,6 +37,7 @@ export interface ChatTextareaApi {
|
||||||
setValue: (value: string) => void;
|
setValue: (value: string) => void;
|
||||||
focus: () => void;
|
focus: () => void;
|
||||||
ref: React.RefObject<HTMLTextAreaElement>;
|
ref: React.RefObject<HTMLTextAreaElement>;
|
||||||
|
refOnSubmit: React.MutableRefObject<(() => void) | null>; // Submit handler
|
||||||
onInput: (event: React.FormEvent<HTMLTextAreaElement>) => void; // Input handler
|
onInput: (event: React.FormEvent<HTMLTextAreaElement>) => void; // Input handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ export interface ChatTextareaApi {
|
||||||
export function useChatTextarea(initValue: string): ChatTextareaApi {
|
export function useChatTextarea(initValue: string): ChatTextareaApi {
|
||||||
const [savedInitValue, setSavedInitValue] = useState<string>(initValue);
|
const [savedInitValue, setSavedInitValue] = useState<string>(initValue);
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
const onSubmitRef = useRef<(() => void) | null>(null);
|
||||||
|
|
||||||
// Effect to set initial value and height on mount or when initValue changes
|
// Effect to set initial value and height on mount or when initValue changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -91,6 +93,7 @@ export function useChatTextarea(initValue: string): ChatTextareaApi {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ref: textareaRef,
|
ref: textareaRef,
|
||||||
|
refOnSubmit: onSubmitRef,
|
||||||
onInput: handleInput,
|
onInput: handleInput,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@ export const useVSCodeContext = (textarea: ChatTextareaApi) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
|
setTimeout(() => {
|
||||||
|
textarea.refOnSubmit.current?.();
|
||||||
|
}, 10); // wait for setExtraContext to finish
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue