fix: read opencode sessions from session_v2/session_message
opencode 2.0.24 migrated its session store: the session, message and part tables stopped being written, and sessions now live in session_v2 with messages in session_message. The ingest kept querying the abandoned tables, so every sweep after the migration logged "0 new" and no error. Session titles are nullable in session_v2, so keep the COALESCE and the "Session <short id>" fallback. Transcripts are rebuilt from both message shapes the new store uses: user turns carry text at $.text, assistant turns carry a typed part list at $.content of which only "text" parts are conversation (reasoning and tool parts are not indexed). Rows are ordered by seq, then part index, so a session reads in order. Harness reminders arrive as synthetic messages now; drop <system-reminder> text so it does not consume the 4000-byte summary budget. Also stop skipping an entry purely on created_at: resuming a session appends messages without touching the creation time, so the summary is compared too and the entry refreshes. Bump the ingester to opencode-db/v2 and cover both message shapes with a test that builds the new schema in a temp database. Fixes #6
This commit is contained in:
@@ -537,7 +537,10 @@ func (w *Watcher) ingestOpenCodeDB() {
|
||||
var newCount, skipped int
|
||||
for _, result := range results {
|
||||
existing, _ := w.knoxDB.FindEntry(result.Fingerprint)
|
||||
if existing != nil && existing.CreatedAt == result.CreatedAt {
|
||||
// created_at alone cannot detect a resumed session: resuming appends
|
||||
// messages without touching the creation time, so compare the summary
|
||||
// (which carries the transcript) as well.
|
||||
if existing != nil && existing.CreatedAt == result.CreatedAt && existing.Summary == result.Summary {
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user