Skip to content

The open alternative to Salesforce, designed for AI.

Remove the unused addAgentChatThreadParticipants mutation (#27557)

Félix Malfait188832dae839
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
index 6af14c04727..b442ace652c 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql
@@ -2952,7 +2952,6 @@ enum ModelFamily {
type Mutation {
activateSkill(id: UUID!): Skill!
activateWorkspace(data: ActivateWorkspaceInput!): Workspace!
- addAgentChatThreadParticipants(threadId: UUID!, workspaceMemberIds: [UUID!]!): [UUID!]!
addQueryToEventStream(input: AddQuerySubscriptionInput!): Boolean!
assignAgentChatThread(assigneeWorkspaceMemberId: UUID, threadId: UUID!): Boolean!
assignRoleToAgent(agentId: UUID!, roleId: UUID!): Boolean!
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
index 3e697c6e67e..139722c64d8 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts
@@ -1994,7 +1994,6 @@ export type ModelFamily = 'CLAUDE' | 'GEMINI' | 'GPT' | 'GROK' | 'MISTRAL'
export interface Mutation {
activateSkill: Skill
activateWorkspace: Workspace
- addAgentChatThreadParticipants: Scalars['UUID'][]
addQueryToEventStream: Scalars['Boolean']
assignAgentChatThread: Scalars['Boolean']
assignRoleToAgent: Scalars['Boolean']
@@ -6159,7 +6158,6 @@ export interface MinimalViewGenqlSelection{
export interface MutationGenqlSelection{
activateSkill?: (SkillGenqlSelection & { __args: {id: Scalars['UUID']} })
activateWorkspace?: (WorkspaceGenqlSelection & { __args: {data: ActivateWorkspaceInput} })
- addAgentChatThreadParticipants?: { __args: {threadId: Scalars['UUID'], workspaceMemberIds: Scalars['UUID'][]} }
addQueryToEventStream?: { __args: {input: AddQuerySubscriptionInput} }
assignAgentChatThread?: { __args: {assigneeWorkspaceMemberId?: (Scalars['UUID'] | null), threadId: Scalars['UUID']} }
assignRoleToAgent?: { __args: {agentId: Scalars['UUID'], roleId: Scalars['UUID']} }
diff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.ts
index d9e52eddf0f..927cd4c3d9f 100644
--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts
+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts
@@ -5944,19 +5944,6 @@ export default {
]
}
],
- "addAgentChatThreadParticipants": [
- 482,
- {
- "threadId": [
- 482,
- "UUID!"
- ],
- "workspaceMemberIds": [
- 482,
- "[UUID!]!"
- ]
- }
- ],
"addQueryToEventStream": [
4,
{
diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts
index f96574297b1..8bf06b42708 100644
--- a/packages/twenty-front/src/generated-metadata/graphql.ts
+++ b/packages/twenty-front/src/generated-metadata/graphql.ts
@@ -3113,7 +3113,6 @@ export type Mutation = {
__typename?: 'Mutation';
activateSkill: Skill;
activateWorkspace: Workspace;
- addAgentChatThreadParticipants: Array<Scalars['UUID']['output']>;
addQueryToEventStream: Scalars['Boolean']['output'];
assignAgentChatThread: Scalars['Boolean']['output'];
assignRoleToAgent: Scalars['Boolean']['output'];
@@ -3401,12 +3400,6 @@ export type MutationActivateWorkspaceArgs = {
};
-export type MutationAddAgentChatThreadParticipantsArgs = {
- threadId: Scalars['UUID']['input'];
- workspaceMemberIds: Array<Scalars['UUID']['input']>;
-};
-
-
export type MutationAddQueryToEventStreamArgs = {
input: AddQuerySubscriptionInput;
};
diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/agent-chat-thread-participant.resolver.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/agent-chat-thread-participant.resolver.ts
index a4284db084b..6e0c715ee1a 100644
--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/agent-chat-thread-participant.resolver.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-chat/resolvers/agent-chat-thread-participant.resolver.ts
@@ -107,21 +107,4 @@ export class AgentChatThreadParticipantResolver {
return true;
}
-
- // Returns the members who were added, leaving out those who cannot reply in the chat
- @Mutation(() => [UUIDScalarType])
- async addAgentChatThreadParticipants(
- @Args('threadId', { type: () => UUIDScalarType }) threadId: string,
- @Args('workspaceMemberIds', { type: () => [UUIDScalarType] })
- participantWorkspaceMemberIds: string[],
- @AuthWorkspaceMemberId() workspaceMemberId: string,
- @AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
- ): Promise<string[]> {
- return this.threadService.addParticipants({
- threadId,
- participantWorkspaceMemberIds,
- workspaceMemberId,
- workspaceId,
- });
- }
}
diff --git a/packages/twenty-server/test/integration/endpoint-permissions/__snapshots__/endpoint-permission-declarations.integration-spec.ts.snap b/packages/twenty-server/test/integration/endpoint-permissions/__snapshots__/endpoint-permission-declarations.integration-spec.ts.snap
index 42a1902e2a8..adc8bdfb82b 100644
--- a/packages/twenty-server/test/integration/endpoint-permissions/__snapshots__/endpoint-permission-declarations.integration-spec.ts.snap
+++ b/packages/twenty-server/test/integration/endpoint-permissions/__snapshots__/endpoint-permission-declarations.integration-spec.ts.snap
@@ -72,7 +72,6 @@ exports[`endpoint permission declarations should match the AuthPrincipalGuard an
"AgentChatResolver.sendChatMessage {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
"AgentChatResolver.stopAgentChatStream {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
"AgentChatSubscriptionResolver.onAgentChatEvent {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
- "AgentChatThreadParticipantResolver.addAgentChatThreadParticipants {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
"AgentChatThreadParticipantResolver.agentChatOpenThreadsSummary {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
"AgentChatThreadParticipantResolver.assignAgentChatThread {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
"AgentChatThreadParticipantResolver.updateAgentChatThreadInboxState {"applicationTarget":null,"authPrincipalGuards":[{"apiKey":false,"application":{"withUser":true,"withoutUser":false},"oauthClient":{"withUser":true,"withoutUser":false},"userSession":{"impersonated":true,"playground":true,"standard":true,"workspaceAgnostic":false}}]}",
diff --git a/packages/twenty-server/test/integration/graphql/suites/chat-thread-participant.integration-spec.ts b/packages/twenty-server/test/integration/graphql/suites/chat-thread-participant.integration-spec.ts
index afbc3a17762..3d9d916f536 100644
--- a/packages/twenty-server/test/integration/graphql/suites/chat-thread-participant.integration-spec.ts
+++ b/packages/twenty-server/test/integration/graphql/suites/chat-thread-participant.integration-spec.ts
@@ -22,6 +22,7 @@ import { AgentChatInboxAction } from 'src/engine/metadata-modules/ai/ai-chat/enu
import { type AgentChatSharingService } from 'src/engine/metadata-modules/ai/ai-chat/services/agent-chat-sharing.service';
import { type AgentChatThreadParticipantService } from 'src/engine/metadata-modules/ai/ai-chat/services/agent-chat-thread-participant.service';
import { type AgentChatThreadService } from 'src/engine/metadata-modules/ai/ai-chat/services/agent-chat-thread.service';
+import { AiExceptionCode } from 'src/engine/metadata-modules/ai/ai.exception';
import { type WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
import { getWorkspaceSchemaName } from 'src/engine/workspace-datasource/utils/get-workspace-schema-name.util';
import { type WorkspaceEventEmitter } from 'src/engine/workspace-event-emitter/workspace-event-emitter';
@@ -65,19 +66,19 @@ const readAssigneeId = async (threadId: string): Promise<string | null> => {
return assigneeId;
};
-const ADD_PARTICIPANTS = parse(
- `mutation AddParticipants($threadId: UUID!, $workspaceMemberIds: [UUID!]!) { addAgentChatThreadParticipants(threadId: $threadId, workspaceMemberIds: $workspaceMemberIds) }`,
-);
-
const addParticipants = (
threadId: string,
- workspaceMemberIds: string[],
- token: string = APPLE_JANE_ADMIN_ACCESS_TOKEN,
+ participantWorkspaceMemberIds: string[],
+ workspaceMemberId: string = WORKSPACE_MEMBER_DATA_SEED_IDS.JANE,
) =>
- makeMetadataApiRequest(
- { query: ADD_PARTICIPANTS, variables: { threadId, workspaceMemberIds } },
- token,
- );
+ getAppProviderByClassName<AgentChatThreadService>(
+ 'AgentChatThreadService',
+ ).addParticipants({
+ workspaceId: SEED_APPLE_WORKSPACE_ID,
+ workspaceMemberId,
+ threadId,
+ participantWorkspaceMemberIds,
+ });
type Participant = {
id: string;
@@ -768,15 +769,12 @@ describe('Chat thread participant state through the authenticated API', () => {
await findMyParticipant(threadId, APPLE_JONY_MEMBER_ACCESS_TOKEN),
).toBeUndefined();
- const response = await addParticipants(threadId, [
- WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
- WORKSPACE_MEMBER_DATA_SEED_IDS.JANE,
- ]);
-
- expect(response.body.errors).toBeUndefined();
- expect(response.body.data.addAgentChatThreadParticipants).toEqual([
- WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
- ]);
+ expect(
+ await addParticipants(threadId, [
+ WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
+ WORKSPACE_MEMBER_DATA_SEED_IDS.JANE,
+ ]),
+ ).toEqual([WORKSPACE_MEMBER_DATA_SEED_IDS.JONY]);
expect(
await findMyParticipant(threadId, APPLE_JONY_MEMBER_ACCESS_TOKEN),
).toMatchObject({ lastReadAt: null, archivedAt: null, snoozedUntil: null });
@@ -785,16 +783,13 @@ describe('Chat thread participant state through the authenticated API', () => {
).toEqual([WORKSPACE_MEMBER_DATA_SEED_IDS.JONY]);
// Editors can mention others too; the owner keeps following as owner
- const addedByJony = await addParticipants(
- threadId,
- [WORKSPACE_MEMBER_DATA_SEED_IDS.JANE],
- APPLE_JONY_MEMBER_ACCESS_TOKEN,
- );
-
- expect(addedByJony.body.errors).toBeUndefined();
- expect(addedByJony.body.data.addAgentChatThreadParticipants).toEqual([
- WORKSPACE_MEMBER_DATA_SEED_IDS.JANE,
- ]);
+ expect(
+ await addParticipants(
+ threadId,
+ [WORKSPACE_MEMBER_DATA_SEED_IDS.JANE],
+ WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
+ ),
+ ).toEqual([WORKSPACE_MEMBER_DATA_SEED_IDS.JANE]);
expect(await findMyParticipant(threadId)).toMatchObject({
lastReadAt: null,
});
@@ -828,13 +823,13 @@ describe('Chat thread participant state through the authenticated API', () => {
await setShareWithJony(threadId, true);
- const response = await addParticipants(
- threadId,
- [WORKSPACE_MEMBER_DATA_SEED_IDS.TIM],
- APPLE_JONY_MEMBER_ACCESS_TOKEN,
- );
-
- expect(response.body.errors[0].extensions.code).toBe('NOT_FOUND');
+ await expect(
+ addParticipants(
+ threadId,
+ [WORKSPACE_MEMBER_DATA_SEED_IDS.TIM],
+ WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
+ ),
+ ).rejects.toMatchObject({ code: AiExceptionCode.THREAD_NOT_FOUND });
expect(
(await readThreadActivity(threadId)).writerWorkspaceMemberIds ?? [],
).toEqual([]);
@@ -856,14 +851,13 @@ describe('Chat thread participant state through the authenticated API', () => {
enabled: true,
});
- const response = await addParticipants(
- threadId,
- [WORKSPACE_MEMBER_DATA_SEED_IDS.TIM],
- APPLE_JONY_MEMBER_ACCESS_TOKEN,
- );
-
- expect(response.body.errors).toBeUndefined();
- expect(response.body.data.addAgentChatThreadParticipants).toEqual([]);
+ expect(
+ await addParticipants(
+ threadId,
+ [WORKSPACE_MEMBER_DATA_SEED_IDS.TIM],
+ WORKSPACE_MEMBER_DATA_SEED_IDS.JONY,
+ ),
+ ).toEqual([]);
expect(
(await readThreadActivity(threadId)).writerWorkspaceMemberIds ?? [],
).toEqual([]);