fix(indexer): preserve session metadata during incremental reindex
Previously the session metadata accumulator started from zero on every reindex pass, so an incremental update would overwrite started_at and message_count with values derived only from the new lines. Now reads the existing session row first and merges new data on top.
This commit is contained in:
+9
-1
@@ -135,7 +135,15 @@ function indexJsonl(db, fi) {
|
||||
idx: db.prepare('INSERT OR REPLACE INTO index_state (jsonl_path,mtime,lines_processed) VALUES (?,?,?)'),
|
||||
};
|
||||
|
||||
const sm = { started_at: null, ended_at: null, git_branch: null, version: null, title: null, n: 0 };
|
||||
const existing = !fi.isSubagent ? db.prepare('SELECT * FROM sessions WHERE id = ?').get(fi.sessionId) : null;
|
||||
const sm = {
|
||||
started_at: existing?.started_at || null,
|
||||
ended_at: existing?.ended_at || null,
|
||||
git_branch: existing?.git_branch || null,
|
||||
version: existing?.version || null,
|
||||
title: existing?.title || null,
|
||||
n: existing?.message_count || 0,
|
||||
};
|
||||
|
||||
for (let i = skip; i < lines.length; i++) {
|
||||
let obj;
|
||||
|
||||
Reference in New Issue
Block a user