Skip to content

fix(pi): parse OMP title-before-session logs - #231

Merged
vakovalskii merged 1 commit into
vakovalskii:mainfrom
timseriakov:fix/pi-title-before-session
Jul 20, 2026
Merged

vakovalskii merged 1 commit into
vakovalskii:mainfrom
timseriakov:fix/pi-title-before-session

Conversation

@timseriakov

@timseriakov timseriakov commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • accept Pi/OhMyPi JSONL logs where a title metadata record appears before the session header
  • keep parsing scoped to parsePiSessionFile() so scanning/detail/rescan behavior stays unchanged
  • use a preceding title record only when the session header has no title

Why this happened

The original Pi/OhMyPi parser assumed every session JSONL starts with a session record on the first line. That matched the Pi logs I tested first.

Oh My Pi changed its session log stream to emit title metadata as its own JSONL record before the session header, for example:

{"type":"title","v":1,"title":"brief-improve","source":"user","updatedAt":"..."}
{"type":"session","version":3,"id":"...","timestamp":"...","cwd":"..."}

So the file is still a valid session log, but line 1 is no longer the session header. Codbash treated that first title record as an invalid header and returned null, silently dropping the whole session from scans. Locally this matched the missing-session symptom: Pi/OhMyPi counts went from the old undercount to pi count: 555, ohmy: 431 after parsing the delayed session header.

Fix

  • scan the first 50 lines for the first { type: 'session', id } record instead of requiring it at line 1
  • start message parsing after the actual session header
  • if the session header has no title, reuse the preceding title metadata record
  • leave unrelated scan/detail/rescan code untouched

Validation

  • node --check src/data.js
  • node --test test/pi-session.test.js → 14 pass, 0 fail
  • local real-data scan after fix: pi count: 555, ohmy: 431

@timseriakov

Copy link
Copy Markdown
Contributor Author

@vakovalskii bro, mr plz

@vakovalskii

Copy link
Copy Markdown
Owner

Thanks for the thorough writeup and the repro — the title-before-session case is a real gap. The fix is nicely scoped to parsePiSessionFile(), keeps us dependency-free, and the added test covers exactly the new layout. Diff applies cleanly on current main and the pi-session suite passes. One optional follow-up (not blocking): loadPiDetail() still assumes the header is on line 1 — it works today because it filters on type === 'message', but reusing the same header detection there would be nice for consistency. Merging — thanks for the contribution!

@vakovalskii
vakovalskii merged commit 4f4fae3 into vakovalskii:main Jul 20, 2026
6 checks passed
vakovalskii added a commit that referenced this pull request Jul 21, 2026
Ships the changes merged since 7.14.5: native Add-project folder picker
(desktop), Oh My Pi title-before-session parsing (#231/#260), GitHub avatar
CSP fix (#249), Overview/Recommended full-width tiles (#243), Neuraldeep
footer, and signed-release docs + manual npm publish workflow.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants