From faea2b2fa23c6121b5f844d520e7689e2b7aca84 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Mon, 4 Mar 2024 23:09:09 +0530 Subject: [PATCH 01/10] Add typing state to PlaygroundForm component --- package.json | 2 +- src/components/Option/Playground/PlaygroundForm.tsx | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1097869..1f77712 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pageassist", "displayName": "Page Assist - A Web UI for Local AI Models", - "version": "1.0.5", + "version": "1.0.6", "description": "Use your locally running AI models to assist you in your web browsing.", "author": "n4ze3m", "scripts": { diff --git a/src/components/Option/Playground/PlaygroundForm.tsx b/src/components/Option/Playground/PlaygroundForm.tsx index 786f7f7..1597d66 100644 --- a/src/components/Option/Playground/PlaygroundForm.tsx +++ b/src/components/Option/Playground/PlaygroundForm.tsx @@ -18,6 +18,7 @@ type Props = { export const PlaygroundForm = ({ dropedFile }: Props) => { const inputRef = React.useRef(null) + const [typing, setTyping] = React.useState(false) const { onSubmit, selectedModel, @@ -115,14 +116,14 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { } }) - const handleKeyDown = (e: KeyboardEvent) => { - if (e.key === "Process" || e.key === "229") return + const handleKeyDown = (e: React.KeyboardEvent) => { + if (e.key === "Process" || e.key === "229" ) return if ( + !typing && e.key === "Enter" && !e.shiftKey && !isSending && - sendWhenEnter && - !e.isComposing + sendWhenEnter ) { e.preventDefault() form.onSubmit(async (value) => { @@ -213,7 +214,9 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { />