Files
twenty/packages/twenty-front/src/modules/ai/hooks/useAgentChatContextOrThrow.ts
T
Abdul Rahman 0648dc5c65 Fix AI chat streaming persistence when command menu closes (#14854)
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>
2025-10-03 12:37:41 +02:00

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;
};