diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts index 615603dded..9866b0cfb0 100644 --- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts +++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/chat-panel-input.ts @@ -27,6 +27,7 @@ import { readBlobAsURL } from '../utils/image'; import type { AINetworkSearchConfig } from './chat-config'; import type { ChatContextValue, ChatMessage, DocContext } from './chat-context'; import { isDocChip } from './components/utils'; +import { PROMPT_NAME_AFFINE_AI, PROMPT_NAME_NETWORK_SEARCH } from './const'; const MaximumImageCount = 32; @@ -289,11 +290,11 @@ export class ChatPanelInput extends SignalWatcher(WithDisposable(LitElement)) { private get _promptName() { if (this._isNetworkDisabled) { - return 'Chat With AFFiNE AI'; + return PROMPT_NAME_AFFINE_AI; } return this._isNetworkActive - ? 'Search With AFFiNE AI' - : 'Chat With AFFiNE AI'; + ? PROMPT_NAME_NETWORK_SEARCH + : PROMPT_NAME_AFFINE_AI; } private async _updatePromptName() { diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.ts index bd5c350b37..2009ce9837 100644 --- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.ts +++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/const.ts @@ -8,3 +8,6 @@ export const HISTORY_IMAGE_ACTIONS = [ 'Remove background', 'Convert to sticker', ]; + +export const PROMPT_NAME_AFFINE_AI = 'Chat With AFFiNE AI'; +export const PROMPT_NAME_NETWORK_SEARCH = 'Search With AFFiNE AI'; diff --git a/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts b/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts index f1b1055c52..bf70214fa5 100644 --- a/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts +++ b/packages/frontend/core/src/blocksuite/presets/ai/peek-view/chat-block-input.ts @@ -1,5 +1,11 @@ import type { EditorHost } from '@blocksuite/affine/block-std'; -import { type AIError, openFileOrFiles } from '@blocksuite/affine/blocks'; +import { + type AIError, + openFileOrFiles, + unsafeCSSVarV2, +} from '@blocksuite/affine/blocks'; +import { SignalWatcher } from '@blocksuite/affine/global/utils'; +import { ImageIcon, PublishIcon } from '@blocksuite/icons/lit'; import { css, html, LitElement, nothing } from 'lit'; import { property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; @@ -11,16 +17,21 @@ import { ChatClearIcon, ChatSendIcon, CloseIcon, - ImageIcon, } from '../_common/icons'; +import type { AINetworkSearchConfig } from '../chat-panel/chat-config'; +import { + PROMPT_NAME_AFFINE_AI, + PROMPT_NAME_NETWORK_SEARCH, +} from '../chat-panel/const'; import { AIProvider } from '../provider'; import { reportResponse } from '../utils/action-reporter'; import { readBlobAsURL } from '../utils/image'; +import { stopPropagation } from '../utils/selection-utils'; import type { ChatContext } from './types'; const MaximumImageCount = 8; -export class ChatBlockInput extends LitElement { +export class ChatBlockInput extends SignalWatcher(LitElement) { static override styles = css` :host { width: 100%; @@ -126,6 +137,7 @@ export class ChatBlockInput extends LitElement { display: flex; gap: 8px; align-items: center; + div { width: 24px; height: 24px; @@ -134,6 +146,28 @@ export class ChatBlockInput extends LitElement { div:nth-child(2) { margin-left: auto; } + + .image-upload, + .chat-network-search { + display: flex; + justify-content: center; + align-items: center; + svg { + width: 20px; + height: 20px; + color: ${unsafeCSSVarV2('icon/primary')}; + } + } + .chat-network-search[data-active='true'] svg { + color: ${unsafeCSSVarV2('icon/activated')}; + } + + .chat-network-search[aria-disabled='true'] { + cursor: not-allowed; + } + .chat-network-search[aria-disabled='true'] svg { + color: var(--affine-text-disable-color) !important; + } } .chat-history-clear.disabled { @@ -168,79 +202,44 @@ export class ChatBlockInput extends LitElement {