@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.5
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/components/assistant-animations.d.ts +3 -3
- package/dist/docy-assistant.d.ts +1 -1
- package/dist/index.js +74 -47
- package/dist/index.js.map +1 -1
- package/dist/styles.css +5137 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/views/assistant-view.d.ts +2 -2
- package/package.json +38 -36
- package/src/components/assistant-animations.tsx +0 -29
- package/src/components/assistant-dialogs.tsx +0 -235
- package/src/components/code-view.tsx +0 -278
- package/src/components/create-agent-task.tsx +0 -104
- package/src/components/create-new-work-version.tsx +0 -30
- package/src/components/extract-web.tsx +0 -160
- package/src/components/forward-to-agent.tsx +0 -90
- package/src/components/generate-chart.tsx +0 -101
- package/src/components/generative-action-button.tsx +0 -122
- package/src/components/generative-tool.tsx +0 -685
- package/src/components/generative-ui-object.tsx +0 -210
- package/src/components/input-area.tsx +0 -1209
- package/src/components/json-schema-layout.tsx +0 -326
- package/src/components/list-item-card.tsx +0 -92
- package/src/components/mermaid-diagram.tsx +0 -192
- package/src/components/preview-image.tsx +0 -47
- package/src/components/request-approval.tsx +0 -48
- package/src/components/request-user-input.tsx +0 -270
- package/src/components/search-web.tsx +0 -319
- package/src/components/sheet-command.tsx +0 -88
- package/src/components/shell-canvas.tsx +0 -122
- package/src/components/show-advanced-data-table.tsx +0 -352
- package/src/components/show-generated-content-options.tsx +0 -93
- package/src/components/show-people-cards.tsx +0 -180
- package/src/components/subagent-tool.tsx +0 -180
- package/src/components/text-editor-tool.tsx +0 -328
- package/src/components/work-canvas.tsx +0 -88
- package/src/components/work-card.tsx +0 -42
- package/src/declarations.d.ts +0 -1
- package/src/docy-assistant.tsx +0 -1962
- package/src/hooks/index.ts +0 -7
- package/src/hooks/use-assistant-api.ts +0 -507
- package/src/hooks/use-deployment-data.ts +0 -162
- package/src/hooks/use-project-state.ts +0 -347
- package/src/hooks/use-session-state.ts +0 -207
- package/src/hooks/use-speech-recognition.ts +0 -137
- package/src/hooks/use-ui-state.ts +0 -185
- package/src/hooks/use-works-state.ts +0 -146
- package/src/i18n/context.tsx +0 -253
- package/src/i18n/index.ts +0 -19
- package/src/i18n/locales/de.json +0 -198
- package/src/i18n/locales/el.json +0 -198
- package/src/i18n/locales/en.json +0 -226
- package/src/i18n/locales/es.json +0 -198
- package/src/i18n/locales/fr.json +0 -198
- package/src/i18n/locales/it.json +0 -198
- package/src/i18n/locales/pt.json +0 -198
- package/src/i18n/locales/sl.json +0 -198
- package/src/i18n/locales/tr.json +0 -211
- package/src/i18n/types.ts +0 -23
- package/src/i18n/use-translation.ts +0 -17
- package/src/index.ts +0 -18
- package/src/internal/plate-editor/editor/auth-context.ts +0 -11
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +0 -39
- package/src/internal/plate-editor/editor/editor-kit.tsx +0 -89
- package/src/internal/plate-editor/editor/plate-editor.tsx +0 -75
- package/src/internal/plate-editor/editor/plate-types.ts +0 -126
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +0 -172
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +0 -211
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +0 -51
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +0 -38
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +0 -31
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +0 -23
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +0 -174
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +0 -68
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +0 -13
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +0 -43
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +0 -15
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +0 -12
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +0 -47
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +0 -35
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +0 -18
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +0 -10
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +0 -37
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +0 -53
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +0 -95
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +0 -20
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +0 -9
- package/src/internal/plate-editor/editor/transforms.ts +0 -165
- package/src/internal/plate-editor/editor/use-chat.ts +0 -152
- package/src/internal/plate-editor/hooks/index.ts +0 -3
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +0 -31
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +0 -26
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +0 -21
- package/src/internal/plate-editor/hooks/use-media-query.ts +0 -44
- package/src/internal/plate-editor/hooks/use-mounted.ts +0 -18
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +0 -114
- package/src/internal/plate-editor/hooks/use-upload-file.ts +0 -81
- package/src/internal/plate-editor/i18n/context.tsx +0 -58
- package/src/internal/plate-editor/i18n/index.ts +0 -3
- package/src/internal/plate-editor/i18n/locales/de.json +0 -57
- package/src/internal/plate-editor/i18n/locales/el.json +0 -57
- package/src/internal/plate-editor/i18n/locales/en.json +0 -57
- package/src/internal/plate-editor/i18n/locales/es.json +0 -57
- package/src/internal/plate-editor/i18n/locales/fr.json +0 -57
- package/src/internal/plate-editor/i18n/locales/it.json +0 -57
- package/src/internal/plate-editor/i18n/locales/pt.json +0 -57
- package/src/internal/plate-editor/i18n/locales/sl.json +0 -57
- package/src/internal/plate-editor/i18n/locales/tr.json +0 -57
- package/src/internal/plate-editor/i18n/types.ts +0 -59
- package/src/internal/plate-editor/i18n/use-translation.ts +0 -22
- package/src/internal/plate-editor/index.ts +0 -39
- package/src/internal/plate-editor/lib/ai-output-converter.ts +0 -153
- package/src/internal/plate-editor/lib/download-file.ts +0 -17
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +0 -828
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +0 -145
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +0 -88
- package/src/internal/plate-editor/plate-ui/avatar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +0 -104
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +0 -364
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +0 -557
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +0 -77
- package/src/internal/plate-editor/plate-ui/block-list.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +0 -555
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +0 -469
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +0 -10
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/button.tsx +0 -201
- package/src/internal/plate-editor/plate-ui/calendar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +0 -76
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/caption.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +0 -172
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/code-node.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +0 -65
- package/src/internal/plate-editor/plate-ui/column-node.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/command.tsx +0 -202
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +0 -45
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/comment.tsx +0 -619
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +0 -43
- package/src/internal/plate-editor/plate-ui/date-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/dialog.tsx +0 -445
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +0 -264
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +0 -40
- package/src/internal/plate-editor/plate-ui/editor.tsx +0 -146
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +0 -626
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +0 -155
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +0 -26
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +0 -206
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +0 -157
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +0 -1129
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +0 -129
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +0 -97
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +0 -209
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +0 -152
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +0 -20
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +0 -56
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +0 -9
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +0 -50
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +0 -7
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +0 -122
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +0 -409
- package/src/internal/plate-editor/plate-ui/input.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +0 -258
- package/src/internal/plate-editor/plate-ui/label.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +0 -69
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/link-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +0 -147
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +0 -177
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +0 -21
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +0 -103
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +0 -30
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +0 -183
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +0 -441
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +0 -127
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +0 -227
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +0 -214
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +0 -73
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +0 -119
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +0 -46
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/menu.tsx +0 -539
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +0 -124
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +0 -16
- package/src/internal/plate-editor/plate-ui/popover.tsx +0 -75
- package/src/internal/plate-editor/plate-ui/progress.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +0 -86
- package/src/internal/plate-editor/plate-ui/separator.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +0 -433
- package/src/internal/plate-editor/plate-ui/spinner.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +0 -166
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +0 -84
- package/src/internal/plate-editor/plate-ui/table-node.tsx +0 -283
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +0 -252
- package/src/internal/plate-editor/plate-ui/tabs.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/textarea.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +0 -142
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/toggle.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +0 -378
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +0 -148
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +0 -175
- package/src/internal/plate-editor/types/index.ts +0 -22
- package/src/internal/plate-editor/vite.ts +0 -284
- package/src/internal/sheets/components/univer-sheets.tsx +0 -1104
- package/src/internal/sheets/i18n/context.tsx +0 -183
- package/src/internal/sheets/i18n/index.ts +0 -19
- package/src/internal/sheets/i18n/locales/de.json +0 -21
- package/src/internal/sheets/i18n/locales/el.json +0 -21
- package/src/internal/sheets/i18n/locales/en.json +0 -21
- package/src/internal/sheets/i18n/locales/es.json +0 -21
- package/src/internal/sheets/i18n/locales/fr.json +0 -21
- package/src/internal/sheets/i18n/locales/it.json +0 -21
- package/src/internal/sheets/i18n/locales/pt.json +0 -21
- package/src/internal/sheets/i18n/locales/sl.json +0 -21
- package/src/internal/sheets/i18n/locales/tr.json +0 -21
- package/src/internal/sheets/i18n/types.ts +0 -23
- package/src/internal/sheets/i18n/use-translation.ts +0 -17
- package/src/internal/sheets/index.ts +0 -14
- package/src/internal/sheets/types/css.d.ts +0 -11
- package/src/internal/sheets/types/index.ts +0 -260
- package/src/internal/sheets/xlsx.ts +0 -1169
- package/src/lib/api-client.ts +0 -77
- package/src/lib/assistant-api-actions.ts +0 -549
- package/src/lib/assistant-config.tsx +0 -75
- package/src/lib/class-utils.ts +0 -40
- package/src/lib/index.ts +0 -7
- package/src/lib/message-utils.ts +0 -131
- package/src/tools/tools-schema.json +0 -512
- package/src/types/index.ts +0 -235
- package/src/views/assistant-view.tsx +0 -1137
- package/src/views/canvas-app.tsx +0 -839
- package/src/views/canvas-code.tsx +0 -93
- package/src/views/canvas-deep-research.tsx +0 -44
- package/src/views/canvas-image.tsx +0 -25
- package/src/views/canvas-record-view.tsx +0 -285
- package/src/views/canvas-spreadsheet.tsx +0 -125
- package/src/views/canvas-text.tsx +0 -52
- package/src/views/canvas.tsx +0 -274
- package/src/views/chat-panel.tsx +0 -149
- package/src/views/index.ts +0 -20
- package/src/views/memories-panel.tsx +0 -365
- package/src/views/message-list.tsx +0 -370
- package/src/views/project-detail.tsx +0 -257
- package/src/views/projects-panel.tsx +0 -131
- package/src/views/sessions-list.tsx +0 -98
- package/src/views/sidebar-content.tsx +0 -256
- package/src/views/work-detail.tsx +0 -98
- package/src/vite.ts +0 -64
- package/src/worker.ts +0 -203
|
@@ -1,1137 +0,0 @@
|
|
|
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';
|