refactor(core): get copilot sessions api (#10168)

Fix issue [BS-2575](https://linear.app/affine-design/issue/BS-2575).

### What Changed?
- Refactor `getCopilotSessions` api.
  - Add `docId` parameter.
  - Add `action` parameter.
This commit is contained in:
akumatus
2025-02-14 06:57:57 +00:00
parent f20e3f6d8f
commit 1bf1832211
10 changed files with 82 additions and 96 deletions

View File

@@ -1,8 +1,11 @@
query getCopilotSessions($workspaceId: String!) {
query getCopilotSessions(
$workspaceId: String!
$docId: String
$options: QueryChatSessionsInput
) {
currentUser {
copilot(workspaceId: $workspaceId) {
actions
chats
sessionIds(docId: $docId, options: $options)
}
}
}

View File

@@ -421,11 +421,10 @@ export const getCopilotSessionsQuery = {
definitionName: 'currentUser',
containsFile: false,
query: `
query getCopilotSessions($workspaceId: String!) {
query getCopilotSessions($workspaceId: String!, $docId: String, $options: QueryChatSessionsInput) {
currentUser {
copilot(workspaceId: $workspaceId) {
actions
chats
sessionIds(docId: $docId, options: $options)
}
}
}`,

View File

@@ -76,15 +76,14 @@ export enum ContextFileStatus {
export interface Copilot {
__typename?: 'Copilot';
/** Get the session list of actions in the workspace */
actions: Array<Scalars['String']['output']>;
/** Get the session list of chats in the workspace */
chats: Array<Scalars['String']['output']>;
/** Get the context list of a session */
contexts: Array<CopilotContext>;
docId: Maybe<Scalars['ID']['output']>;
histories: Array<CopilotHistories>;
/** Get the quota of the user in the workspace */
quota: CopilotQuota;
/** Get the session list in the workspace */
sessionIds: Array<Scalars['String']['output']>;
workspaceId: Maybe<Scalars['ID']['output']>;
}
@@ -98,6 +97,11 @@ export interface CopilotHistoriesArgs {
options?: InputMaybe<QueryChatHistoriesInput>;
}
export interface CopilotSessionIdsArgs {
docId?: InputMaybe<Scalars['String']['input']>;
options?: InputMaybe<QueryChatSessionsInput>;
}
export interface CopilotContext {
__typename?: 'CopilotContext';
/** list files in context */
@@ -1301,6 +1305,10 @@ export interface QueryChatHistoriesInput {
withPrompt?: InputMaybe<Scalars['Boolean']['input']>;
}
export interface QueryChatSessionsInput {
action?: InputMaybe<Scalars['Boolean']['input']>;
}
export interface QueryTooLongDataType {
__typename?: 'QueryTooLongDataType';
max: Scalars['Int']['output'];
@@ -2196,17 +2204,15 @@ export type UpdateCopilotSessionMutation = {
export type GetCopilotSessionsQueryVariables = Exact<{
workspaceId: Scalars['String']['input'];
docId?: InputMaybe<Scalars['String']['input']>;
options?: InputMaybe<QueryChatSessionsInput>;
}>;
export type GetCopilotSessionsQuery = {
__typename?: 'Query';
currentUser: {
__typename?: 'UserType';
copilot: {
__typename?: 'Copilot';
actions: Array<string>;
chats: Array<string>;
};
copilot: { __typename?: 'Copilot'; sessionIds: Array<string> };
} | null;
};