Skip to content

fix: normalize startup session ordering across mixed timestamp formats#263

Merged
Robdel12 merged 3 commits intoRobdel12:mainfrom
eba8:codex/fix-session-library-timestamps
May 5, 2026
Merged

fix: normalize startup session ordering across mixed timestamp formats#263
Robdel12 merged 3 commits intoRobdel12:mainfrom
eba8:codex/fix-session-library-timestamps

Conversation

@eba8
Copy link
Copy Markdown
Contributor

@eba8 eba8 commented May 1, 2026

Summary

  • normalize startup session ordering across mixed timestamp formats
  • sort restored sessions by parsed recency in Rust instead of SQLite integer casts
  • add a regression test for mixed RFC3339 and unix-with-Z timestamp values

Root Cause

load_sessions_for_startup() was ordering sessions with SQLite expressions like CAST(REPLACE(timestamp, 'Z', '') AS INTEGER).

That works for unix-style values such as 1776438552Z, but breaks for RFC3339 values such as 2026-05-01T14:10:34Z, which collapse to 2026 when cast to an integer in SQLite.

That lets older unix-style rows sort ahead of newer ISO timestamp rows, which can make recent sessions look stale in the library.

Fix

  • parse unix-with-Z timestamps when available
  • fall back to RFC3339 parsing
  • sort restored sessions by parsed last_progress_at, then parsed last_activity_at, then started_at

Validation

  • added a regression test covering a newer RFC3339 row and an older unix-with-Z row
  • local validation is still pending in this clean worktree because cargo test had to start by downloading the pinned Rust toolchain for origin/main

Closes #262

@Robdel12 Robdel12 force-pushed the codex/fix-session-library-timestamps branch from 0fbebfa to 42b0a1b Compare May 5, 2026 03:14
eba8 and others added 3 commits May 4, 2026 23:30
Use started_at as the final startup restore tiebreaker, keep the merged Codex router helper in rustfmt shape, and bump the Rust CI cache key so stale target artifacts do not poison GitHub runs.
@Robdel12 Robdel12 force-pushed the codex/fix-session-library-timestamps branch from 42b0a1b to c87f35e Compare May 5, 2026 04:32
@Robdel12 Robdel12 marked this pull request as ready for review May 5, 2026 04:33
@Robdel12 Robdel12 enabled auto-merge (squash) May 5, 2026 04:33
@Robdel12 Robdel12 merged commit 6926bc3 into Robdel12:main May 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session library sorts mixed timestamp formats incorrectly, making recent sessions look stale

2 participants