Investigate usage-extension's session log parsing and time filtering
Session from pi-extensions-sessions on Hugging Face by thomasmustier · MIT · condensed by Coders Talk
Click a segment to jump to that moment
3msession
0interventions
by library · 1d
GOAL
Understand how the Pi usage-extension reads session data—whether usage is tracked per log or per message—and how it filters by time range.
- +0Prompt · +0Does usage-extension pull usage per log or per message? Could I see usage between messages 5-20 in a conversation?
- +0mAgent did · +0mSearched the repo, found usage-extension, read its README and index.ts, and grepped for session directory logic, jsonl parsing, and message role filtering.
- +1mAgent did · +1mExplained that the extension reads JSONL session logs from ~/.pi/agent/sessions, counting only assistant messages, so usage is tracked per assistant message not per log file; noted a 5-20 message slice isn't exposed by the UI without custom filtering.
- +2mPrompt · +2mOk but that would be possible presumably. How does the extension filter for time range? By message?
- +3mAgent did · +3mDumped lines 130-340 of index.ts to inspect the parseSessionFile function and time period logic.
- +3mOutcome · +3mConfirmed time filtering happens per assistant message using msg.timestamp compared against start-of-day/week boundaries, with fallback to entry timestamp; no code changes made.
VERDICT
Next time I'd just ask directly 'does usage-extension track per message or per file, and how does it do time filtering' up front instead of two separate prompts—the agent needed the follow-up question to get to the actual timestamp logic. No corrections were needed here since it was pure code reading, but grepping for specific field names like 'timestamp' and 'split(' was what actually got to the answer.