From 2fb7c1ef341a92f8ef533c14f29574045cb07f82 Mon Sep 17 00:00:00 2001 From: Liao Hu <65468844+colinlaoaa@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:15:14 -0500 Subject: [PATCH] clear AutoGenAnalysis result when new session created. (#93) * clear AutoGenAnalysis result when new session created * comment fix * comment fix * comment fix --- .../panel/src/components/UserInputView.js | 14 +++++++++++-- solidportal/panel/src/pages/SolidPortal.js | 21 ++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/solidportal/panel/src/components/UserInputView.js b/solidportal/panel/src/components/UserInputView.js index ee7c8b68..461df064 100644 --- a/solidportal/panel/src/components/UserInputView.js +++ b/solidportal/panel/src/components/UserInputView.js @@ -18,10 +18,15 @@ const UserInputView = ({ showView, setGetAutoGenStatusCall, setSaveSetAutoGenTaskId, getAutoGenTaskId, + getAutoGenResult, + setIsFinal, setSaveOpenAIKey, setSaveUserRequirement, setSaveProductInfo, - setSaveSelectedGraphType + setSaveSelectedGraphType, + autoGenStatus, + setIsAutoGenNewSession, + isAutoGenNewSession }) => { const [selectedGraphType, setSelectedGraphType] = useState(GraphType.OnboardProject); const [openAIKey, setOpenAIKey] = useState(""); @@ -31,7 +36,7 @@ const UserInputView = ({ showView, const [productInfo, setProductInfo] = useState(""); const pollingInterval = 5000; const [uploadStatus, setUploadStatus] = useState(false) - const [isAutoGenNewSession, setIsAutoGenNewSession] = useState(true) + const disableStart = useRef(true) const userRequirementRef = useRef("") @@ -98,6 +103,7 @@ const UserInputView = ({ showView, } }, [uploadStatus, pollingInterval]); + const handleGraphTypeSelectChange = (e) => { setSelectedGraphType(e.target.value); setSaveSelectedGraphType(e.target.value); @@ -364,6 +370,9 @@ const UserInputView = ({ showView, } const AutoGenAnalysis = async ( requirement ) => { + if(requirement.toLowerCase().replace(/\s/g, '') === "confirm"){ + requirement = "" + } disableStart.current = true const requestBody = JSON.stringify({ openai_key: openAIKey, @@ -383,6 +392,7 @@ const UserInputView = ({ showView, setSaveSetAutoGenTaskId(response.data.task_id) setIsAutoGenNewSession(false) setGetAutoGenStatusCall(true) + getAutoGenResult.current = "" } else if (response.data.status === 2) { setIsAutoGenNewSession(true) } else if (response.data.status === 3) { diff --git a/solidportal/panel/src/pages/SolidPortal.js b/solidportal/panel/src/pages/SolidPortal.js index b0e69f50..5ea1c181 100644 --- a/solidportal/panel/src/pages/SolidPortal.js +++ b/solidportal/panel/src/pages/SolidPortal.js @@ -23,6 +23,7 @@ const SolidPortal = () => { const [status, setStatus] = useState(false) const [autoGenStatus, setAutoGenStatus] = useState(false) const [autoGenTaskId, setAutoGenTaskId] = useState(null) + const [isAutoGenNewSession, setIsAutoGenNewSession] = useState(true) let state_id = useRef(""); let autoGenResult = useRef(""); const [showTermsCondition, setShowTermsCondition] = useState(false) @@ -73,8 +74,12 @@ const SolidPortal = () => { setIsFinal(boolean) } + const saveIsAutoGenNewSession = (boolean) => { + setIsAutoGenNewSession(boolean) + } + const userInputView = ( - { setGetAutoGenStatusCall={saveGetAutoGenStatusCall} setSaveSetAutoGenTaskId={saveSetAutoGenTaskId} getAutoGenTaskId={autoGenTaskId} + getAutoGenResult={autoGenResult} setIsFinal={saveIsFinal} setSaveOpenAIKey={saveOpenAIKey} setSaveUserRequirement={saveUserRequirement} setSaveProductInfo={saveProductInfo} setSaveSelectedGraphType={saveSelectedGraphType} autoGenStatus={autoGenStatus} + setIsAutoGenNewSession={saveIsAutoGenNewSession} + isAutoGenNewSession={isAutoGenNewSession} /> ); - + // const [autoGenActivePlannerState, setAutoGenActivePlannerState] = useState(AutoGenActivePlannerState.Disable); // const activeAutoGenPlanner = async () => { @@ -195,7 +203,10 @@ const SolidPortal = () => { console.log(response.data) if (response.data.status === 1 || response.data.status === 2){ setMdEditorValue(response.data.message) - setAutoGenStatus(false) + setAutoGenStatus(false) + if (response.data.status === 2) { + setIsAutoGenNewSession(true) + } }else if(response.data.status === 3){ console.log(response.data.result) if (state_id.current !== response.data.result.state_id){ @@ -204,7 +215,7 @@ const SolidPortal = () => { setMdEditorValue(autoGenResult.current) setAutoGenStatus(false) // check current planner status - // await activeAutoGenPlanner() + // await activeAutoGenPlanner() } state_id.current = response.data.result.state_id; } @@ -308,7 +319,7 @@ const SolidPortal = () => { // if (response.data.status === 1) { // setAutoGenTaskId(response.data.task_id) // saveGetAutoGenStatusCall(true) - // } + // } // else if (response.data.status === 3) { // setAutoGenTaskId(response.data.task_id) // saveGetAutoGenStatusCall(true)