mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +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:
@@ -38,6 +38,7 @@ pub(super) struct ConversationFrame {
|
||||
pub(super) chat_strip: Option<Rect>,
|
||||
pub(super) sidebar_input: Option<(usize, Option<ThreadId>, usize)>,
|
||||
pub(super) leader_hud: Option<Rect>,
|
||||
pub(super) close_buttons: [Rect; 2],
|
||||
/// A dialog can obscure neighboring content in the terminal's completed buffer.
|
||||
behind_dialog: Option<ratatui::buffer::Buffer>,
|
||||
caller_images: Vec<ImagePlacement>,
|
||||
@@ -249,6 +250,12 @@ impl App {
|
||||
self.conversation_frame = ConversationFrame::default();
|
||||
}
|
||||
let caller_inset = self.conversation_frame.inset;
|
||||
let parent = self.sidebar_parent();
|
||||
if !self.conversation_focus_available(tui)
|
||||
&& let Some(pane) = self.sidebars.get_mut(&parent)
|
||||
{
|
||||
pane.close = None;
|
||||
}
|
||||
let layout = sidebar::paint_layout(self, tui, screen_size.into());
|
||||
let displayed = self.current_displayed_thread_id();
|
||||
let chat = match displayed.and_then(|id| self.side_pair_key(id)) {
|
||||
@@ -365,6 +372,15 @@ impl App {
|
||||
ratatui::widgets::Paragraph::new(text)
|
||||
.wrap(ratatui::widgets::Wrap { trim: false })
|
||||
.render(body, frame.buffer);
|
||||
} else if self
|
||||
.sidebar()
|
||||
.is_some_and(|pane| pane.saved_chats_request.is_some())
|
||||
{
|
||||
ratatui::widgets::Clear.render(*sidebar, frame.buffer);
|
||||
Line::from("Loading side chats…").dim().render(
|
||||
sidebar.inner(ratatui::layout::Margin::new(1, 1)),
|
||||
frame.buffer,
|
||||
);
|
||||
} else if let Some(pane) = self.sidebar() {
|
||||
let footer = if let Some(hint) = resize_hint {
|
||||
let row = crate::sidebar_chooser::body_row(*sidebar, sidebar.y);
|
||||
@@ -421,6 +437,27 @@ impl App {
|
||||
if let Some(divider) = divider {
|
||||
side_pane::paint_divider(frame, divider.x, self.divider_drag, highlight_divider);
|
||||
}
|
||||
self.conversation_frame.close_buttons = Default::default();
|
||||
if let Some(close) = self.sidebar().and_then(|pane| pane.close.as_ref()) {
|
||||
// A resize can collapse an unfocused sidebar while its confirmation is open.
|
||||
let viewport = frame.area();
|
||||
let column = self
|
||||
.conversation_frame
|
||||
.chooser_area()
|
||||
.or(strip)
|
||||
.unwrap_or(viewport);
|
||||
let area = Rect {
|
||||
x: column.x,
|
||||
width: column.width,
|
||||
..viewport
|
||||
};
|
||||
let buttons = close.paint(area, frame.buffer);
|
||||
frame
|
||||
.image_placements
|
||||
.retain(|image| !area.intersects(image.area));
|
||||
frame.cursor_position = None;
|
||||
self.conversation_frame.close_buttons = buttons;
|
||||
}
|
||||
self.paint_centered_dialog(frame);
|
||||
self.conversation_frame.leader_hud = hud.map(|hud| {
|
||||
let area = hud.render_overlay(frame.area(), frame.buffer);
|
||||
|
||||
Reference in New Issue
Block a user