Skip to content

Commit

Permalink
[Meru AB] Suggestions: don't show until not ready (#4080)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
philipperolet authored Mar 1, 2024
1 parent 6fcce48 commit 4af0f07
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions front/components/assistant_builder/InstructionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,11 @@ function Suggestions({
owner: WorkspaceType;
instructions: string;
}) {
const [suggestions, setSuggestions] =
useState<BuilderSuggestionsType>(STATIC_SUGGESTIONS);
const [suggestions, setSuggestions] = useState<BuilderSuggestionsType>(
!instructions
? STATIC_SUGGESTIONS
: { status: "unavailable", reason: "irrelevant" }
);

const [loading, setLoading] = useState(false);
const [error, setError] = useState<APIError | null>(null);
Expand Down Expand Up @@ -342,6 +345,12 @@ function Suggestions({
debounce(debounceHandle, updateSuggestions);
}, [instructions, updateSuggestions]);

if (
suggestions.status === "unavailable" &&
suggestions.reason === "irrelevant"
) {
return null;
}
return (
<Collapsible defaultOpen>
<div className="flex flex-col gap-2">
Expand Down Expand Up @@ -384,7 +393,10 @@ function Suggestions({
</ContentMessage>
));
}
if (suggestions.status === "unavailable") {
if (
suggestions.status === "unavailable" &&
suggestions.reason === "user_not_finished"
) {
return (
<ContentMessage size="sm" variant="slate" title="">
Suggestions will appear when you're done writing.
Expand Down

0 comments on commit 4af0f07

Please sign in to comment.