Files
codex/codex-rs/thread-store/src/local/search_threads_tests.rs
T
Jeremy Rose 7dc7096ae1 [codex] Restore thread recency with compatible migration history (#28671)
## Summary

- Revert #28655, restoring the thread `recencyAt` behavior introduced by
#27910.
- Move `threads_recency_at` to migration 0039 so it no longer collides
with `external_agent_config_imports` at version 0038.
- Repair databases that already applied the recency migration as version
38 by moving the matching migration-history row to version 39 before
SQLx validation. The current version-38 migration can then apply
normally.

## Validation

- `just test -p codex-state
migrations::tests::repairs_recency_migration_that_was_applied_as_version_38`
- `just 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-state`
- `just fmt`
- Verified that state migration versions are unique.
2026-06-17 18:52:18 +00:00

30 lines
909 B
Rust

use codex_protocol::ThreadId;
use codex_rollout::ThreadItem;
use pretty_assertions::assert_eq;
use super::ThreadSearchItem;
use super::cursor_from_thread_search_item;
use crate::ThreadSortKey;
#[test]
fn recency_cursor_includes_thread_id_tie_breaker() {
let thread_id = ThreadId::from_string("00000000-0000-0000-0000-000000000123")
.expect("thread ID should parse");
let item = ThreadSearchItem {
item: ThreadItem {
thread_id: Some(thread_id),
recency_at: Some("2026-01-27T12:34:56Z".to_string()),
..Default::default()
},
snippet: String::new(),
};
let cursor = cursor_from_thread_search_item(&item, ThreadSortKey::RecencyAt)
.expect("cursor should build");
assert_eq!(
serde_json::to_string(&cursor).expect("cursor should serialize"),
format!("\"2026-01-27T12:34:56Z|{thread_id}\"")
);
}