core: revert fork_conversation to (path, conversation_id); protocol: ConversationPathResponseEvent carries path again; core: emit path in ConversationHistory; recorder: expose path(); tui: backtrack uses path+id; fmt

This commit is contained in:
Ahmed Ibrahim
2025-09-08 15:45:16 -07:00
parent aa94d9c4b3
commit 52a5ea5f4e
8 changed files with 78 additions and 31 deletions
+6 -1
View File
@@ -1409,7 +1409,12 @@ async fn submission_loop(
id: sub_id.clone(),
msg: EventMsg::ConversationHistory(ConversationPathResponseEvent {
conversation_id: sess.conversation_id,
entries: sess.state.lock_unchecked().history.contents(),
path: sess
.rollout
.lock_unchecked()
.as_ref()
.map(|r| r.path().to_path_buf())
.unwrap_or_default(),
}),
};
sess.send_event(event).await;
+9 -6
View File
@@ -156,16 +156,19 @@ impl ConversationManager {
/// caller's `config`). The new conversation will have a fresh id.
pub async fn fork_conversation(
&self,
conversation_history: Vec<ResponseItem>,
conversation_path: PathBuf,
conversation_id: ConversationId,
num_messages_to_drop: usize,
config: Config,
) -> CodexResult<NewConversation> {
// Compute the prefix up to the cut point.
let items: Vec<RolloutItem> = conversation_history
.into_iter()
.map(RolloutItem::from)
.collect();
let history = truncate_after_dropping_last_messages(items, num_messages_to_drop);
let initial_history = RolloutRecorder::get_rollout_history(&conversation_path).await?;
let conversation_history = match initial_history {
InitialHistory::Resumed(items) => items,
InitialHistory::New => return Err(CodexErr::ConversationNotFound(conversation_id)),
};
let history =
truncate_after_dropping_last_messages(conversation_history, num_messages_to_drop);
// Spawn a new conversation with the computed initial history.
let auth_manager = self.auth_manager.clone();
+3 -4
View File
@@ -138,6 +138,9 @@ impl RolloutRecorderParams {
}
impl RolloutRecorder {
pub fn path(&self) -> &Path {
&self.path
}
#[allow(dead_code)]
/// List conversations (rollout files) under the provided Codex home directory.
pub async fn list_conversations(
@@ -314,10 +317,6 @@ impl RolloutRecorder {
}))
}
pub fn path(&self) -> &Path {
&self.path
}
pub async fn shutdown(&self) -> std::io::Result<()> {
let (tx_done, rx_done) = oneshot::channel();
match self.tx.send(RolloutCmd::Shutdown { ack: tx_done }).await {