There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): copilot client should throw right ai error (#9958)
donteatfriedrice9cae1c3a28ca
diff --git a/blocksuite/blocks/src/root-block/widgets/ai-panel/components/state/error.ts b/blocksuite/blocks/src/root-block/widgets/ai-panel/components/state/error.tsindex 3ea8c75eae..995e6bc134 100644--- a/blocksuite/blocks/src/root-block/widgets/ai-panel/components/state/error.ts+++ b/blocksuite/blocks/src/root-block/widgets/ai-panel/components/state/error.ts@@ -155,7 +155,7 @@ export class AIPanelError extends WithDisposable(LitElement) {<span>Cancel</span></div><div @click=${this.config.login} class="action-button primary">- <span>login</span>+ <span>Login</span></div></div>`,],diff --git a/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts b/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.tsindex de3080e4ee..50b30d67a4 100644--- a/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts+++ b/packages/frontend/core/src/blocksuite/presets/_common/components/text-renderer.ts@@ -100,6 +100,7 @@ export class TextRenderer extends WithDisposable(ShadowlessElement) {.ai-answer-text-editor .affine-page-root-block-container {padding: 0;+ margin: 0;line-height: var(--affine-line-height);color: var(--affine-text-primary-color);font-weight: 400;diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.tsindex cfb7ee2674..46536f7547 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/copilot-client.ts@@ -72,57 +72,77 @@ export class CopilotClient {async createSession(options: OptionsField<typeof createCopilotSessionMutation>) {- const res = await this.gql({- query: createCopilotSessionMutation,- variables: {- options,- },- });- return res.createCopilotSession;+ try {+ const res = await this.gql({+ query: createCopilotSessionMutation,+ variables: {+ options,+ },+ });+ return res.createCopilotSession;+ } catch (err) {+ throw resolveError(err);+ }}async updateSession(options: OptionsField<typeof updateCopilotSessionMutation>) {- const res = await this.gql({- query: updateCopilotSessionMutation,- variables: {- options,- },- });- return res.updateCopilotSession;+ try {+ const res = await this.gql({+ query: updateCopilotSessionMutation,+ variables: {+ options,+ },+ });+ return res.updateCopilotSession;+ } catch (err) {+ throw resolveError(err);+ }}async forkSession(options: OptionsField<typeof forkCopilotSessionMutation>) {- const res = await this.gql({- query: forkCopilotSessionMutation,- variables: {- options,- },- });- return res.forkCopilotSession;+ try {+ const res = await this.gql({+ query: forkCopilotSessionMutation,+ variables: {+ options,+ },+ });+ return res.forkCopilotSession;+ } catch (err) {+ throw resolveError(err);+ }}async createMessage(options: OptionsField<typeof createCopilotMessageMutation>) {- const res = await this.gql({- query: createCopilotMessageMutation,- variables: {- options,- },- });- return res.createCopilotMessage;+ try {+ const res = await this.gql({+ query: createCopilotMessageMutation,+ variables: {+ options,+ },+ });+ return res.createCopilotMessage;+ } catch (err) {+ throw resolveError(err);+ }}async getSessions(workspaceId: string) {- const res = await this.gql({- query: getCopilotSessionsQuery,- variables: {- workspaceId,- },- });- return res.currentUser?.copilot;+ try {+ const res = await this.gql({+ query: getCopilotSessionsQuery,+ variables: {+ workspaceId,+ },+ });+ return res.currentUser?.copilot;+ } catch (err) {+ throw resolveError(err);+ }}async getHistories(@@ -132,16 +152,20 @@ export class CopilotClient {typeof getCopilotHistoriesQuery>['variables']['options']) {- const res = await this.gql({- query: getCopilotHistoriesQuery,- variables: {- workspaceId,- docId,- options,- },- });-- return res.currentUser?.copilot?.histories;+ try {+ const res = await this.gql({+ query: getCopilotHistoriesQuery,+ variables: {+ workspaceId,+ docId,+ options,+ },+ });++ return res.currentUser?.copilot?.histories;+ } catch (err) {+ throw resolveError(err);+ }}async getHistoryIds(@@ -151,16 +175,20 @@ export class CopilotClient {typeof getCopilotHistoriesQuery>['variables']['options']) {- const res = await this.gql({- query: getCopilotHistoryIdsQuery,- variables: {- workspaceId,- docId,- options,- },- });-- return res.currentUser?.copilot?.histories;+ try {+ const res = await this.gql({+ query: getCopilotHistoryIdsQuery,+ variables: {+ workspaceId,+ docId,+ options,+ },+ });++ return res.currentUser?.copilot?.histories;+ } catch (err) {+ throw resolveError(err);+ }}async cleanupSessions(input: {@@ -168,13 +196,17 @@ export class CopilotClient {docId: string;sessionIds: string[];}) {- const res = await this.gql({- query: cleanupCopilotSessionMutation,- variables: {- input,- },- });- return res.cleanupCopilotSession;+ try {+ const res = await this.gql({+ query: cleanupCopilotSessionMutation,+ variables: {+ input,+ },+ });+ return res.cleanupCopilotSession;+ } catch (err) {+ throw resolveError(err);+ }}async chatText({