Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | 'use client'; |
| 2 | |
| 3 | import { useSyncExternalStore } from 'react'; |
| 4 | |
| 5 | /** |
| 6 | * Tiny open/close store for the Eve chat panel, so any "Ask AI" trigger can |
| 7 | * open it without prop-drilling. Mirrors the old decimal-widget toggle surface. |
| 8 | */ |
| 9 | |
| 10 | let open = false; |
| 11 | const listeners = new Set<() => void>(); |
| 12 | |
| 13 | function emit() { |
| 14 | for (const listener of listeners) listener(); |
| 15 | } |
| 16 | |
| 17 | export function openEveChat() { |
| 18 | if (open) return; |
| 19 | open = true; |
| 20 | emit(); |
| 21 | } |
| 22 | |
| 23 | export function closeEveChat() { |
| 24 | if (!open) return; |
| 25 | open = false; |
| 26 | emit(); |
| 27 | } |
| 28 | |
| 29 | export function toggleEveChat() { |
| 30 | open = !open; |
| 31 | emit(); |
| 32 | } |
| 33 | |
| 34 | export function useEveChatOpen(): boolean { |
| 35 | return useSyncExternalStore( |
| 36 | (callback) => { |
| 37 | listeners.add(callback); |
| 38 | return () => listeners.delete(callback); |
| 39 | }, |
| 40 | () => open, |
| 41 | () => false, |
| 42 | ); |
| 43 | } |