mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Branch conversations when editing earlier TUI prompts (#33201)
## What changed - Fork the conversation immediately before the selected prompt instead of rolling back the current thread in place, preserving the original conversation. - Reopen the selected prompt in the new conversation with its images, text elements, and mention bindings intact. - Start a fresh conversation when editing the first prompt, show a dedicated continuation notice, and restore the prompt with an error if branching fails. ## Testing - Cover branching before first and later prompts, source preservation, prompt restoration, hidden review prompts, mid-turn steering, in-progress turns, stale transcript entries, and mention bindings. GitOrigin-RevId: 15473535b3f9733b0300711a498969e6d389db79
This commit is contained in:
1 parent
72b41c55fb
commit
469ce0db51
17 files changed
+928
-549
No files matched your search
@@ -6,6 +6,12 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) enum ThreadAttachPresentation {
|
||||
SessionLineage,
|
||||
PromptEdit,
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub(super) async fn open_agent_picker(&mut self, app_server: &mut AppServerSession) {
|
||||
self.backfill_loaded_subagent_threads(app_server).await;
|
||||
@@ -571,6 +577,7 @@ impl App {
|
||||
tui,
|
||||
app_server,
|
||||
started,
|
||||
ThreadAttachPresentation::SessionLineage,
|
||||
initial_user_message,
|
||||
)
|
||||
.await
|
||||
@@ -605,6 +612,7 @@ impl App {
|
||||
tui: &mut tui::Tui,
|
||||
app_server: &mut AppServerSession,
|
||||
started: AppServerStartedThread,
|
||||
presentation: ThreadAttachPresentation,
|
||||
initial_user_message: Option<crate::chatwidget::UserMessage>,
|
||||
) -> Result<()> {
|
||||
// Initial messages are for freshly attached primary threads only. Thread switches and
|
||||
@@ -617,8 +625,12 @@ impl App {
|
||||
initial_user_message,
|
||||
);
|
||||
self.replace_chat_widget(ChatWidget::new_with_app_event(init));
|
||||
self.enqueue_primary_thread_session(started.session, started.turns)
|
||||
.await?;
|
||||
self.enqueue_primary_thread_session_with_presentation(
|
||||
started.session,
|
||||
started.turns,
|
||||
presentation,
|
||||
)
|
||||
.await?;
|
||||
self.backfill_loaded_subagent_threads(app_server).await;
|
||||
Ok(())
|
||||
}
|
||||
@@ -808,7 +820,11 @@ impl App {
|
||||
.update_search_dir(self.config.cwd.to_path_buf());
|
||||
match self
|
||||
.replace_chat_widget_with_app_server_thread(
|
||||
tui, app_server, resumed, /*initial_user_message*/ None,
|
||||
tui,
|
||||
app_server,
|
||||
resumed,
|
||||
ThreadAttachPresentation::SessionLineage,
|
||||
/*initial_user_message*/ None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user