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
@@ -3,6 +3,7 @@ use std::path::Path;
|
||||
use crate::key_hint;
|
||||
use crate::legacy_core::config::Config;
|
||||
use crate::legacy_core::config::edit::ConfigEditsBuilder;
|
||||
use crate::local_settings::LocalSettings;
|
||||
use crate::render::Insets;
|
||||
use crate::render::renderable::ColumnRenderable;
|
||||
use crate::render::renderable::Renderable;
|
||||
@@ -149,7 +150,9 @@ pub(crate) async fn run_cwd_selection_prompt(
|
||||
Ok(CwdPromptOutcome::Exit)
|
||||
} else {
|
||||
let selection = screen.selection().unwrap_or(CwdSelection::Session);
|
||||
if let Some(error_line) = persist_remembered_cwd_selection(config, selection).await {
|
||||
if let Some(error_line) =
|
||||
persist_remembered_cwd_selection(&LocalSettings::from(config), selection).await
|
||||
{
|
||||
tui.insert_history_lines(vec![error_line]);
|
||||
}
|
||||
Ok(CwdPromptOutcome::Selection(selection))
|
||||
@@ -157,11 +160,11 @@ pub(crate) async fn run_cwd_selection_prompt(
|
||||
}
|
||||
|
||||
async fn persist_remembered_cwd_selection(
|
||||
config: &Config,
|
||||
config: &LocalSettings,
|
||||
selection: CwdSelection,
|
||||
) -> Option<Line<'static>> {
|
||||
let mode = selection.remembered_mode()?;
|
||||
match ConfigEditsBuilder::for_config(config)
|
||||
match ConfigEditsBuilder::for_config_path(config.user_config_path.as_path())
|
||||
.set_resume_cwd(mode)
|
||||
.apply()
|
||||
.await
|
||||
@@ -521,7 +524,7 @@ mod tests {
|
||||
expected_cwd
|
||||
);
|
||||
assert_eq!(
|
||||
persist_remembered_cwd_selection(&config, selection).await,
|
||||
persist_remembered_cwd_selection(&LocalSettings::from(&config), selection).await,
|
||||
None
|
||||
);
|
||||
let persisted: toml::Value = toml::from_str(&std::fs::read_to_string(
|
||||
@@ -543,10 +546,12 @@ mod tests {
|
||||
let config_path = temp_dir.path().join("config.toml");
|
||||
std::fs::create_dir(&config_path)?;
|
||||
|
||||
let error_line =
|
||||
persist_remembered_cwd_selection(&config, CwdSelection::CurrentAndRemember)
|
||||
.await
|
||||
.expect("saving to a directory should fail");
|
||||
let error_line = persist_remembered_cwd_selection(
|
||||
&LocalSettings::from(&config),
|
||||
CwdSelection::CurrentAndRemember,
|
||||
)
|
||||
.await
|
||||
.expect("saving to a directory should fail");
|
||||
let mut terminal =
|
||||
Terminal::new(VT100Backend::new(/*width*/ 100, /*height*/ 1)).expect("terminal");
|
||||
terminal
|
||||
|
||||
Reference in new issue
Block a user