mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Preserve pending Effects toggles across save refreshes (#53496)
## Why Saving an Effects preference refreshes the picker. When users toggle repeatedly before saves finish, that refresh can discard newer choices and cause subsequent toggles to use stale values. ## What changed - Update Effects checkboxes immediately and track pending saves per row, preserving newer choices when an earlier save takes effect. - Preserve pending Composer stars choices while Animations disables the row, and clear pending state on a regular panel refresh. - Use the shared list toggle handling for Effects, including Space support, while giving configured key bindings precedence over Space toggling. ## Testing Add regression tests for repeated toggles across save refreshes, pending Composer stars choices while disabled, clearing pending state, and a Space cancel binding taking precedence over toggling. Update the Effects picker snapshot. GitOrigin-RevId: 847dcc2dfd40448c7adc56c8c40879db28b1fc39
This commit is contained in:
@@ -119,6 +119,50 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
pub(crate) fn refresh_config_panel(&mut self, notice: Option<String>) -> bool {
|
||||
self.refresh_config_panel_with_effects_state(notice, Vec::new())
|
||||
}
|
||||
|
||||
/// Refresh after an effective save without discarding newer Effects choices still queued.
|
||||
pub(crate) fn refresh_config_panel_after_effective_save(
|
||||
&mut self,
|
||||
notice: Option<String>,
|
||||
preference: ConfigPreference,
|
||||
) -> bool {
|
||||
if let ConfigPreference::Toggle { setting, .. } = preference {
|
||||
match setting {
|
||||
ConfigToggle::Animations => {
|
||||
self.bottom_pane.complete_selection_toggle_for_active_view(
|
||||
crate::config_panel::EFFECTS_VIEW_ID,
|
||||
/*index*/ 0,
|
||||
);
|
||||
}
|
||||
ConfigToggle::ComposerStars => {
|
||||
self.bottom_pane.complete_selection_toggle_for_active_view(
|
||||
crate::config_panel::EFFECTS_VIEW_ID,
|
||||
/*index*/ 1,
|
||||
);
|
||||
}
|
||||
ConfigToggle::AutomaticRecaps
|
||||
| ConfigToggle::CopyOnSelectClearSelection
|
||||
| ConfigToggle::Notifications
|
||||
| ConfigToggle::PasteDetection
|
||||
| ConfigToggle::StartInVimMode
|
||||
| ConfigToggle::StatusLineColors
|
||||
| ConfigToggle::Tips => {}
|
||||
}
|
||||
}
|
||||
let toggle_states = self
|
||||
.bottom_pane
|
||||
.selection_toggle_states_for_active_view(crate::config_panel::EFFECTS_VIEW_ID)
|
||||
.unwrap_or_default();
|
||||
self.refresh_config_panel_with_effects_state(notice, toggle_states)
|
||||
}
|
||||
|
||||
fn refresh_config_panel_with_effects_state(
|
||||
&mut self,
|
||||
notice: Option<String>,
|
||||
effects_toggle_states: Vec<Option<crate::bottom_pane::SelectionToggleState>>,
|
||||
) -> bool {
|
||||
let panel_updated = self.bottom_pane.update_config_panel(&ConfigPanelUpdate {
|
||||
tui: self.config_panel_tui.clone(),
|
||||
keymap: self.bottom_pane.list_keymap(),
|
||||
@@ -132,7 +176,11 @@ impl ChatWidget {
|
||||
return panel_updated;
|
||||
};
|
||||
let keymap = self.bottom_pane.list_keymap();
|
||||
let mut params = crate::config_panel::effects(&self.config_panel_tui, &keymap);
|
||||
let mut params = crate::config_panel::effects_with_toggle_states(
|
||||
&self.config_panel_tui,
|
||||
&keymap,
|
||||
&effects_toggle_states,
|
||||
);
|
||||
params.initial_selected_idx = Some(selected_idx);
|
||||
params.subtitle = notice.or(params.subtitle);
|
||||
let effects_updated = self
|
||||
|
||||
Reference in New Issue
Block a user