From d200db0eebde40a643d94e37b62e911e5c9269a6 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Wed, 4 Sep 2024 00:20:42 +0530 Subject: [PATCH 1/4] clean pkg json after publish --- extensions/react-widget/package-lock.json | 4 ++-- extensions/react-widget/package.json | 16 ++-------------- extensions/react-widget/publish.sh | 8 ++++++-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/extensions/react-widget/package-lock.json b/extensions/react-widget/package-lock.json index 2ad80282..610909de 100644 --- a/extensions/react-widget/package-lock.json +++ b/extensions/react-widget/package-lock.json @@ -1,12 +1,12 @@ { "name": "docsgpt", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "docsgpt", - "version": "0.4.1", + "version": "0.4.2", "license": "Apache-2.0", "dependencies": { "@babel/plugin-transform-flow-strip-types": "^7.23.3", diff --git a/extensions/react-widget/package.json b/extensions/react-widget/package.json index d12b76c4..813478e2 100644 --- a/extensions/react-widget/package.json +++ b/extensions/react-widget/package.json @@ -1,6 +1,6 @@ { - "name": "docsgpt", - "version": "0.4.1", + "name": "docsgpt-react", + "version": "0.4.2", "private": false, "description": "DocsGPT 🦖 is an innovative open-source tool designed to simplify the retrieval of information from project documentation using advanced GPT models 🤖.", "source": "./src/index.html", @@ -11,18 +11,6 @@ "dist", "package.json" ], - "targets": { - "modern": { - "engines": { - "browsers": "Chrome 80" - } - }, - "legacy": { - "engines": { - "browsers": "> 0.5%, last 2 versions, not dead" - } - } - }, "@parcel/resolver-default": { "packageExports": true }, diff --git a/extensions/react-widget/publish.sh b/extensions/react-widget/publish.sh index 0441d50c..c4545d85 100755 --- a/extensions/react-widget/publish.sh +++ b/extensions/react-widget/publish.sh @@ -2,6 +2,7 @@ ## chmod +x publish.sh - to upgrade ownership set -e cat package.json >> package_copy.json +cat package-lock.json >> package-lock_copy.json publish_package() { PACKAGE_NAME=$1 BUILD_COMMAND=$2 @@ -24,6 +25,9 @@ publish_package() { # Publish to npm npm publish + # Clean up + mv package_copy.json package.json + mv package-lock_copy.json package-lock.json echo "Published ${PACKAGE_NAME}" } @@ -33,7 +37,7 @@ publish_package "docsgpt" "build" # Publish docsgpt-react package publish_package "docsgpt-react" "build:react" -# Clean up -mv package_copy.json package.json + rm -rf package_copy.json +rm -rf package-lock_copy.json echo "---Process completed---" \ No newline at end of file From adb7132e02b29a32f175dd7c5083dabc69fd3042 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Thu, 5 Sep 2024 02:34:15 +0530 Subject: [PATCH 2/4] conversation: refined scrolling --- frontend/src/conversation/Conversation.tsx | 41 +++++++--------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index e585e784..cf477e8f 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -1,4 +1,4 @@ -import React, { Fragment, useEffect, useRef, useState } from 'react'; +import { Fragment, useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch, useSelector } from 'react-redux'; @@ -30,7 +30,7 @@ export default function Conversation() { const status = useSelector(selectStatus); const conversationId = useSelector(selectConversationId); const dispatch = useDispatch(); - const endMessageRef = useRef(null); + const conversationRef = useRef(null); const inputRef = useRef(null); const [isDarkTheme] = useDarkTheme(); const [hasScrolledToLast, setHasScrolledToLast] = useState(true); @@ -58,26 +58,6 @@ export default function Conversation() { fetchStream.current && fetchStream.current.abort(); }, [conversationId]); - useEffect(() => { - const observerCallback: IntersectionObserverCallback = (entries) => { - entries.forEach((entry) => { - setHasScrolledToLast(entry.isIntersecting); - }); - }; - - const observer = new IntersectionObserver(observerCallback, { - root: null, - threshold: [1, 0.8], - }); - if (endMessageRef.current) { - observer.observe(endMessageRef.current); - } - - return () => { - observer.disconnect(); - }; - }, [endMessageRef.current]); - useEffect(() => { if (queries.length) { queries[queries.length - 1].error && setLastQueryReturnedErr(true); @@ -86,10 +66,16 @@ export default function Conversation() { }, [queries[queries.length - 1]]); const scrollIntoView = () => { - endMessageRef?.current?.scrollIntoView({ - behavior: 'smooth', - block: 'start', - }); + if (!conversationRef?.current || eventInterrupt) return; + + if (status === 'idle') { + conversationRef.current.scrollTo({ + behavior: 'smooth', + top: conversationRef.current.scrollHeight, + }); + } else { + conversationRef.current.scrollTop = conversationRef.current.scrollHeight; + } }; const handleQuestion = ({ @@ -143,7 +129,6 @@ export default function Conversation() { if (query.response) { responseView = ( )}
Date: Thu, 5 Sep 2024 03:07:32 +0530 Subject: [PATCH 3/4] fix: wrap code without a match --- frontend/src/conversation/ConversationBubble.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 7ec98820..cd8cc1e8 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -250,7 +250,10 @@ const ConversationBubble = forwardRef<
) : ( - + {children} ); From a8582be54dfd31b0e8249a0eb254ab61fc37ee9b Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Thu, 5 Sep 2024 03:17:14 +0530 Subject: [PATCH 4/4] smooth transition to new input --- frontend/src/conversation/Conversation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index cf477e8f..01b8a2de 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -68,7 +68,7 @@ export default function Conversation() { const scrollIntoView = () => { if (!conversationRef?.current || eventInterrupt) return; - if (status === 'idle') { + if (status === 'idle' || !queries[queries.length - 1].response) { conversationRef.current.scrollTo({ behavior: 'smooth', top: conversationRef.current.scrollHeight,