Skip to content

Commit

Permalink
RHCLOUD-29601 Allow to minimize the assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
josejulio committed Dec 8, 2023
1 parent 7f94d46 commit 8b85f0c
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ import { commandMessageProcessor } from './CommandMessageProcessor';
const messageProcessors = [commandMessageProcessor];

export const AstroVirtualAssistant: FunctionComponent = () => {
const { messages, ask, start, stop, status } = useAstro(messageProcessors);
const { messages, ask, start, status } = useAstro(messageProcessors);
const [isOpen, setOpen] = useState<boolean>(false);

useEffect(() => {
if (isOpen) {
void start();
} else {
void stop();
}
}, [isOpen]);

return (
<Stack className="astro-wrapper-stack">
<StackItem className="pf-v5-u-box-shadow-lg">
{status === Status.STARTED && <AstroChat key="astro-chat" messages={messages} ask={ask} onClose={() => setOpen(false)} />}
{status === Status.LOADING && <AstroChatSkeleton />}
{status === Status.STARTED && isOpen && <AstroChat key="astro-chat" messages={messages} ask={ask} onClose={() => setOpen(false)} />}
{status === Status.LOADING && isOpen && <AstroChatSkeleton />}
</StackItem>
<StackItem className="astro-wrapper-stack__badge">
<AstroBadge onClick={() => setOpen((prev) => !prev)} />
Expand Down

0 comments on commit 8b85f0c

Please sign in to comment.