fix: Session Msgs-Counter zaehlt echte Nachrichten, nicht alle Zeilen

Vorher: wc -l auf der .jsonl — zaehlt auch Tool-Calls, Run-Events,
Metadata-Eintraege mit. Diagnostic zeigte z.B. "10 Msgs" fuer eine
Session mit 6 echten User/Assistant-Nachrichten.

Jetzt: grep -cE '"role":"(user|assistant)"' — zaehlt nur echte
Konversations-Messages. Matcht wie der Export und die Chat-History
das interpretieren.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
duffyduck 2026-04-18 12:09:01 +02:00
parent 6fec8588c1
commit 87deede078
1 changed files with 3 additions and 2 deletions

View File

@ -1582,10 +1582,11 @@ async function handleListSessions(clientWs) {
for f in ${SESSIONS_DIR}/*.jsonl; do
[ -f "$f" ] || continue
name=$(basename "$f")
lines=$(wc -l < "$f" 2>/dev/null || echo 0)
# Nur echte User/Assistant Messages zaehlen nicht Tool-Calls, Events etc.
msgs=$(grep -cE '"role":"(user|assistant)"' "$f" 2>/dev/null || echo 0)
size=$(du -h "$f" 2>/dev/null | cut -f1)
modified=$(stat -c '%Y' "$f" 2>/dev/null || echo 0)
echo "FILE:$name|LINES:$lines|SIZE:$size|MODIFIED:$modified"
echo "FILE:$name|LINES:$msgs|SIZE:$size|MODIFIED:$modified"
done
`.trim());