diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index fc3365440..836979e30 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -2971,6 +2971,14 @@ export type WorkspaceUrlsAndId = { workspaceUrls: WorkspaceUrls; }; +export type AssignRoleToAgentMutationVariables = Exact<{ + agentId: Scalars['UUID']; + roleId: Scalars['UUID']; +}>; + + +export type AssignRoleToAgentMutation = { __typename?: 'Mutation', assignRoleToAgent: boolean }; + export type CreateAgentChatThreadMutationVariables = Exact<{ input: CreateAgentChatThreadInput; }>; @@ -2978,6 +2986,27 @@ export type CreateAgentChatThreadMutationVariables = Exact<{ export type CreateAgentChatThreadMutation = { __typename?: 'Mutation', createAgentChatThread: { __typename?: 'AgentChatThread', id: any, agentId: any, title?: string | null, createdAt: string, updatedAt: string } }; +export type RemoveRoleFromAgentMutationVariables = Exact<{ + agentId: Scalars['UUID']; +}>; + + +export type RemoveRoleFromAgentMutation = { __typename?: 'Mutation', removeRoleFromAgent: boolean }; + +export type UpdateOneAgentMutationVariables = Exact<{ + input: UpdateAgentInput; +}>; + + +export type UpdateOneAgentMutation = { __typename?: 'Mutation', updateOneAgent: { __typename?: 'Agent', id: any, name: string, description?: string | null, prompt: string, modelId: string, responseFormat?: any | null } }; + +export type FindOneAgentQueryVariables = Exact<{ + id: Scalars['UUID']; +}>; + + +export type FindOneAgentQuery = { __typename?: 'Query', findOneAgent: { __typename?: 'Agent', id: any, name: string, description?: string | null, prompt: string, modelId: string, responseFormat?: any | null, roleId?: any | null } }; + export type GetAgentChatMessagesQueryVariables = Exact<{ threadId: Scalars['String']; }>; @@ -3795,35 +3824,6 @@ export type UpdateWorkflowVersionStepMutationVariables = Exact<{ export type UpdateWorkflowVersionStepMutation = { __typename?: 'Mutation', updateWorkflowVersionStep: { __typename?: 'WorkflowAction', id: any, name: string, type: string, settings: any, valid: boolean, nextStepIds?: Array | null } }; -export type AssignRoleToAgentMutationVariables = Exact<{ - agentId: Scalars['UUID']; - roleId: Scalars['UUID']; -}>; - - -export type AssignRoleToAgentMutation = { __typename?: 'Mutation', assignRoleToAgent: boolean }; - -export type RemoveRoleFromAgentMutationVariables = Exact<{ - agentId: Scalars['UUID']; -}>; - - -export type RemoveRoleFromAgentMutation = { __typename?: 'Mutation', removeRoleFromAgent: boolean }; - -export type UpdateOneAgentMutationVariables = Exact<{ - input: UpdateAgentInput; -}>; - - -export type UpdateOneAgentMutation = { __typename?: 'Mutation', updateOneAgent: { __typename?: 'Agent', id: any, name: string, description?: string | null, prompt: string, modelId: string, responseFormat?: any | null } }; - -export type FindOneAgentQueryVariables = Exact<{ - id: Scalars['UUID']; -}>; - - -export type FindOneAgentQuery = { __typename?: 'Query', findOneAgent: { __typename?: 'Agent', id: any, name: string, description?: string | null, prompt: string, modelId: string, responseFormat?: any | null, roleId?: any | null } }; - export type SubmitFormStepMutationVariables = Exact<{ input: SubmitFormStepInput; }>; @@ -4169,6 +4169,38 @@ ${ObjectPermissionFragmentFragmentDoc} ${WorkspaceUrlsFragmentFragmentDoc} ${RoleFragmentFragmentDoc} ${AvailableWorkspacesFragmentFragmentDoc}`; +export const AssignRoleToAgentDocument = gql` + mutation AssignRoleToAgent($agentId: UUID!, $roleId: UUID!) { + assignRoleToAgent(agentId: $agentId, roleId: $roleId) +} + `; +export type AssignRoleToAgentMutationFn = Apollo.MutationFunction; + +/** + * __useAssignRoleToAgentMutation__ + * + * To run a mutation, you first call `useAssignRoleToAgentMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useAssignRoleToAgentMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [assignRoleToAgentMutation, { data, loading, error }] = useAssignRoleToAgentMutation({ + * variables: { + * agentId: // value for 'agentId' + * roleId: // value for 'roleId' + * }, + * }); + */ +export function useAssignRoleToAgentMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(AssignRoleToAgentDocument, options); + } +export type AssignRoleToAgentMutationHookResult = ReturnType; +export type AssignRoleToAgentMutationResult = Apollo.MutationResult; +export type AssignRoleToAgentMutationOptions = Apollo.BaseMutationOptions; export const CreateAgentChatThreadDocument = gql` mutation CreateAgentChatThread($input: CreateAgentChatThreadInput!) { createAgentChatThread(input: $input) { @@ -4206,6 +4238,116 @@ export function useCreateAgentChatThreadMutation(baseOptions?: Apollo.MutationHo export type CreateAgentChatThreadMutationHookResult = ReturnType; export type CreateAgentChatThreadMutationResult = Apollo.MutationResult; export type CreateAgentChatThreadMutationOptions = Apollo.BaseMutationOptions; +export const RemoveRoleFromAgentDocument = gql` + mutation RemoveRoleFromAgent($agentId: UUID!) { + removeRoleFromAgent(agentId: $agentId) +} + `; +export type RemoveRoleFromAgentMutationFn = Apollo.MutationFunction; + +/** + * __useRemoveRoleFromAgentMutation__ + * + * To run a mutation, you first call `useRemoveRoleFromAgentMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useRemoveRoleFromAgentMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [removeRoleFromAgentMutation, { data, loading, error }] = useRemoveRoleFromAgentMutation({ + * variables: { + * agentId: // value for 'agentId' + * }, + * }); + */ +export function useRemoveRoleFromAgentMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(RemoveRoleFromAgentDocument, options); + } +export type RemoveRoleFromAgentMutationHookResult = ReturnType; +export type RemoveRoleFromAgentMutationResult = Apollo.MutationResult; +export type RemoveRoleFromAgentMutationOptions = Apollo.BaseMutationOptions; +export const UpdateOneAgentDocument = gql` + mutation UpdateOneAgent($input: UpdateAgentInput!) { + updateOneAgent(input: $input) { + id + name + description + prompt + modelId + responseFormat + } +} + `; +export type UpdateOneAgentMutationFn = Apollo.MutationFunction; + +/** + * __useUpdateOneAgentMutation__ + * + * To run a mutation, you first call `useUpdateOneAgentMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateOneAgentMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [updateOneAgentMutation, { data, loading, error }] = useUpdateOneAgentMutation({ + * variables: { + * input: // value for 'input' + * }, + * }); + */ +export function useUpdateOneAgentMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(UpdateOneAgentDocument, options); + } +export type UpdateOneAgentMutationHookResult = ReturnType; +export type UpdateOneAgentMutationResult = Apollo.MutationResult; +export type UpdateOneAgentMutationOptions = Apollo.BaseMutationOptions; +export const FindOneAgentDocument = gql` + query FindOneAgent($id: UUID!) { + findOneAgent(input: {id: $id}) { + id + name + description + prompt + modelId + responseFormat + roleId + } +} + `; + +/** + * __useFindOneAgentQuery__ + * + * To run a query within a React component, call `useFindOneAgentQuery` and pass it any options that fit your needs. + * When your component renders, `useFindOneAgentQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useFindOneAgentQuery({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useFindOneAgentQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(FindOneAgentDocument, options); + } +export function useFindOneAgentLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(FindOneAgentDocument, options); + } +export type FindOneAgentQueryHookResult = ReturnType; +export type FindOneAgentLazyQueryHookResult = ReturnType; +export type FindOneAgentQueryResult = Apollo.QueryResult; export const GetAgentChatMessagesDocument = gql` query GetAgentChatMessages($threadId: String!) { agentChatMessages(threadId: $threadId) { @@ -8463,148 +8605,6 @@ export function useUpdateWorkflowVersionStepMutation(baseOptions?: Apollo.Mutati export type UpdateWorkflowVersionStepMutationHookResult = ReturnType; export type UpdateWorkflowVersionStepMutationResult = Apollo.MutationResult; export type UpdateWorkflowVersionStepMutationOptions = Apollo.BaseMutationOptions; -export const AssignRoleToAgentDocument = gql` - mutation AssignRoleToAgent($agentId: UUID!, $roleId: UUID!) { - assignRoleToAgent(agentId: $agentId, roleId: $roleId) -} - `; -export type AssignRoleToAgentMutationFn = Apollo.MutationFunction; - -/** - * __useAssignRoleToAgentMutation__ - * - * To run a mutation, you first call `useAssignRoleToAgentMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useAssignRoleToAgentMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [assignRoleToAgentMutation, { data, loading, error }] = useAssignRoleToAgentMutation({ - * variables: { - * agentId: // value for 'agentId' - * roleId: // value for 'roleId' - * }, - * }); - */ -export function useAssignRoleToAgentMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AssignRoleToAgentDocument, options); - } -export type AssignRoleToAgentMutationHookResult = ReturnType; -export type AssignRoleToAgentMutationResult = Apollo.MutationResult; -export type AssignRoleToAgentMutationOptions = Apollo.BaseMutationOptions; -export const RemoveRoleFromAgentDocument = gql` - mutation RemoveRoleFromAgent($agentId: UUID!) { - removeRoleFromAgent(agentId: $agentId) -} - `; -export type RemoveRoleFromAgentMutationFn = Apollo.MutationFunction; - -/** - * __useRemoveRoleFromAgentMutation__ - * - * To run a mutation, you first call `useRemoveRoleFromAgentMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useRemoveRoleFromAgentMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [removeRoleFromAgentMutation, { data, loading, error }] = useRemoveRoleFromAgentMutation({ - * variables: { - * agentId: // value for 'agentId' - * }, - * }); - */ -export function useRemoveRoleFromAgentMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(RemoveRoleFromAgentDocument, options); - } -export type RemoveRoleFromAgentMutationHookResult = ReturnType; -export type RemoveRoleFromAgentMutationResult = Apollo.MutationResult; -export type RemoveRoleFromAgentMutationOptions = Apollo.BaseMutationOptions; -export const UpdateOneAgentDocument = gql` - mutation UpdateOneAgent($input: UpdateAgentInput!) { - updateOneAgent(input: $input) { - id - name - description - prompt - modelId - responseFormat - } -} - `; -export type UpdateOneAgentMutationFn = Apollo.MutationFunction; - -/** - * __useUpdateOneAgentMutation__ - * - * To run a mutation, you first call `useUpdateOneAgentMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useUpdateOneAgentMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [updateOneAgentMutation, { data, loading, error }] = useUpdateOneAgentMutation({ - * variables: { - * input: // value for 'input' - * }, - * }); - */ -export function useUpdateOneAgentMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(UpdateOneAgentDocument, options); - } -export type UpdateOneAgentMutationHookResult = ReturnType; -export type UpdateOneAgentMutationResult = Apollo.MutationResult; -export type UpdateOneAgentMutationOptions = Apollo.BaseMutationOptions; -export const FindOneAgentDocument = gql` - query FindOneAgent($id: UUID!) { - findOneAgent(input: {id: $id}) { - id - name - description - prompt - modelId - responseFormat - roleId - } -} - `; - -/** - * __useFindOneAgentQuery__ - * - * To run a query within a React component, call `useFindOneAgentQuery` and pass it any options that fit your needs. - * When your component renders, `useFindOneAgentQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useFindOneAgentQuery({ - * variables: { - * id: // value for 'id' - * }, - * }); - */ -export function useFindOneAgentQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(FindOneAgentDocument, options); - } -export function useFindOneAgentLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(FindOneAgentDocument, options); - } -export type FindOneAgentQueryHookResult = ReturnType; -export type FindOneAgentLazyQueryHookResult = ReturnType; -export type FindOneAgentQueryResult = Apollo.QueryResult; export const SubmitFormStepDocument = gql` mutation SubmitFormStep($input: SubmitFormStepInput!) { submitFormStep(input: $input) diff --git a/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx b/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx index 05f894bb7..3cf0d370a 100644 --- a/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx +++ b/packages/twenty-front/src/modules/ai/components/AIChatMessage.tsx @@ -3,8 +3,8 @@ import styled from '@emotion/styled'; import { Avatar, IconDotsVertical, IconSparkles } from 'twenty-ui/display'; import { LightCopyIconButton } from '@/object-record/record-field/components/LightCopyIconButton'; -import { AgentChatFilePreview } from '@/workflow/workflow-steps/workflow-actions/ai-agent-action/components/AgentChatFilePreview'; -import { AgentChatMessageRole } from '@/workflow/workflow-steps/workflow-actions/ai-agent-action/constants/agent-chat-message-role'; +import { AgentChatFilePreview } from '@/ai/components/internal/AgentChatFilePreview'; +import { AgentChatMessageRole } from '@/ai/constants/agent-chat-message-role'; import { AgentChatMessage } from '~/generated/graphql'; import { beautifyPastDateRelativeToNow } from '~/utils/date-utils'; diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/AIChatTab.tsx b/packages/twenty-front/src/modules/ai/components/AIChatTab.tsx similarity index 78% rename from packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/AIChatTab.tsx rename to packages/twenty-front/src/modules/ai/components/AIChatTab.tsx index 398f4a57e..bb39232f6 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/AIChatTab.tsx +++ b/packages/twenty-front/src/modules/ai/components/AIChatTab.tsx @@ -7,7 +7,7 @@ import { useCreateNewAIChatThread } from '@/ai/hooks/useCreateNewAIChatThread'; import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu'; import { CommandMenuPages } from '@/command-menu/types/CommandMenuPages'; import { ScrollWrapper } from '@/ui/utilities/scroll/components/ScrollWrapper'; -import { AgentChatFileUpload } from '@/workflow/workflow-steps/workflow-actions/ai-agent-action/components/AgentChatFileUpload'; +import { AgentChatFileUploadButton } from '@/ai/components/internal/AgentChatFileUploadButton'; import { AIChatEmptyState } from '@/ai/components/AIChatEmptyState'; import { AIChatMessage } from '@/ai/components/AIChatMessage'; @@ -16,8 +16,12 @@ import { t } from '@lingui/core/macro'; import { useState } from 'react'; import { Button } from 'twenty-ui/input'; import { useAgentChat } from '../hooks/useAgentChat'; -import { AIChatSkeletonLoader } from './AIChatSkeletonLoader'; -import { AgentChatSelectedFilesPreview } from './AgentChatSelectedFilesPreview'; +import { AIChatSkeletonLoader } from '@/ai/components/internal/AIChatSkeletonLoader'; +import { AgentChatContextPreview } from '@/ai/components/internal/AgentChatContextPreview'; +import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataItemIdComponentState'; +import { SendMessageWithRecordsContextButton } from '@/ai/components/internal/SendMessageWithRecordsContextButton'; +import { SendMessageButton } from '@/ai/components/internal/SendMessageButton'; const StyledContainer = styled.div<{ isDraggingFile: boolean }>` background: ${({ theme }) => theme.background.primary}; @@ -63,10 +67,13 @@ export const AIChatTab = ({ }) => { const [isDraggingFile, setIsDraggingFile] = useState(false); + const contextStoreCurrentObjectMetadataItemId = useRecoilComponentValueV2( + contextStoreCurrentObjectMetadataItemIdComponentState, + ); + const { messages, isLoading, - handleSendMessage, input, handleInputChange, agentStreamingMessage, @@ -105,7 +112,7 @@ export const AIChatTab = ({ {isLoading && messages.length === 0 && } - +