mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Persist local workspace side chats and add tab close controls (#60152)
## What changed - Save side chats as attachments to their parent conversation when local workspace history supports them, and let users reopen them from the sidebar after a restart. - Show chat names or first-prompt previews in sidebar labels, and allow saved side chats to be renamed with `/rename`. - Add tab close buttons, middle-click closing, and the configurable `close_sidebar_tab` shortcut, defaulting to `Ctrl-X W`. Closing a saved chat keeps it available in the picker; archiving removes it from Side chats. - Confirm actions that stop running work, discard unsent input, or lose temporary history. Delete saved TUI side chats when deleting their parent conversation. ## Testing Add coverage for reopening saved side chats after restart, archive handling, close confirmations, and preventing close-confirmation keys from accepting a replacement approval dialog. GitOrigin-RevId: 3d47533d007286a7354660c08df13a83dd48d5d7
This commit is contained in:
@@ -18,6 +18,7 @@ use crate::keymap::KeymapContext;
|
||||
use crate::pager_overlay::TranscriptHistoryState;
|
||||
use crate::test_support::test_path_display;
|
||||
use crate::tui::Tui;
|
||||
use codex_app_server_protocol::ThreadHistoryMode;
|
||||
use codex_app_server_protocol::ToolRequestUserInputOption;
|
||||
use codex_app_server_protocol::ToolRequestUserInputParams;
|
||||
use codex_app_server_protocol::ToolRequestUserInputQuestion;
|
||||
@@ -1239,6 +1240,7 @@ async fn sidebar_chooser_preserves_the_parent_draft_and_starts_a_side_chat() ->
|
||||
super::enable_side_retention(&mut app)?;
|
||||
tui.set_owned_screen(/*owned*/ true)?;
|
||||
let parent = ThreadId::new();
|
||||
server.remember_thread_history_mode(parent, ThreadHistoryMode::Legacy);
|
||||
app.chat_widget
|
||||
.handle_thread_session(test_thread_session(parent, app.config.cwd.to_path_buf()));
|
||||
app.chat_widget.local_settings.tui.status_line = Some(vec!["model-with-reasoning".into()]);
|
||||
|
||||
@@ -364,7 +364,7 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
while app.agents_overview.request_id.is_some() {
|
||||
let event = events.recv().await.expect("inventory refresh event");
|
||||
if matches!(event, AppEvent::AgentsOverviewThreadsLoaded { .. }) {
|
||||
app.handle_event(&mut tui, &mut session, event).await?;
|
||||
Box::pin(app.handle_event(&mut tui, &mut session, event)).await?;
|
||||
} else {
|
||||
deferred.push(event);
|
||||
}
|
||||
@@ -498,7 +498,7 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
app.chat_widget.composer_text_with_pending(),
|
||||
"latest draft!"
|
||||
);
|
||||
app.handle_event(&mut tui, &mut session, AppEvent::OpenAgentsOverview)
|
||||
Box::pin(app.handle_event(&mut tui, &mut session, AppEvent::OpenAgentsOverview))
|
||||
.await?;
|
||||
assert!(app.chat_widget.has_active_view());
|
||||
app.handle_tui_event(
|
||||
@@ -545,11 +545,11 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
);
|
||||
}
|
||||
available.store(true, std::sync::atomic::Ordering::SeqCst);
|
||||
app.handle_event(
|
||||
Box::pin(app.handle_event(
|
||||
&mut tui,
|
||||
&mut session,
|
||||
AppEvent::SelectAgentsOverviewThread { thread_id: id },
|
||||
)
|
||||
))
|
||||
.await?;
|
||||
assert!(!app.thread_unavailable(id));
|
||||
assert_eq!(
|
||||
@@ -595,7 +595,7 @@ async fn reconnect_daemon_command_center_after_socket_replacement_without_a_conv
|
||||
.await?;
|
||||
while let Ok(event) = events.try_recv() {
|
||||
if matches!(event, AppEvent::CodexOp(AppCommand::UserTurn { .. })) {
|
||||
app.handle_event(&mut tui, &mut session, event).await?;
|
||||
Box::pin(app.handle_event(&mut tui, &mut session, event)).await?;
|
||||
}
|
||||
}
|
||||
let channel = app.thread_event_channels.get(&id).unwrap();
|
||||
|
||||
@@ -424,6 +424,7 @@ async fn custom_permission_selection_scenario() -> Result<()> {
|
||||
app.agents_overview
|
||||
.requested_permission_profiles
|
||||
.get(&thread_id),
|
||||
crate::app_server_session::SideChatStorage::Temporary,
|
||||
),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -140,7 +140,7 @@ async fn next_turn_started(
|
||||
}
|
||||
}
|
||||
|
||||
async fn wait_for_turn_completed(
|
||||
pub(super) async fn wait_for_turn_completed(
|
||||
app: &mut App,
|
||||
app_server: &mut AppServerSession,
|
||||
thread_id: ThreadId,
|
||||
|
||||
@@ -1635,6 +1635,7 @@ async fn delete_current_thread_navigates_only_after_success() -> Result<()> {
|
||||
side_config.clone(),
|
||||
thread_id,
|
||||
/*selected_profile*/ None,
|
||||
crate::app_server_session::SideChatStorage::Temporary,
|
||||
)
|
||||
.await?;
|
||||
let side_id = side.session.thread_id;
|
||||
@@ -1651,7 +1652,8 @@ async fn delete_current_thread_navigates_only_after_success() -> Result<()> {
|
||||
&app.local_settings,
|
||||
side_config,
|
||||
thread_id,
|
||||
/*selected_profile*/ None
|
||||
/*selected_profile*/ None,
|
||||
crate::app_server_session::SideChatStorage::Temporary,
|
||||
)
|
||||
.await
|
||||
.is_err()
|
||||
@@ -1946,6 +1948,7 @@ async fn archive_current_thread_returns_to_agents() -> Result<()> {
|
||||
side_config,
|
||||
thread_id,
|
||||
/*selected_profile*/ None,
|
||||
crate::app_server_session::SideChatStorage::Temporary,
|
||||
)
|
||||
.await?
|
||||
.session
|
||||
@@ -3901,6 +3904,7 @@ async fn paginated_workflows_never_request_full_thread_history() -> Result<()> {
|
||||
side_config,
|
||||
paginated_thread_id,
|
||||
/*selected_profile*/ None,
|
||||
crate::app_server_session::SideChatStorage::Temporary,
|
||||
))
|
||||
.await?;
|
||||
|
||||
@@ -4873,8 +4877,24 @@ terminal_visualization_instructions = true
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn changing_directory_preserves_project_trust_permissions_history_and_hooks() -> Result<()> {
|
||||
#[test]
|
||||
fn changing_directory_preserves_project_trust_permissions_history_and_hooks() -> Result<()> {
|
||||
// The TUI and embedded app-server load full configurations on the same test thread.
|
||||
const TEST_STACK_SIZE_BYTES: usize = 16 * 1024 * 1024;
|
||||
std::thread::Builder::new()
|
||||
.name("tui-change-directory".into())
|
||||
.stack_size(TEST_STACK_SIZE_BYTES)
|
||||
.spawn(|| {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()?
|
||||
.block_on(boxed_future!(change_directory_scenario()))
|
||||
})?
|
||||
.join()
|
||||
.expect("directory change test thread panicked")
|
||||
}
|
||||
|
||||
async fn change_directory_scenario() -> Result<()> {
|
||||
use codex_protocol::config_types::TrustLevel as T;
|
||||
use serde_json::json;
|
||||
use std::fs;
|
||||
|
||||
@@ -11,7 +11,7 @@ use codex_app_server_protocol::TurnStartResponse;
|
||||
use core_test_support::responses;
|
||||
|
||||
/// Captures one real model request and waits until its turn can be inherited by a fork.
|
||||
async fn ask(
|
||||
pub(super) async fn ask(
|
||||
server: &mut AppServerSession,
|
||||
model: &wiremock::MockServer,
|
||||
thread: ThreadId,
|
||||
@@ -77,6 +77,7 @@ async fn temporary_side_chat_sends_policy_on_its_first_request() -> Result<()> {
|
||||
app.side_fork_config(),
|
||||
parent,
|
||||
/*profile*/ None,
|
||||
crate::app_server_session::SideChatStorage::Temporary,
|
||||
)
|
||||
.await?;
|
||||
fork.boundary.expect("side-chat context injection");
|
||||
|
||||
Reference in New Issue
Block a user