import { useState } from 'react'
import { Plus, Trash2, MessageSquare, Download, StickyNote, Pencil, Check, X } from 'lucide-react'
import { useStore, useActiveProject } from '../../store/useStore'
import { Btn, Field, Section, inputCls, download, stamp } from '../ui'
import ModelPicker from './ModelPicker'
function NoteItem({ note, projectId }) {
const { updateNote, removeNote } = useStore.getState()
const [edit, setEdit] = useState(false)
const [draft, setDraft] = useState(note)
if (edit) {
return (
)
}
return (
{note.title}
{note.content}
)
}
export default function ProjectPanel({ onDone }) {
const project = useActiveProject()
const projects = useStore((s) => s.projects)
const agents = useStore((s) => s.agents)
const conversations = useStore((s) => s.conversations)
const activeConversationId = useStore((s) => s.activeConversationId)
const running = useStore((s) => s.running)
const st = useStore.getState()
const convs = Object.values(conversations)
.filter((c) => c.projectId === project.id)
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
const up = (patch) => st.updateProject(project.id, patch)
return (
{
const name = prompt('新專案名稱', '新專案')
if (name !== null) st.createProject(name.trim() || '新專案')
}}>
}
>
{projects.map((p) => {
const count = Object.values(conversations).filter((c) => c.projectId === p.id).length
return (
)
})}
{ st.createConversation(); onDone?.() }}>
}
>
{ st.createConversation(); onDone?.() }}>
新對話
{convs.length === 0 &&
這個專案還沒有對話
}
{convs.map((c) => {
const a = agents.find((x) => x.id === c.agentId)
return (
st.selectConversation(c.id)}
>
{running[c.id] ? : }
{c.title}
{a?.icon}
)
})}
筆記會自動帶進這個專案所有對話的 system prompt;Agent 也能用 save_note / read_notes 工具讀寫。
{(project.notes || []).map((n) => )}
st.addNote(project.id, { title: '新筆記', content: '' })}>
新增筆記
)
}