From 4af0f07deffaa65730ff9e0a1e9cd79079259298 Mon Sep 17 00:00:00 2001 From: Philippe Rolet Date: Fri, 1 Mar 2024 10:20:24 +0100 Subject: [PATCH] [Meru AB] Suggestions: don't show until not ready (#4080) When no instructions are typed, we show static suggestions. When instructions are typed, the static suggestions flash appear for a while => this is bad UX. This PR fixes that --- .../assistant_builder/InstructionScreen.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/front/components/assistant_builder/InstructionScreen.tsx b/front/components/assistant_builder/InstructionScreen.tsx index 22c15f231193..f9758a2b85d5 100644 --- a/front/components/assistant_builder/InstructionScreen.tsx +++ b/front/components/assistant_builder/InstructionScreen.tsx @@ -307,8 +307,11 @@ function Suggestions({ owner: WorkspaceType; instructions: string; }) { - const [suggestions, setSuggestions] = - useState(STATIC_SUGGESTIONS); + const [suggestions, setSuggestions] = useState( + !instructions + ? STATIC_SUGGESTIONS + : { status: "unavailable", reason: "irrelevant" } + ); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -342,6 +345,12 @@ function Suggestions({ debounce(debounceHandle, updateSuggestions); }, [instructions, updateSuggestions]); + if ( + suggestions.status === "unavailable" && + suggestions.reason === "irrelevant" + ) { + return null; + } return (
@@ -384,7 +393,10 @@ function Suggestions({ )); } - if (suggestions.status === "unavailable") { + if ( + suggestions.status === "unavailable" && + suggestions.reason === "user_not_finished" + ) { return ( Suggestions will appear when you're done writing.