feat(core): add get session graphql api (#12237)

Close [AI-116](https://linear.app/affine-design/issue/AI-116)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added the ability to retrieve detailed information for a specific Copilot session by its ID, including model metadata and optional models, via the user interface and API.
  - Session data now includes additional fields such as the model used and a list of optional models.
  - Enhanced GraphQL queries and UI components to support fetching and displaying these new session details.

- **Improvements**
  - Session lists now provide richer information, including model details, for each session.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
akumatus
2025-05-15 04:55:50 +00:00
parent 6052743671
commit fcc9b31da9
10 changed files with 173 additions and 20 deletions

View File

@@ -380,6 +380,10 @@ declare global {
docId?: string,
options?: { action?: boolean }
) => Promise<CopilotSessionType[] | undefined>;
getSession: (
workspaceId: string,
sessionId: string
) => Promise<CopilotSessionType | undefined>;
updateSession: (sessionId: string, promptName: string) => Promise<string>;
}

View File

@@ -11,6 +11,7 @@ import {
forkCopilotSessionMutation,
getCopilotHistoriesQuery,
getCopilotHistoryIdsQuery,
getCopilotSessionQuery,
getCopilotSessionsQuery,
type GraphQLQuery,
listContextObjectQuery,
@@ -136,6 +137,18 @@ export class CopilotClient {
}
}
async getSession(workspaceId: string, sessionId: string) {
try {
const res = await this.gql({
query: getCopilotSessionQuery,
variables: { sessionId, workspaceId },
});
return res.currentUser?.copilot?.session;
} catch (err) {
throw resolveError(err);
}
}
async getSessions(
workspaceId: string,
docId?: string,

View File

@@ -579,6 +579,9 @@ Could you make a new website based on these notes and send back just the html fi
AIProvider.provide('session', {
createSession,
getSession: async (workspaceId: string, sessionId: string) => {
return client.getSession(workspaceId, sessionId);
},
getSessions: async (
workspaceId: string,
docId?: string,