mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 04:26:56 +00:00
feat(webui): add chatbot layout and drag-drop context store
This commit is contained in:
@@ -23,7 +23,16 @@ import { cn } from '@/ui/lib/utils'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import type { AncestorFolder } from '@shumai/dtos'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { Check, ChevronDown, Columns2, FileIcon, History, LayoutGrid, List } from 'lucide-react'
|
||||
import {
|
||||
Check,
|
||||
ChevronDown,
|
||||
Columns2,
|
||||
FileIcon,
|
||||
History,
|
||||
LayoutGrid,
|
||||
List,
|
||||
MessageSquare,
|
||||
} from 'lucide-react'
|
||||
|
||||
interface BreadcrumbNavProps {
|
||||
teamId: string
|
||||
@@ -43,6 +52,8 @@ interface BreadcrumbNavProps {
|
||||
onLeftSidebarToggle?: () => void
|
||||
isRightSidebarCollapsed: boolean
|
||||
onRightSidebarToggle: () => void
|
||||
isChatbotOpen?: boolean
|
||||
onChatbotToggle?: () => void
|
||||
isPublic?: boolean
|
||||
shareId?: string
|
||||
onFolderClick?: (folderId: string) => void
|
||||
@@ -81,6 +92,8 @@ export function BreadcrumbNav({
|
||||
onLeftSidebarToggle,
|
||||
isRightSidebarCollapsed,
|
||||
onRightSidebarToggle,
|
||||
isChatbotOpen = false,
|
||||
onChatbotToggle,
|
||||
isPublic = false,
|
||||
onFolderClick,
|
||||
fileId,
|
||||
@@ -364,67 +377,89 @@ export function BreadcrumbNav({
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!fileId && (
|
||||
<div className="flex flex-shrink-0 items-center gap-1 rounded-md border border-border bg-background p-1">
|
||||
{/* Left Sidebar Toggle */}
|
||||
{!isPublic && onLeftSidebarToggle && (
|
||||
<button
|
||||
onClick={onLeftSidebarToggle}
|
||||
className="rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"
|
||||
title={isLeftSidebarCollapsed ? 'Show Left Sidebar' : 'Hide Left Sidebar'}
|
||||
>
|
||||
{isLeftSidebarCollapsed ? (
|
||||
<DockToLeft className="h-4 w-4" />
|
||||
) : (
|
||||
<DockToLeftFilled className="h-4 w-4 fill-primary stroke-0" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Card View */}
|
||||
{!isPublic && displayStyle && onDisplayStyleChange && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => onDisplayStyleChange('card')}
|
||||
className={`rounded p-1.5 transition-colors ${
|
||||
displayStyle === 'card'
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'
|
||||
}`}
|
||||
title="Card View"
|
||||
>
|
||||
<LayoutGrid className="h-4 w-4" />
|
||||
</button>
|
||||
|
||||
{/* List View */}
|
||||
<button
|
||||
onClick={() => onDisplayStyleChange('list')}
|
||||
className={`rounded p-1.5 transition-colors ${
|
||||
displayStyle === 'list'
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'
|
||||
}`}
|
||||
title="List View"
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Right Sidebar Toggle */}
|
||||
<div className="flex flex-shrink-0 items-center gap-1 rounded-md border border-border bg-background p-1">
|
||||
{/* Left Sidebar Toggle */}
|
||||
{!fileId && !isPublic && onLeftSidebarToggle && (
|
||||
<button
|
||||
onClick={onRightSidebarToggle}
|
||||
onClick={onLeftSidebarToggle}
|
||||
className="rounded p-1.5 text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground"
|
||||
title={isRightSidebarCollapsed ? 'Show Right Sidebar' : 'Hide Right Sidebar'}
|
||||
title={isLeftSidebarCollapsed ? 'Show Left Sidebar' : 'Hide Left Sidebar'}
|
||||
>
|
||||
{isRightSidebarCollapsed ? (
|
||||
<DockToRight className="h-4 w-4" />
|
||||
{isLeftSidebarCollapsed ? (
|
||||
<DockToLeft className="h-4 w-4" />
|
||||
) : (
|
||||
<DockToRightFilled className="h-4 w-4 fill-primary stroke-0" />
|
||||
<DockToLeftFilled className="h-4 w-4 fill-primary stroke-0" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
|
||||
{/* Card View */}
|
||||
{!fileId && !isPublic && displayStyle && onDisplayStyleChange && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => onDisplayStyleChange('card')}
|
||||
className={`rounded p-1.5 transition-colors ${
|
||||
displayStyle === 'card'
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'
|
||||
}`}
|
||||
title="Card View"
|
||||
>
|
||||
<LayoutGrid className="h-4 w-4" />
|
||||
</button>
|
||||
|
||||
{/* List View */}
|
||||
<button
|
||||
onClick={() => onDisplayStyleChange('list')}
|
||||
className={`rounded p-1.5 transition-colors ${
|
||||
displayStyle === 'list'
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'
|
||||
}`}
|
||||
title="List View"
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Right Sidebar Toggle */}
|
||||
<button
|
||||
onClick={onRightSidebarToggle}
|
||||
className={`rounded p-1.5 transition-colors ${
|
||||
!isRightSidebarCollapsed && !isChatbotOpen
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'
|
||||
}`}
|
||||
title={isRightSidebarCollapsed ? 'Show Right Sidebar' : 'Hide Right Sidebar'}
|
||||
>
|
||||
{!isRightSidebarCollapsed && !isChatbotOpen ? (
|
||||
<DockToRightFilled className="h-4 w-4 fill-primary stroke-0" />
|
||||
) : (
|
||||
<DockToRight className="h-4 w-4" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Chatbot Toggle Button */}
|
||||
{!isPublic && onChatbotToggle && (
|
||||
<button
|
||||
onClick={onChatbotToggle}
|
||||
className={`rounded p-1.5 transition-colors ${
|
||||
isChatbotOpen
|
||||
? 'bg-accent text-accent-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'
|
||||
}`}
|
||||
title={isChatbotOpen ? m.hide_chatbot() : m.show_chatbot()}
|
||||
>
|
||||
<MessageSquare
|
||||
className={cn(
|
||||
'h-4 w-4 transition-colors',
|
||||
isChatbotOpen ? 'text-primary fill-primary stroke-1' : 'text-muted-foreground',
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import { useDroppable } from '@dnd-kit/react'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
import { File, Folder, X, MessageSquare } from 'lucide-react'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
export function ChatbotSidebar() {
|
||||
const { chatAssets, removeAsset, clearAssets } = useChatbotStore()
|
||||
|
||||
const { ref: setDroppableRef, isDropTarget: isOver } = useDroppable({
|
||||
id: 'chatbot-sidebar',
|
||||
data: {
|
||||
type: 'chatbot-sidebar',
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={setDroppableRef}
|
||||
className={cn(
|
||||
'flex flex-col h-full bg-background transition-colors duration-200 min-h-0',
|
||||
isOver && 'bg-accent/50 ring-2 ring-primary ring-inset',
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center justify-between p-4 border-b border-border flex-shrink-0">
|
||||
<div className="flex items-center gap-2 font-semibold">
|
||||
<MessageSquare className="h-5 w-5 text-primary" />
|
||||
<span>{m.chatbot_context()}</span>
|
||||
</div>
|
||||
{chatAssets.length > 0 && (
|
||||
<button
|
||||
onClick={clearAssets}
|
||||
className="text-xs text-muted-foreground hover:text-foreground underline transition-colors"
|
||||
>
|
||||
{m.clear()}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex-1 p-4 overflow-y-auto min-h-0 space-y-4">
|
||||
{chatAssets.length === 0 ? (
|
||||
<div className="flex flex-col items-center justify-center h-48 border-2 border-dashed border-border rounded-lg text-muted-foreground p-4 text-center">
|
||||
<MessageSquare className="h-8 w-8 mb-2 opacity-50 text-muted-foreground" />
|
||||
<p className="text-sm">{m.chatbot_drag_drop_hint()}</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
|
||||
{m.context_assets_count({ count: chatAssets.length })}
|
||||
</h3>
|
||||
<div className="divide-y divide-border border border-border rounded-md bg-muted/10 max-h-[400px] overflow-y-auto">
|
||||
{chatAssets.map((asset) => (
|
||||
<div
|
||||
key={asset.id}
|
||||
className="flex items-center justify-between p-2.5 text-sm group"
|
||||
>
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
{asset.type === 'folder' ? (
|
||||
<Folder className="h-4 w-4 text-blue-500 flex-shrink-0" />
|
||||
) : (
|
||||
<File className="h-4 w-4 text-muted-foreground flex-shrink-0" />
|
||||
)}
|
||||
<span className="truncate font-medium text-foreground">{asset.name}</span>
|
||||
<span className="text-[10px] bg-muted text-muted-foreground px-1.5 py-0.5 rounded-full capitalize">
|
||||
{asset.type}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => removeAsset(asset.id)}
|
||||
className="text-muted-foreground hover:text-destructive opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity p-0.5"
|
||||
title={m.remove_from_context()}
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import { FileViewerRightSidebar } from './file-viewer-right-sidebar'
|
||||
import { FolderTree } from './folder-tree'
|
||||
import { ResizeHandle } from './resize-handle'
|
||||
import { useFileSystemDnd } from './use-file-system-dnd'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
import { ChatbotSidebar } from './chatbot-sidebar'
|
||||
|
||||
type FileSystemManagerProps = {
|
||||
teamId: string
|
||||
@@ -87,6 +89,7 @@ export default function FileSystemManager({
|
||||
const [lastSelectedId, setLastSelectedId] = useState<string | null>(null)
|
||||
const [leftSidebarWidth, setLeftSidebarWidth] = useState(240)
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const { isChatbotOpen } = useChatbotStore()
|
||||
|
||||
const { members, fetchMembers } = useMemberStore()
|
||||
const { metadata, fetchMetadata, setMetadata: setUserMetadata } = useUserMetadataStore()
|
||||
@@ -433,10 +436,13 @@ export default function FileSystemManager({
|
||||
onClick={() => setIsLeftSidebarCollapsed(true)}
|
||||
/>
|
||||
)}
|
||||
{!isRightSidebarCollapsed && (
|
||||
{(!isRightSidebarCollapsed || isChatbotOpen) && (
|
||||
<div
|
||||
className="md:hidden fixed inset-0 bg-black/50 z-40"
|
||||
onClick={() => setIsRightSidebarCollapsed(true)}
|
||||
onClick={() => {
|
||||
setIsRightSidebarCollapsed(true)
|
||||
useChatbotStore.getState().setIsChatbotOpen(false)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -495,7 +501,7 @@ export default function FileSystemManager({
|
||||
rootFolderId={rootFolderId}
|
||||
/>
|
||||
|
||||
{!isRightSidebarCollapsed && (
|
||||
{(!isRightSidebarCollapsed || isChatbotOpen) && (
|
||||
<>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
@@ -507,7 +513,9 @@ export default function FileSystemManager({
|
||||
style={{ width: rightSidebarWidth }}
|
||||
className="bg-background border-l border-border flex flex-col flex-shrink-0"
|
||||
>
|
||||
{singleSelectedFile ? (
|
||||
{isChatbotOpen ? (
|
||||
<ChatbotSidebar />
|
||||
) : singleSelectedFile ? (
|
||||
<FileViewerRightSidebar
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
|
||||
@@ -2,10 +2,12 @@ import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { BreadcrumbNav } from './breadcrumb-nav'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
|
||||
export function TopNav() {
|
||||
const { projectState } = useTopNavStore()
|
||||
const uiStore = useUiStore()
|
||||
const { isChatbotOpen, setIsChatbotOpen } = useChatbotStore()
|
||||
|
||||
if (!projectState) {
|
||||
return <TeamHeader />
|
||||
@@ -58,14 +60,32 @@ export function TopNav() {
|
||||
const onRightSidebarToggle =
|
||||
isPublic && projectState.onRightSidebarToggle
|
||||
? projectState.onRightSidebarToggle
|
||||
: () =>
|
||||
isFileView
|
||||
? uiStore.setFileViewRightSidebarCollapsed(!uiStore.fileViewRightSidebarCollapsed)
|
||||
: isShareConfig
|
||||
? uiStore.setShareConfigRightSidebarCollapsed(
|
||||
!uiStore.shareConfigRightSidebarCollapsed,
|
||||
)
|
||||
: uiStore.setFileListRightSidebarCollapsed(!uiStore.fileListRightSidebarCollapsed)
|
||||
: () => {
|
||||
if (!isPublic && isChatbotOpen) {
|
||||
setIsChatbotOpen(false)
|
||||
if (isFileView) {
|
||||
uiStore.setFileViewRightSidebarCollapsed(false)
|
||||
} else if (isShareConfig) {
|
||||
uiStore.setShareConfigRightSidebarCollapsed(false)
|
||||
} else {
|
||||
uiStore.setFileListRightSidebarCollapsed(false)
|
||||
}
|
||||
} else {
|
||||
if (isFileView) {
|
||||
uiStore.setFileViewRightSidebarCollapsed(!uiStore.fileViewRightSidebarCollapsed)
|
||||
} else if (isShareConfig) {
|
||||
uiStore.setShareConfigRightSidebarCollapsed(!uiStore.shareConfigRightSidebarCollapsed)
|
||||
} else {
|
||||
uiStore.setFileListRightSidebarCollapsed(!uiStore.fileListRightSidebarCollapsed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onChatbotToggle = isPublic
|
||||
? undefined
|
||||
: () => {
|
||||
setIsChatbotOpen(!isChatbotOpen)
|
||||
}
|
||||
|
||||
const displayStyle = projectId ? (uiStore.viewModes[projectId] ?? 'card') : 'card'
|
||||
const onDisplayStyleChange = isPublic
|
||||
@@ -88,6 +108,8 @@ export function TopNav() {
|
||||
onLeftSidebarToggle={onLeftSidebarToggle}
|
||||
isRightSidebarCollapsed={isRightSidebarCollapsed}
|
||||
onRightSidebarToggle={onRightSidebarToggle}
|
||||
isChatbotOpen={!isPublic && isChatbotOpen}
|
||||
onChatbotToggle={onChatbotToggle}
|
||||
isPublic={isPublic}
|
||||
shareId={shareId}
|
||||
fileId={fileId}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import type { DragEndEvent, DragStartEvent } from '@dnd-kit/react'
|
||||
import type { DragState } from './dnd-types'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
|
||||
interface UseFileSystemDndProps {
|
||||
teamId: string
|
||||
@@ -188,6 +189,24 @@ export function useFileSystemDnd({
|
||||
const targetId = (target.id as string).split(':').pop()!
|
||||
const targetData = target.data as { type: string; item: AssetInfo } | undefined
|
||||
|
||||
if (targetData?.type === 'chatbot-sidebar') {
|
||||
const draggedItems = [...folders, ...files].filter((item) =>
|
||||
dragState.draggedIds.has(item.id!),
|
||||
)
|
||||
|
||||
const chatAssets = draggedItems.map((item) => ({
|
||||
id: item.id!,
|
||||
name: item.name || 'Unnamed',
|
||||
type: item.type as 'file' | 'folder',
|
||||
}))
|
||||
|
||||
useChatbotStore.getState().addAssets(chatAssets)
|
||||
toast.success(`Added ${chatAssets.length} item(s) to chatbot context`)
|
||||
onClearSelection()
|
||||
setDragState(undefined)
|
||||
return
|
||||
}
|
||||
|
||||
if (targetData?.type === 'share-link') {
|
||||
const shareId = targetId
|
||||
const assetIds = Array.from(dragState.draggedIds)
|
||||
|
||||
@@ -819,5 +819,12 @@
|
||||
"created_by_at": "{time} by {author}",
|
||||
"date_format_long": "MMMM d, yyyy",
|
||||
"tool_result_with_name": "Tool Result: {name}",
|
||||
"reply_to_message": "reply to: {message}"
|
||||
"reply_to_message": "reply to: {message}",
|
||||
"chatbot_context": "Chatbot Context",
|
||||
"clear": "Clear",
|
||||
"chatbot_drag_drop_hint": "Drag and drop files or folders here to add them to chatbot context",
|
||||
"context_assets_count": "Context Assets ({count})",
|
||||
"remove_from_context": "Remove from context",
|
||||
"hide_chatbot": "Hide Chatbot",
|
||||
"show_chatbot": "Show Chatbot"
|
||||
}
|
||||
|
||||
@@ -819,5 +819,12 @@
|
||||
"created_by_at": "{time} 由 {author} 创建",
|
||||
"date_format_long": "yyyy年M月d日",
|
||||
"tool_result_with_name": "工具结果:{name}",
|
||||
"reply_to_message": "回复:{message}"
|
||||
"reply_to_message": "回复:{message}",
|
||||
"chatbot_context": "聊天机器人上下文",
|
||||
"clear": "清空",
|
||||
"chatbot_drag_drop_hint": "拖拽文件或文件夹到此处以添加到聊天机器人上下文",
|
||||
"context_assets_count": "上下文资源 ({count})",
|
||||
"remove_from_context": "从上下文中移除",
|
||||
"hide_chatbot": "隐藏聊天机器人",
|
||||
"show_chatbot": "显示聊天机器人"
|
||||
}
|
||||
|
||||
+7
@@ -767,4 +767,11 @@ export * from "./created_by_at.js";
|
||||
export * from "./date_format_long.js";
|
||||
export * from "./tool_result_with_name.js";
|
||||
export * from "./reply_to_message.js";
|
||||
export * from "./chatbot_context.js";
|
||||
export * from "./clear.js";
|
||||
export * from "./chatbot_drag_drop_hint.js";
|
||||
export * from "./context_assets_count.js";
|
||||
export * from "./remove_from_context.js";
|
||||
export * from "./hide_chatbot.js";
|
||||
export * from "./show_chatbot.js";
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
|
||||
+8
-1
@@ -768,4 +768,11 @@ export * from './fullscreen.js'
|
||||
export * from './created_by_at.js'
|
||||
export * from './date_format_long.js'
|
||||
export * from './tool_result_with_name.js'
|
||||
export * from './reply_to_message.js'
|
||||
export * from './reply_to_message.js'
|
||||
export * from './chatbot_context.js'
|
||||
export * from './clear.js'
|
||||
export * from './chatbot_drag_drop_hint.js'
|
||||
export * from './context_assets_count.js'
|
||||
export * from './remove_from_context.js'
|
||||
export * from './hide_chatbot.js'
|
||||
export * from './show_chatbot.js'
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Chatbot Context" |
|
||||
*
|
||||
* @param {Chatbot_ContextInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const chatbot_context: ((inputs?: Chatbot_ContextInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Chatbot_ContextInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Chatbot_ContextInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Chatbot_ContextInputs */
|
||||
|
||||
const en_chatbot_context = /** @type {(inputs: Chatbot_ContextInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Chatbot Context`)
|
||||
};
|
||||
|
||||
const zh_chatbot_context = /** @type {(inputs: Chatbot_ContextInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`聊天机器人上下文`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Chatbot Context" |
|
||||
*
|
||||
* @param {Chatbot_ContextInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const chatbot_context = /** @type {((inputs?: Chatbot_ContextInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Chatbot_ContextInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_chatbot_context(inputs)
|
||||
return zh_chatbot_context(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Drag and drop files or folders here to add them to chatbot context" |
|
||||
*
|
||||
* @param {Chatbot_Drag_Drop_HintInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const chatbot_drag_drop_hint: ((inputs?: Chatbot_Drag_Drop_HintInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Chatbot_Drag_Drop_HintInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Chatbot_Drag_Drop_HintInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Chatbot_Drag_Drop_HintInputs */
|
||||
|
||||
const en_chatbot_drag_drop_hint = /** @type {(inputs: Chatbot_Drag_Drop_HintInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Drag and drop files or folders here to add them to chatbot context`)
|
||||
};
|
||||
|
||||
const zh_chatbot_drag_drop_hint = /** @type {(inputs: Chatbot_Drag_Drop_HintInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`拖拽文件或文件夹到此处以添加到聊天机器人上下文`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Drag and drop files or folders here to add them to chatbot context" |
|
||||
*
|
||||
* @param {Chatbot_Drag_Drop_HintInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const chatbot_drag_drop_hint = /** @type {((inputs?: Chatbot_Drag_Drop_HintInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Chatbot_Drag_Drop_HintInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_chatbot_drag_drop_hint(inputs)
|
||||
return zh_chatbot_drag_drop_hint(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Clear" |
|
||||
*
|
||||
* @param {ClearInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const clear: ((inputs?: ClearInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<ClearInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type ClearInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} ClearInputs */
|
||||
|
||||
const en_clear = /** @type {(inputs: ClearInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Clear`)
|
||||
};
|
||||
|
||||
const zh_clear = /** @type {(inputs: ClearInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`清空`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Clear" |
|
||||
*
|
||||
* @param {ClearInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const clear = /** @type {((inputs?: ClearInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<ClearInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_clear(inputs)
|
||||
return zh_clear(inputs)
|
||||
});
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Context Assets ({count})" |
|
||||
*
|
||||
* @param {Context_Assets_CountInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const context_assets_count: ((inputs: Context_Assets_CountInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Context_Assets_CountInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Context_Assets_CountInputs = {
|
||||
count: NonNullable<unknown>;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{ count: NonNullable<unknown> }} Context_Assets_CountInputs */
|
||||
|
||||
const en_context_assets_count = /** @type {(inputs: Context_Assets_CountInputs) => LocalizedString} */ (i) => {
|
||||
return /** @type {LocalizedString} */ (`Context Assets (${i?.count})`)
|
||||
};
|
||||
|
||||
const zh_context_assets_count = /** @type {(inputs: Context_Assets_CountInputs) => LocalizedString} */ (i) => {
|
||||
return /** @type {LocalizedString} */ (`上下文资源 (${i?.count})`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Context Assets ({count})" |
|
||||
*
|
||||
* @param {Context_Assets_CountInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const context_assets_count = /** @type {((inputs: Context_Assets_CountInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Context_Assets_CountInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_context_assets_count(inputs)
|
||||
return zh_context_assets_count(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Hide Chatbot" |
|
||||
*
|
||||
* @param {Hide_ChatbotInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const hide_chatbot: ((inputs?: Hide_ChatbotInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Hide_ChatbotInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Hide_ChatbotInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Hide_ChatbotInputs */
|
||||
|
||||
const en_hide_chatbot = /** @type {(inputs: Hide_ChatbotInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Hide Chatbot`)
|
||||
};
|
||||
|
||||
const zh_hide_chatbot = /** @type {(inputs: Hide_ChatbotInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`隐藏聊天机器人`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Hide Chatbot" |
|
||||
*
|
||||
* @param {Hide_ChatbotInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const hide_chatbot = /** @type {((inputs?: Hide_ChatbotInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Hide_ChatbotInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_hide_chatbot(inputs)
|
||||
return zh_hide_chatbot(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Remove from context" |
|
||||
*
|
||||
* @param {Remove_From_ContextInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const remove_from_context: ((inputs?: Remove_From_ContextInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Remove_From_ContextInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Remove_From_ContextInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Remove_From_ContextInputs */
|
||||
|
||||
const en_remove_from_context = /** @type {(inputs: Remove_From_ContextInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Remove from context`)
|
||||
};
|
||||
|
||||
const zh_remove_from_context = /** @type {(inputs: Remove_From_ContextInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`从上下文中移除`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Remove from context" |
|
||||
*
|
||||
* @param {Remove_From_ContextInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const remove_from_context = /** @type {((inputs?: Remove_From_ContextInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Remove_From_ContextInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_remove_from_context(inputs)
|
||||
return zh_remove_from_context(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Show Chatbot" |
|
||||
*
|
||||
* @param {Show_ChatbotInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const show_chatbot: ((inputs?: Show_ChatbotInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Show_ChatbotInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Show_ChatbotInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Show_ChatbotInputs */
|
||||
|
||||
const en_show_chatbot = /** @type {(inputs: Show_ChatbotInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Show Chatbot`)
|
||||
};
|
||||
|
||||
const zh_show_chatbot = /** @type {(inputs: Show_ChatbotInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`显示聊天机器人`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Show Chatbot" |
|
||||
*
|
||||
* @param {Show_ChatbotInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const show_chatbot = /** @type {((inputs?: Show_ChatbotInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Show_ChatbotInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_show_chatbot(inputs)
|
||||
return zh_show_chatbot(inputs)
|
||||
});
|
||||
@@ -11,6 +11,9 @@ import { FileDetailSkeleton } from '@/ui/components/loading-skeletons'
|
||||
import { useMemberStore } from '@/ui/stores/members'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
import { ChatbotSidebar } from '@/ui/components/chatbot-sidebar'
|
||||
import { type Annotation } from '@/ui/types'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { InferRequestType, InferResponseType } from 'hono/client'
|
||||
@@ -37,6 +40,8 @@ function FileViewPage() {
|
||||
const { teamId, ensureTeamIdForProject } = useTeamContextStore()
|
||||
const [rightSidebarWidth, setRightSidebarWidth] = useState(360)
|
||||
const [annotations, setAnnotations] = useState<Annotation[]>([])
|
||||
const { fileViewRightSidebarCollapsed } = useUiStore()
|
||||
const { isChatbotOpen } = useChatbotStore()
|
||||
const [currentTime, setCurrentTime] = useState(0)
|
||||
const [selectedCommentId, setSelectedCommentId] = useState<string | null>(null)
|
||||
const [compareActiveAsset, setCompareActiveAsset] = useState<AssetInfo | null>(null)
|
||||
@@ -431,29 +436,40 @@ function FileViewPage() {
|
||||
</FileViewer>
|
||||
)}
|
||||
</div>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
setRightSidebarWidth((prev) => Math.max(300, Math.min(600, prev - delta)))
|
||||
}}
|
||||
className="hidden md:block"
|
||||
/>
|
||||
<div style={{ width: rightSidebarWidth }} className="flex-shrink-0">
|
||||
<FileViewerRightSidebar
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
file={sidebarFile}
|
||||
onSaveField={handleSaveField}
|
||||
members={members}
|
||||
onCommentSelect={handleCommentSelect}
|
||||
currentTime={currentTime}
|
||||
onTyping={() => {
|
||||
if (isCompareMode) return
|
||||
mediaControllerRef.current?.pause()
|
||||
}}
|
||||
selectedCommentId={selectedCommentId}
|
||||
hideAnnotationControl={sidebarFile?.mediaType?.startsWith('audio/')}
|
||||
/>
|
||||
</div>
|
||||
{(!fileViewRightSidebarCollapsed || isChatbotOpen) && (
|
||||
<>
|
||||
<ResizeHandle
|
||||
onResize={(delta) => {
|
||||
setRightSidebarWidth((prev) => Math.max(300, Math.min(600, prev - delta)))
|
||||
}}
|
||||
className="hidden md:block"
|
||||
/>
|
||||
<div
|
||||
style={{ width: rightSidebarWidth }}
|
||||
className="flex-shrink-0 bg-background border-l border-border flex flex-col"
|
||||
>
|
||||
{isChatbotOpen ? (
|
||||
<ChatbotSidebar />
|
||||
) : (
|
||||
<FileViewerRightSidebar
|
||||
teamId={teamId}
|
||||
projectId={projectId}
|
||||
file={sidebarFile}
|
||||
onSaveField={handleSaveField}
|
||||
members={members}
|
||||
onCommentSelect={handleCommentSelect}
|
||||
currentTime={currentTime}
|
||||
onTyping={() => {
|
||||
if (isCompareMode) return
|
||||
mediaControllerRef.current?.pause()
|
||||
}}
|
||||
selectedCommentId={selectedCommentId}
|
||||
hideAnnotationControl={sidebarFile?.mediaType?.startsWith('audio/')}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { create } from 'zustand'
|
||||
|
||||
export interface ChatAsset {
|
||||
id: string
|
||||
name: string
|
||||
type: 'file' | 'folder'
|
||||
}
|
||||
|
||||
interface ChatbotState {
|
||||
isChatbotOpen: boolean
|
||||
setIsChatbotOpen: (open: boolean) => void
|
||||
chatAssets: ChatAsset[]
|
||||
addAssets: (assets: ChatAsset[]) => void
|
||||
removeAsset: (id: string) => void
|
||||
clearAssets: () => void
|
||||
}
|
||||
|
||||
export const useChatbotStore = create<ChatbotState>((set) => ({
|
||||
isChatbotOpen: false,
|
||||
setIsChatbotOpen: (open) => set({ isChatbotOpen: open }),
|
||||
chatAssets: [],
|
||||
addAssets: (assets) =>
|
||||
set((state) => {
|
||||
const existingIds = new Set(state.chatAssets.map((a) => a.id))
|
||||
const uniqueNewAssets = assets.filter((a) => !existingIds.has(a.id))
|
||||
return { chatAssets: [...state.chatAssets, ...uniqueNewAssets] }
|
||||
}),
|
||||
removeAsset: (id) =>
|
||||
set((state) => ({
|
||||
chatAssets: state.chatAssets.filter((a) => a.id !== id),
|
||||
})),
|
||||
clearAssets: () => set({ chatAssets: [] }),
|
||||
}))
|
||||
+10
-6
@@ -97,11 +97,15 @@ export default defineConfig({
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 120_000,
|
||||
},
|
||||
...(process.env.E2E_SKIP_APP_SERVER === 'true' ? [] : [{
|
||||
command: 'bun run apps/web/e2e/serve.ts',
|
||||
url: 'http://localhost:5200',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 120_000,
|
||||
}]),
|
||||
...(process.env.E2E_SKIP_APP_SERVER === 'true'
|
||||
? []
|
||||
: [
|
||||
{
|
||||
command: 'bun run apps/web/e2e/serve.ts',
|
||||
url: 'http://localhost:5200',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 120_000,
|
||||
},
|
||||
]),
|
||||
],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user