diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-context.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-context.ts index 59fc903d0a..b1d025f584 100644 --- a/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-context.ts +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/chat-context.ts @@ -88,4 +88,15 @@ export interface FileChip extends BaseChip { fileType: string; } +export interface TagChip extends BaseChip { + tagId: string; + tagName: string; + tagColor: string; +} + +export interface CollectionChip extends BaseChip { + collectionId: string; + collectionName: string; +} + export type ChatChip = DocChip | FileChip; diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/components/collection-chip.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/components/collection-chip.ts new file mode 100644 index 0000000000..27a2254aab --- /dev/null +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/components/collection-chip.ts @@ -0,0 +1,31 @@ +import { ShadowlessElement } from '@blocksuite/affine/block-std'; +import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit'; +import { AddCollectionIcon } from '@blocksuite/icons/lit'; +import { html } from 'lit'; +import { property } from 'lit/decorators.js'; + +import type { CollectionChip } from '../chat-context'; +import { getChipIcon, getChipTooltip } from './utils'; + +export class ChatPanelCollectionChip extends SignalWatcher( + WithDisposable(ShadowlessElement) +) { + @property({ attribute: false }) + accessor chip!: CollectionChip; + + override render() { + const { state, collectionName } = this.chip; + const isLoading = state === 'processing'; + const tooltip = getChipTooltip(state, collectionName, this.chip.tooltip); + const collectionIcon = AddCollectionIcon(); + const icon = getChipIcon(state, collectionIcon); + + return html``; + } +} diff --git a/packages/frontend/core/src/blocksuite/ai/chat-panel/components/tag-chip.ts b/packages/frontend/core/src/blocksuite/ai/chat-panel/components/tag-chip.ts new file mode 100644 index 0000000000..2fea7e9058 --- /dev/null +++ b/packages/frontend/core/src/blocksuite/ai/chat-panel/components/tag-chip.ts @@ -0,0 +1,49 @@ +import { ShadowlessElement } from '@blocksuite/affine/block-std'; +import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit'; +import { css, html } from 'lit'; +import { property } from 'lit/decorators.js'; + +import type { TagChip } from '../chat-context'; +import { getChipIcon, getChipTooltip } from './utils'; + +export class ChatPanelTagChip extends SignalWatcher( + WithDisposable(ShadowlessElement) +) { + static override styles = css` + .tag-icon-container { + display: flex; + align-items: center; + justify-content: center; + } + .tag-icon { + border-radius: 50%; + height: 8px; + width: 8px; + margin: 4px; + background-color: var(--affine-color-secondary); + } + `; + + @property({ attribute: false }) + accessor chip!: TagChip; + + override render() { + const { state, tagName, tagColor } = this.chip; + const isLoading = state === 'processing'; + const tooltip = getChipTooltip(state, tagName, this.chip.tooltip); + const tagIcon = html` +
+
+
+ `; + const icon = getChipIcon(state, tagIcon); + + return html``; + } +} diff --git a/packages/frontend/core/src/blocksuite/ai/effects.ts b/packages/frontend/core/src/blocksuite/ai/effects.ts index d742bf040d..ab93fee852 100644 --- a/packages/frontend/core/src/blocksuite/ai/effects.ts +++ b/packages/frontend/core/src/blocksuite/ai/effects.ts @@ -28,8 +28,10 @@ import { ChatPanelInput } from './chat-panel/chat-panel-input'; import { ChatPanelMessages } from './chat-panel/chat-panel-messages'; import { ChatPanelAddPopover } from './chat-panel/components/add-popover'; import { ChatPanelChip } from './chat-panel/components/chip'; +import { ChatPanelCollectionChip } from './chat-panel/components/collection-chip'; import { ChatPanelDocChip } from './chat-panel/components/doc-chip'; import { ChatPanelFileChip } from './chat-panel/components/file-chip'; +import { ChatPanelTagChip } from './chat-panel/components/tag-chip'; import { effects as componentAiItemEffects } from './components/ai-item'; import { AIScrollableTextRenderer } from './components/ai-scrollable-text-renderer'; import { AskAIButton } from './components/ask-ai-button'; @@ -94,6 +96,8 @@ export function registerAIEffects() { customElements.define('chat-panel-add-popover', ChatPanelAddPopover); customElements.define('chat-panel-doc-chip', ChatPanelDocChip); customElements.define('chat-panel-file-chip', ChatPanelFileChip); + customElements.define('chat-panel-tag-chip', ChatPanelTagChip); + customElements.define('chat-panel-collection-chip', ChatPanelCollectionChip); customElements.define('chat-panel-chip', ChatPanelChip); customElements.define('ai-error-wrapper', AIErrorWrapper); customElements.define('ai-slides-renderer', AISlidesRenderer);