fix(server): nullable value for parent id (#10725)

This commit is contained in:
darkskygit
2025-03-12 03:53:32 +00:00
parent 1b62b4b625
commit 10605b3793
6 changed files with 13 additions and 14 deletions

View File

@@ -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);

View File

@@ -196,7 +196,7 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
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 };
}
}

View File

@@ -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),

View File

@@ -101,7 +101,7 @@ export type SubmittedMessage = z.infer<typeof SubmittedMessageSchema>;
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(),

View File

@@ -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"""