feat(server): allow multiple session attach to doc (#12933)

fix AI-236
This commit is contained in:
DarkSky
2025-06-26 10:15:31 +08:00
committed by GitHub
parent e32c9a814a
commit 06f27e8d6a
14 changed files with 1304 additions and 306 deletions

View File

@@ -235,6 +235,12 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
@Field(() => String)
sessionId!: string;
@Field(() => String)
workspaceId!: string;
@Field(() => String, { nullable: true })
docId!: string | null;
@Field(() => Boolean)
pinned!: boolean;
@@ -254,6 +260,9 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
@Field(() => Date)
createdAt!: Date;
@Field(() => Date)
updatedAt!: Date;
}
@ObjectType('CopilotQuota')

View File

@@ -298,13 +298,16 @@ export class ChatSessionService {
const histories = await Promise.all(
sessions.map(
async ({
id,
userId: uid,
id,
workspaceId,
docId,
pinned,
promptName,
tokenCost,
messages,
createdAt,
updatedAt,
}) => {
try {
const prompt = await this.prompt.get(promptName);
@@ -341,10 +344,13 @@ export class ChatSessionService {
return {
sessionId: id,
workspaceId,
docId,
pinned,
action: prompt.action || null,
tokens: tokenCost,
createdAt,
updatedAt,
messages: preload.concat(ret.data).map(m => ({
...m,
attachments: m.attachments

View File

@@ -47,11 +47,14 @@ export type ChatMessage = z.infer<typeof ChatMessageSchema>;
export const ChatHistorySchema = z
.object({
sessionId: z.string(),
workspaceId: z.string(),
docId: z.string().nullable(),
pinned: z.boolean(),
action: z.string().nullable(),
tokens: z.number(),
messages: z.array(ChatMessageSchema),
createdAt: z.date(),
updatedAt: z.date(),
})
.strict();