Files
agent/apps/web_v1/src/pages/projects/project-ai.tsx

88 lines
3.2 KiB
TypeScript
Raw Normal View History

2026-07-21 11:29:36 +08:00
import { Button, Card, Input, Space, Typography } from '@arco-design/web-react'
import {
IconArrowUp,
IconAttachment,
IconPlusCircle,
IconRobot,
} from '@arco-design/web-react/icon'
import type { AISession, ProjectWorkspace } from './project-types'
2026-07-20 12:26:21 +08:00
2026-07-21 11:29:36 +08:00
const { Title, Text } = Typography
2026-07-20 12:26:21 +08:00
export function ProjectAi({ activeWorkspace, onSelectItem }: { activeWorkspace: ProjectWorkspace; onSelectItem: (title: string) => void }) {
const { aiSessions, project } = activeWorkspace
2026-07-21 11:29:36 +08:00
const groupedSessions = groupSessions(aiSessions)
2026-07-20 12:26:21 +08:00
return (
<div className="project-channel-page project-ai-page overview-page">
<div className="overview-head">
<div>
2026-07-21 11:29:36 +08:00
<Title heading={4}>AI智能体</Title>
<Text type="secondary">{project.name} </Text>
2026-07-20 12:26:21 +08:00
</div>
</div>
2026-07-21 11:29:36 +08:00
<div className="agent-chat-shell">
<Card className="agent-session-list queue-section" bordered>
<Button className="agent-new-chat" icon={<IconPlusCircle />}>
</Button>
<div className="agent-session-groups">
{groupedSessions.length ? (
groupedSessions.map((group) => (
<section className="agent-session-group" key={group.label}>
<Text type="secondary">{group.label}</Text>
{group.items.map((session, index) => (
<button
className={index === 0 && group.label === groupedSessions[0]?.label ? 'agent-session active' : 'agent-session'}
key={session.id}
onClick={() => onSelectItem(session.title)}
>
{session.title}
</button>
))}
</section>
))
) : (
<Text type="secondary"></Text>
)}
2026-07-20 12:26:21 +08:00
</div>
</Card>
2026-07-21 11:29:36 +08:00
<Card className="agent-chat-panel queue-section" bordered>
<div className="agent-chat-main">
<Title heading={2}></Title>
2026-07-20 12:26:21 +08:00
</div>
2026-07-21 11:29:36 +08:00
<div className="agent-composer">
<Input.TextArea placeholder="给 DeepSeek 发送消息" autoSize={{ minRows: 3, maxRows: 6 }} />
<div className="agent-composer-footer">
<Button className="agent-model-chip" icon={<IconRobot />}>
DeepSeek V4.0 Flash
</Button>
<Space>
<Button type="text" icon={<IconAttachment />} />
<Button className="agent-send-button" type="primary" shape="circle" icon={<IconArrowUp />} />
</Space>
</div>
2026-07-20 12:26:21 +08:00
</div>
</Card>
</div>
</div>
)
}
2026-07-21 11:29:36 +08:00
function groupSessions(sessions: AISession[]) {
const labels = ['今天', '昨天', '7 天内']
return labels.map((label) => ({
label,
items: sessions.filter((session, index) => session.time.includes(label) || (!labels.some((item) => session.time.includes(item)) && labels.indexOf(label) === fallbackGroupIndex(index))),
})).filter((group) => group.items.length > 0)
}
function fallbackGroupIndex(index: number) {
if (index === 0) return 0
if (index === 1) return 1
return 2
}