[codex] Restore thread recency with compatible migration history#28671
Conversation
…plicate-recency-migration # Conflicts: # codex-rs/state/migrations/0039_threads_recency_at.sql
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ba569b4de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let timestamp = match sort_key { | ||
| StoreThreadSortKey::CreatedAt => thread.created_at, | ||
| StoreThreadSortKey::UpdatedAt => thread.updated_at, | ||
| StoreThreadSortKey::RecencyAt => thread.recency_at, |
There was a problem hiding this comment.
Preserve recency tie-breakers in backwards cursors
When clients request sortKey: recency_at and use backwardsCursor for forward delta sync, this path collapses the cursor to a timestamp-only offset. Recency pagination now depends on the (recency_at, thread_id) tie-breaker; if two rows share a recency millisecond (for example rows inserted by an older binary), the subsequent ASC query seeded from this cursor includes same-timestamp threads that sort behind the watermark, so clients can see already-old threads as new. Build the recency backwards cursor with the thread id tie-breaker instead of using the timestamp-only offset.
AGENTS.md reference: AGENTS.md:L103-L107
Useful? React with 👍 / 👎.
Summary
recencyAtbehavior introduced by Add thread recencyAt for sidebar ordering #27910.threads_recency_atto migration 0039 so it no longer collides withexternal_agent_config_importsat version 0038.Validation
just test -p codex-state migrations::tests::repairs_recency_migration_that_was_applied_as_version_38just test -p codex-state -p codex-rollout -p codex-thread-store -p codex-app-server-protocol -p codex-tui: 3,439 passed; six TUI tests could not open the machine's existing read-only incident database at~/.codex/sqlite/state_5.sqlite.just fix -p codex-statejust fmt