Refactor useAgentChat hook and remove agentChatContextState

- Simplified useAgentChat hook by removing the agentChatContextState and related context handling.
- Deleted agentChatContextState file to streamline state management in the AI chat module.
This commit is contained in:
Abdul Rahman
2025-10-13 23:18:25 +05:30
parent afc518a056
commit 800b5b538d
2 changed files with 0 additions and 29 deletions
@@ -1,10 +1,6 @@
import { useRecoilState, useRecoilValue } from 'recoil';
import { useAgentChatContextOrThrow } from '@/ai/hooks/useAgentChatContextOrThrow';
import {
type AIChatObjectMetadataAndRecordContext,
agentChatContextState,
} from '@/ai/states/agentChatContextState';
import { agentChatSelectedFilesState } from '@/ai/states/agentChatSelectedFilesState';
import { currentAIChatThreadState } from '@/ai/states/currentAIChatThreadState';
import { useChat } from '@ai-sdk/react';
@@ -15,10 +11,6 @@ export const useAgentChat = (agentId: string) => {
const agentChatSelectedFiles = useRecoilValue(agentChatSelectedFilesState);
const [agentChatContext, setAgentChatContext] = useRecoilState(
agentChatContextState,
);
const currentAIChatThread = useRecoilValue(currentAIChatThreadState);
const [agentChatInput, setAgentChatInput] =
@@ -38,18 +30,10 @@ export const useAgentChat = (agentId: string) => {
isStreaming ||
agentChatSelectedFiles.length > 0;
const handleSetContext = async (
items: Array<AIChatObjectMetadataAndRecordContext>,
) => {
setAgentChatContext(items);
};
return {
handleInputChange: (value: string) => setAgentChatInput(value),
messages,
input: agentChatInput,
context: agentChatContext,
handleSetContext,
isLoading,
scrollWrapperId,
isStreaming,
@@ -1,13 +0,0 @@
import { atom } from 'recoil';
export type AIChatObjectMetadataAndRecordContext = {
type: 'objectMetadataId' | 'recordId';
id: string;
};
export const agentChatContextState = atom<
Array<AIChatObjectMetadataAndRecordContext>
>({
key: 'ai/agentChatContextState',
default: [],
});