From 0a65490839d00c585c7385351d4189cc09a671ec Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Thu, 2 Apr 2026 10:49:30 -0700 Subject: [PATCH] Expose fork source thread ids in app-server v2 --- .../schema/typescript/ConversationSummary.ts | 2 +- codex-rs/app-server-protocol/src/protocol/v1.rs | 1 + codex-rs/app-server/src/codex_message_processor.rs | 14 +++++++++++++- .../app-server/tests/suite/conversation_summary.rs | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/codex-rs/app-server-protocol/schema/typescript/ConversationSummary.ts b/codex-rs/app-server-protocol/schema/typescript/ConversationSummary.ts index 2cc2a05706..bb86d2c79b 100644 --- a/codex-rs/app-server-protocol/schema/typescript/ConversationSummary.ts +++ b/codex-rs/app-server-protocol/schema/typescript/ConversationSummary.ts @@ -5,4 +5,4 @@ import type { ConversationGitInfo } from "./ConversationGitInfo"; import type { SessionSource } from "./SessionSource"; import type { ThreadId } from "./ThreadId"; -export type ConversationSummary = { conversationId: ThreadId, path: string, preview: string, timestamp: string | null, updatedAt: string | null, modelProvider: string, cwd: string, cliVersion: string, source: SessionSource, gitInfo: ConversationGitInfo | null, }; +export type ConversationSummary = { conversationId: ThreadId, forkedFromId: ThreadId | null, path: string, preview: string, timestamp: string | null, updatedAt: string | null, modelProvider: string, cwd: string, cliVersion: string, source: SessionSource, gitInfo: ConversationGitInfo | null, }; diff --git a/codex-rs/app-server-protocol/src/protocol/v1.rs b/codex-rs/app-server-protocol/src/protocol/v1.rs index 6aa2e9fa30..fb8324b6fc 100644 --- a/codex-rs/app-server-protocol/src/protocol/v1.rs +++ b/codex-rs/app-server-protocol/src/protocol/v1.rs @@ -89,6 +89,7 @@ pub struct GetConversationSummaryResponse { #[serde(rename_all = "camelCase")] pub struct ConversationSummary { pub conversation_id: ThreadId, + pub forked_from_id: Option, pub path: PathBuf, pub preview: String, pub timestamp: Option, diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index fc9ebf7461..60a82fbdf2 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -8487,6 +8487,7 @@ async fn summary_from_thread_list_item( ); return Some(ConversationSummary { conversation_id: thread_id, + forked_from_id: None, path: it.path, preview: it.first_user_message.unwrap_or_default(), timestamp, @@ -8561,6 +8562,7 @@ fn summary_from_state_db_metadata( }; ConversationSummary { conversation_id, + forked_from_id: None, path, preview, timestamp: Some(timestamp), @@ -8658,6 +8660,7 @@ pub(crate) async fn read_summary_from_rollout( Ok(ConversationSummary { conversation_id: session_meta.id, + forked_from_id: session_meta.forked_from_id, timestamp, updated_at, path: path.to_path_buf(), @@ -8718,6 +8721,7 @@ fn extract_conversation_summary( Some(ConversationSummary { conversation_id, + forked_from_id: session_meta.forked_from_id, timestamp, updated_at, path, @@ -8876,6 +8880,7 @@ fn build_thread_from_snapshot( pub(crate) fn summary_to_thread(summary: ConversationSummary) -> Thread { let ConversationSummary { conversation_id, + forked_from_id, path, preview, timestamp, @@ -8897,7 +8902,7 @@ pub(crate) fn summary_to_thread(summary: ConversationSummary) -> Thread { Thread { id: conversation_id.to_string(), - forked_from_id: None, + forked_from_id: forked_from_id.map(|id| id.to_string()), preview, ephemeral: false, model_provider, @@ -9276,6 +9281,7 @@ mod tests { let expected = ConversationSummary { conversation_id, + forked_from_id: None, timestamp: timestamp.clone(), updated_at: timestamp, path, @@ -9332,6 +9338,7 @@ mod tests { let expected = ConversationSummary { conversation_id, + forked_from_id: None, timestamp: Some(timestamp.clone()), updated_at: Some("2025-09-05T16:53:11Z".to_string()), path: path.clone(), @@ -9429,6 +9436,11 @@ mod tests { forked_from_id_from_rollout(path.as_path()).await, Some(forked_from_id.to_string()) ); + + let summary = read_summary_from_rollout(path.as_path(), "fallback").await?; + let thread = summary_to_thread(summary); + + assert_eq!(thread.forked_from_id, Some(forked_from_id.to_string())); Ok(()) } diff --git a/codex-rs/app-server/tests/suite/conversation_summary.rs b/codex-rs/app-server/tests/suite/conversation_summary.rs index 9e292d602f..159c2edbe9 100644 --- a/codex-rs/app-server/tests/suite/conversation_summary.rs +++ b/codex-rs/app-server/tests/suite/conversation_summary.rs @@ -24,6 +24,7 @@ const MODEL_PROVIDER: &str = "openai"; fn expected_summary(conversation_id: ThreadId, path: PathBuf) -> ConversationSummary { ConversationSummary { conversation_id, + forked_from_id: None, path, preview: PREVIEW.to_string(), timestamp: Some(META_RFC3339.to_string()),