diff --git a/packages/backend/server/src/plugins/copilot/context/resolver.ts b/packages/backend/server/src/plugins/copilot/context/resolver.ts index 7ba20a236..d585486e6 100644 --- a/packages/backend/server/src/plugins/copilot/context/resolver.ts +++ b/packages/backend/server/src/plugins/copilot/context/resolver.ts @@ -146,7 +146,11 @@ export class CopilotContextRootResolver { if (!lock) { return new TooManyRequest('Server is busy'); } - await this.checkChatSession(user, sessionId, copilot.workspaceId); + await this.checkChatSession( + user, + sessionId, + copilot.workspaceId || undefined + ); if (contextId) { const context = await this.context.get(contextId); diff --git a/packages/backend/server/src/plugins/copilot/resolver.ts b/packages/backend/server/src/plugins/copilot/resolver.ts index fc9c916a7..7c9703b76 100644 --- a/packages/backend/server/src/plugins/copilot/resolver.ts +++ b/packages/backend/server/src/plugins/copilot/resolver.ts @@ -196,7 +196,7 @@ class CopilotHistoriesType implements Partial { description: 'An mark identifying which view to use to display the session', nullable: true, }) - action!: string | undefined; + action!: string | null; @Field(() => Number, { description: 'The number of tokens used in the session', @@ -281,7 +281,7 @@ class CopilotSessionType { id!: string; @Field(() => ID, { nullable: true }) - parentSessionId!: string | undefined; + parentSessionId!: string | null; @Field(() => String) promptName!: string; @@ -292,10 +292,7 @@ class CopilotSessionType { @ObjectType('Copilot') export class CopilotType { @Field(() => ID, { nullable: true }) - workspaceId!: string | undefined; - - @Field(() => ID, { nullable: true }) - docId!: string | undefined; + workspaceId!: string | null; } @Throttle() @@ -575,7 +572,7 @@ export class UserCopilotResolver { .allowLocal() .assert('Workspace.Copilot'); } - return { workspaceId }; + return { workspaceId: workspaceId || null }; } } diff --git a/packages/backend/server/src/plugins/copilot/session.ts b/packages/backend/server/src/plugins/copilot/session.ts index 94ec7bea3..cdbedf0cd 100644 --- a/packages/backend/server/src/plugins/copilot/session.ts +++ b/packages/backend/server/src/plugins/copilot/session.ts @@ -409,7 +409,7 @@ export class ChatSessionService { ): Promise< Array<{ id: string; - parentSessionId?: string; + parentSessionId: string | null; promptName: string; }> > { @@ -433,7 +433,7 @@ export class ChatSessionService { .then(sessions => sessions.map(({ id, parentSessionId, promptName }) => ({ id, - parentSessionId: parentSessionId || undefined, + parentSessionId: parentSessionId || null, promptName, })) ); @@ -548,7 +548,7 @@ export class ChatSessionService { return { sessionId: id, - action: prompt.action || undefined, + action: prompt.action || null, tokens: tokenCost, createdAt, messages: preload.concat(ret.data), diff --git a/packages/backend/server/src/plugins/copilot/types.ts b/packages/backend/server/src/plugins/copilot/types.ts index 9070b406e..a8ee21e12 100644 --- a/packages/backend/server/src/plugins/copilot/types.ts +++ b/packages/backend/server/src/plugins/copilot/types.ts @@ -101,7 +101,7 @@ export type SubmittedMessage = z.infer; export const ChatHistorySchema = z .object({ sessionId: z.string(), - action: z.string().optional(), + action: z.string().nullable(), tokens: z.number(), messages: z.array(PromptMessageSchema.or(ChatMessageSchema)), createdAt: z.date(), diff --git a/packages/backend/server/src/schema.gql b/packages/backend/server/src/schema.gql index 57b0c723e..7893a4739 100644 --- a/packages/backend/server/src/schema.gql +++ b/packages/backend/server/src/schema.gql @@ -39,7 +39,6 @@ enum ContextFileStatus { type Copilot { """Get the context list of a session""" contexts(contextId: String, sessionId: String!): [CopilotContext!]! - docId: ID histories(docId: String, options: QueryChatHistoriesInput): [CopilotHistories!]! """Get the quota of the user in the workspace""" diff --git a/packages/frontend/graphql/src/schema.ts b/packages/frontend/graphql/src/schema.ts index 4c9e1774e..3d6870d97 100644 --- a/packages/frontend/graphql/src/schema.ts +++ b/packages/frontend/graphql/src/schema.ts @@ -78,7 +78,6 @@ export interface Copilot { __typename?: 'Copilot'; /** Get the context list of a session */ contexts: Array; - docId: Maybe; histories: Array; /** Get the quota of the user in the workspace */ quota: CopilotQuota;