From 3d2f0e7b5b8eef3992c6803ebe09ea8ca31eea3b Mon Sep 17 00:00:00 2001 From: akumatus Date: Thu, 24 Apr 2025 14:32:54 +0000 Subject: [PATCH] feat(core): chat-panel buttons ui (#11942) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close [AI-7](https://linear.app/affine-design/issue/AI-7). ![截屏2025-04-23 23.29.32.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/a984a28f-0ccf-4e8d-ba2d-239ad03f2998.png) --- .../src/blocksuite/ai/chat-panel/index.ts | 30 ++--- .../ai-chat-composer/ai-chat-composer.ts | 39 +----- .../components/ai-chat-input/ai-chat-input.ts | 122 +++++++++--------- .../ai-history-clear/ai-history-clear.ts | 93 +++++++++++++ .../ai/components/ai-history-clear/index.ts | 1 + .../core/src/blocksuite/ai/effects.ts | 4 +- .../ai/peek-view/chat-block-peek-view.ts | 10 +- .../src/blocksuite/ai/peek-view/styles.ts | 7 + .../e2e/chat-with/reasoning.spec.ts | 30 +++++ .../e2e/utils/chat-panel-utils.ts | 14 ++ 10 files changed, 235 insertions(+), 115 deletions(-) create mode 100644 packages/frontend/core/src/blocksuite/ai/components/ai-history-clear/ai-history-clear.ts create mode 100644 packages/frontend/core/src/blocksuite/ai/components/ai-history-clear/index.ts create mode 100644 tests/affine-cloud-copilot/e2e/chat-with/reasoning.spec.ts diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts index ad1105a94e..0e4abc86c0 100644 --- a/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/index.ts @@ -5,7 +5,6 @@ import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit'; import type { EditorHost } from '@blocksuite/affine/std'; import { ShadowlessElement } from '@blocksuite/affine/std'; import type { ExtensionType, Store } from '@blocksuite/affine/store'; -import { HelpIcon } from '@blocksuite/icons/lit'; import { type Signal, signal } from '@preact/signals-core'; import { css, html, type PropertyValues } from 'lit'; import { property, state } from 'lit/decorators.js'; @@ -68,21 +67,12 @@ export class ChatPanel extends SignalWatcher( align-items: center; z-index: 1; - div:first-child { + .chat-panel-title-text { font-size: 14px; font-weight: 500; color: var(--affine-text-secondary-color); } - div:last-child { - width: 24px; - height: 24px; - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; - } - svg { width: 18px; height: 18px; @@ -385,20 +375,20 @@ export class ChatPanel extends SignalWatcher( return html`
-
+
${isEmbedding ? html`Embedding ${done}/${total}` : 'AFFiNE AI'}
-
{ - AIProvider.toggleGeneralAIOnboarding?.(true); - }} - > - ${HelpIcon()} -
+
`; } diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts index 1536cdae3e..a8690e3c2b 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-chat-composer/ai-chat-composer.ts @@ -5,7 +5,6 @@ import type { CopilotDocType, } from '@affine/graphql'; import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit'; -import { NotificationProvider } from '@blocksuite/affine/shared/services'; import type { EditorHost } from '@blocksuite/affine/std'; import { ShadowlessElement } from '@blocksuite/affine/std'; import type { Store } from '@blocksuite/affine/store'; @@ -65,9 +64,6 @@ export class AIChatComposer extends SignalWatcher( @property({ attribute: false }) accessor updateContext!: (context: Partial) => void; - @property({ attribute: false }) - accessor onHistoryCleared: (() => void) | undefined; - @property({ attribute: false }) accessor isVisible: Signal = signal(false); @@ -97,6 +93,9 @@ export class AIChatComposer extends SignalWatcher( @property({ attribute: false }) accessor portalContainer: HTMLElement | null = null; + @property({ attribute: false }) + accessor sideBarWidth: Signal = signal(undefined); + @state() accessor chips: ChatChip[] = []; @@ -131,9 +130,9 @@ export class AIChatComposer extends SignalWatcher( .networkSearchConfig=${this.networkSearchConfig} .reasoningConfig=${this.reasoningConfig} .docDisplayConfig=${this.docDisplayConfig} - .cleanupHistories=${this._cleanupHistories} .onChatSuccess=${this.onChatSuccess} .trackOptions=${this.trackOptions} + .sideBarWidth=${this.sideBarWidth} >