feat: console ui, streaming report, history actions
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
ee4a88e499
commit
a5529ce542
@@ -45,7 +45,10 @@ export const db: DatabaseSync = new Proxy({} as DatabaseSync, {
|
||||
|
||||
const now = () => Date.now();
|
||||
type Row = string | number | null;
|
||||
const one = <T>(sql: string, ...p: Row[]): T | null => (db.prepare(sql).get(...p) as T | undefined) ?? null;
|
||||
// node:sqlite hands back null-prototype objects. React refuses to serialize those into a client component
|
||||
// ("Only plain objects ... can be passed to Client Components"), so every row is spread back to a normal object here.
|
||||
const plain = <T>(r: unknown): T | null => (r ? { ...r } as T : null);
|
||||
const one = <T>(sql: string, ...p: Row[]): T | null => plain<T>(db.prepare(sql).get(...p));
|
||||
// node:sqlite binds null/number/string/bigint/Buffer only: pass 0/1, never booleans.
|
||||
|
||||
export type SettingsInput = { analyst_base_url: string; analyst_key: string; analyst_model: string;
|
||||
@@ -106,8 +109,9 @@ export function patchAnalysis(id: string, p: Record<string, string>) {
|
||||
.run(...keys.map((k) => p[k]), now(), id);
|
||||
}
|
||||
export const listAnalyses = (userId: string) =>
|
||||
db.prepare("SELECT id, title, status, created_at FROM analyses WHERE user_id = ? ORDER BY created_at DESC")
|
||||
.all(userId) as { id: string; title: string; status: string; created_at: number }[];
|
||||
(db.prepare("SELECT id, title, status, created_at FROM analyses WHERE user_id = ? ORDER BY created_at DESC")
|
||||
.all(userId) as { id: string; title: string; status: string; created_at: number }[])
|
||||
.map((r) => ({ ...r }));
|
||||
export const getAnalysis = (id: string, userId: string) =>
|
||||
one<Analysis>("SELECT * FROM analyses WHERE id = ? AND user_id = ?", id, userId);
|
||||
export const renameAnalysis = (id: string, userId: string, title: string) =>
|
||||
|
||||
Reference in New Issue
Block a user