fix: 仪表盘数字终于可信 — 时长、成本、日期、丢失的消息与 CLI 快捷方式#42
Conversation
IM-1: the turn_duration special case added durationMs, then the generic durationMs branch added the same field again — every duration stat the dashboard and reports show was inflated 2x for those events. The generic read alone covers turn_duration system events. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…oles IM-2: the string-content branch was nested inside the Array.isArray branch (unreachable) and the fallback branch only handled the human role, so legacy assistant messages with plain string content produced zero events — entire turns missing from session views. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
IM-4: firstActivity was initialized to new Date() (scan time), so discovery's 'getTime() > 0' check was always true and the file birthtime fallback never ran — sessions without timestamps got a creation date that changed on every scan. A max-date sentinel now tracks the minimum and normalizes to epoch when nothing was seen. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
IM-3: stored timestamps are SQLite UTC strings, but the day key was sliced from the UTC text while range boundaries used local date components — in Asia/Shanghai anything done 00:00-08:00 local landed in the previous day's report, and rendered timestamps showed 8h early (JS parses bare datetime strings as local, compounding the mismatch). Date handling is now single-sourced in report-dates.ts: bare DB timestamps parse as UTC, day keys and range boundaries both use the local calendar, and the HTML renderer formats true local time. Adds the TZ-boundary tests the CI TZ=Asia/Shanghai pin was meant for. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
IM-24: Claude cost was session-granular — one record per session booked at last-activity time with empty token totals and a hardcoded model, so a week-long session dumped its entire cost on one day and 'today's cost' could inflate by orders of magnitude. scanSession now aggregates cost and tokens per (local day, model) into a compact dailyUsage list, and the cost report emits one record per bucket with real token counts. Sessions scanned before this change keep the legacy whole-session fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ommander 14 IM-15: commander 14 hard-errors with 'too many arguments' for words it doesn't recognize, so 'devlog abc123' (open a session) and 'devlog help' were both broken in the published CLI. The default command now declares an optional [ref] argument that routes to 'show', and 'help' prints program help. Verified against the bundled dist/cli.js. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The hardcoded VERSION was two releases behind package.json (0.4.0 vs 0.5.0). The CLI now reads the version from the resolved package root, so --version and the help banner always match the installed package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Claude finished @moose-lab's task in 4m 2s —— View job Code Review
Findings
What's solid: The core fixes are all correct and the reasoning checks out:
Verdict: APPROVE The two should-fixes are real data-quality issues but neither affects cost correctness (Claude spend flows from |
用户视角:这次更新你会感受到什么
DevLog 的核心价值是"如实告诉你今天干了什么、花了多少"。这批修复让这些数字第一次真正可信:
⏱️ 时长不再虚高一倍
每个带
turn_duration的事件之前被计了两次——你看到的会话时长统计普遍偏高(最多 2 倍)。现在每段时长只计一次。💰 「今日花费」恢复真实
📅 凌晨的工作不再"消失"
报表按你的本地日历日分桶。之前日期键取的是 UTC:在东八区,凌晨 00:00–08:00 做的工作会落进前一天的日报,报表里的时间戳也早 8 小时。现在日报、周报、月报、HTML 导出全链路一个时区,CI 固定 TZ 的测试这次真的在守护这件事。
💬 旧会话里"凭空消失"的回复回来了
旧格式(纯字符串内容)的 assistant 消息之前解析出 0 条事件——翻看历史会话时整段回复缺失。现在两种角色、两种格式都正常显示。
📂 无时间戳会话的创建时间不再每次扫描都变
损坏或无时间戳的会话现在回退到文件创建时间,而不是"扫描那一刻"。
⌨️ CLI 快捷方式修复
devlog abc123(直接打开某个会话)和devlog help之前在 commander 14 下直接报错 "too many arguments",现在都正常。devlog --version显示真实版本号(之前停留在两个版本前的 0.4.0)。范围与验证
quality:build(Next + tsup)通过;CLI 行为用打包产物实测验证。🤖 Generated with Claude Code