semantic search within project

This commit is contained in:
Storme-bit
2026-04-15 03:15:26 -07:00
parent e1c16a5714
commit 27e3c98304
2 changed files with 29 additions and 15 deletions

View File

@@ -65,13 +65,20 @@ function deleteSession(id) {
function updateSession(id, { name, projectId } = {}) { function updateSession(id, { name, projectId } = {}) {
const db = getDB(); const db = getDB();
db.prepare(`
UPDATE sessions // Build update dynamically based on what was provided
SET name = ?, const updates = [];
project_id = COALESCE(?, project_id), const values = [];
updated_at = unixepoch()
WHERE id = ? if (name !== undefined) { updates.push('name = ?'); values.push(name ?? null); }
`).run(name ?? null, projectId ?? null, id); if (projectId !== undefined) { updates.push('project_id = ?'); values.push(projectId ?? null); }
if (updates.length === 0) return getSession(id);
updates.push('updated_at = unixepoch()');
values.push(id);
db.prepare(`UPDATE sessions SET ${updates.join(', ')} WHERE id = ?`).run(...values);
return getSession(id); return getSession(id);
} }

View File

@@ -31,15 +31,22 @@ router.get('/', async (req, res) => {
}); });
router.patch('/:sessionId', async (req, res) => { router.patch('/:sessionId', async (req, res) => {
const { name, projectId } = req.body; const { name, projectId } = req.body;
if (!name?.trim()) return res.status(400).json({ error: 'name is required' });
// Allow patch with just projectId, or just name, or both
if (!name?.trim() && projectId === undefined) {
return res.status(400).json({ error: 'name or projectId is required' });
}
try { try {
const session = await memory.updateSession(req.params.sessionId, { name, projectId }); const session = await memory.updateSession(req.params.sessionId, {
res.json(session); name: name?.trim() || undefined,
} catch (err) { projectId
res.status(500).json({ error: err.message }); });
} res.json(session);
} catch (err) {
res.status(500).json({ error: err.message });
}
}); });
router.delete('/:sessionId', async (req, res) => { router.delete('/:sessionId', async (req, res) => {