mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:19:04 +00:00
Persist names for paginated threads (#34229)
## Why Paginated threads need explicit user-facing names to remain distinct from derived titles and previews without requiring rollout metadata writes. ## What changed - Add a nullable `name` column to persisted thread metadata and use it as the canonical name for paginated threads. - Route paginated name updates through the state database while retaining the name index as best-effort compatibility data and preserving legacy thread behavior. - Return persisted names when reading, listing, searching, and resuming paginated threads, and include them in state-database search matching. ## Testing - Cover paginated name updates, reads, list/search results, and metadata-only resume behavior, including stale or unavailable compatibility data. GitOrigin-RevId: 5ac4dfa2a83682b43d59ecc87e0f515580164dca
This commit is contained in:
1 parent
7844386e3d
commit
5a208c1fc3
13 files changed
+483
-148
No files matched your search
@@ -189,6 +189,7 @@ SELECT
|
||||
threads.cwd,
|
||||
threads.cli_version,
|
||||
threads.title,
|
||||
threads.name,
|
||||
threads.preview,
|
||||
threads.sandbox_policy,
|
||||
threads.approval_mode,
|
||||
@@ -562,6 +563,7 @@ SELECT
|
||||
threads.cwd,
|
||||
threads.cli_version,
|
||||
threads.title,
|
||||
threads.name,
|
||||
threads.preview,
|
||||
threads.sandbox_policy,
|
||||
threads.approval_mode,
|
||||
|
||||
@@ -62,6 +62,7 @@ pub(super) fn test_thread_metadata(
|
||||
cwd,
|
||||
cli_version: "0.0.0".to_string(),
|
||||
title: String::new(),
|
||||
name: None,
|
||||
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),
|
||||
|
||||
@@ -26,6 +26,7 @@ SELECT
|
||||
threads.cwd,
|
||||
threads.cli_version,
|
||||
threads.title,
|
||||
threads.name,
|
||||
threads.preview,
|
||||
threads.sandbox_policy,
|
||||
threads.approval_mode,
|
||||
@@ -556,6 +557,7 @@ INSERT INTO threads (
|
||||
cwd,
|
||||
cli_version,
|
||||
title,
|
||||
name,
|
||||
preview,
|
||||
sandbox_policy,
|
||||
approval_mode,
|
||||
@@ -567,7 +569,7 @@ INSERT INTO threads (
|
||||
git_branch,
|
||||
git_origin_url,
|
||||
memory_mode
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(id) DO NOTHING
|
||||
"#,
|
||||
)
|
||||
@@ -601,6 +603,7 @@ ON CONFLICT(id) DO NOTHING
|
||||
.bind(metadata.cwd.display().to_string())
|
||||
.bind(metadata.cli_version.as_str())
|
||||
.bind(metadata.title.as_str())
|
||||
.bind(metadata.name.as_deref())
|
||||
.bind(preview)
|
||||
.bind(metadata.sandbox_policy.as_str())
|
||||
.bind(metadata.approval_mode.as_str())
|
||||
@@ -645,6 +648,19 @@ ON CONFLICT(id) DO NOTHING
|
||||
Ok(result.rows_affected() > 0)
|
||||
}
|
||||
|
||||
pub async fn update_thread_name(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
name: Option<&str>,
|
||||
) -> anyhow::Result<bool> {
|
||||
let result = sqlx::query("UPDATE threads SET name = ? WHERE id = ?")
|
||||
.bind(name)
|
||||
.bind(thread_id.to_string())
|
||||
.execute(self.pool.as_ref())
|
||||
.await?;
|
||||
Ok(result.rows_affected() > 0)
|
||||
}
|
||||
|
||||
pub async fn touch_thread_updated_at(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
@@ -810,6 +826,7 @@ INSERT INTO threads (
|
||||
cwd,
|
||||
cli_version,
|
||||
title,
|
||||
name,
|
||||
preview,
|
||||
sandbox_policy,
|
||||
approval_mode,
|
||||
@@ -821,7 +838,7 @@ INSERT INTO threads (
|
||||
git_branch,
|
||||
git_origin_url,
|
||||
memory_mode
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
rollout_path = excluded.rollout_path,
|
||||
created_at = excluded.created_at,
|
||||
@@ -884,6 +901,7 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
.bind(metadata.cwd.display().to_string())
|
||||
.bind(metadata.cli_version.as_str())
|
||||
.bind(metadata.title.as_str())
|
||||
.bind(metadata.name.as_deref())
|
||||
.bind(preview)
|
||||
.bind(metadata.sandbox_policy.as_str())
|
||||
.bind(metadata.approval_mode.as_str())
|
||||
@@ -1223,6 +1241,7 @@ SELECT
|
||||
threads.cwd,
|
||||
threads.cli_version,
|
||||
threads.title,
|
||||
threads.name,
|
||||
threads.preview,
|
||||
threads.sandbox_policy,
|
||||
threads.approval_mode,
|
||||
@@ -1322,7 +1341,9 @@ pub(super) fn push_thread_filters<'a>(
|
||||
None => {}
|
||||
}
|
||||
if let Some(search_term) = search_term {
|
||||
builder.push(" AND (instr(threads.title, ");
|
||||
builder.push(" AND (instr(COALESCE(threads.name, ''), ");
|
||||
builder.push_bind(search_term);
|
||||
builder.push(") > 0 OR instr(threads.title, ");
|
||||
builder.push_bind(search_term);
|
||||
builder.push(") > 0 OR instr(threads.preview, ");
|
||||
builder.push_bind(search_term);
|
||||
|
||||
Reference in new issue
Block a user