mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Separate TUI preferences from server configuration (#42202)
## Why TUI preferences and persistence paths belong to the local client, while thread configuration and account requirements may come from the active app server. Keeping both in the same resolved `Config` can replace live local preferences when a thread is resumed, forked, reconnected, or switched. ## What changed - Add `LocalSettings` as the TUI-owned source for UI, history, notice, and local persistence settings, and preserve it across session lifecycle transitions. - Write preference changes to the selected user config file and reload local settings from disk when changing roots. - Use the app server's account response for authentication-dependent onboarding and status UI instead of the local model-provider configuration. - Retain platform family and OS metadata reported by remote app servers. ## Testing - Cover local setting defaults, overrides, persistence destinations, reloads, and preservation across widget replacement and root switching. - Cover remote platform metadata and server-controlled authentication UI. GitOrigin-RevId: dbc2965fb1d6cbecb3f973f6133f3dcd4467b753
This commit is contained in:
1 parent
0b509e930e
commit
9d57be71ba
87 files changed
+1188
-459
No files matched your search
@@ -215,7 +215,7 @@ impl ChatWidget {
|
||||
|
||||
self.set_status_line(status_line_from_segments(
|
||||
segments,
|
||||
self.config.tui_status_line_use_colors,
|
||||
self.local_settings.tui.status_line_use_colors,
|
||||
));
|
||||
let hyperlink_url = selections
|
||||
.status_line_items
|
||||
@@ -358,7 +358,7 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
fn action_required_terminal_title_prefix_at(&self, now: Instant) -> &'static str {
|
||||
if !self.config.animations {
|
||||
if !self.local_settings.tui.animations {
|
||||
return TERMINAL_TITLE_ACTION_REQUIRED_PREFIX;
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ impl ChatWidget {
|
||||
&self,
|
||||
selections: &StatusSurfaceSelections,
|
||||
) -> Option<Duration> {
|
||||
if self.config.animations
|
||||
if self.local_settings.tui.animations
|
||||
&& self.terminal_title_shows_action_required_with_selections(selections)
|
||||
{
|
||||
return Some(TERMINAL_TITLE_ACTION_REQUIRED_INTERVAL);
|
||||
@@ -423,12 +423,16 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
pub(super) fn configured_status_line_items(&self) -> Vec<String> {
|
||||
self.config.tui_status_line.clone().unwrap_or_else(|| {
|
||||
DEFAULT_STATUS_LINE_ITEMS
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect()
|
||||
})
|
||||
self.local_settings
|
||||
.tui
|
||||
.status_line
|
||||
.clone()
|
||||
.unwrap_or_else(|| {
|
||||
DEFAULT_STATUS_LINE_ITEMS
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
/// Parses configured terminal-title ids into known items and collects unknown ids.
|
||||
@@ -440,12 +444,16 @@ impl ChatWidget {
|
||||
|
||||
/// Returns the configured terminal-title ids, or the default ordering when unset.
|
||||
pub(super) fn configured_terminal_title_items(&self) -> Vec<String> {
|
||||
self.config.tui_terminal_title.clone().unwrap_or_else(|| {
|
||||
DEFAULT_TERMINAL_TITLE_ITEMS
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect()
|
||||
})
|
||||
self.local_settings
|
||||
.tui
|
||||
.terminal_title
|
||||
.clone()
|
||||
.unwrap_or_else(|| {
|
||||
DEFAULT_TERMINAL_TITLE_ITEMS
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
fn status_line_cwd(&self) -> &Path {
|
||||
@@ -960,7 +968,7 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
pub(super) fn terminal_title_spinner_text_at(&self, now: Instant) -> Option<String> {
|
||||
if !self.config.animations {
|
||||
if !self.local_settings.tui.animations {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -979,11 +987,15 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
fn terminal_title_uses_activity(&self) -> bool {
|
||||
self.config.tui_terminal_title.as_ref().is_none_or(|items| {
|
||||
items
|
||||
.iter()
|
||||
.any(|item| item == "activity" || item == "spinner")
|
||||
})
|
||||
self.local_settings
|
||||
.tui
|
||||
.terminal_title
|
||||
.as_ref()
|
||||
.is_none_or(|items| {
|
||||
items
|
||||
.iter()
|
||||
.any(|item| item == "activity" || item == "spinner")
|
||||
})
|
||||
}
|
||||
|
||||
fn terminal_title_has_active_progress(&self) -> bool {
|
||||
@@ -995,20 +1007,20 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
pub(super) fn should_animate_terminal_title_spinner(&self) -> bool {
|
||||
self.config.animations
|
||||
self.local_settings.tui.animations
|
||||
&& self.terminal_title_uses_activity()
|
||||
&& self.terminal_title_has_active_progress()
|
||||
}
|
||||
|
||||
pub(super) fn should_animate_terminal_title_action_required(&self) -> bool {
|
||||
self.config.animations && self.terminal_title_shows_action_required()
|
||||
self.local_settings.tui.animations && self.terminal_title_shows_action_required()
|
||||
}
|
||||
|
||||
fn should_animate_terminal_title_spinner_with_selections(
|
||||
&self,
|
||||
selections: &StatusSurfaceSelections,
|
||||
) -> bool {
|
||||
self.config.animations
|
||||
self.local_settings.tui.animations
|
||||
&& selections
|
||||
.terminal_title_items
|
||||
.contains(&TerminalTitleItem::Spinner)
|
||||
|
||||
Reference in new issue
Block a user