fix(source): derive Claude session time from JSONL timestamp#60
Merged
Conversation
- Add jsonlMeta struct to parseJSONL, eliminating brittle multi-return signatures; future fields require no call-site changes - Parse last valid RFC3339 timestamp across all JSONL records as session time; fall back to file mtime when none found - Add SessionTime to MetaEntry for cache persistence; zero value preserves backward compatibility with old cache entries - Update parseOne and ReloadSession to use JSONL-derived time Closes #36
Claude emits "2006-01-02T15:04:05.000Z" (3-digit millis, trailing zeros preserved). RFC3339Nano uses the '9' placeholder which requires trailing zeros stripped — so ".800Z" would silently fail. Replace the two-step RFC3339 / RFC3339Nano parse with a single fixed-width millisecond layout that matches Claude's actual output. Update test fixtures from whole-second "…:00Z" to millisecond "…:00.000Z" to reflect real data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parseJSONLnow returns ajsonlMetastruct instead of multiple values — future fields require no call-site changesSessionTimetoMetaEntryfor cache persistence; zero value preserves backward compatibility with old cache entriesparseOneandReloadSessionboth use the JSONL-derived timeTest plan
TestParseJSONL_TimestampLastWins— last timestamp in file winsTestParseJSONL_TimestampNoTimestampIsZero— zero returned when no timestamp presentTestParseJSONL_TimestampInvalidIgnored— invalid strings skipped, last valid winsTestParseJSONL_TimestampMetadataRowAfterConversation— metadata row timestamp countsTestMetaCache_SessionTimeRoundTrip— SessionTime survives gob round-tripTestMetaCache_SessionTimeZeroBackcompat— old cache entries (zero SessionTime) still hitTestLoadClaude_UsesJSONLTimestamp— Session.Time comes from JSONL, not mtimeTestLoadClaude_FallsBackToMtimeWhenNoTimestamp— mtime fallback worksTestLoadClaude_CacheHitUsesSessionTime— cached SessionTime used on hitTestLoadClaude_CacheHitZeroSessionTimeFallsBackToMtime— legacy cache entry falls back to mtimeTestReloadSession_UsesJSONLTimestamp— ReloadSession uses JSONL timeTestReloadSession_FallsBackToMtimeWhenNoTimestamp— ReloadSession mtime fallbackgo test ./...passesCloses #36