From 2b02a7b6c8bd85b6b00b1d1047bc204e39960738 Mon Sep 17 00:00:00 2001 From: tommy0103 Date: Sat, 30 May 2026 03:53:16 +0800 Subject: [PATCH] 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. --- README.md | 7 ++++--- scripts/runtime.mjs | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1febe33..b9739dd 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,15 @@ Every past session, subagent, and workflow — searchable in natural language. - - - [![stars](https://img.shields.io/github/stars/tommy0103/obelisk?style=flat-square)](https://github.com/tommy0103/obelisk/stargazers) [![version](https://img.shields.io/github/v/tag/tommy0103/obelisk?label=version&style=flat-square)](https://github.com/tommy0103/obelisk/releases) [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE) + + + +
diff --git a/scripts/runtime.mjs b/scripts/runtime.mjs index 92fba22..a826b1b 100644 --- a/scripts/runtime.mjs +++ b/scripts/runtime.mjs @@ -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;