@docyrus/ui-pro-ai-assistant 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26161 -0
- package/dist/index.js.map +1 -0
- package/package.json +155 -0
- package/src/components/assistant-animations.tsx +29 -0
- package/src/components/assistant-dialogs.tsx +235 -0
- package/src/components/code-view.tsx +278 -0
- package/src/components/create-agent-task.tsx +104 -0
- package/src/components/create-new-work-version.tsx +30 -0
- package/src/components/extract-web.tsx +160 -0
- package/src/components/forward-to-agent.tsx +90 -0
- package/src/components/generate-chart.tsx +101 -0
- package/src/components/generative-action-button.tsx +122 -0
- package/src/components/generative-tool.tsx +685 -0
- package/src/components/generative-ui-object.tsx +210 -0
- package/src/components/input-area.tsx +1209 -0
- package/src/components/json-schema-layout.tsx +326 -0
- package/src/components/list-item-card.tsx +92 -0
- package/src/components/mermaid-diagram.tsx +192 -0
- package/src/components/preview-image.tsx +47 -0
- package/src/components/request-approval.tsx +48 -0
- package/src/components/request-user-input.tsx +270 -0
- package/src/components/search-web.tsx +319 -0
- package/src/components/sheet-command.tsx +88 -0
- package/src/components/shell-canvas.tsx +122 -0
- package/src/components/show-advanced-data-table.tsx +352 -0
- package/src/components/show-generated-content-options.tsx +93 -0
- package/src/components/show-people-cards.tsx +180 -0
- package/src/components/subagent-tool.tsx +180 -0
- package/src/components/text-editor-tool.tsx +328 -0
- package/src/components/work-canvas.tsx +88 -0
- package/src/components/work-card.tsx +42 -0
- package/src/declarations.d.ts +1 -0
- package/src/docy-assistant.tsx +1962 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/use-assistant-api.ts +507 -0
- package/src/hooks/use-deployment-data.ts +162 -0
- package/src/hooks/use-project-state.ts +347 -0
- package/src/hooks/use-session-state.ts +207 -0
- package/src/hooks/use-speech-recognition.ts +137 -0
- package/src/hooks/use-ui-state.ts +185 -0
- package/src/hooks/use-works-state.ts +146 -0
- package/src/i18n/context.tsx +253 -0
- package/src/i18n/index.ts +19 -0
- package/src/i18n/locales/de.json +198 -0
- package/src/i18n/locales/el.json +198 -0
- package/src/i18n/locales/en.json +226 -0
- package/src/i18n/locales/es.json +198 -0
- package/src/i18n/locales/fr.json +198 -0
- package/src/i18n/locales/it.json +198 -0
- package/src/i18n/locales/pt.json +198 -0
- package/src/i18n/locales/sl.json +198 -0
- package/src/i18n/locales/tr.json +211 -0
- package/src/i18n/types.ts +23 -0
- package/src/i18n/use-translation.ts +17 -0
- package/src/index.ts +18 -0
- package/src/internal/plate-editor/editor/auth-context.ts +11 -0
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +39 -0
- package/src/internal/plate-editor/editor/editor-kit.tsx +89 -0
- package/src/internal/plate-editor/editor/plate-editor.tsx +75 -0
- package/src/internal/plate-editor/editor/plate-types.ts +126 -0
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +172 -0
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +211 -0
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +26 -0
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +51 -0
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +24 -0
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +38 -0
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +6 -0
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +14 -0
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +17 -0
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +31 -0
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +23 -0
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +26 -0
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +8 -0
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +174 -0
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +68 -0
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +13 -0
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +7 -0
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +27 -0
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +43 -0
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +6 -0
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +15 -0
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +12 -0
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +19 -0
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +47 -0
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +19 -0
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +22 -0
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +35 -0
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +24 -0
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +27 -0
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +18 -0
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +8 -0
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +10 -0
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +37 -0
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +53 -0
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +36 -0
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +17 -0
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +95 -0
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +20 -0
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +22 -0
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +14 -0
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +5 -0
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +9 -0
- package/src/internal/plate-editor/editor/transforms.ts +165 -0
- package/src/internal/plate-editor/editor/use-chat.ts +152 -0
- package/src/internal/plate-editor/hooks/index.ts +3 -0
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +31 -0
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +26 -0
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +21 -0
- package/src/internal/plate-editor/hooks/use-media-query.ts +44 -0
- package/src/internal/plate-editor/hooks/use-mounted.ts +18 -0
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +114 -0
- package/src/internal/plate-editor/hooks/use-upload-file.ts +81 -0
- package/src/internal/plate-editor/i18n/context.tsx +58 -0
- package/src/internal/plate-editor/i18n/index.ts +3 -0
- package/src/internal/plate-editor/i18n/locales/de.json +57 -0
- package/src/internal/plate-editor/i18n/locales/el.json +57 -0
- package/src/internal/plate-editor/i18n/locales/en.json +57 -0
- package/src/internal/plate-editor/i18n/locales/es.json +57 -0
- package/src/internal/plate-editor/i18n/locales/fr.json +57 -0
- package/src/internal/plate-editor/i18n/locales/it.json +57 -0
- package/src/internal/plate-editor/i18n/locales/pt.json +57 -0
- package/src/internal/plate-editor/i18n/locales/sl.json +57 -0
- package/src/internal/plate-editor/i18n/locales/tr.json +57 -0
- package/src/internal/plate-editor/i18n/types.ts +59 -0
- package/src/internal/plate-editor/i18n/use-translation.ts +22 -0
- package/src/internal/plate-editor/index.ts +39 -0
- package/src/internal/plate-editor/lib/ai-output-converter.ts +153 -0
- package/src/internal/plate-editor/lib/download-file.ts +17 -0
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +828 -0
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +41 -0
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +27 -0
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +147 -0
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +90 -0
- package/src/internal/plate-editor/plate-ui/avatar.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +106 -0
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +364 -0
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +556 -0
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +78 -0
- package/src/internal/plate-editor/plate-ui/block-list.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +557 -0
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +47 -0
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +469 -0
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +10 -0
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/button.tsx +190 -0
- package/src/internal/plate-editor/plate-ui/calendar.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +76 -0
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +54 -0
- package/src/internal/plate-editor/plate-ui/caption.tsx +48 -0
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +172 -0
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +228 -0
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/code-node.tsx +12 -0
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +65 -0
- package/src/internal/plate-editor/plate-ui/column-node.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/command.tsx +204 -0
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +12 -0
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +45 -0
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/comment.tsx +619 -0
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +43 -0
- package/src/internal/plate-editor/plate-ui/date-node.tsx +56 -0
- package/src/internal/plate-editor/plate-ui/dialog.tsx +426 -0
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +266 -0
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +40 -0
- package/src/internal/plate-editor/plate-ui/editor.tsx +148 -0
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +48 -0
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +626 -0
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +155 -0
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +226 -0
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +208 -0
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +157 -0
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +27 -0
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +1129 -0
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +129 -0
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +99 -0
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +211 -0
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +154 -0
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +20 -0
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +56 -0
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +9 -0
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +11 -0
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +7 -0
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +18 -0
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +28 -0
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +124 -0
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +34 -0
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +409 -0
- package/src/internal/plate-editor/plate-ui/input.tsx +39 -0
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +260 -0
- package/src/internal/plate-editor/plate-ui/label.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +71 -0
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +15 -0
- package/src/internal/plate-editor/plate-ui/link-node.tsx +33 -0
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +30 -0
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +149 -0
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +179 -0
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +36 -0
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +21 -0
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +32 -0
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +103 -0
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +30 -0
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +52 -0
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +37 -0
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +183 -0
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +441 -0
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +127 -0
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +229 -0
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +216 -0
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +73 -0
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +35 -0
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +119 -0
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +46 -0
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +79 -0
- package/src/internal/plate-editor/plate-ui/menu.tsx +532 -0
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +126 -0
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +34 -0
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +15 -0
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +16 -0
- package/src/internal/plate-editor/plate-ui/popover.tsx +77 -0
- package/src/internal/plate-editor/plate-ui/progress.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +81 -0
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +88 -0
- package/src/internal/plate-editor/plate-ui/separator.tsx +43 -0
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +435 -0
- package/src/internal/plate-editor/plate-ui/spinner.tsx +1 -0
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +35 -0
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +168 -0
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +24 -0
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +85 -0
- package/src/internal/plate-editor/plate-ui/table-node.tsx +285 -0
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +254 -0
- package/src/internal/plate-editor/plate-ui/tabs.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/textarea.tsx +58 -0
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +142 -0
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +57 -0
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +50 -0
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +18 -0
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +33 -0
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +26 -0
- package/src/internal/plate-editor/plate-ui/toggle.tsx +3 -0
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +380 -0
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +149 -0
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +177 -0
- package/src/internal/plate-editor/types/index.ts +22 -0
- package/src/internal/plate-editor/vite.ts +284 -0
- package/src/internal/sheets/components/univer-sheets.tsx +1104 -0
- package/src/internal/sheets/i18n/context.tsx +183 -0
- package/src/internal/sheets/i18n/index.ts +19 -0
- package/src/internal/sheets/i18n/locales/de.json +21 -0
- package/src/internal/sheets/i18n/locales/el.json +21 -0
- package/src/internal/sheets/i18n/locales/en.json +21 -0
- package/src/internal/sheets/i18n/locales/es.json +21 -0
- package/src/internal/sheets/i18n/locales/fr.json +21 -0
- package/src/internal/sheets/i18n/locales/it.json +21 -0
- package/src/internal/sheets/i18n/locales/pt.json +21 -0
- package/src/internal/sheets/i18n/locales/sl.json +21 -0
- package/src/internal/sheets/i18n/locales/tr.json +21 -0
- package/src/internal/sheets/i18n/types.ts +23 -0
- package/src/internal/sheets/i18n/use-translation.ts +17 -0
- package/src/internal/sheets/index.ts +14 -0
- package/src/internal/sheets/types/css.d.ts +11 -0
- package/src/internal/sheets/types/index.ts +260 -0
- package/src/internal/sheets/xlsx.ts +1169 -0
- package/src/lib/api-client.ts +77 -0
- package/src/lib/assistant-api-actions.ts +549 -0
- package/src/lib/assistant-config.tsx +71 -0
- package/src/lib/class-utils.ts +40 -0
- package/src/lib/index.ts +7 -0
- package/src/lib/message-utils.ts +131 -0
- package/src/tools/tools-schema.json +512 -0
- package/src/types/index.ts +235 -0
- package/src/views/assistant-view.tsx +1137 -0
- package/src/views/canvas-app.tsx +839 -0
- package/src/views/canvas-code.tsx +93 -0
- package/src/views/canvas-deep-research.tsx +44 -0
- package/src/views/canvas-image.tsx +25 -0
- package/src/views/canvas-record-view.tsx +285 -0
- package/src/views/canvas-spreadsheet.tsx +125 -0
- package/src/views/canvas-text.tsx +52 -0
- package/src/views/canvas.tsx +274 -0
- package/src/views/chat-panel.tsx +149 -0
- package/src/views/index.ts +20 -0
- package/src/views/memories-panel.tsx +365 -0
- package/src/views/message-list.tsx +370 -0
- package/src/views/project-detail.tsx +257 -0
- package/src/views/projects-panel.tsx +131 -0
- package/src/views/sessions-list.tsx +98 -0
- package/src/views/sidebar-content.tsx +256 -0
- package/src/views/work-detail.tsx +98 -0
- package/src/vite.ts +284 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useCallback, useEffect, useRef, useState, type ChangeEvent, type FC, type FormEvent, type ReactNode, type Ref
|
|
5
|
+
} from 'react';
|
|
6
|
+
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
|
|
9
|
+
import { Avatar, AvatarFallback, AvatarImage } from '@docyrus/ui-pro-shared/components/avatar';
|
|
10
|
+
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
11
|
+
import {
|
|
12
|
+
DropdownMenu,
|
|
13
|
+
DropdownMenuContent,
|
|
14
|
+
DropdownMenuItem,
|
|
15
|
+
DropdownMenuSeparator,
|
|
16
|
+
DropdownMenuTrigger
|
|
17
|
+
} from '@docyrus/ui-pro-shared/components/dropdown-menu';
|
|
18
|
+
import { Input } from '@docyrus/ui-pro-shared/components/input';
|
|
19
|
+
import { ScrollArea } from '@docyrus/ui-pro-shared/components/scroll-area';
|
|
20
|
+
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
21
|
+
import {
|
|
22
|
+
ArrowLeft,
|
|
23
|
+
Brain,
|
|
24
|
+
ChevronDown,
|
|
25
|
+
Code2,
|
|
26
|
+
Edit,
|
|
27
|
+
Eye,
|
|
28
|
+
Loader2,
|
|
29
|
+
Maximize2,
|
|
30
|
+
Minimize2,
|
|
31
|
+
PanelLeft,
|
|
32
|
+
Search,
|
|
33
|
+
Sparkles,
|
|
34
|
+
X
|
|
35
|
+
} from 'lucide-react';
|
|
36
|
+
|
|
37
|
+
import { type ApiResponse, useApiClient } from '../lib/api-client';
|
|
38
|
+
import { type ToolActionEvent, type Work, WorkTypes } from '../types';
|
|
39
|
+
|
|
40
|
+
import { type CanvasViewOptions, ChatPanel } from './chat-panel';
|
|
41
|
+
|
|
42
|
+
import { ShellCanvas } from '../components/shell-canvas';
|
|
43
|
+
import { CanvasAppView } from './canvas-app';
|
|
44
|
+
import { CanvasCodeView } from './canvas-code';
|
|
45
|
+
import { CanvasSpreadsheetView } from './canvas-spreadsheet';
|
|
46
|
+
import { CanvasDeepResearchView } from './canvas-deep-research';
|
|
47
|
+
import { CanvasImageView } from './canvas-image';
|
|
48
|
+
import { CanvasRecordView } from './canvas-record-view';
|
|
49
|
+
import { CanvasTextView } from './canvas-text';
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* ---------------------------------------------------------------------------
|
|
53
|
+
* Shared props (both modes)
|
|
54
|
+
* ---------------------------------------------------------------------------
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
interface AssistantViewCommonProps {
|
|
58
|
+
messages: any[];
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
input: string;
|
|
61
|
+
onInputChange: (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
62
|
+
onSendMessage: (e?: FormEvent, options?: any) => void;
|
|
63
|
+
onStop: () => void;
|
|
64
|
+
logo?: string;
|
|
65
|
+
userPhoto?: string;
|
|
66
|
+
userDisplayName?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
title?: string;
|
|
69
|
+
welcomeMessage?: string;
|
|
70
|
+
isLoadingAgent?: boolean;
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
footerText?: string;
|
|
73
|
+
supportFiles?: boolean;
|
|
74
|
+
supportWebSearch?: boolean;
|
|
75
|
+
supportDocumentSearch?: boolean;
|
|
76
|
+
supportDeepResearch?: boolean;
|
|
77
|
+
supportThinking?: boolean;
|
|
78
|
+
supportWorkCanvas?: boolean;
|
|
79
|
+
supportMultiModels?: boolean;
|
|
80
|
+
deploymentId?: string;
|
|
81
|
+
tenantAiAgentId?: string;
|
|
82
|
+
enableMicrophone?: boolean;
|
|
83
|
+
enableVoice?: boolean;
|
|
84
|
+
isRecording?: boolean;
|
|
85
|
+
recognition?: any;
|
|
86
|
+
onMicrophoneClick?: () => void;
|
|
87
|
+
onToolAction?: (event: ToolActionEvent) => void;
|
|
88
|
+
threadId?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* ---------------------------------------------------------------------------
|
|
93
|
+
* Inline mode props
|
|
94
|
+
* ---------------------------------------------------------------------------
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
export interface InlineModeProps extends AssistantViewCommonProps {
|
|
98
|
+
mode: 'inline';
|
|
99
|
+
|
|
100
|
+
// Visibility
|
|
101
|
+
open: boolean;
|
|
102
|
+
onOpenChange: (open: boolean) => void;
|
|
103
|
+
|
|
104
|
+
// Display
|
|
105
|
+
className?: string;
|
|
106
|
+
|
|
107
|
+
// Sidebar
|
|
108
|
+
enableSidebar?: boolean;
|
|
109
|
+
isSidebarOpen?: boolean;
|
|
110
|
+
onToggleSidebar?: () => void;
|
|
111
|
+
renderSidebar?: () => ReactNode;
|
|
112
|
+
|
|
113
|
+
// Tabs
|
|
114
|
+
activeTab?: number;
|
|
115
|
+
onTabChange?: (tab: number) => void;
|
|
116
|
+
|
|
117
|
+
// Navigation
|
|
118
|
+
onExpand?: () => void;
|
|
119
|
+
onNewChat?: () => void;
|
|
120
|
+
enableNavDropdown?: boolean;
|
|
121
|
+
isFullscreen?: boolean;
|
|
122
|
+
|
|
123
|
+
// Content renderers
|
|
124
|
+
renderSessionsView?: () => ReactNode;
|
|
125
|
+
renderProjectsView?: () => ReactNode;
|
|
126
|
+
renderWorksView?: () => ReactNode;
|
|
127
|
+
renderMemoriesView?: () => ReactNode;
|
|
128
|
+
renderThreadHeader?: () => ReactNode;
|
|
129
|
+
|
|
130
|
+
// Agent selector
|
|
131
|
+
agentSelectorUrl?: string;
|
|
132
|
+
baseAgentSelectorUrl?: string;
|
|
133
|
+
onAgentChange?: (agentId: string, agentType: 'base' | 'deployment') => void;
|
|
134
|
+
|
|
135
|
+
// i18n
|
|
136
|
+
t: (key: string) => string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
* ---------------------------------------------------------------------------
|
|
141
|
+
* Conversation mode props
|
|
142
|
+
* ---------------------------------------------------------------------------
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
export interface ConversationModeProps extends AssistantViewCommonProps {
|
|
146
|
+
mode: 'conversation';
|
|
147
|
+
onWorkSelect: (work: Work) => void;
|
|
148
|
+
onOpenRightSidebar: () => void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* ---------------------------------------------------------------------------
|
|
153
|
+
* Union type
|
|
154
|
+
* ---------------------------------------------------------------------------
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
export type AssistantViewProps = InlineModeProps | ConversationModeProps;
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* ---------------------------------------------------------------------------
|
|
161
|
+
* Unified component
|
|
162
|
+
* ---------------------------------------------------------------------------
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
export const AssistantView = ({ ref, ...props }: AssistantViewProps & { ref?: Ref<HTMLDivElement | null> }) => {
|
|
166
|
+
// Canvas state — always declared (rules of hooks), only used in inline mode
|
|
167
|
+
const [canvasWork, setCanvasWork] = useState<Work | null>(null);
|
|
168
|
+
const [canvasVersions, setCanvasVersions] = useState<{ id: string; name: string }[]>([]);
|
|
169
|
+
const [canvasVersionsLoading, setCanvasVersionsLoading] = useState(false);
|
|
170
|
+
const [canvasSelectedVersionId, setCanvasSelectedVersionId] = useState<string | null>(null);
|
|
171
|
+
const [canvasVersionImages, setCanvasVersionImages] = useState<any[] | null>(null);
|
|
172
|
+
const [canvasVersionContent, setCanvasVersionContent] = useState<string | null>(null);
|
|
173
|
+
const [canvasVersionLanguage, setCanvasVersionLanguage] = useState<string | undefined>(undefined);
|
|
174
|
+
const [activeCanvasTab, setActiveCanvasTab] = useState<0 | 1>(0);
|
|
175
|
+
const [canvasSpreadsheetCommands, setCanvasSpreadsheetCommands] = useState<any[]>([]);
|
|
176
|
+
const apiClient = useApiClient();
|
|
177
|
+
|
|
178
|
+
// Agent selector state
|
|
179
|
+
const [agentSelectorOpen, setAgentSelectorOpen] = useState(false);
|
|
180
|
+
const [agents, setAgents] = useState<any[]>([]);
|
|
181
|
+
const [baseAgents, setBaseAgents] = useState<any[]>([]);
|
|
182
|
+
const [agentsLoading, setAgentsLoading] = useState(false);
|
|
183
|
+
const [agentSearch, setAgentSearch] = useState('');
|
|
184
|
+
const [selectedAgent, setSelectedAgent] = useState<any | null>(null);
|
|
185
|
+
const agentSearchRef = useRef<HTMLInputElement>(null);
|
|
186
|
+
|
|
187
|
+
// Canvas open handler for inline mode
|
|
188
|
+
const handleOpenCanvasViewInline = (options: CanvasViewOptions) => {
|
|
189
|
+
if (options.type === 'xlsx' && canvasWork?.id === options.id && canvasWork?.type === WorkTypes.Xlsx) {
|
|
190
|
+
setCanvasSpreadsheetCommands(options.commands ?? []);
|
|
191
|
+
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
setCanvasVersions([]);
|
|
196
|
+
setCanvasVersionsLoading(false);
|
|
197
|
+
setCanvasSelectedVersionId(null);
|
|
198
|
+
setCanvasVersionImages(null);
|
|
199
|
+
setCanvasVersionContent(null);
|
|
200
|
+
setCanvasVersionLanguage(undefined);
|
|
201
|
+
setActiveCanvasTab(0);
|
|
202
|
+
setCanvasSpreadsheetCommands([]);
|
|
203
|
+
|
|
204
|
+
if (options.type === 'record') {
|
|
205
|
+
setCanvasWork({
|
|
206
|
+
id: options.id,
|
|
207
|
+
title: options.title || 'Record Form',
|
|
208
|
+
type: WorkTypes.Record,
|
|
209
|
+
content_json: {
|
|
210
|
+
dataSourceId: options.dataSourceId,
|
|
211
|
+
data: options.data,
|
|
212
|
+
mode: options.mode || 'add',
|
|
213
|
+
recordId: options.recordId
|
|
214
|
+
},
|
|
215
|
+
created_on: new Date(),
|
|
216
|
+
last_modified_on: new Date()
|
|
217
|
+
});
|
|
218
|
+
} else if (options.type === 'image') {
|
|
219
|
+
setCanvasWork({
|
|
220
|
+
id: options.id,
|
|
221
|
+
title: options.title || 'Image',
|
|
222
|
+
type: WorkTypes.Image,
|
|
223
|
+
content_json: options.images,
|
|
224
|
+
created_on: new Date(),
|
|
225
|
+
last_modified_on: new Date()
|
|
226
|
+
});
|
|
227
|
+
} else if (options.type === 'text' || options.type === 'code') {
|
|
228
|
+
setCanvasWork({
|
|
229
|
+
id: options.id,
|
|
230
|
+
title: options.title || (options.type === 'text' ? 'Text' : 'Code'),
|
|
231
|
+
type: options.type === 'text' ? WorkTypes.Text : WorkTypes.Code,
|
|
232
|
+
created_on: new Date(),
|
|
233
|
+
last_modified_on: new Date()
|
|
234
|
+
});
|
|
235
|
+
} else if (options.type === 'data') {
|
|
236
|
+
setCanvasWork({
|
|
237
|
+
id: options.id,
|
|
238
|
+
title: options.title || 'Deep Research',
|
|
239
|
+
type: WorkTypes.Data,
|
|
240
|
+
content_json: options.contentJson ?? null,
|
|
241
|
+
created_on: new Date(),
|
|
242
|
+
last_modified_on: new Date()
|
|
243
|
+
});
|
|
244
|
+
} else if (options.type === 'app') {
|
|
245
|
+
setCanvasWork({
|
|
246
|
+
id: options.id,
|
|
247
|
+
title: options.title || options.contentJson?.layout?.title || 'App Preview',
|
|
248
|
+
type: WorkTypes.App,
|
|
249
|
+
content_json: options.contentJson ?? null,
|
|
250
|
+
created_on: new Date(),
|
|
251
|
+
last_modified_on: new Date()
|
|
252
|
+
});
|
|
253
|
+
} else if (options.type === 'xlsx') {
|
|
254
|
+
if (canvasWork?.id === options.id && canvasWork?.type === WorkTypes.Xlsx) {
|
|
255
|
+
setCanvasSpreadsheetCommands(options.commands ?? []);
|
|
256
|
+
} else {
|
|
257
|
+
setCanvasWork({
|
|
258
|
+
id: options.id,
|
|
259
|
+
title: options.title || 'Spreadsheet',
|
|
260
|
+
type: WorkTypes.Xlsx,
|
|
261
|
+
content_json: options.contentJson ?? null,
|
|
262
|
+
created_on: new Date(),
|
|
263
|
+
last_modified_on: new Date()
|
|
264
|
+
});
|
|
265
|
+
setCanvasSpreadsheetCommands(options.commands ?? []);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const handleCanvasVersionSelect = useCallback(async (versionId: string) => {
|
|
271
|
+
if (!canvasWork?.id) return;
|
|
272
|
+
|
|
273
|
+
setCanvasSelectedVersionId(versionId);
|
|
274
|
+
setCanvasVersionImages(null);
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
const response = await apiClient.get(`/ai/works/${canvasWork.id}/versions/${versionId}`) as ApiResponse & { data: any };
|
|
278
|
+
|
|
279
|
+
if (response.success && response.data) {
|
|
280
|
+
setCanvasVersionImages(response.data.content_json);
|
|
281
|
+
setCanvasVersionContent(response.data.content_text ?? null);
|
|
282
|
+
setCanvasVersionLanguage(response.data.content_json?.language ?? response.data.content_json?.subType ?? undefined);
|
|
283
|
+
|
|
284
|
+
if (response.data.type) {
|
|
285
|
+
setCanvasWork(prev => prev ? { ...prev, type: response.data.type as WorkTypes } : prev);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
} catch {
|
|
289
|
+
// silently ignore
|
|
290
|
+
}
|
|
291
|
+
}, [apiClient, canvasWork?.id]);
|
|
292
|
+
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
const fetchVersions = async () => {
|
|
295
|
+
if (!canvasWork?.id || canvasWork.id.startsWith('record-') || canvasWork.type === WorkTypes.Data || canvasWork.type === WorkTypes.App) {
|
|
296
|
+
setCanvasVersions([]);
|
|
297
|
+
setCanvasVersionsLoading(false);
|
|
298
|
+
setCanvasSelectedVersionId(null);
|
|
299
|
+
setCanvasVersionImages(null);
|
|
300
|
+
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
setCanvasVersionsLoading(true);
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
const response = await apiClient.get(`/ai/works/${canvasWork.id}`) as ApiResponse & { data: any };
|
|
308
|
+
|
|
309
|
+
if (response.success && response.data?.versions?.length > 0) {
|
|
310
|
+
const sorted = [...response.data.versions].sort(
|
|
311
|
+
(a: any, b: any) => new Date(a.created_on).getTime() - new Date(b.created_on).getTime()
|
|
312
|
+
);
|
|
313
|
+
const mapped = sorted.map((v: any, i: number) => ({ id: v.id, name: `v${i + 1}` })).reverse();
|
|
314
|
+
|
|
315
|
+
setCanvasVersions(mapped);
|
|
316
|
+
setCanvasSelectedVersionId(mapped[0].id);
|
|
317
|
+
await handleCanvasVersionSelect(mapped[0].id);
|
|
318
|
+
}
|
|
319
|
+
} catch {
|
|
320
|
+
// silently ignore
|
|
321
|
+
} finally {
|
|
322
|
+
setCanvasVersionsLoading(false);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
fetchVersions();
|
|
327
|
+
}, [
|
|
328
|
+
apiClient,
|
|
329
|
+
canvasWork?.id,
|
|
330
|
+
canvasWork?.type,
|
|
331
|
+
handleCanvasVersionSelect
|
|
332
|
+
]);
|
|
333
|
+
|
|
334
|
+
// Fetch agents when selector opens
|
|
335
|
+
const tenantAiAgentId = props.mode !== 'conversation' ? props.tenantAiAgentId : undefined;
|
|
336
|
+
const inlineProps = props.mode !== 'conversation' ? props as InlineModeProps : null;
|
|
337
|
+
const agentUrl = inlineProps?.agentSelectorUrl;
|
|
338
|
+
const baseAgentUrl = inlineProps?.baseAgentSelectorUrl;
|
|
339
|
+
const hasFetchedRef = useRef(false);
|
|
340
|
+
|
|
341
|
+
useEffect(() => {
|
|
342
|
+
if (!agentSelectorOpen) return;
|
|
343
|
+
if (hasFetchedRef.current) return;
|
|
344
|
+
if (!agentUrl && !baseAgentUrl) return;
|
|
345
|
+
|
|
346
|
+
hasFetchedRef.current = true;
|
|
347
|
+
|
|
348
|
+
const fetchAgents = async () => {
|
|
349
|
+
setAgentsLoading(true);
|
|
350
|
+
|
|
351
|
+
try {
|
|
352
|
+
const deployedRes = agentUrl ? await apiClient.get(agentUrl) : { success: true, data: [] };
|
|
353
|
+
const baseRes = baseAgentUrl ? await apiClient.get(baseAgentUrl) : { success: true, data: [] };
|
|
354
|
+
|
|
355
|
+
if (deployedRes.success) {
|
|
356
|
+
const raw = Array.isArray(deployedRes.data) ? deployedRes.data : [];
|
|
357
|
+
|
|
358
|
+
setAgents(raw.map((d: any) => ({
|
|
359
|
+
id: d.deploymentId ?? d.id,
|
|
360
|
+
name: d.agentName ?? d.name,
|
|
361
|
+
avatar: d.agentAvatar?.signed_url ?? d.avatar
|
|
362
|
+
})));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (baseRes.success) {
|
|
366
|
+
const rawBase = Array.isArray(baseRes.data) ? baseRes.data : [];
|
|
367
|
+
|
|
368
|
+
setBaseAgents(rawBase.map((d: any) => ({
|
|
369
|
+
id: d.agentId ?? d.id,
|
|
370
|
+
name: d.agentName ?? d.name,
|
|
371
|
+
avatar: d.agentAvatar?.signed_url ?? d.agentAvatar ?? d.avatar
|
|
372
|
+
})));
|
|
373
|
+
}
|
|
374
|
+
} catch {
|
|
375
|
+
// silently ignore
|
|
376
|
+
} finally {
|
|
377
|
+
setAgentsLoading(false);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
fetchAgents();
|
|
382
|
+
}, [
|
|
383
|
+
agentSelectorOpen,
|
|
384
|
+
agentUrl,
|
|
385
|
+
baseAgentUrl,
|
|
386
|
+
apiClient
|
|
387
|
+
]);
|
|
388
|
+
|
|
389
|
+
const allAgents = [...agents, ...baseAgents];
|
|
390
|
+
|
|
391
|
+
let activeAgent: any;
|
|
392
|
+
|
|
393
|
+
if (selectedAgent != null) {
|
|
394
|
+
activeAgent = selectedAgent;
|
|
395
|
+
} else if (props.deploymentId) {
|
|
396
|
+
activeAgent = agents.find(a => a.id === props.deploymentId) ?? null;
|
|
397
|
+
} else {
|
|
398
|
+
activeAgent = tenantAiAgentId ? (allAgents.find(a => a.id === tenantAiAgentId) ?? null) : null;
|
|
399
|
+
}
|
|
400
|
+
const filteredDeployedAgents = agents.filter(
|
|
401
|
+
a => !agentSearch || a.name?.toLowerCase().includes(agentSearch.toLowerCase())
|
|
402
|
+
);
|
|
403
|
+
const filteredBaseAgents = baseAgents.filter(
|
|
404
|
+
a => !agentSearch || a.name?.toLowerCase().includes(agentSearch.toLowerCase())
|
|
405
|
+
);
|
|
406
|
+
const hasAnyAgents = filteredDeployedAgents.length > 0 || filteredBaseAgents.length > 0;
|
|
407
|
+
|
|
408
|
+
/*
|
|
409
|
+
* -----------------------------------------------------------------------
|
|
410
|
+
* Conversation mode
|
|
411
|
+
* -----------------------------------------------------------------------
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
if (props.mode === 'conversation') {
|
|
415
|
+
const { onWorkSelect, onOpenRightSidebar, ...commonProps } = props;
|
|
416
|
+
|
|
417
|
+
const handleOpenCanvasView = (options: CanvasViewOptions) => {
|
|
418
|
+
let tempWork: Work | null = null;
|
|
419
|
+
|
|
420
|
+
if (options.type === 'image') {
|
|
421
|
+
tempWork = {
|
|
422
|
+
id: options.id || `image-${Date.now()}`,
|
|
423
|
+
title: options.title || 'Generated Image',
|
|
424
|
+
type: WorkTypes.Image,
|
|
425
|
+
content_json: options.images,
|
|
426
|
+
created_on: new Date(),
|
|
427
|
+
last_modified_on: new Date()
|
|
428
|
+
};
|
|
429
|
+
} else if (options.type === 'code') {
|
|
430
|
+
tempWork = {
|
|
431
|
+
id: options.id || `preview-${Date.now()}`,
|
|
432
|
+
title: options.title || 'Code Preview',
|
|
433
|
+
content_text: '',
|
|
434
|
+
type: WorkTypes.Code,
|
|
435
|
+
created_on: new Date(),
|
|
436
|
+
last_modified_on: new Date()
|
|
437
|
+
};
|
|
438
|
+
} else if (options.type === 'record') {
|
|
439
|
+
tempWork = {
|
|
440
|
+
id: options.id || `record-${Date.now()}`,
|
|
441
|
+
title: options.title || 'Record Form',
|
|
442
|
+
type: WorkTypes.Record,
|
|
443
|
+
content_json: {
|
|
444
|
+
dataSourceId: options.dataSourceId,
|
|
445
|
+
data: options.data,
|
|
446
|
+
mode: options.mode || 'add',
|
|
447
|
+
recordId: options.recordId
|
|
448
|
+
},
|
|
449
|
+
created_on: new Date(),
|
|
450
|
+
last_modified_on: new Date()
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (tempWork) {
|
|
455
|
+
onWorkSelect(tempWork);
|
|
456
|
+
onOpenRightSidebar();
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
return (
|
|
461
|
+
<ChatPanel
|
|
462
|
+
messages={commonProps.messages}
|
|
463
|
+
isLoading={commonProps.isLoading}
|
|
464
|
+
input={commonProps.input}
|
|
465
|
+
onInputChange={commonProps.onInputChange}
|
|
466
|
+
onSendMessage={commonProps.onSendMessage}
|
|
467
|
+
onStop={commonProps.onStop}
|
|
468
|
+
logo={commonProps.logo}
|
|
469
|
+
userPhoto={commonProps.userPhoto}
|
|
470
|
+
userDisplayName={commonProps.userDisplayName}
|
|
471
|
+
description={commonProps.description}
|
|
472
|
+
title={commonProps.title}
|
|
473
|
+
welcomeMessage={commonProps.welcomeMessage}
|
|
474
|
+
isLoadingAgent={commonProps.isLoadingAgent}
|
|
475
|
+
placeholder={commonProps.placeholder}
|
|
476
|
+
footerText={commonProps.footerText}
|
|
477
|
+
supportFiles={commonProps.supportFiles}
|
|
478
|
+
supportWebSearch={commonProps.supportWebSearch}
|
|
479
|
+
supportDocumentSearch={commonProps.supportDocumentSearch}
|
|
480
|
+
supportDeepResearch={commonProps.supportDeepResearch}
|
|
481
|
+
supportThinking={commonProps.supportThinking}
|
|
482
|
+
supportWorkCanvas={commonProps.supportWorkCanvas}
|
|
483
|
+
supportMultiModels={commonProps.supportMultiModels}
|
|
484
|
+
deploymentId={commonProps.deploymentId}
|
|
485
|
+
tenantAiAgentId={commonProps.tenantAiAgentId}
|
|
486
|
+
enableMicrophone={commonProps.enableMicrophone}
|
|
487
|
+
enableVoice={commonProps.enableVoice}
|
|
488
|
+
isRecording={commonProps.isRecording}
|
|
489
|
+
recognition={commonProps.recognition}
|
|
490
|
+
onMicrophoneClick={commonProps.onMicrophoneClick}
|
|
491
|
+
onToolAction={commonProps.onToolAction}
|
|
492
|
+
openCanvasView={handleOpenCanvasView}
|
|
493
|
+
threadId={commonProps.threadId}
|
|
494
|
+
messagesClassName="p-4" />
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/*
|
|
499
|
+
* -----------------------------------------------------------------------
|
|
500
|
+
* Inline mode
|
|
501
|
+
* -----------------------------------------------------------------------
|
|
502
|
+
*/
|
|
503
|
+
|
|
504
|
+
const {
|
|
505
|
+
open,
|
|
506
|
+
onOpenChange,
|
|
507
|
+
className,
|
|
508
|
+
enableSidebar,
|
|
509
|
+
isSidebarOpen,
|
|
510
|
+
onToggleSidebar,
|
|
511
|
+
renderSidebar,
|
|
512
|
+
activeTab = 0,
|
|
513
|
+
onTabChange,
|
|
514
|
+
onExpand,
|
|
515
|
+
onNewChat,
|
|
516
|
+
enableNavDropdown = false,
|
|
517
|
+
isFullscreen = false,
|
|
518
|
+
renderSessionsView,
|
|
519
|
+
renderProjectsView,
|
|
520
|
+
renderWorksView,
|
|
521
|
+
renderMemoriesView,
|
|
522
|
+
renderThreadHeader,
|
|
523
|
+
agentSelectorUrl,
|
|
524
|
+
baseAgentSelectorUrl,
|
|
525
|
+
onAgentChange,
|
|
526
|
+
t,
|
|
527
|
+
...commonProps
|
|
528
|
+
} = props;
|
|
529
|
+
|
|
530
|
+
if (!open) return null;
|
|
531
|
+
|
|
532
|
+
const content = (
|
|
533
|
+
<div
|
|
534
|
+
className={cn(
|
|
535
|
+
'relative flex flex-col bg-background text-foreground border shadow-sm @container',
|
|
536
|
+
isFullscreen ? 'fixed inset-0 z-[9999] rounded-none h-screen' : 'h-full rounded-xl',
|
|
537
|
+
className
|
|
538
|
+
)}
|
|
539
|
+
data-render-mode="inline"
|
|
540
|
+
ref={ref}>
|
|
541
|
+
{/* Header */}
|
|
542
|
+
<div className="flex items-center justify-between h-12 px-3 border-b shrink-0">
|
|
543
|
+
<div className="flex items-center gap-1">
|
|
544
|
+
{enableNavDropdown && (
|
|
545
|
+
<DropdownMenu>
|
|
546
|
+
<DropdownMenuTrigger asChild>
|
|
547
|
+
<Button
|
|
548
|
+
variant="ghost"
|
|
549
|
+
size="icon"
|
|
550
|
+
className="h-8 w-8 rounded-md hover:bg-accent relative overflow-hidden group">
|
|
551
|
+
<span
|
|
552
|
+
className="pointer-events-none absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-violet-200/60 to-transparent group-hover:translate-x-full transition-transform duration-700 ease-in-out"
|
|
553
|
+
aria-hidden="true" />
|
|
554
|
+
<Sparkles className="w-4 h-4 text-brown-500 relative z-10" />
|
|
555
|
+
</Button>
|
|
556
|
+
</DropdownMenuTrigger>
|
|
557
|
+
<DropdownMenuContent align="start" className={cn('w-40', isFullscreen && 'z-[10000]')}>
|
|
558
|
+
<DropdownMenuItem
|
|
559
|
+
className="cursor-pointer"
|
|
560
|
+
onClick={() => onTabChange?.(activeTab === 1 ? 0 : 1)}>
|
|
561
|
+
{t('tabs.sessions')}
|
|
562
|
+
</DropdownMenuItem>
|
|
563
|
+
<DropdownMenuSeparator />
|
|
564
|
+
<DropdownMenuItem
|
|
565
|
+
className="cursor-pointer"
|
|
566
|
+
onClick={() => onTabChange?.(activeTab === 2 ? 0 : 2)}>
|
|
567
|
+
{t('sections.projects')}
|
|
568
|
+
</DropdownMenuItem>
|
|
569
|
+
<DropdownMenuSeparator />
|
|
570
|
+
<DropdownMenuItem
|
|
571
|
+
className="cursor-pointer"
|
|
572
|
+
onClick={() => onTabChange?.(activeTab === 3 ? 0 : 3)}>
|
|
573
|
+
{t('tabs.works')}
|
|
574
|
+
</DropdownMenuItem>
|
|
575
|
+
</DropdownMenuContent>
|
|
576
|
+
</DropdownMenu>
|
|
577
|
+
)}
|
|
578
|
+
|
|
579
|
+
{(agentSelectorUrl || baseAgentSelectorUrl) ? (
|
|
580
|
+
<DropdownMenu
|
|
581
|
+
open={agentSelectorOpen}
|
|
582
|
+
onOpenChange={(o) => {
|
|
583
|
+
setAgentSelectorOpen(o);
|
|
584
|
+
if (!o) setAgentSearch('');
|
|
585
|
+
}}>
|
|
586
|
+
<DropdownMenuTrigger asChild>
|
|
587
|
+
<Button
|
|
588
|
+
variant="ghost"
|
|
589
|
+
className="h-8 px-2 gap-1 text-sm font-medium text-foreground hover:bg-accent rounded-md max-w-[260px]">
|
|
590
|
+
<span className="truncate">{activeAgent?.name ?? commonProps.title ?? 'Assistant'}</span>
|
|
591
|
+
<ChevronDown className="w-3 h-3 shrink-0 text-muted-foreground" />
|
|
592
|
+
</Button>
|
|
593
|
+
</DropdownMenuTrigger>
|
|
594
|
+
<DropdownMenuContent
|
|
595
|
+
align="start"
|
|
596
|
+
className={cn('w-64 p-0', isFullscreen && 'z-[10000]')}
|
|
597
|
+
onCloseAutoFocus={e => e.preventDefault()}>
|
|
598
|
+
<div className="p-2 border-b">
|
|
599
|
+
<div className="relative">
|
|
600
|
+
<Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none" />
|
|
601
|
+
<Input
|
|
602
|
+
ref={agentSearchRef}
|
|
603
|
+
value={agentSearch}
|
|
604
|
+
onChange={e => setAgentSearch(e.target.value)}
|
|
605
|
+
onKeyDown={e => e.stopPropagation()}
|
|
606
|
+
placeholder="Search agents..."
|
|
607
|
+
className="h-7 pl-7 text-sm"
|
|
608
|
+
autoFocus />
|
|
609
|
+
</div>
|
|
610
|
+
</div>
|
|
611
|
+
<ScrollArea className="max-h-56">
|
|
612
|
+
{agentsLoading ? (
|
|
613
|
+
<div className="flex items-center justify-center py-4">
|
|
614
|
+
<Loader2 className="w-4 h-4 animate-spin text-muted-foreground" />
|
|
615
|
+
</div>
|
|
616
|
+
) : !hasAnyAgents ? (
|
|
617
|
+
<div className="py-4 text-center text-xs text-muted-foreground">No agents found</div>
|
|
618
|
+
) : (
|
|
619
|
+
<>
|
|
620
|
+
{filteredBaseAgents.length > 0 && (
|
|
621
|
+
<>
|
|
622
|
+
<div className="px-3 py-1.5 text-xs font-medium text-muted-foreground">Base Agents</div>
|
|
623
|
+
{filteredBaseAgents.map(agent => (
|
|
624
|
+
<DropdownMenuItem
|
|
625
|
+
key={agent.id}
|
|
626
|
+
className="cursor-pointer gap-2 px-3 py-2"
|
|
627
|
+
onClick={() => {
|
|
628
|
+
setSelectedAgent(agent);
|
|
629
|
+
setAgentSelectorOpen(false);
|
|
630
|
+
setAgentSearch('');
|
|
631
|
+
onAgentChange?.(agent.id, 'base');
|
|
632
|
+
}}>
|
|
633
|
+
{agent.avatar ? (
|
|
634
|
+
<img src={typeof agent.avatar === 'string' ? agent.avatar : agent.avatar?.signed_url} alt="" className="w-5 h-5 rounded-full shrink-0 object-cover" />
|
|
635
|
+
) : (
|
|
636
|
+
<div className="w-5 h-5 rounded-full shrink-0 bg-muted flex items-center justify-center">
|
|
637
|
+
<Brain className="w-3 h-3 text-muted-foreground" />
|
|
638
|
+
</div>
|
|
639
|
+
)}
|
|
640
|
+
<span className="truncate text-sm">{agent.name}</span>
|
|
641
|
+
</DropdownMenuItem>
|
|
642
|
+
))}
|
|
643
|
+
</>
|
|
644
|
+
)}
|
|
645
|
+
{filteredDeployedAgents.length > 0 && (
|
|
646
|
+
<>
|
|
647
|
+
{filteredBaseAgents.length > 0 && <DropdownMenuSeparator />}
|
|
648
|
+
<div className="px-3 py-1.5 text-xs font-medium text-muted-foreground">Deployed Agents</div>
|
|
649
|
+
{filteredDeployedAgents.map(agent => (
|
|
650
|
+
<DropdownMenuItem
|
|
651
|
+
key={agent.id}
|
|
652
|
+
className="cursor-pointer gap-2 px-3 py-2"
|
|
653
|
+
onClick={() => {
|
|
654
|
+
setSelectedAgent(agent);
|
|
655
|
+
setAgentSelectorOpen(false);
|
|
656
|
+
setAgentSearch('');
|
|
657
|
+
onAgentChange?.(agent.id, 'deployment');
|
|
658
|
+
}}>
|
|
659
|
+
{agent.avatar ? (
|
|
660
|
+
<img src={typeof agent.avatar === 'string' ? agent.avatar : agent.avatar?.signed_url} alt="" className="w-5 h-5 rounded-full shrink-0 object-cover" />
|
|
661
|
+
) : (
|
|
662
|
+
<div className="w-5 h-5 rounded-full shrink-0 bg-muted flex items-center justify-center">
|
|
663
|
+
<Brain className="w-3 h-3 text-muted-foreground" />
|
|
664
|
+
</div>
|
|
665
|
+
)}
|
|
666
|
+
<span className="truncate text-sm">{agent.name}</span>
|
|
667
|
+
</DropdownMenuItem>
|
|
668
|
+
))}
|
|
669
|
+
</>
|
|
670
|
+
)}
|
|
671
|
+
</>
|
|
672
|
+
)}
|
|
673
|
+
</ScrollArea>
|
|
674
|
+
</DropdownMenuContent>
|
|
675
|
+
</DropdownMenu>
|
|
676
|
+
) : (
|
|
677
|
+
<span className="text-sm font-medium text-foreground">{commonProps.title || 'Assistant'}</span>
|
|
678
|
+
)}
|
|
679
|
+
</div>
|
|
680
|
+
<div className="flex items-center gap-1">
|
|
681
|
+
{enableNavDropdown && onNewChat && (
|
|
682
|
+
<Button
|
|
683
|
+
variant="ghost"
|
|
684
|
+
size="icon"
|
|
685
|
+
className="h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md"
|
|
686
|
+
onClick={onNewChat}
|
|
687
|
+
title={t('buttons.start_new_thread')}>
|
|
688
|
+
<Edit className="w-4 h-4" />
|
|
689
|
+
</Button>
|
|
690
|
+
)}
|
|
691
|
+
{onExpand && (
|
|
692
|
+
<Button
|
|
693
|
+
variant="ghost"
|
|
694
|
+
size="icon"
|
|
695
|
+
className="h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md"
|
|
696
|
+
onClick={onExpand}
|
|
697
|
+
title={isFullscreen ? t('actions.minimize') : t('actions.expand_fullscreen')}>
|
|
698
|
+
{isFullscreen ? <Minimize2 className="w-4 h-4" /> : <Maximize2 className="w-4 h-4" />}
|
|
699
|
+
</Button>
|
|
700
|
+
)}
|
|
701
|
+
<Button
|
|
702
|
+
variant="ghost"
|
|
703
|
+
size="icon"
|
|
704
|
+
className="h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md"
|
|
705
|
+
onClick={() => onOpenChange(false)}
|
|
706
|
+
title={t('common.close')}>
|
|
707
|
+
<X className="w-4 h-4" />
|
|
708
|
+
</Button>
|
|
709
|
+
</div>
|
|
710
|
+
</div>
|
|
711
|
+
|
|
712
|
+
{/* Main Content Area + Canvas Panel (side-by-side) */}
|
|
713
|
+
<div className="flex-1 flex flex-row min-h-0 overflow-hidden relative">
|
|
714
|
+
|
|
715
|
+
{/* Floating Buttons — visible only when sidebar is closed */}
|
|
716
|
+
{!isSidebarOpen && (
|
|
717
|
+
<div className="absolute top-2 left-2 z-40 flex flex-col gap-1">
|
|
718
|
+
{enableSidebar && onToggleSidebar && (
|
|
719
|
+
<Button
|
|
720
|
+
variant="ghost"
|
|
721
|
+
size="icon"
|
|
722
|
+
onClick={onToggleSidebar}
|
|
723
|
+
className="h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md shadow-sm"
|
|
724
|
+
title={t('tabs.sessions')}>
|
|
725
|
+
<PanelLeft className="w-4 h-4" />
|
|
726
|
+
</Button>
|
|
727
|
+
)}
|
|
728
|
+
{onTabChange && (
|
|
729
|
+
<Button
|
|
730
|
+
variant="ghost"
|
|
731
|
+
size="icon"
|
|
732
|
+
onClick={() => onTabChange(activeTab === 4 ? 0 : 4)}
|
|
733
|
+
className={cn(
|
|
734
|
+
'h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md shadow-sm',
|
|
735
|
+
activeTab === 4 && 'bg-background text-foreground shadow'
|
|
736
|
+
)}
|
|
737
|
+
title={t('tabs.memories')}>
|
|
738
|
+
<Brain className="w-4 h-4" />
|
|
739
|
+
</Button>
|
|
740
|
+
)}
|
|
741
|
+
{isFullscreen && onNewChat && (
|
|
742
|
+
<Button
|
|
743
|
+
variant="ghost"
|
|
744
|
+
size="icon"
|
|
745
|
+
onClick={onNewChat}
|
|
746
|
+
className="h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md shadow-sm"
|
|
747
|
+
title={t('buttons.start_new_thread')}>
|
|
748
|
+
<Edit className="w-4 h-4" />
|
|
749
|
+
</Button>
|
|
750
|
+
)}
|
|
751
|
+
</div>
|
|
752
|
+
)}
|
|
753
|
+
|
|
754
|
+
{/* Floating Sidebar — narrow screens only */}
|
|
755
|
+
{enableSidebar && isSidebarOpen && renderSidebar && (
|
|
756
|
+
<>
|
|
757
|
+
{/* Background Mask */}
|
|
758
|
+
<div
|
|
759
|
+
className="absolute inset-0 bg-black/20 z-[99] @3xl:hidden"
|
|
760
|
+
onClick={onToggleSidebar} />
|
|
761
|
+
|
|
762
|
+
{/* Sidebar Panel */}
|
|
763
|
+
<div className="absolute left-0 top-0 h-full w-72 bg-background z-[100] shadow-xl border-r @3xl:hidden">
|
|
764
|
+
<div className="w-full h-full flex flex-col">
|
|
765
|
+
{/* Sidebar Header */}
|
|
766
|
+
<div className="flex items-center justify-between h-12 px-3 border-b shrink-0">
|
|
767
|
+
{commonProps.logo || commonProps.title ? (
|
|
768
|
+
<div className="flex items-center gap-2 min-w-0">
|
|
769
|
+
<Avatar className="h-7 w-7 shrink-0 after:hidden">
|
|
770
|
+
<AvatarImage src={commonProps.logo} alt={commonProps.title} />
|
|
771
|
+
<AvatarFallback className="text-xs">
|
|
772
|
+
{(commonProps.title || 'AI').substring(0, 2).toUpperCase()}
|
|
773
|
+
</AvatarFallback>
|
|
774
|
+
</Avatar>
|
|
775
|
+
<span className="text-sm font-medium truncate">{commonProps.title}</span>
|
|
776
|
+
</div>
|
|
777
|
+
) : <div />}
|
|
778
|
+
<Button
|
|
779
|
+
variant="ghost"
|
|
780
|
+
size="icon"
|
|
781
|
+
onClick={onToggleSidebar}
|
|
782
|
+
className="h-8 w-8 shrink-0 text-muted-foreground hover:text-foreground">
|
|
783
|
+
<X className="w-4 h-4" />
|
|
784
|
+
</Button>
|
|
785
|
+
</div>
|
|
786
|
+
{/* Sidebar Content */}
|
|
787
|
+
<div className="flex-1 p-4 flex flex-col min-h-0 overflow-hidden">
|
|
788
|
+
{renderSidebar()}
|
|
789
|
+
</div>
|
|
790
|
+
</div>
|
|
791
|
+
</div>
|
|
792
|
+
</>
|
|
793
|
+
)}
|
|
794
|
+
|
|
795
|
+
{/* Inline Sidebar — wide screens only */}
|
|
796
|
+
{enableSidebar && renderSidebar && (
|
|
797
|
+
<div
|
|
798
|
+
className={cn(
|
|
799
|
+
'hidden @3xl:flex flex-col flex-none bg-background border-r transition-all duration-300 overflow-hidden',
|
|
800
|
+
isSidebarOpen ? 'w-72' : 'w-0'
|
|
801
|
+
)}>
|
|
802
|
+
<div className="w-72 h-full flex flex-col relative">
|
|
803
|
+
{/* Top-right controls inside sidebar when open */}
|
|
804
|
+
{isSidebarOpen && (
|
|
805
|
+
<div className="absolute top-2 right-2 z-10 flex flex-col gap-1">
|
|
806
|
+
{onToggleSidebar && (
|
|
807
|
+
<Button
|
|
808
|
+
variant="ghost"
|
|
809
|
+
size="icon"
|
|
810
|
+
onClick={onToggleSidebar}
|
|
811
|
+
className="h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md">
|
|
812
|
+
<PanelLeft className="w-4 h-4" />
|
|
813
|
+
</Button>
|
|
814
|
+
)}
|
|
815
|
+
{onTabChange && (
|
|
816
|
+
<Button
|
|
817
|
+
variant="ghost"
|
|
818
|
+
size="icon"
|
|
819
|
+
onClick={() => onTabChange(activeTab === 4 ? 0 : 4)}
|
|
820
|
+
className={cn(
|
|
821
|
+
'h-8 w-8 text-muted-foreground hover:bg-accent hover:text-accent-foreground rounded-md',
|
|
822
|
+
activeTab === 4 && 'bg-accent text-accent-foreground'
|
|
823
|
+
)}
|
|
824
|
+
title={t('tabs.memories')}>
|
|
825
|
+
<Brain className="w-4 h-4" />
|
|
826
|
+
</Button>
|
|
827
|
+
)}
|
|
828
|
+
</div>
|
|
829
|
+
)}
|
|
830
|
+
<div className="flex-1 p-4 flex flex-col min-h-0 overflow-hidden">
|
|
831
|
+
{renderSidebar()}
|
|
832
|
+
</div>
|
|
833
|
+
</div>
|
|
834
|
+
</div>
|
|
835
|
+
)}
|
|
836
|
+
|
|
837
|
+
{/* Chat */}
|
|
838
|
+
<div className={cn(
|
|
839
|
+
'flex flex-col min-h-0 overflow-hidden transition-all duration-200',
|
|
840
|
+
canvasWork ? 'w-2/5' : 'flex-1',
|
|
841
|
+
!isSidebarOpen && enableSidebar && 'pl-10'
|
|
842
|
+
)}>
|
|
843
|
+
{activeTab === 1 ? (
|
|
844
|
+
// Sessions View
|
|
845
|
+
<div className="flex flex-col flex-1 min-h-0 overflow-hidden">
|
|
846
|
+
<div className="flex items-center gap-1 px-3 h-10 shrink-0">
|
|
847
|
+
<Button
|
|
848
|
+
variant="ghost"
|
|
849
|
+
size="icon"
|
|
850
|
+
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
851
|
+
onClick={() => onTabChange?.(0)}>
|
|
852
|
+
<ArrowLeft className="w-4 h-4" />
|
|
853
|
+
</Button>
|
|
854
|
+
</div>
|
|
855
|
+
{renderSessionsView ? (
|
|
856
|
+
renderSessionsView()
|
|
857
|
+
) : (
|
|
858
|
+
<div className="flex-1 flex items-center justify-center text-muted-foreground">
|
|
859
|
+
Sessions view not available
|
|
860
|
+
</div>
|
|
861
|
+
)}
|
|
862
|
+
</div>
|
|
863
|
+
) : activeTab === 2 ? (
|
|
864
|
+
// Projects View
|
|
865
|
+
<div className="flex flex-col flex-1 min-h-0 overflow-hidden">
|
|
866
|
+
<div className="flex items-center gap-1 px-3 h-10 shrink-0">
|
|
867
|
+
<Button
|
|
868
|
+
variant="ghost"
|
|
869
|
+
size="icon"
|
|
870
|
+
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
871
|
+
onClick={() => onTabChange?.(0)}>
|
|
872
|
+
<ArrowLeft className="w-4 h-4" />
|
|
873
|
+
</Button>
|
|
874
|
+
</div>
|
|
875
|
+
{renderProjectsView ? (
|
|
876
|
+
renderProjectsView()
|
|
877
|
+
) : (
|
|
878
|
+
<div className="flex-1 flex items-center justify-center text-muted-foreground">
|
|
879
|
+
Projects view not available
|
|
880
|
+
</div>
|
|
881
|
+
)}
|
|
882
|
+
</div>
|
|
883
|
+
) : activeTab === 4 ? (
|
|
884
|
+
// Memories View
|
|
885
|
+
<div className="flex flex-col flex-1 min-h-0 overflow-hidden">
|
|
886
|
+
<div className="flex items-center gap-1 px-3 h-10 shrink-0">
|
|
887
|
+
<Button
|
|
888
|
+
variant="ghost"
|
|
889
|
+
size="icon"
|
|
890
|
+
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
891
|
+
onClick={() => onTabChange?.(0)}>
|
|
892
|
+
<ArrowLeft className="w-4 h-4" />
|
|
893
|
+
</Button>
|
|
894
|
+
</div>
|
|
895
|
+
{renderMemoriesView ? (
|
|
896
|
+
renderMemoriesView()
|
|
897
|
+
) : (
|
|
898
|
+
<div className="flex-1 flex items-center justify-center text-muted-foreground">
|
|
899
|
+
Memories view not available
|
|
900
|
+
</div>
|
|
901
|
+
)}
|
|
902
|
+
</div>
|
|
903
|
+
) : activeTab === 3 ? (
|
|
904
|
+
// Works View
|
|
905
|
+
<div className="flex flex-col flex-1 min-h-0 overflow-hidden">
|
|
906
|
+
<div className="flex items-center gap-1 px-3 h-10 shrink-0">
|
|
907
|
+
<Button
|
|
908
|
+
variant="ghost"
|
|
909
|
+
size="icon"
|
|
910
|
+
className="h-7 w-7 text-muted-foreground hover:text-foreground"
|
|
911
|
+
onClick={() => onTabChange?.(0)}>
|
|
912
|
+
<ArrowLeft className="w-4 h-4" />
|
|
913
|
+
</Button>
|
|
914
|
+
</div>
|
|
915
|
+
{renderWorksView ? (
|
|
916
|
+
renderWorksView()
|
|
917
|
+
) : (
|
|
918
|
+
<div className="flex-1 flex items-center justify-center text-muted-foreground">
|
|
919
|
+
Works view not available
|
|
920
|
+
</div>
|
|
921
|
+
)}
|
|
922
|
+
</div>
|
|
923
|
+
) : (
|
|
924
|
+
// Default: Chat View
|
|
925
|
+
<ChatPanel
|
|
926
|
+
messages={commonProps.messages}
|
|
927
|
+
isLoading={commonProps.isLoading}
|
|
928
|
+
input={commonProps.input}
|
|
929
|
+
onInputChange={commonProps.onInputChange}
|
|
930
|
+
onSendMessage={commonProps.onSendMessage}
|
|
931
|
+
onStop={commonProps.onStop}
|
|
932
|
+
logo={commonProps.logo}
|
|
933
|
+
userPhoto={commonProps.userPhoto}
|
|
934
|
+
userDisplayName={commonProps.userDisplayName}
|
|
935
|
+
description={commonProps.description}
|
|
936
|
+
title={commonProps.title}
|
|
937
|
+
welcomeMessage={commonProps.welcomeMessage}
|
|
938
|
+
isLoadingAgent={commonProps.isLoadingAgent}
|
|
939
|
+
placeholder={commonProps.placeholder}
|
|
940
|
+
footerText={commonProps.footerText}
|
|
941
|
+
supportFiles={commonProps.supportFiles}
|
|
942
|
+
supportWebSearch={commonProps.supportWebSearch}
|
|
943
|
+
supportDocumentSearch={commonProps.supportDocumentSearch}
|
|
944
|
+
supportDeepResearch={commonProps.supportDeepResearch}
|
|
945
|
+
supportThinking={commonProps.supportThinking}
|
|
946
|
+
supportWorkCanvas={commonProps.supportWorkCanvas}
|
|
947
|
+
supportMultiModels={commonProps.supportMultiModels}
|
|
948
|
+
deploymentId={commonProps.deploymentId}
|
|
949
|
+
tenantAiAgentId={commonProps.tenantAiAgentId}
|
|
950
|
+
enableMicrophone={commonProps.enableMicrophone}
|
|
951
|
+
enableVoice={commonProps.enableVoice}
|
|
952
|
+
isRecording={commonProps.isRecording}
|
|
953
|
+
recognition={commonProps.recognition}
|
|
954
|
+
onMicrophoneClick={commonProps.onMicrophoneClick}
|
|
955
|
+
onToolAction={commonProps.onToolAction}
|
|
956
|
+
openCanvasView={handleOpenCanvasViewInline}
|
|
957
|
+
renderThreadHeader={renderThreadHeader}
|
|
958
|
+
threadId={commonProps.threadId}
|
|
959
|
+
compactToolbar={!isFullscreen} />
|
|
960
|
+
)}
|
|
961
|
+
</div>
|
|
962
|
+
|
|
963
|
+
{/* Canvas Panel */}
|
|
964
|
+
{canvasWork && (
|
|
965
|
+
<div className="w-3/5 border-l bg-background flex flex-col shrink-0">
|
|
966
|
+
<div className="flex items-center gap-2 h-12 px-3 border-b shrink-0">
|
|
967
|
+
<span className="text-sm font-medium truncate flex-1">{canvasWork.title}</span>
|
|
968
|
+
{canvasWork.type === WorkTypes.Code && (
|
|
969
|
+
<div className="flex items-center gap-0.5 bg-muted rounded-md p-0.5 shrink-0">
|
|
970
|
+
<Button
|
|
971
|
+
variant="ghost"
|
|
972
|
+
size="sm"
|
|
973
|
+
className={cn(
|
|
974
|
+
'h-6 px-2 text-xs rounded-sm',
|
|
975
|
+
activeCanvasTab === 0 ? 'bg-background shadow-sm text-foreground' : 'text-muted-foreground hover:text-foreground'
|
|
976
|
+
)}
|
|
977
|
+
onClick={() => setActiveCanvasTab(0)}>
|
|
978
|
+
<Eye className="w-3 h-3 mr-1" />
|
|
979
|
+
Preview
|
|
980
|
+
</Button>
|
|
981
|
+
<Button
|
|
982
|
+
variant="ghost"
|
|
983
|
+
size="sm"
|
|
984
|
+
className={cn(
|
|
985
|
+
'h-6 px-2 text-xs rounded-sm',
|
|
986
|
+
activeCanvasTab === 1 ? 'bg-background shadow-sm text-foreground' : 'text-muted-foreground hover:text-foreground'
|
|
987
|
+
)}
|
|
988
|
+
onClick={() => setActiveCanvasTab(1)}>
|
|
989
|
+
<Code2 className="w-3 h-3 mr-1" />
|
|
990
|
+
Code
|
|
991
|
+
</Button>
|
|
992
|
+
</div>
|
|
993
|
+
)}
|
|
994
|
+
{canvasWork.type !== WorkTypes.Record && canvasWork.type !== WorkTypes.Data && canvasWork.type !== WorkTypes.App && (
|
|
995
|
+
<DropdownMenu>
|
|
996
|
+
<DropdownMenuTrigger asChild>
|
|
997
|
+
<Button variant="outline" size="sm" className="h-7 text-xs px-2 shrink-0" disabled={canvasVersionsLoading}>
|
|
998
|
+
{canvasVersionsLoading ? '...' : (canvasVersions.find(v => v.id === canvasSelectedVersionId)?.name ?? t('labels.select_version'))}
|
|
999
|
+
<ChevronDown className="ml-1 h-3 w-3" />
|
|
1000
|
+
</Button>
|
|
1001
|
+
</DropdownMenuTrigger>
|
|
1002
|
+
<DropdownMenuContent align="end" className="max-h-60 overflow-y-auto">
|
|
1003
|
+
{canvasVersions.length === 0 ? (
|
|
1004
|
+
<DropdownMenuItem disabled className="text-xs text-muted-foreground">
|
|
1005
|
+
{t('messages.no_versions_found')}
|
|
1006
|
+
</DropdownMenuItem>
|
|
1007
|
+
) : (
|
|
1008
|
+
canvasVersions.map(v => (
|
|
1009
|
+
<DropdownMenuItem
|
|
1010
|
+
key={v.id}
|
|
1011
|
+
className={`cursor-pointer text-xs ${canvasSelectedVersionId === v.id ? 'bg-accent text-accent-foreground' : ''}`}
|
|
1012
|
+
onClick={() => handleCanvasVersionSelect(v.id)}>
|
|
1013
|
+
{v.name}
|
|
1014
|
+
</DropdownMenuItem>
|
|
1015
|
+
))
|
|
1016
|
+
)}
|
|
1017
|
+
</DropdownMenuContent>
|
|
1018
|
+
</DropdownMenu>
|
|
1019
|
+
)}
|
|
1020
|
+
<Button
|
|
1021
|
+
variant="ghost"
|
|
1022
|
+
size="icon"
|
|
1023
|
+
onClick={() => setCanvasWork(null)}
|
|
1024
|
+
className="h-8 w-8 shrink-0 text-muted-foreground hover:text-foreground">
|
|
1025
|
+
<X className="w-4 h-4" />
|
|
1026
|
+
</Button>
|
|
1027
|
+
</div>
|
|
1028
|
+
<div className="flex-1 overflow-y-auto">
|
|
1029
|
+
{canvasVersionsLoading && (
|
|
1030
|
+
<div className="flex h-full items-center justify-center">
|
|
1031
|
+
<Loader2 className="size-5 animate-spin text-muted-foreground" />
|
|
1032
|
+
</div>
|
|
1033
|
+
)}
|
|
1034
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.Record && (
|
|
1035
|
+
<CanvasRecordView
|
|
1036
|
+
dataSourceId={canvasWork.content_json?.dataSourceId ?? ''}
|
|
1037
|
+
mode={canvasWork.content_json?.mode ?? 'add'}
|
|
1038
|
+
defaultValues={canvasWork.content_json?.data}
|
|
1039
|
+
recordId={canvasWork.content_json?.recordId}
|
|
1040
|
+
onClose={() => setCanvasWork(null)}
|
|
1041
|
+
onSave={(id, data) => {
|
|
1042
|
+
console.info('[CanvasRecordView] saved:', id, data);
|
|
1043
|
+
}} />
|
|
1044
|
+
)}
|
|
1045
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.Image && (
|
|
1046
|
+
<CanvasImageView
|
|
1047
|
+
title={canvasWork.title}
|
|
1048
|
+
images={canvasVersionImages ?? canvasWork.content_json} />
|
|
1049
|
+
)}
|
|
1050
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.Text && (
|
|
1051
|
+
<CanvasTextView
|
|
1052
|
+
contentText={canvasVersionContent ?? ''}
|
|
1053
|
+
language={(canvasVersionLanguage as any) ?? 'markdown'}
|
|
1054
|
+
title={canvasWork.title} />
|
|
1055
|
+
)}
|
|
1056
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.Data && (
|
|
1057
|
+
<CanvasDeepResearchView
|
|
1058
|
+
title={canvasWork.title}
|
|
1059
|
+
output_schema={canvasWork.content_json?.output_schema}
|
|
1060
|
+
content={canvasWork.content_json?.content}
|
|
1061
|
+
basis={canvasWork.content_json?.basis} />
|
|
1062
|
+
)}
|
|
1063
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.Xlsx && (
|
|
1064
|
+
canvasSelectedVersionId && !canvasVersionImages ? (
|
|
1065
|
+
<div className="flex h-full items-center justify-center">
|
|
1066
|
+
<Loader2 className="size-5 animate-spin text-muted-foreground" />
|
|
1067
|
+
</div>
|
|
1068
|
+
) : (
|
|
1069
|
+
<CanvasSpreadsheetView
|
|
1070
|
+
key={canvasSelectedVersionId ?? canvasWork.id}
|
|
1071
|
+
title={canvasWork.title}
|
|
1072
|
+
content={canvasVersionImages ?? canvasWork.content_json}
|
|
1073
|
+
workId={canvasWork.id}
|
|
1074
|
+
versionId={canvasSelectedVersionId ?? undefined}
|
|
1075
|
+
commands={canvasSpreadsheetCommands}
|
|
1076
|
+
onData={async (data) => {
|
|
1077
|
+
const workId = canvasWork.id;
|
|
1078
|
+
|
|
1079
|
+
if (!workId || workId === 'streaming') return;
|
|
1080
|
+
|
|
1081
|
+
try {
|
|
1082
|
+
await apiClient.post(`/ai/works/${workId}/modify`, {
|
|
1083
|
+
content_json: {
|
|
1084
|
+
...(canvasWork.content_json ?? {}),
|
|
1085
|
+
workbook: data.workbook
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
} catch {
|
|
1089
|
+
console.warn("Version didn't save succesfully.");
|
|
1090
|
+
}
|
|
1091
|
+
}} />
|
|
1092
|
+
)
|
|
1093
|
+
)}
|
|
1094
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.App && (
|
|
1095
|
+
<CanvasAppView app={canvasWork.content_json} />
|
|
1096
|
+
)}
|
|
1097
|
+
{!canvasVersionsLoading && canvasWork.type === WorkTypes.Code && canvasWork.id && (
|
|
1098
|
+
activeCanvasTab === 0 ? (
|
|
1099
|
+
<ShellCanvas
|
|
1100
|
+
workId={canvasWork.id}
|
|
1101
|
+
versionId={canvasSelectedVersionId}
|
|
1102
|
+
title={canvasWork.title} />
|
|
1103
|
+
) : (
|
|
1104
|
+
<CanvasCodeView
|
|
1105
|
+
contentText={canvasVersionContent ?? ''}
|
|
1106
|
+
language={canvasVersionLanguage as any}
|
|
1107
|
+
title={canvasWork.title} />
|
|
1108
|
+
)
|
|
1109
|
+
)}
|
|
1110
|
+
</div>
|
|
1111
|
+
</div>
|
|
1112
|
+
)}
|
|
1113
|
+
</div>
|
|
1114
|
+
</div>
|
|
1115
|
+
);
|
|
1116
|
+
|
|
1117
|
+
if (isFullscreen && typeof document !== 'undefined') {
|
|
1118
|
+
return createPortal(content, document.body);
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
return content;
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
AssistantView.displayName = 'AssistantView';
|
|
1125
|
+
|
|
1126
|
+
export type InlineViewProps = Omit<InlineModeProps, 'mode'>;
|
|
1127
|
+
export type ConversationViewProps = Omit<ConversationModeProps, 'mode'>;
|
|
1128
|
+
|
|
1129
|
+
export const InlineView = ({ ref, ...props }: InlineViewProps & { ref?: Ref<HTMLDivElement | null> }) => <AssistantView mode="inline" {...props} ref={ref} />;
|
|
1130
|
+
|
|
1131
|
+
InlineView.displayName = 'InlineView';
|
|
1132
|
+
|
|
1133
|
+
export const ConversationView: FC<ConversationViewProps> = props => (
|
|
1134
|
+
<AssistantView mode="conversation" {...props} />
|
|
1135
|
+
);
|
|
1136
|
+
|
|
1137
|
+
ConversationView.displayName = 'ConversationView';
|