mirror of
https://github.com/openai/codex.git
synced 2026-10-31 19:28:49 +00:00
updated_at on renaming
This commit is contained in:
@@ -301,6 +301,18 @@ async fn thread_rename_updates_state_db_name() -> Result<()> {
|
||||
let thread_id = test.session_configured.session_id;
|
||||
let new_name = "renamed thread";
|
||||
|
||||
let mut metadata = None;
|
||||
for _ in 0..100 {
|
||||
metadata = db.get_thread(thread_id).await?;
|
||||
if metadata.is_some() {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(25)).await;
|
||||
}
|
||||
let metadata = metadata.expect("thread should exist in state db");
|
||||
let previous_updated_at = metadata.updated_at;
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
test.codex
|
||||
.submit(Op::SetThreadName {
|
||||
name: new_name.to_string(),
|
||||
@@ -325,6 +337,10 @@ async fn thread_rename_updates_state_db_name() -> Result<()> {
|
||||
|
||||
let metadata = metadata.expect("thread should exist in state db");
|
||||
assert_eq!(metadata.name, new_name);
|
||||
assert!(
|
||||
metadata.updated_at > previous_updated_at,
|
||||
"expected updated_at to bump after rename"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -394,8 +394,10 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
|
||||
/// Update the thread name for an existing thread.
|
||||
pub async fn update_thread_name(&self, thread_id: ThreadId, name: &str) -> anyhow::Result<()> {
|
||||
sqlx::query("UPDATE threads SET name = ? WHERE id = ?")
|
||||
let updated_at = datetime_to_epoch_seconds(Utc::now());
|
||||
sqlx::query("UPDATE threads SET name = ?, updated_at = ? WHERE id = ?")
|
||||
.bind(name)
|
||||
.bind(updated_at)
|
||||
.bind(thread_id.to_string())
|
||||
.execute(self.pool.as_ref())
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user