mirror of
https://github.com/openai/codex.git
synced 2026-11-19 23:05:23 +00:00
Return to the command center after session cancellation or deletion (#44711)
## Why Deleting a session, canceling an archived session resume or fork, and pressing `Esc` in a conversation open in another app previously exited the TUI. Local daemon and remote connections can instead return to the command center to select another conversation. ## What changed - Return to the command center after successful deletion on local daemon and remote connections. Shut down side conversations before deletion and clear the deleted thread's local state. - Return to the command center when an unarchive prompt is canceled, discarding startup input intended for the canceled resume or fork. Keep explicit quit actions and embedded server exit behavior. - Make `Esc` open the command center from a conversation open in another app. Reselecting that conversation preserves its read-only snapshot and draft; `R` explicitly retries attachment. - Update deletion confirmation text and keyboard hints to reflect these destinations. ## Testing Add lifecycle tests for deletion success and failure, side conversation cleanup, unarchive cancellation and quitting, and read-only snapshot preservation. Add snapshots for command center navigation hints and deletion confirmation. GitOrigin-RevId: 55a96358edb7af73949877a515614943bdc73643
This commit is contained in:
1 parent
fc948f8c47
commit
08e49689b8
18 files changed
+500
-142
No files matched your search
@@ -389,7 +389,7 @@ impl App {
|
||||
return self.archive_current_thread(tui, app_server).await;
|
||||
}
|
||||
AppEvent::DeleteCurrentThread => {
|
||||
return Ok(self.delete_current_thread(app_server).await);
|
||||
return self.delete_current_thread(tui, app_server).await;
|
||||
}
|
||||
AppEvent::ForkCurrentSession { name } => {
|
||||
self.session_telemetry.counter(
|
||||
@@ -3540,28 +3540,61 @@ impl App {
|
||||
|
||||
pub(super) async fn delete_current_thread(
|
||||
&mut self,
|
||||
tui: &mut tui::Tui,
|
||||
app_server: &mut AppServerSession,
|
||||
) -> AppRunControl {
|
||||
) -> Result<AppRunControl> {
|
||||
let Some(thread_id) = self.active_thread_id.or(self.chat_widget.thread_id()) else {
|
||||
self.chat_widget
|
||||
.add_error_message("A thread must start before it can be deleted.".to_string());
|
||||
return AppRunControl::Continue;
|
||||
return Ok(AppRunControl::Continue);
|
||||
};
|
||||
if self.side_threads.contains_key(&thread_id) {
|
||||
self.chat_widget.add_error_message(
|
||||
"'/delete' is unavailable in side conversations. Press Ctrl+C to return to the main thread first."
|
||||
.to_string(),
|
||||
);
|
||||
return AppRunControl::Continue;
|
||||
return Ok(AppRunControl::Continue);
|
||||
}
|
||||
|
||||
match app_server.thread_delete(thread_id).await {
|
||||
Ok(()) => AppRunControl::Exit(ExitReason::ThreadRemoved),
|
||||
if !matches!(self.app_server_target, AppServerTarget::Embedded) {
|
||||
self.shutdown_side_threads(app_server).await;
|
||||
if !self.side_threads.is_empty() {
|
||||
return Ok(AppRunControl::Continue);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(match app_server.thread_delete(thread_id).await {
|
||||
Ok(()) if matches!(self.app_server_target, AppServerTarget::Embedded) => {
|
||||
AppRunControl::Exit(ExitReason::ThreadRemoved)
|
||||
}
|
||||
Ok(()) => {
|
||||
self.track_agents_overview_notification(&ServerNotification::ThreadDeleted(
|
||||
codex_app_server_protocol::ThreadDeletedNotification {
|
||||
thread_id: thread_id.to_string(),
|
||||
},
|
||||
));
|
||||
self.discard_thread_local_state(thread_id).await;
|
||||
self.agents_overview.input_states.remove(&thread_id);
|
||||
self.agents_overview.dispatched_requests.remove(&thread_id);
|
||||
self.reset_for_thread_switch(tui)?;
|
||||
self.pending_thread_switch_resets += 1;
|
||||
self.app_event_tx
|
||||
.send(AppEvent::ResetTranscriptForThreadSwitch);
|
||||
self.reset_thread_event_state();
|
||||
let init = self.chatwidget_init_for_forked_or_resumed_thread(
|
||||
tui,
|
||||
self.config.clone(),
|
||||
/*initial_user_message*/ None,
|
||||
);
|
||||
self.replace_chat_widget(ChatWidget::new_with_app_event(init));
|
||||
self.open_agents_overview(app_server, AgentsOverviewFocus::List);
|
||||
AppRunControl::Continue
|
||||
}
|
||||
Err(err) => {
|
||||
self.chat_widget
|
||||
.add_error_message(format!("Failed to delete current thread: {err}"));
|
||||
AppRunControl::Continue
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user