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 diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index e585e784..01b8a2de 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' || !queries[queries.length - 1].response) { + 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 = ( )}
) : ( - + {children} );