feat(web): add conversation search, rename, and pipeline resume
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
import { Plus } from 'lucide-react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { useAppStore } from '@/store';
|
||||
import { api } from '@/lib/api';
|
||||
|
||||
export function MiddlePanel() {
|
||||
const { conversations, activeConversationId, setActiveConversationId } = useAppStore();
|
||||
const { conversations, activeConversationId, setActiveConversationId, setConversations } = useAppStore();
|
||||
const [search, setSearch] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
api.listConversations().then(setConversations).catch(() => {});
|
||||
}, []);
|
||||
|
||||
const handleSearch = (value: string) => {
|
||||
setSearch(value);
|
||||
const qs = value ? `?search=${encodeURIComponent(value)}` : '';
|
||||
fetch(`/api/pipeline/conversations${qs}`)
|
||||
.then((r) => r.json())
|
||||
.then(setConversations)
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
return (
|
||||
<aside className="w-60 flex flex-col border-r border-zinc-800">
|
||||
@@ -13,6 +29,8 @@ export function MiddlePanel() {
|
||||
<Input
|
||||
placeholder="搜索对话..."
|
||||
className="h-8 text-xs bg-zinc-900 border-zinc-800"
|
||||
value={search}
|
||||
onChange={(e) => handleSearch(e.target.value)}
|
||||
/>
|
||||
<Button size="icon" variant="ghost" className="h-8 w-8 ml-1">
|
||||
<Plus size={16} />
|
||||
|
||||
@@ -11,8 +11,16 @@ const PIPELINE_SCRIPT = path.join(PROJECT_ROOT, '.claude', 'skills', 'video-from
|
||||
|
||||
export const pipelineRouter = Router();
|
||||
|
||||
pipelineRouter.get('/conversations', (_req, res) => {
|
||||
const rows = getDb().prepare('SELECT * FROM conversations ORDER BY updated_at DESC').all();
|
||||
pipelineRouter.get('/conversations', (req, res) => {
|
||||
const { search } = req.query;
|
||||
let sql = 'SELECT * FROM conversations';
|
||||
const params: string[] = [];
|
||||
if (search) {
|
||||
sql += ' WHERE title LIKE ?';
|
||||
params.push(`%${search}%`);
|
||||
}
|
||||
sql += ' ORDER BY updated_at DESC LIMIT 100';
|
||||
const rows = getDb().prepare(sql).all(...params);
|
||||
res.json(rows);
|
||||
});
|
||||
|
||||
@@ -28,6 +36,16 @@ pipelineRouter.delete('/conversations/:id', (req, res) => {
|
||||
res.status(204).send();
|
||||
});
|
||||
|
||||
// Rename conversation
|
||||
pipelineRouter.patch('/conversations/:id', (req, res) => {
|
||||
const { title } = req.body;
|
||||
if (!title) return res.status(400).json({ error: 'title required' });
|
||||
getDb().prepare(
|
||||
'UPDATE conversations SET title = ?, updated_at = datetime(\'now\') WHERE id = ?'
|
||||
).run(title, req.params.id);
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
pipelineRouter.get('/status', (req, res) => {
|
||||
const { manifest } = req.query;
|
||||
if (!manifest) return res.status(400).json({ error: 'manifest path required' });
|
||||
|
||||
Reference in New Issue
Block a user