feat(server): allow chat session dangling & pin session support (#12849)

fix AI-181
fix AI-179
fix AI-178
fix PD-2682
fix PD-2683
This commit is contained in:
DarkSky
2025-06-19 13:17:01 +08:00
committed by GitHub
parent d80bfac1d2
commit bd04930560
28 changed files with 1422 additions and 394 deletions
@@ -20,8 +20,9 @@ export const cleanObject = (
export async function createCopilotSession(
app: TestingApp,
workspaceId: string,
docId: string,
promptName: string
docId: string | null,
promptName: string,
pinned: boolean = false
): Promise<string> {
const res = await app.gql(
`
@@ -29,12 +30,73 @@ export async function createCopilotSession(
createCopilotSession(options: $options)
}
`,
{ options: { workspaceId, docId, promptName } }
{ options: { workspaceId, docId, promptName, pinned } }
);
return res.createCopilotSession;
}
export async function createWorkspaceCopilotSession(
app: TestingApp,
workspaceId: string,
promptName: string
): Promise<string> {
return createCopilotSession(app, workspaceId, null, promptName);
}
export async function createPinnedCopilotSession(
app: TestingApp,
workspaceId: string,
docId: string,
promptName: string
): Promise<string> {
return createCopilotSession(app, workspaceId, docId, promptName, true);
}
export async function createDocCopilotSession(
app: TestingApp,
workspaceId: string,
docId: string,
promptName: string
): Promise<string> {
return createCopilotSession(app, workspaceId, docId, promptName);
}
export async function getCopilotSession(
app: TestingApp,
workspaceId: string,
sessionId: string
): Promise<{
id: string;
docId: string | null;
parentSessionId: string | null;
pinned: boolean;
promptName: string;
}> {
const res = await app.gql(
`
query getCopilotSession(
$workspaceId: String!
$sessionId: String!
) {
currentUser {
copilot(workspaceId: $workspaceId) {
session(sessionId: $sessionId) {
id
docId
parentSessionId
pinned
promptName
}
}
}
}`,
{ workspaceId, sessionId }
);
return res.currentUser?.copilot?.session;
}
export async function updateCopilotSession(
app: TestingApp,
sessionId: string,