syle minor fix

This commit is contained in:
yiling
2026-07-12 10:29:29 +08:00
parent bcb17acaf7
commit 0a4622ed8a
3 changed files with 34 additions and 27 deletions
+19 -10
View File
@@ -7,6 +7,7 @@ import type { ChatMessage } from '@shumai/dtos'
import { ArrowLeft, ArrowUp, Bot, History, Loader2, Plus, Trash2 } from 'lucide-react' import { ArrowLeft, ArrowUp, Bot, History, Loader2, Plus, Trash2 } from 'lucide-react'
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import Markdown from 'react-markdown' import Markdown from 'react-markdown'
import { formatTimeAgo } from '../lib/time'
interface ChatbotSidebarProps { interface ChatbotSidebarProps {
projectId: string projectId: string
@@ -135,7 +136,19 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
return ( return (
<div key={msg.id} className="flex flex-col w-full space-y-1"> <div key={msg.id} className="flex flex-col w-full space-y-1">
<div className="text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words"> <div className="text-sm leading-[1.8] prose prose-sm dark:prose-invert max-w-none break-words">
<Markdown>{preprocessMarkdown(getMessageText(msg.content))}</Markdown> <Markdown
components={{
// Intercept the <pre> tag
pre: ({ node, ...props }) => (
<pre
className="whitespace-pre-wrap break-all break-words bg-gray-100 p-4 rounded-md"
{...props}
/>
),
}}
>
{preprocessMarkdown(getMessageText(msg.content))}
</Markdown>
</div> </div>
<div className="text-[10px] text-muted-foreground self-start italic"> <div className="text-[10px] text-muted-foreground self-start italic">
{m.created_by_agent()} {m.created_by_agent()}
@@ -176,7 +189,7 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
<div <div
ref={setDroppableRef} ref={setDroppableRef}
className={cn( className={cn(
'relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0 border-l border-border', 'relative flex flex-col h-full bg-background transition-colors duration-200 min-h-0',
)} )}
> >
{isOver && ( {isOver && (
@@ -191,11 +204,10 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
)} )}
{/* Header section */} {/* Header section */}
<div className="flex items-center justify-between p-4 flex-shrink-0"> <div className="flex items-center justify-between p-4 pt-[0.7rem] flex-shrink-0">
{isHistoryMode ? ( {isHistoryMode ? (
<> <>
<div className="flex items-center gap-2 font-semibold"> <div className="flex items-center gap-2 font-semibold">
<History className="h-5 w-5 text-primary" />
<span>{m.history()}</span> <span>{m.history()}</span>
</div> </div>
<button <button
@@ -209,7 +221,6 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
) : ( ) : (
<> <>
<div className="flex items-center gap-2 font-semibold"> <div className="flex items-center gap-2 font-semibold">
<Bot className="h-5 w-5 text-primary" />
<span>{m.shumai_agent()}</span> <span>{m.shumai_agent()}</span>
</div> </div>
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
@@ -249,9 +260,7 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
key={sess.id} key={sess.id}
className={cn( className={cn(
'group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card', 'group relative flex items-center justify-between p-3 border rounded-lg transition-all cursor-pointer bg-card',
isActive isActive ? 'border-primary' : 'border-border hover:bg-accent/30',
? 'border-primary ring-1 ring-primary'
: 'border-border hover:bg-accent/30',
)} )}
> >
<div onClick={() => loadSession(sess.id)} className="flex-1 min-w-0 pr-6"> <div onClick={() => loadSession(sess.id)} className="flex-1 min-w-0 pr-6">
@@ -259,7 +268,7 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
{sess.name || m.new_chat()} {sess.name || m.new_chat()}
</div> </div>
<div className="text-xs text-muted-foreground mt-0.5"> <div className="text-xs text-muted-foreground mt-0.5">
{new Date(sess.createdAt).toLocaleString()} {formatTimeAgo(sess.createdAt)}
</div> </div>
</div> </div>
<button <button
@@ -283,7 +292,7 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
) : ( ) : (
<> <>
{/* Active Chat view */} {/* Active Chat view */}
<ScrollArea className="flex-1 p-4 min-h-0"> <ScrollArea className="flex-1 p-4 min-h-0 [&>div>div]:!block">
{messages.length === 0 ? ( {messages.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"> <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">
<Bot className="h-8 w-8 mb-2 opacity-50 text-muted-foreground" /> <Bot className="h-8 w-8 mb-2 opacity-50 text-muted-foreground" />
@@ -1,13 +1,12 @@
import type { AssetInfo, AssetInfoPaginatedList } from '@shumai/dtos'
import type { CollectionInfo } from '@shumai/dtos'
import { type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
import type { SearchCondition, SearchSort } from '@shumai/dtos'
import { client } from '@/ui/api/client' import { client } from '@/ui/api/client'
import { usePermissions } from '@/ui/hooks/use-permissions' import { usePermissions } from '@/ui/hooks/use-permissions'
import { m } from '@/ui/paraglide/messages.js'
import type { AssetInfo, AssetInfoPaginatedList, CollectionInfo, SearchCondition, SearchSort } from '@shumai/dtos'
import { type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
import { useMutation } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query'
import { InferRequestType, InferResponseType } from 'hono/client' import { InferRequestType, InferResponseType } from 'hono/client'
import { m } from '@/ui/paraglide/messages.js'
import { useChatbotStore } from '@/ui/stores/chatbot'
import { useFieldStore } from '@/ui/stores/fields' import { useFieldStore } from '@/ui/stores/fields'
import { useMemberStore } from '@/ui/stores/members' import { useMemberStore } from '@/ui/stores/members'
import { useTopNavStore } from '@/ui/stores/top-nav' import { useTopNavStore } from '@/ui/stores/top-nav'
@@ -19,14 +18,13 @@ import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-quer
import { useNavigate } from '@tanstack/react-router' import { useNavigate } from '@tanstack/react-router'
import { useEffect, useMemo, useRef, useState } from 'react' import { useEffect, useMemo, useRef, useState } from 'react'
import { cn } from '../lib/utils' import { cn } from '../lib/utils'
import { ChatbotSidebar } from './chatbot-sidebar'
import { SnapToPointer } from './dnd-modifiers' import { SnapToPointer } from './dnd-modifiers'
import { FileBrowser } from './file-browser/file-browser' import { FileBrowser } from './file-browser/file-browser'
import { FileViewerRightSidebar } from './file-viewer-right-sidebar' import { FileViewerRightSidebar } from './file-viewer-right-sidebar'
import { FolderTree } from './folder-tree' import { FolderTree } from './folder-tree'
import { ResizeHandle } from './resize-handle' import { ResizeHandle } from './resize-handle'
import { useFileSystemDnd } from './use-file-system-dnd' import { useFileSystemDnd } from './use-file-system-dnd'
import { useChatbotStore } from '@/ui/stores/chatbot'
import { ChatbotSidebar } from './chatbot-sidebar'
type FileSystemManagerProps = { type FileSystemManagerProps = {
teamId: string teamId: string
@@ -511,7 +509,7 @@ export default function FileSystemManager({
/> />
<div <div
style={{ width: rightSidebarWidth }} style={{ width: rightSidebarWidth }}
className="bg-background border-l border-border flex flex-col flex-shrink-0" className="bg-background flex flex-col flex-shrink-0"
> >
{isChatbotOpen ? ( {isChatbotOpen ? (
<ChatbotSidebar projectId={projectId} contextAssetId={assetId} /> <ChatbotSidebar projectId={projectId} contextAssetId={assetId} />
@@ -1,29 +1,29 @@
import { createLazyFileRoute } from '@tanstack/react-router'
import { client } from '@/ui/api/client' import { client } from '@/ui/api/client'
import { FileViewer } from '@/ui/components/file-viewer' import { ChatbotSidebar } from '@/ui/components/chatbot-sidebar'
import { CompareViewer } from '@/ui/components/compare/compare-viewer'
import { pickDefaultCompareVersions } from '@/ui/components/compare/compare-utils' import { pickDefaultCompareVersions } from '@/ui/components/compare/compare-utils'
import { CompareViewer } from '@/ui/components/compare/compare-viewer'
import { FileViewer } from '@/ui/components/file-viewer'
import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar' import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar'
import { m } from '@/ui/paraglide/messages.js'
import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar' import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar'
import { ResizeHandle } from '@/ui/components/resize-handle'
import { FileDetailSkeleton } from '@/ui/components/loading-skeletons' import { FileDetailSkeleton } from '@/ui/components/loading-skeletons'
import { ResizeHandle } from '@/ui/components/resize-handle'
import { m } from '@/ui/paraglide/messages.js'
import { useChatbotStore } from '@/ui/stores/chatbot'
import { useMemberStore } from '@/ui/stores/members' import { useMemberStore } from '@/ui/stores/members'
import { useTeamContextStore } from '@/ui/stores/team-context' import { useTeamContextStore } from '@/ui/stores/team-context'
import { useTopNavStore } from '@/ui/stores/top-nav' import { useTopNavStore } from '@/ui/stores/top-nav'
import { useUiStore } from '@/ui/stores/ui' 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 { type Annotation } from '@/ui/types'
import { useMutation } from '@tanstack/react-query' import { useMutation } from '@tanstack/react-query'
import { createLazyFileRoute } from '@tanstack/react-router'
import { InferRequestType, InferResponseType } from 'hono/client' import { InferRequestType, InferResponseType } from 'hono/client'
import type { MediaController } from '@/ui/components/viewers/types'
import type { AssetInfo, AssetInfoPaginatedList, CommentInfo } from '@shumai/dtos' import type { AssetInfo, AssetInfoPaginatedList, CommentInfo } from '@shumai/dtos'
import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query' import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'
import { useNavigate } from '@tanstack/react-router' import { useNavigate } from '@tanstack/react-router'
import { Loader2 } from 'lucide-react' import { Loader2 } from 'lucide-react'
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import type { MediaController } from '@/ui/components/viewers/types'
function FileViewPage() { function FileViewPage() {
const { projectId, fileId } = Route.useParams() const { projectId, fileId } = Route.useParams()
@@ -446,7 +446,7 @@ function FileViewPage() {
/> />
<div <div
style={{ width: rightSidebarWidth }} style={{ width: rightSidebarWidth }}
className="flex-shrink-0 bg-background border-l border-border flex flex-col" className="flex-shrink-0 bg-background flex flex-col"
> >
{isChatbotOpen ? ( {isChatbotOpen ? (
<ChatbotSidebar projectId={projectId} contextAssetId={activeFileId} /> <ChatbotSidebar projectId={projectId} contextAssetId={activeFileId} />