Skip to main content

parse_event_timestamp

Function parse_event_timestamp 

Source
pub(super) fn parse_event_timestamp(v: &Value) -> Option<u64>
Expand description

Epoch-millis for a subagent JSONL line’s timestamp field, tolerant of BOTH shapes that occur in real transcripts.

Claude Code writes an ISO-8601 STRING ("2026-07-03T08:09:20.743Z"), but this was read with a bare as_u64(), which returns None for a string and silently fell through to now_millis(). Every replayed historical event therefore claimed to have happened at replay time.

That is not a cosmetic timestamp bug: last_event_at becomes subagentToActivity’s endedAt (activity/subagent-adapter.ts), and the Activity Dock keeps a terminal row only while now - endedAt < RETENTION_MS[status]. With endedAt ≈ now, every long-dead subagent replayed on pane (re)open passed that window and rendered as a live-looking dock row, then vanished a few seconds later when it aged out — the “dock flashes on load, then disappears” report. With real historical timestamps these rows are filtered out immediately and never paint at all.

Numeric epoch-millis are still accepted unchanged (other providers, and any future writer that emits a number). An unparseable value returns None so the caller keeps its existing now_millis() fallback — a genuinely-live event with a malformed timestamp is better dated “now” than dropped to the epoch.

See docs/retro/retro-activitydock-appears-on-agent-pane-load-2026-09-02.md.