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) { if (!lock) {
return new TooManyRequest('Server is busy'); return new TooManyRequest('Server is busy');
} }
await this.checkChatSession(user, sessionId, copilot.workspaceId); await this.checkChatSession(
user,
sessionId,
copilot.workspaceId || undefined
);
if (contextId) { if (contextId) {
const context = await this.context.get(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', description: 'An mark identifying which view to use to display the session',
nullable: true, nullable: true,
}) })
action!: string | undefined; action!: string | null;
@Field(() => Number, { @Field(() => Number, {
description: 'The number of tokens used in the session', description: 'The number of tokens used in the session',
@@ -281,7 +281,7 @@ class CopilotSessionType {
id!: string; id!: string;
@Field(() => ID, { nullable: true }) @Field(() => ID, { nullable: true })
parentSessionId!: string | undefined; parentSessionId!: string | null;
@Field(() => String) @Field(() => String)
promptName!: string; promptName!: string;
@@ -292,10 +292,7 @@ class CopilotSessionType {
@ObjectType('Copilot') @ObjectType('Copilot')
export class CopilotType { export class CopilotType {
@Field(() => ID, { nullable: true }) @Field(() => ID, { nullable: true })
workspaceId!: string | undefined; workspaceId!: string | null;
@Field(() => ID, { nullable: true })
docId!: string | undefined;
} }
@Throttle() @Throttle()
@@ -575,7 +572,7 @@ export class UserCopilotResolver {
.allowLocal() .allowLocal()
.assert('Workspace.Copilot'); .assert('Workspace.Copilot');
} }
return { workspaceId }; return { workspaceId: workspaceId || null };
} }
} }

View File

@@ -409,7 +409,7 @@ export class ChatSessionService {
): Promise< ): Promise<
Array<{ Array<{
id: string; id: string;
parentSessionId?: string; parentSessionId: string | null;
promptName: string; promptName: string;
}> }>
> { > {
@@ -433,7 +433,7 @@ export class ChatSessionService {
.then(sessions => .then(sessions =>
sessions.map(({ id, parentSessionId, promptName }) => ({ sessions.map(({ id, parentSessionId, promptName }) => ({
id, id,
parentSessionId: parentSessionId || undefined, parentSessionId: parentSessionId || null,
promptName, promptName,
})) }))
); );
@@ -548,7 +548,7 @@ export class ChatSessionService {
return { return {
sessionId: id, sessionId: id,
action: prompt.action || undefined, action: prompt.action || null,
tokens: tokenCost, tokens: tokenCost,
createdAt, createdAt,
messages: preload.concat(ret.data), messages: preload.concat(ret.data),

View File

@@ -101,7 +101,7 @@ export type SubmittedMessage = z.infer<typeof SubmittedMessageSchema>;
export const ChatHistorySchema = z export const ChatHistorySchema = z
.object({ .object({
sessionId: z.string(), sessionId: z.string(),
action: z.string().optional(), action: z.string().nullable(),
tokens: z.number(), tokens: z.number(),
messages: z.array(PromptMessageSchema.or(ChatMessageSchema)), messages: z.array(PromptMessageSchema.or(ChatMessageSchema)),
createdAt: z.date(), createdAt: z.date(),

View File

@@ -39,7 +39,6 @@ enum ContextFileStatus {
type Copilot { type Copilot {
"""Get the context list of a session""" """Get the context list of a session"""
contexts(contextId: String, sessionId: String!): [CopilotContext!]! contexts(contextId: String, sessionId: String!): [CopilotContext!]!
docId: ID
histories(docId: String, options: QueryChatHistoriesInput): [CopilotHistories!]! histories(docId: String, options: QueryChatHistoriesInput): [CopilotHistories!]!
"""Get the quota of the user in the workspace""" """Get the quota of the user in the workspace"""

View File

@@ -78,7 +78,6 @@ export interface Copilot {
__typename?: 'Copilot'; __typename?: 'Copilot';
/** Get the context list of a session */ /** Get the context list of a session */
contexts: Array<CopilotContext>; contexts: Array<CopilotContext>;
docId: Maybe<Scalars['ID']['output']>;
histories: Array<CopilotHistories>; histories: Array<CopilotHistories>;
/** Get the quota of the user in the workspace */ /** Get the quota of the user in the workspace */
quota: CopilotQuota; quota: CopilotQuota;