project view updates

This commit is contained in:
Storme-bit
2026-04-18 22:53:03 -07:00
parent ad5ecb5ff3
commit e69ceb44e7
10 changed files with 274 additions and 121 deletions

View File

@@ -30,6 +30,9 @@ function getDB() {
db.exec(`ALTER TABLE projects ADD COLUMN isolated INTEGER NOT NULL DEFAULT 0`);
} catch {}
try {
db.exec(`ALTER TABLE projects ADD COLUMN notes TEXT`); // ← add this
} catch {}
// Sync FTS index with any existing episodes data
db.exec(`INSERT OR REPLACE INTO episodes_fts(rowid, user_message, ai_response)

View File

@@ -20,12 +20,23 @@ function getProject(id) {
return parseRow(db.prepare(`SELECT * FROM projects WHERE id = ?`).get(id));
}
function updateProject(id, { name, description, colour, icon, isolated }) {
function updateProject(id, fields = {}) {
const db = getDB();
db.prepare(`
UPDATE projects SET name = ?, description = ?, colour = ?, icon = ?, isolated = ?
WHERE id = ?
`).run(name, description ?? null, colour ?? null, icon ?? null, isolated ?? 0, id);
const allowed = ['name', 'description', 'colour', 'icon', 'isolated', 'notes'];
const updates = [];
const values = [];
for (const key of allowed) {
if (fields[key] !== undefined) {
updates.push(`${key} = ?`);
values.push(fields[key] ?? null);
}
}
if (updates.length === 0) return getProject(id);
values.push(id);
db.prepare(`UPDATE projects SET ${updates.join(', ')} WHERE id = ?`).run(...values);
return getProject(id);
}