0648dc5c65
Closes [#1583](https://github.com/twentyhq/core-team-issues/issues/1583) - Removed `messageId` column from `File` table and its references in code (unrelated to this PR) - Updated AI chat to use React Context API with persistent provider in `CommandMenuContainer` - Converted all AI chat component states to regular Recoil atoms (no instance context needed) --------- Co-authored-by: Félix Malfait <felix@twenty.com>
15 lines
419 B
TypeScript
15 lines
419 B
TypeScript
import { AgentChatContext } from '@/ai/contexts/AgentChatContext';
|
|
import { useContext } from 'react';
|
|
|
|
export const useAgentChatContextOrThrow = () => {
|
|
const context = useContext(AgentChatContext);
|
|
|
|
if (!context) {
|
|
throw new Error(
|
|
'AgentChatContext not found. Please wrap your component tree with <AgentChatContextProvider> before using useAgentChatContextOrThrow().',
|
|
);
|
|
}
|
|
|
|
return context;
|
|
};
|