mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
Include session titles in external agent import history (#35870)
## What changed - Preserve the original title when importing an external-agent session and return it with successful session entries from `externalAgentConfig/import/readHistories`. - Add dedicated history-record success types so externally completed imports can optionally supply a session title without changing the live import result type. ## Testing - Verify imported session titles are returned by the app server and persisted when session import ledger entries are created or refreshed. GitOrigin-RevId: e896688a5763c238f1e1dc8b4672a7aa7bc1ed4c
This commit is contained in:
1 parent
28f3f1f9ef
commit
9f23e97797
28 files changed
+465
-130
No files matched your search
@@ -31,6 +31,8 @@ struct ImportedExternalAgentSessionRecord {
|
||||
source_modified_at: Option<i64>,
|
||||
#[serde(default)]
|
||||
connector_names: Vec<String>,
|
||||
#[serde(default)]
|
||||
title: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@@ -39,6 +41,7 @@ pub struct CompletedExternalAgentSessionImport {
|
||||
pub source_content_sha256: String,
|
||||
pub imported_thread_id: ThreadId,
|
||||
pub connector_names: Vec<String>,
|
||||
pub title: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -74,6 +77,7 @@ pub(crate) fn record_imported_session(
|
||||
source_path,
|
||||
imported_thread_id,
|
||||
connector_names: Vec::new(),
|
||||
title: None,
|
||||
}],
|
||||
)
|
||||
}
|
||||
@@ -98,6 +102,7 @@ pub fn record_completed_session_imports(
|
||||
record.imported_at = imported_at;
|
||||
record.source_modified_at = source_modified_at.or(record.source_modified_at);
|
||||
record.connector_names = import.connector_names;
|
||||
record.title = import.title;
|
||||
ledger.records.push(record);
|
||||
continue;
|
||||
}
|
||||
@@ -108,6 +113,7 @@ pub fn record_completed_session_imports(
|
||||
imported_at,
|
||||
source_modified_at,
|
||||
connector_names: import.connector_names,
|
||||
title: import.title,
|
||||
});
|
||||
}
|
||||
save_import_ledger(codex_home, &ledger)
|
||||
|
||||
@@ -38,6 +38,7 @@ fn completed_imports_do_not_read_source_files() {
|
||||
source_content_sha256: format!("{:x}", Sha256::digest(contents)),
|
||||
imported_thread_id,
|
||||
connector_names: Vec::new(),
|
||||
title: Some("Imported session".to_string()),
|
||||
}],
|
||||
)
|
||||
.expect("record completed imports");
|
||||
@@ -47,6 +48,7 @@ fn completed_imports_do_not_read_source_files() {
|
||||
assert_eq!(ledger.records[0].source_path, source_path);
|
||||
assert_eq!(ledger.records[0].imported_thread_id, imported_thread_id);
|
||||
assert_eq!(ledger.records[0].source_modified_at, None);
|
||||
assert_eq!(ledger.records[0].title.as_deref(), Some("Imported session"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -68,6 +70,7 @@ fn completed_import_refreshes_existing_record_metadata() {
|
||||
source_content_sha256: content_sha256.clone(),
|
||||
imported_thread_id: first_thread_id,
|
||||
connector_names: vec!["Gmail".to_string()],
|
||||
title: Some("First title".to_string()),
|
||||
}],
|
||||
)
|
||||
.expect("record first import");
|
||||
@@ -78,6 +81,7 @@ fn completed_import_refreshes_existing_record_metadata() {
|
||||
source_content_sha256: content_sha256,
|
||||
imported_thread_id: second_thread_id,
|
||||
connector_names: vec!["Slack".to_string()],
|
||||
title: Some("Second title".to_string()),
|
||||
}],
|
||||
)
|
||||
.expect("record replacement import");
|
||||
@@ -88,6 +92,7 @@ fn completed_import_refreshes_existing_record_metadata() {
|
||||
assert_eq!(ledger.records[0].imported_thread_id, second_thread_id);
|
||||
assert!(ledger.records[0].source_modified_at.is_some());
|
||||
assert_eq!(ledger.records[0].connector_names, vec!["Slack"]);
|
||||
assert_eq!(ledger.records[0].title.as_deref(), Some("Second title"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -105,18 +110,21 @@ fn connector_candidates_use_latest_import_for_each_source() {
|
||||
source_content_sha256: "first-version".to_string(),
|
||||
imported_thread_id: ThreadId::new(),
|
||||
connector_names: vec!["Gmail".to_string()],
|
||||
title: None,
|
||||
},
|
||||
CompletedExternalAgentSessionImport {
|
||||
source_path: first_source,
|
||||
source_content_sha256: "second-version".to_string(),
|
||||
imported_thread_id: ThreadId::new(),
|
||||
connector_names: vec!["Slack".to_string()],
|
||||
title: None,
|
||||
},
|
||||
CompletedExternalAgentSessionImport {
|
||||
source_path: second_source,
|
||||
source_content_sha256: "only-version".to_string(),
|
||||
imported_thread_id: ThreadId::new(),
|
||||
connector_names: vec!["Gmail".to_string(), "Slack".to_string()],
|
||||
title: None,
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user