mirror of
https://github.com/openai/codex.git
synced 2026-09-04 15:08:45 +00:00
## 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.
73 lines
2.0 KiB
Rust
73 lines
2.0 KiB
Rust
#[cfg(test)]
|
|
use chrono::DateTime;
|
|
#[cfg(test)]
|
|
use chrono::Utc;
|
|
#[cfg(test)]
|
|
use codex_protocol::ThreadId;
|
|
#[cfg(test)]
|
|
use codex_protocol::openai_models::ReasoningEffort;
|
|
#[cfg(test)]
|
|
use codex_protocol::protocol::AskForApproval;
|
|
#[cfg(test)]
|
|
use codex_protocol::protocol::SandboxPolicy;
|
|
#[cfg(test)]
|
|
use std::path::Path;
|
|
#[cfg(test)]
|
|
use std::path::PathBuf;
|
|
#[cfg(test)]
|
|
use std::time::SystemTime;
|
|
#[cfg(test)]
|
|
use std::time::UNIX_EPOCH;
|
|
#[cfg(test)]
|
|
use uuid::Uuid;
|
|
|
|
#[cfg(test)]
|
|
use crate::ThreadMetadata;
|
|
|
|
#[cfg(test)]
|
|
pub(super) fn unique_temp_dir() -> PathBuf {
|
|
let nanos = SystemTime::now()
|
|
.duration_since(UNIX_EPOCH)
|
|
.map_or(0, |duration| duration.as_nanos());
|
|
std::env::temp_dir().join(format!(
|
|
"codex-state-runtime-test-{nanos}-{}",
|
|
Uuid::new_v4()
|
|
))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
pub(super) fn test_thread_metadata(
|
|
codex_home: &Path,
|
|
thread_id: ThreadId,
|
|
cwd: PathBuf,
|
|
) -> ThreadMetadata {
|
|
let now = DateTime::<Utc>::from_timestamp(1_700_000_000, 0).expect("timestamp");
|
|
ThreadMetadata {
|
|
id: thread_id,
|
|
rollout_path: codex_home.join(format!("rollout-{thread_id}.jsonl")),
|
|
created_at: now,
|
|
updated_at: now,
|
|
recency_at: now,
|
|
source: "cli".to_string(),
|
|
thread_source: None,
|
|
agent_nickname: None,
|
|
agent_role: None,
|
|
agent_path: None,
|
|
model_provider: "test-provider".to_string(),
|
|
model: Some("gpt-5".to_string()),
|
|
reasoning_effort: Some(ReasoningEffort::Medium),
|
|
cwd,
|
|
cli_version: "0.0.0".to_string(),
|
|
title: String::new(),
|
|
preview: Some("hello".to_string()),
|
|
sandbox_policy: crate::extract::enum_to_string(&SandboxPolicy::new_read_only_policy()),
|
|
approval_mode: crate::extract::enum_to_string(&AskForApproval::OnRequest),
|
|
tokens_used: 0,
|
|
first_user_message: Some("hello".to_string()),
|
|
archived_at: None,
|
|
git_sha: None,
|
|
git_branch: None,
|
|
git_origin_url: None,
|
|
}
|
|
}
|