Skip to content

Conversation

aibrahim-oai
Copy link
Collaborator

@aibrahim-oai aibrahim-oai commented Sep 12, 2025

Adding the ability to resume conversations.
we have one verb resume.

Behavior:

tui:
codex resume: opens session picker
codex resume --last: continue last message
codex resume <session id>: continue conversation with session id

exec:
codex resume --last: continue last conversation
codex resume <session id>: continue conversation with session id

Implementation:

  • I added a function to find the path in ~/.codex/sessions/ with a UUID. This is helpful in resuming with session id.
  • Added the above mentioned flags
  • Added lots of testing


/// Prompt to send after resuming the session. If `-` is used, read from stdin.
#[arg(value_name = "PROMPT")]
pub prompt: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this is a good one. why aren't we doing the same for codex resume ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we supporting that in tui?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's punt for now but yes. codex "some request" works.

} else if let Some(id_str) = args.session_id.as_deref() {
find_conversation_path_by_id_str(&config.codex_home, id_str).await?
} else {
None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this happen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we resume with a --last flag

let deadline = Instant::now() + Duration::from_secs(10);
let mut path = None;
while Instant::now() < deadline && path.is_none() {
path = find_session_file_containing_marker(&sessions_dir, &marker);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be only one file in sessions. Why marker search?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just extra confirmation that things are written right.

Copy link
Collaborator

@pakrym-oai pakrym-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions.

})
.await;
let codex =
resume_conversation_for_server(&server, &codex_home, session_file.clone(), |_| {}).await;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we use the mutator?

Ok(())
}

async fn resolve_resume_path(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non blocking. Why is this logic specific to exec? We should be doing a very similar thing in tui.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we use find_conversation_path_by_id_str?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah probably in a followup pr

)
.await?
} else {
conversation_manager.new_conversation(config).await?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: can we collapse this line and the one below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fmt revert it.

@aibrahim-oai aibrahim-oai merged commit a30e5e4 into main Sep 14, 2025
33 of 35 checks passed
@aibrahim-oai aibrahim-oai deleted the enable-resume branch September 14, 2025 23:33
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants