mirror of
https://github.com/openai/codex.git
synced 2026-11-13 21:30:47 +00:00
## What changed - Add `tui.collapse_turn_details`, disabled by default, and a “Collapse turn details” toggle in the full-screen settings panel. - Summarize command executions with output-free labels, grouping multiple calls behind an expandable row. Keep full details available through transcript search and detailed view. - Restore interruption notices at their turn boundaries when resuming and loading older history, including turns split across pages. ## Testing Add coverage for live summary updates, expansion controls, search access to hidden output, settings visibility, and interruption ordering across history pages. GitOrigin-RevId: 68987fb0239e39414dac383098acac190fc4f516
162 lines
6.7 KiB
Rust
162 lines
6.7 KiB
Rust
//! Maps config-panel preference changes to persisted and effective TUI values.
|
|
|
|
use crate::legacy_core::config::edit::ConfigEdit;
|
|
use crate::legacy_core::config::edit::session_picker_view_edit;
|
|
use codex_config::types::CopyOnSelect;
|
|
use codex_config::types::NotificationCondition;
|
|
use codex_config::types::Notifications;
|
|
use codex_config::types::ResumeCwdMode;
|
|
use codex_config::types::RightClickPaste;
|
|
use codex_config::types::SessionPickerViewMode;
|
|
use codex_config::types::Tui;
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub(crate) enum ConfigToggle {
|
|
Animations,
|
|
AutomaticRecaps,
|
|
CollapseTurnDetails,
|
|
ComposerStars,
|
|
CopyOnSelectClearSelection,
|
|
Notifications,
|
|
PasteDetection,
|
|
StartInVimMode,
|
|
StatusLineColors,
|
|
Tips,
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub(crate) enum ConfigPreference {
|
|
Toggle {
|
|
setting: ConfigToggle,
|
|
enabled: bool,
|
|
},
|
|
CopyOnSelect(CopyOnSelect),
|
|
NotificationCondition(NotificationCondition),
|
|
RightClickPaste(RightClickPaste),
|
|
SessionPickerLayout(SessionPickerViewMode),
|
|
ResumeDirectory(Option<ResumeCwdMode>),
|
|
}
|
|
|
|
impl ConfigPreference {
|
|
pub(crate) fn edit(self) -> ConfigEdit {
|
|
match self {
|
|
Self::Toggle { setting, enabled } => setting.edit(enabled),
|
|
Self::CopyOnSelect(mode) => ConfigEdit::SetPath {
|
|
segments: vec!["tui".to_string(), "copy_on_select".to_string()],
|
|
value: toml_edit::value(match mode {
|
|
CopyOnSelect::Auto => "auto",
|
|
CopyOnSelect::Always => "always",
|
|
CopyOnSelect::Never => "never",
|
|
}),
|
|
},
|
|
Self::NotificationCondition(condition) => ConfigEdit::SetPath {
|
|
segments: vec!["tui".to_string(), "notification_condition".to_string()],
|
|
value: toml_edit::value(condition.to_string()),
|
|
},
|
|
Self::RightClickPaste(mode) => ConfigEdit::SetPath {
|
|
segments: vec!["tui".to_string(), "right_click_paste".to_string()],
|
|
value: toml_edit::value(match mode {
|
|
RightClickPaste::Auto => "auto",
|
|
RightClickPaste::On => "on",
|
|
RightClickPaste::Off => "off",
|
|
}),
|
|
},
|
|
Self::SessionPickerLayout(mode) => session_picker_view_edit(mode),
|
|
Self::ResumeDirectory(None) => ConfigEdit::ClearPath {
|
|
segments: vec!["tui".to_string(), "resume_cwd".to_string()],
|
|
},
|
|
Self::ResumeDirectory(Some(mode)) => ConfigEdit::SetPath {
|
|
segments: vec!["tui".to_string(), "resume_cwd".to_string()],
|
|
value: toml_edit::value(mode.as_str()),
|
|
},
|
|
}
|
|
}
|
|
|
|
/// Copies only this preference, leaving unrelated settings unchanged.
|
|
pub(crate) fn adopt(self, target: &mut Tui, source: &Tui) {
|
|
match self {
|
|
Self::Toggle { setting, .. } => setting.adopt(target, source),
|
|
Self::CopyOnSelect(_) => target.copy_on_select = source.copy_on_select,
|
|
Self::NotificationCondition(_) => {
|
|
target.notification_settings.condition = source.notification_settings.condition;
|
|
}
|
|
Self::RightClickPaste(_) => target.right_click_paste = source.right_click_paste,
|
|
Self::SessionPickerLayout(_) => {
|
|
target.session_picker_view = source.session_picker_view;
|
|
}
|
|
Self::ResumeDirectory(_) => target.resume_cwd = source.resume_cwd,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ConfigToggle {
|
|
pub(crate) fn edit(self, enabled: bool) -> ConfigEdit {
|
|
let (key, value) = match self {
|
|
Self::ComposerStars => {
|
|
return ConfigEdit::SetPath {
|
|
segments: vec!["tui".into(), "effects".into(), "starfield".into()],
|
|
value: toml_edit::value(enabled),
|
|
};
|
|
}
|
|
Self::Notifications => {
|
|
return ConfigEdit::SetTuiNotificationsEnabled { enabled };
|
|
}
|
|
Self::Animations => ("animations", enabled),
|
|
Self::AutomaticRecaps => ("auto_recap", enabled),
|
|
Self::CollapseTurnDetails => ("collapse_turn_details", enabled),
|
|
Self::CopyOnSelectClearSelection => ("copy_on_select_clear_selection", enabled),
|
|
Self::PasteDetection => ("disable_paste_burst", !enabled),
|
|
Self::StartInVimMode => ("vim_mode_default", enabled),
|
|
Self::StatusLineColors => ("status_line_use_colors", enabled),
|
|
Self::Tips => ("show_tooltips", enabled),
|
|
};
|
|
ConfigEdit::SetPath {
|
|
segments: vec!["tui".into(), key.into()],
|
|
value: toml_edit::value(value),
|
|
}
|
|
}
|
|
|
|
pub(crate) fn enabled(self, tui: &Tui) -> bool {
|
|
match self {
|
|
Self::Animations => tui.animations,
|
|
Self::AutomaticRecaps => tui.auto_recap,
|
|
Self::CollapseTurnDetails => tui.collapse_turn_details,
|
|
Self::ComposerStars => tui.effects.starfield,
|
|
Self::CopyOnSelectClearSelection => tui.copy_on_select_clear_selection,
|
|
Self::Notifications => !matches!(
|
|
tui.notification_settings.notifications,
|
|
Notifications::Enabled(false)
|
|
),
|
|
Self::PasteDetection => !tui.disable_paste_burst.unwrap_or(/*default*/ false),
|
|
Self::StartInVimMode => tui.vim_mode_default,
|
|
Self::StatusLineColors => tui.status_line_use_colors,
|
|
Self::Tips => tui.show_tooltips,
|
|
}
|
|
}
|
|
|
|
/// Copies only this preference, leaving unrelated settings unchanged.
|
|
pub(crate) fn adopt(self, target: &mut Tui, source: &Tui) {
|
|
match self {
|
|
Self::Animations => target.animations = source.animations,
|
|
Self::AutomaticRecaps => target.auto_recap = source.auto_recap,
|
|
Self::CollapseTurnDetails => {
|
|
target.collapse_turn_details = source.collapse_turn_details
|
|
}
|
|
Self::ComposerStars => target.effects.starfield = source.effects.starfield,
|
|
Self::CopyOnSelectClearSelection => {
|
|
target.copy_on_select_clear_selection = source.copy_on_select_clear_selection;
|
|
}
|
|
Self::Notifications => {
|
|
target.notification_settings.notifications =
|
|
source.notification_settings.notifications.clone();
|
|
}
|
|
Self::PasteDetection => target.disable_paste_burst = source.disable_paste_burst,
|
|
Self::StartInVimMode => target.vim_mode_default = source.vim_mode_default,
|
|
Self::StatusLineColors => {
|
|
target.status_line_use_colors = source.status_line_use_colors;
|
|
}
|
|
Self::Tips => target.show_tooltips = source.show_tooltips,
|
|
}
|
|
}
|
|
}
|