feat(server): paginated list endpoint (#13026)

fix AI-323
This commit is contained in:
DarkSky
2025-07-08 17:11:58 +08:00
committed by GitHub
parent 8c49a45162
commit 6dac94d90a
36 changed files with 1136 additions and 702 deletions

View File

@@ -2,13 +2,13 @@ import type {
ContextMatchedDocChunk,
ContextMatchedFileChunk,
ContextWorkspaceEmbeddingStatus,
CopilotChatHistoryFragment,
CopilotContextCategory,
CopilotContextDoc,
CopilotContextFile,
CopilotHistories,
CopilotSessionType,
getCopilotHistoriesQuery,
QueryChatSessionsInput,
QueryChatHistoriesInput,
RequestOptions,
StreamObject,
UpdateChatSessionInput,
@@ -356,10 +356,10 @@ declare global {
interface AIHistory {
sessionId: string;
tokens: number;
action: string;
action: string | null;
createdAt: string;
messages: {
id: string; // message id
id: string | null; // message id
content: string;
createdAt: string;
role: MessageRole;
@@ -392,19 +392,19 @@ declare global {
interface AISessionService {
createSession: (options: AICreateSessionOptions) => Promise<string>;
getSession: (
workspaceId: string,
sessionId: string
) => Promise<CopilotChatHistoryFragment | undefined>;
getSessions: (
workspaceId: string,
docId?: string,
options?: QueryChatSessionsInput
) => Promise<CopilotSessionType[] | undefined>;
options?: QueryChatHistoriesInput
) => Promise<CopilotChatHistoryFragment[] | undefined>;
getRecentSessions: (
workspaceId: string,
limit?: number
) => Promise<AIRecentSession[] | undefined>;
getSession: (
workspaceId: string,
sessionId: string
) => Promise<CopilotSessionType | undefined>;
updateSession: (options: UpdateChatSessionInput) => Promise<string>;
}

View File

@@ -3,7 +3,7 @@ import type { FeatureFlagService } from '@affine/core/modules/feature-flag';
import type { WorkbenchService } from '@affine/core/modules/workbench';
import type {
ContextEmbedStatus,
CopilotSessionType,
CopilotChatHistoryFragment,
UpdateChatSessionInput,
} from '@affine/graphql';
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
@@ -103,7 +103,7 @@ export class ChatPanel extends SignalWatcher(
accessor affineWorkbenchService!: WorkbenchService;
@state()
accessor session: CopilotSessionType | null | undefined;
accessor session: CopilotChatHistoryFragment | null | undefined;
@state()
accessor embeddingProgress: [number, number] = [0, 0];
@@ -170,7 +170,7 @@ export class ChatPanel extends SignalWatcher(
};
private readonly setSession = (
session: CopilotSessionType | null | undefined
session: CopilotChatHistoryFragment | null | undefined
) => {
this.session = session ?? null;
};
@@ -250,7 +250,7 @@ export class ChatPanel extends SignalWatcher(
};
private readonly openSession = async (sessionId: string) => {
if (this.session?.id === sessionId) {
if (this.session?.sessionId === sessionId) {
return;
}
this.resetPanel();
@@ -263,7 +263,7 @@ export class ChatPanel extends SignalWatcher(
private readonly openDoc = async (docId: string, sessionId: string) => {
if (this.doc.id === docId) {
if (this.session?.id === sessionId || this.session?.pinned) {
if (this.session?.sessionId === sessionId || this.session?.pinned) {
return;
}
await this.openSession(sessionId);
@@ -284,7 +284,7 @@ export class ChatPanel extends SignalWatcher(
await this.createSession({ pinned });
} else {
await this.updateSession({
sessionId: this.session.id,
sessionId: this.session.sessionId,
pinned,
});
}
@@ -296,7 +296,7 @@ export class ChatPanel extends SignalWatcher(
}
if (this.session.docId !== this.doc.id) {
await this.updateSession({
sessionId: this.session.id,
sessionId: this.session.sessionId,
docId: this.doc.id,
});
}
@@ -399,7 +399,7 @@ export class ChatPanel extends SignalWatcher(
return html`<div class="chat-panel-container">
${keyed(
this.hasPinned ? this.session?.id : this.doc.id,
this.hasPinned ? this.session?.sessionId : this.doc.id,
html`<ai-chat-content
.chatTitle=${this.chatTitle}
.host=${this.host}

View File

@@ -1,5 +1,5 @@
import type { FeatureFlagService } from '@affine/core/modules/feature-flag';
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { WithDisposable } from '@blocksuite/affine/global/lit';
import { isInsidePageEditor } from '@blocksuite/affine/shared/utils';
import type { EditorHost } from '@blocksuite/affine/std';
@@ -57,7 +57,7 @@ export class ChatMessageAssistant extends WithDisposable(ShadowlessElement) {
accessor affineFeatureFlagService!: FeatureFlagService;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor retry!: () => void;

View File

@@ -4,10 +4,10 @@ import type { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import type {
ContextEmbedStatus,
ContextWorkspaceEmbeddingStatus,
CopilotChatHistoryFragment,
CopilotContextDoc,
CopilotContextFile,
CopilotDocType,
CopilotSessionType,
} from '@affine/graphql';
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
import type { EditorHost } from '@blocksuite/affine/std';
@@ -63,10 +63,12 @@ export class AIChatComposer extends SignalWatcher(
accessor docId: string | undefined;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor createSession!: () => Promise<CopilotSessionType | undefined>;
accessor createSession!: () => Promise<
CopilotChatHistoryFragment | undefined
>;
@property({ attribute: false })
accessor chatContextValue!: AIChatInputContext;
@@ -178,7 +180,7 @@ export class AIChatComposer extends SignalWatcher(
return this._contextId;
}
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
if (!sessionId) return;
const contextId = await AIProvider.context?.getContextId(
@@ -194,7 +196,7 @@ export class AIChatComposer extends SignalWatcher(
return this._contextId;
}
const sessionId = (await this.createSession())?.id;
const sessionId = (await this.createSession())?.sessionId;
if (!sessionId) return;
this._contextId = await AIProvider.context?.createContext(
@@ -206,7 +208,7 @@ export class AIChatComposer extends SignalWatcher(
private readonly _initChips = async () => {
// context not initialized
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
const contextId = await this._getContextId();
if (!sessionId || !contextId) {
return;
@@ -282,7 +284,7 @@ export class AIChatComposer extends SignalWatcher(
};
private readonly _pollContextDocsAndFiles = async () => {
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
const contextId = await this._getContextId();
if (!sessionId || !contextId || !AIProvider.context) {
return;

View File

@@ -1,6 +1,9 @@
import type { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import type { FeatureFlagService } from '@affine/core/modules/feature-flag';
import type { ContextEmbedStatus, CopilotSessionType } from '@affine/graphql';
import type {
ContextEmbedStatus,
CopilotChatHistoryFragment,
} from '@affine/graphql';
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
import type { EditorHost } from '@blocksuite/affine/std';
import { ShadowlessElement } from '@blocksuite/affine/std';
@@ -123,10 +126,12 @@ export class AIChatContent extends SignalWatcher(
accessor host: EditorHost | null | undefined;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor createSession!: () => Promise<CopilotSessionType | undefined>;
accessor createSession!: () => Promise<
CopilotChatHistoryFragment | undefined
>;
@property({ attribute: false })
accessor workspaceId!: string;
@@ -214,7 +219,7 @@ export class AIChatContent extends SignalWatcher(
return;
}
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
const [histories, actions] = await Promise.all([
sessionId
? AIProvider.histories.chats(this.workspaceId, sessionId)

View File

@@ -1,5 +1,5 @@
import { toast } from '@affine/component';
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
import { unsafeCSSVar, unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme';
import { openFilesWith } from '@blocksuite/affine/shared/utils';
@@ -304,7 +304,7 @@ export class AIChatInput extends SignalWatcher(
accessor docId: string | undefined;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@query('image-preview-grid')
accessor imagePreviewGrid: HTMLDivElement | null = null;
@@ -328,7 +328,9 @@ export class AIChatInput extends SignalWatcher(
accessor chips: ChatChip[] = [];
@property({ attribute: false })
accessor createSession!: () => Promise<CopilotSessionType | undefined>;
accessor createSession!: () => Promise<
CopilotChatHistoryFragment | undefined
>;
@property({ attribute: false })
accessor updateContext!: (context: Partial<AIChatInputContext>) => void;
@@ -608,7 +610,7 @@ export class AIChatInput extends SignalWatcher(
// optimistic update messages
await this._preUpdateMessages(userInput, attachments);
const sessionId = (await this.createSession())?.id;
const sessionId = (await this.createSession())?.sessionId;
let contexts = await this._getMatchedContexts();
if (abortController.signal.aborted) {
return;
@@ -694,7 +696,7 @@ export class AIChatInput extends SignalWatcher(
};
private readonly _postUpdateMessages = async () => {
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
if (!sessionId || !AIProvider.histories) return;
const { messages } = this.chatContextValue;
@@ -703,7 +705,7 @@ export class AIChatInput extends SignalWatcher(
const historyIds = await AIProvider.histories.ids(
this.workspaceId,
this.docId,
{ sessionId }
{ sessionId, withMessages: true }
);
if (!historyIds || !historyIds[0]) return;
last.id = historyIds[0].messages.at(-1)?.id ?? '';

View File

@@ -1,4 +1,4 @@
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import {
menu,
popMenu,
@@ -49,7 +49,7 @@ export class ChatInputPreference extends SignalWatcher(
`;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor onModelChange: ((modelId: string) => void) | undefined;

View File

@@ -1,4 +1,4 @@
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { WithDisposable } from '@blocksuite/affine/global/lit';
import {
DocModeProvider,
@@ -171,10 +171,12 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
accessor chatContextValue!: ChatContextValue;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor createSession!: () => Promise<CopilotSessionType | undefined>;
accessor createSession!: () => Promise<
CopilotChatHistoryFragment | undefined
>;
@property({ attribute: false })
accessor updateContext!: (context: Partial<ChatContextValue>) => void;
@@ -418,7 +420,7 @@ export class AIChatMessages extends WithDisposable(ShadowlessElement) {
retry = async () => {
try {
const sessionId = (await this.createSession())?.id;
const sessionId = (await this.createSession())?.sessionId;
if (!sessionId) return;
if (!AIProvider.actions.chat) return;

View File

@@ -1,4 +1,4 @@
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { createLitPortal } from '@blocksuite/affine/components/portal';
import { WithDisposable } from '@blocksuite/affine/global/lit';
import type { NotificationService } from '@blocksuite/affine/shared/services';
@@ -18,7 +18,7 @@ import type { DocDisplayConfig } from '../ai-chat-chips';
export class AIChatToolbar extends WithDisposable(ShadowlessElement) {
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor workspaceId!: string;
@@ -132,7 +132,7 @@ export class AIChatToolbar extends WithDisposable(ShadowlessElement) {
};
private readonly onSessionClick = async (sessionId: string) => {
if (this.session?.id === sessionId) {
if (this.session?.sessionId === sessionId) {
this.notification?.toast('You are already in this chat');
return;
}
@@ -143,7 +143,7 @@ export class AIChatToolbar extends WithDisposable(ShadowlessElement) {
};
private readonly onDocClick = async (docId: string, sessionId: string) => {
if (this.docId === docId && this.session?.id === sessionId) {
if (this.docId === docId && this.session?.sessionId === sessionId) {
this.notification?.toast('You are already in this chat');
return;
}

View File

@@ -1,4 +1,4 @@
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { WithDisposable } from '@blocksuite/affine/global/lit';
import { type NotificationService } from '@blocksuite/affine/shared/services';
import { unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme';
@@ -15,7 +15,7 @@ export class AIHistoryClear extends WithDisposable(ShadowlessElement) {
accessor chatContextValue!: ChatContextValue;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor notification: NotificationService | null | undefined;
@@ -50,7 +50,7 @@ export class AIHistoryClear extends WithDisposable(ShadowlessElement) {
if (this._isHistoryClearDisabled || !this.session) {
return;
}
const sessionId = this.session.id;
const sessionId = this.session.sessionId;
try {
const confirm = this.notification
? await this.notification.confirm({

View File

@@ -1,4 +1,4 @@
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import type { ImageSelection } from '@blocksuite/affine/shared/selection';
import { NotificationProvider } from '@blocksuite/affine/shared/services';
import type {
@@ -82,7 +82,7 @@ export class ChatActionList extends LitElement {
accessor content: string = '';
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor messageId: string | undefined = undefined;
@@ -139,7 +139,7 @@ export class ChatActionList extends LitElement {
blocks: this._currentBlockSelections,
images: this._currentImageSelections,
};
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
const success = await action.handler(
host,
content,

View File

@@ -1,4 +1,4 @@
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { Tooltip } from '@blocksuite/affine/components/toolbar';
import { WithDisposable } from '@blocksuite/affine/global/lit';
import { noop } from '@blocksuite/affine/global/utils';
@@ -111,7 +111,7 @@ export class ChatCopyMore extends WithDisposable(LitElement) {
accessor actions: ChatAction[] = [];
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor content!: string;
@@ -224,7 +224,7 @@ export class ChatCopyMore extends WithDisposable(LitElement) {
};
return html`<div
@click=${async () => {
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
const success = await action.handler(
host,
content,

View File

@@ -1,5 +1,8 @@
import type { FeatureFlagService } from '@affine/core/modules/feature-flag';
import type { ContextEmbedStatus, CopilotSessionType } from '@affine/graphql';
import type {
ContextEmbedStatus,
CopilotChatHistoryFragment,
} from '@affine/graphql';
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
import { NotificationProvider } from '@blocksuite/affine/shared/services';
import { unsafeCSSVarV2 } from '@blocksuite/affine/shared/theme';
@@ -130,7 +133,7 @@ export class PlaygroundChat extends SignalWatcher(
accessor doc!: Store;
@property({ attribute: false })
accessor session!: CopilotSessionType | null | undefined;
accessor session!: CopilotChatHistoryFragment | null | undefined;
@property({ attribute: false })
accessor networkSearchConfig!: AINetworkSearchConfig;
@@ -194,7 +197,7 @@ export class PlaygroundChat extends SignalWatcher(
const currentRequest = ++this._updateHistoryCounter;
const sessionId = this.session?.id;
const sessionId = this.session?.sessionId;
const [histories, actions] = await Promise.all([
sessionId
? AIProvider.histories.chats(

View File

@@ -1,5 +1,5 @@
import type { FeatureFlagService } from '@affine/core/modules/feature-flag';
import type { CopilotSessionType } from '@affine/graphql';
import type { CopilotChatHistoryFragment } from '@affine/graphql';
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
import type { EditorHost } from '@blocksuite/affine/std';
import { ShadowlessElement } from '@blocksuite/affine/std';
@@ -84,7 +84,7 @@ export class PlaygroundContent extends SignalWatcher(
accessor affineFeatureFlagService!: FeatureFlagService;
@state()
accessor sessions: CopilotSessionType[] = [];
accessor sessions: CopilotChatHistoryFragment[] = [];
@state()
accessor sharedInputValue: string = '';
@@ -118,14 +118,14 @@ export class PlaygroundContent extends SignalWatcher(
}
}
} else {
this.rootSessionId = rootSession.id;
this.rootSessionId = rootSession.sessionId;
const childSessions = sessions.filter(
session => session.parentSessionId === rootSession.id
session => session.parentSessionId === rootSession.sessionId
);
if (childSessions.length > 0) {
this.sessions = childSessions;
} else {
const forkSession = await this.forkSession(rootSession.id);
const forkSession = await this.forkSession(rootSession.sessionId);
if (forkSession) {
this.sessions = [forkSession];
}
@@ -321,7 +321,7 @@ export class PlaygroundContent extends SignalWatcher(
<div class="playground-content">
${repeat(
this.sessions,
session => session.id,
session => session.sessionId,
session => html`
<div class="playground-chat-item">
<playground-chat

View File

@@ -1,6 +1,9 @@
import type { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import type { FeatureFlagService } from '@affine/core/modules/feature-flag';
import type { ContextEmbedStatus, CopilotSessionType } from '@affine/graphql';
import type {
ContextEmbedStatus,
CopilotChatHistoryFragment,
} from '@affine/graphql';
import {
CanvasElementType,
EdgelessCRUDIdentifier,
@@ -216,7 +219,7 @@ export class AIChatBlockPeekView extends LitElement {
}
// If there is no session id or chat messages, do not create a new chat block
const forkSessionId = this.forkSession?.id;
const forkSessionId = this.forkSession?.sessionId;
if (!forkSessionId || !this.chatContext.messages.length) {
return;
}
@@ -284,7 +287,7 @@ export class AIChatBlockPeekView extends LitElement {
* Update the current chat messages with the new message
*/
updateChatBlockMessages = async () => {
const forkSessionId = this.forkSession?.id;
const forkSessionId = this.forkSession?.sessionId;
if (!this._forkBlockId || !forkSessionId) {
return;
}
@@ -360,7 +363,7 @@ export class AIChatBlockPeekView extends LitElement {
*/
retry = async () => {
try {
const forkSessionId = this.forkSession?.id;
const forkSessionId = this.forkSession?.sessionId;
if (!this._forkBlockId || !forkSessionId) return;
if (!AIProvider.actions.chat) return;
@@ -656,10 +659,10 @@ export class AIChatBlockPeekView extends LitElement {
accessor embeddingProgress: [number, number] = [0, 0];
@state()
accessor session: CopilotSessionType | null | undefined;
accessor session: CopilotChatHistoryFragment | null | undefined;
@state()
accessor forkSession: CopilotSessionType | null | undefined;
accessor forkSession: CopilotChatHistoryFragment | null | undefined;
}
declare global {

View File

@@ -19,6 +19,7 @@ import {
listContextObjectQuery,
listContextQuery,
matchContextQuery,
type PaginationInput,
type QueryOptions,
type QueryResponse,
removeContextCategoryMutation,
@@ -152,7 +153,7 @@ export class CopilotClient {
query: getCopilotSessionQuery,
variables: { sessionId, workspaceId },
});
return res.currentUser?.copilot?.session;
return res.currentUser?.copilot?.chats?.edges?.[0]?.node;
} catch (err) {
throw resolveError(err);
}
@@ -160,6 +161,7 @@ export class CopilotClient {
async getSessions(
workspaceId: string,
pagination: PaginationInput,
docId?: string,
options?: RequestOptions<
typeof getCopilotSessionsQuery
@@ -170,11 +172,12 @@ export class CopilotClient {
query: getCopilotSessionsQuery,
variables: {
workspaceId,
pagination,
docId,
options,
},
});
return res.currentUser?.copilot?.sessions;
return res.currentUser?.copilot?.chats.edges.map(e => e.node);
} catch (err) {
throw resolveError(err);
}
@@ -189,7 +192,7 @@ export class CopilotClient {
limit,
},
});
return res.currentUser?.copilot?.histories;
return res.currentUser?.copilot?.chats.edges.map(e => e.node);
} catch (err) {
throw resolveError(err);
}
@@ -197,6 +200,7 @@ export class CopilotClient {
async getHistories(
workspaceId: string,
pagination: PaginationInput,
docId?: string,
options?: RequestOptions<
typeof getCopilotHistoriesQuery
@@ -207,12 +211,13 @@ export class CopilotClient {
query: getCopilotHistoriesQuery,
variables: {
workspaceId,
pagination,
docId,
options,
},
});
return res.currentUser?.copilot?.histories;
return res.currentUser?.copilot?.chats.edges.map(e => e.node);
} catch (err) {
throw resolveError(err);
}
@@ -220,9 +225,10 @@ export class CopilotClient {
async getHistoryIds(
workspaceId: string,
pagination: PaginationInput,
docId?: string,
options?: RequestOptions<
typeof getCopilotHistoriesQuery
typeof getCopilotHistoryIdsQuery
>['variables']['options']
) {
try {
@@ -230,12 +236,13 @@ export class CopilotClient {
query: getCopilotHistoryIdsQuery,
variables: {
workspaceId,
pagination,
docId,
options,
},
});
return res.currentUser?.copilot?.histories;
return res.currentUser?.copilot?.chats.edges.map(e => e.node);
} catch (err) {
throw resolveError(err);
}

View File

@@ -586,7 +586,7 @@ Could you make a new website based on these notes and send back just the html fi
docId?: string,
options?: QueryChatSessionsInput
) => {
return client.getSessions(workspaceId, docId, options);
return client.getSessions(workspaceId, {}, docId, options);
},
getRecentSessions: async (workspaceId: string, limit?: number) => {
return client.getRecentSessions(workspaceId, limit);
@@ -744,9 +744,10 @@ Could you make a new website based on these notes and send back just the html fi
): Promise<BlockSuitePresets.AIHistory[]> => {
// @ts-expect-error - 'action' is missing in server impl
return (
(await client.getHistories(workspaceId, docId, {
(await client.getHistories(workspaceId, {}, docId, {
action: true,
withPrompt: true,
withMessages: true,
})) ?? []
);
},
@@ -757,8 +758,9 @@ Could you make a new website based on these notes and send back just the html fi
): Promise<BlockSuitePresets.AIHistory[]> => {
// @ts-expect-error - 'action' is missing in server impl
return (
(await client.getHistories(workspaceId, docId, {
(await client.getHistories(workspaceId, {}, docId, {
sessionId,
withMessages: true,
})) ?? []
);
},
@@ -776,8 +778,8 @@ Could you make a new website based on these notes and send back just the html fi
typeof getCopilotHistoriesQuery
>['variables']['options']
): Promise<BlockSuitePresets.AIHistoryIds[]> => {
// @ts-expect-error - 'role' is missing type in server impl
return await client.getHistoryIds(workspaceId, docId, options);
// @ts-expect-error - 'action' is missing in server impl
return await client.getHistoryIds(workspaceId, {}, docId, options);
},
});

View File

@@ -98,11 +98,14 @@ export const Component = () => {
await createSession({ pinned });
} else {
await client.updateSession({
sessionId: currentSession.id,
sessionId: currentSession.sessionId,
pinned,
});
// retrieve the latest session and update the state
const session = await client.getSession(workspaceId, currentSession.id);
const session = await client.getSession(
workspaceId,
currentSession.sessionId
);
setCurrentSession(session);
}
} finally {