mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Decouple TUI startup presentation from execution configuration (#49875)
## Why Startup presentation needs client preferences before thread initialization establishes effective execution permissions. The startup header should not infer permission state from local configuration. ## What changed - Load `LocalSettings` directly from bootstrap TOML, preserving preference defaults and overrides, accessibility settings, and audio settings that exclude project layers. - Use those settings for first-frame presentation and pass `LocalSettings` plus the working directory to the startup draft instead of a full `Config`. - Stop showing the YOLO indicator in the startup header while execution permissions are unknown. ## Testing Update tests to compare bootstrap settings with resolved configuration, verify first-frame keybindings and paste preferences with an unresolved permission-profile parent, and snapshot the configured startup header. Adapt startup editor tests to the settings-based interface. GitOrigin-RevId: f33cf8f42c53a9ddcbe0273491b5a849da9e6808
This commit is contained in:
@@ -988,7 +988,10 @@ impl App {
|
||||
}
|
||||
.to_path_buf();
|
||||
if let Some(draft) = startup_draft.as_deref_mut() {
|
||||
draft.apply_config(&config);
|
||||
draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
}
|
||||
let mut server_model_cleared = false;
|
||||
match StartupDraftPump::run_with_optional_draft(
|
||||
|
||||
@@ -61,7 +61,10 @@ impl App {
|
||||
if let Some(cwd) = cwd.as_ref() {
|
||||
display_config.cwd = cwd.clone();
|
||||
}
|
||||
draft.apply_config(&display_config);
|
||||
draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&display_config),
|
||||
display_config.cwd.as_path(),
|
||||
);
|
||||
draft.show(tui)?;
|
||||
// Keep the large session-start future off the TUI's stack in dev builds.
|
||||
let result = Box::pin(self.start_agents_overview_session(
|
||||
@@ -144,7 +147,7 @@ impl App {
|
||||
});
|
||||
let local_settings = self.local_settings.reloaded(&config);
|
||||
if let Some(draft) = startup_draft.as_deref_mut() {
|
||||
draft.apply_config(&config);
|
||||
draft.apply_settings(&local_settings, config.cwd.as_path());
|
||||
}
|
||||
let result = StartupDraftPump::run_with_optional_draft(
|
||||
startup_draft.as_deref_mut(),
|
||||
|
||||
@@ -221,7 +221,10 @@ impl App {
|
||||
config.cwd.to_path_buf(),
|
||||
);
|
||||
let hooks = if let Some(draft) = startup_draft {
|
||||
draft.apply_config(config);
|
||||
draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&*config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
async {
|
||||
let hooks = draft.run_until(tui, load_hooks).await?;
|
||||
draft.flush_pending_events(tui).await?;
|
||||
|
||||
@@ -110,7 +110,10 @@ async fn owned_startup_preserves_loading_until_resume_replay_is_applied() -> Res
|
||||
tui.set_owned_screen(/*owned*/ true)?;
|
||||
let thread_id = ThreadId::new();
|
||||
let mut startup = quiet_startup_test_pump();
|
||||
startup.apply_config(&app.config);
|
||||
startup.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&app.config),
|
||||
app.config.cwd.as_path(),
|
||||
);
|
||||
startup.update_session_selection(
|
||||
&mut tui,
|
||||
&SessionSelection::Resume(crate::resume_picker::SessionTarget {
|
||||
|
||||
+12
-3
@@ -1396,7 +1396,10 @@ async fn run_ratatui_app(
|
||||
if app_server_target.uses_embedded_network_policy() {
|
||||
embedded_network_policy.bind_config(&mut config);
|
||||
}
|
||||
startup_draft.apply_config(&config);
|
||||
startup_draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
if !(cli.resume_picker || cli.fork_picker || cli.agents_overview)
|
||||
&& let Err(err) = startup_draft.show(&mut tui)
|
||||
{
|
||||
@@ -1748,7 +1751,10 @@ async fn run_ratatui_app(
|
||||
if app_server_target.uses_embedded_network_policy() {
|
||||
embedded_network_policy.bind_config(&mut config);
|
||||
}
|
||||
startup_draft.apply_config(&config);
|
||||
startup_draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
|
||||
if config.model_provider_id != startup_model_provider {
|
||||
startup_account = None;
|
||||
@@ -1908,7 +1914,10 @@ async fn run_ratatui_app(
|
||||
if app_server_target.uses_embedded_network_policy() {
|
||||
embedded_network_policy.bind_config(&mut config);
|
||||
}
|
||||
startup_draft.apply_config(&config);
|
||||
startup_draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
|
||||
// Count launches that reach final config resolution, regardless of screen policy.
|
||||
if config.analytics_enabled != Some(false)
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
//! Client-owned preferences and persistence paths, independent of active server settings.
|
||||
//!
|
||||
//! The resolved core config is a temporary input at local load/reload boundaries. Server thread
|
||||
//! responses must never refresh these values; live preference changes belong here. The remaining
|
||||
//! Config-based lifecycle adapters also use this conversion until their interfaces are migrated.
|
||||
//! The first frame reads preferences from bootstrap TOML without executable core config.
|
||||
//! Server thread responses must never refresh these values; live preference changes belong here.
|
||||
//! Legacy Config-based lifecycle adapters remain until their interfaces are migrated.
|
||||
//! Audio preferences exclude project layers so thread cwd cannot route local capture.
|
||||
//! Effective animations also respect the TUI host's launch-time accessibility preference.
|
||||
//! The selected transcript ownership and alternate-screen restrictions survive local reloads.
|
||||
|
||||
use crate::legacy_core::config::Config;
|
||||
use crate::legacy_core::config::ConfigTomlLoadResult;
|
||||
use crate::legacy_core::config::TerminalResizeReflowConfig;
|
||||
use crate::legacy_core::config::TerminalResizeReflowMaxRows;
|
||||
use crate::transcript_mode::TranscriptMode;
|
||||
use codex_config::ConfigLayerStack;
|
||||
use codex_config::types::CopyOnSelect;
|
||||
use codex_config::types::History;
|
||||
use codex_config::types::Notice;
|
||||
@@ -46,37 +48,15 @@ impl LocalSettings {
|
||||
system_motion: crate::motion::MotionMode,
|
||||
screen_reader_default: crate::motion::MotionMode,
|
||||
) -> Self {
|
||||
let animations = if screen_reader_default == crate::motion::MotionMode::Reduced {
|
||||
// Consult the current layers so preferences edited after startup still win.
|
||||
config
|
||||
.config_layer_stack
|
||||
.effective_config()
|
||||
.get("tui")
|
||||
.and_then(|tui| tui.get("animations"))
|
||||
.is_some()
|
||||
&& config.animations
|
||||
} else {
|
||||
config.animations
|
||||
};
|
||||
let mut audio = toml::Value::Table(Default::default());
|
||||
for layer in config.config_layer_stack.layers_low_to_high() {
|
||||
if !matches!(layer.name, codex_config::ConfigLayerSource::Project { .. })
|
||||
&& let Some(value) = layer.config.get("audio")
|
||||
{
|
||||
codex_config::merge_toml_values(&mut audio, value);
|
||||
}
|
||||
}
|
||||
Self {
|
||||
audio: audio.try_into().map_err(|error: toml::de::Error| {
|
||||
format!("Invalid machine audio settings: {error}")
|
||||
}),
|
||||
let mut settings = Self {
|
||||
audio: Ok(Default::default()),
|
||||
transcript_mode: TranscriptMode::resolve(
|
||||
config.tui_fullscreen_transcript,
|
||||
config.tui_alternate_screen != codex_config::types::AltScreenMode::Never,
|
||||
),
|
||||
tui: Tui {
|
||||
notification_settings: config.tui_notifications.clone(),
|
||||
animations: animations && system_motion == crate::motion::MotionMode::Animated,
|
||||
animations: config.animations,
|
||||
screen_reader_detection_done: None,
|
||||
effects: config.tui_effects,
|
||||
rendering: config.tui_rendering,
|
||||
@@ -115,7 +95,82 @@ impl LocalSettings {
|
||||
.get_user_config_file()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| config.codex_home.join("config.toml")),
|
||||
};
|
||||
settings.apply_host_preferences(
|
||||
&config.config_layer_stack,
|
||||
system_motion,
|
||||
screen_reader_default,
|
||||
);
|
||||
settings
|
||||
}
|
||||
|
||||
/// Read client preferences without resolving model providers or execution permissions.
|
||||
pub(crate) fn from_bootstrap(
|
||||
bootstrap: &ConfigTomlLoadResult,
|
||||
codex_home: AbsolutePathBuf,
|
||||
) -> Result<Self, toml::de::Error> {
|
||||
let config = &bootstrap.config_toml;
|
||||
let mut tui = match &config.tui {
|
||||
Some(tui) => tui.clone(),
|
||||
None => toml::Value::Table(Default::default()).try_into()?,
|
||||
};
|
||||
tui.disable_paste_burst = Some(
|
||||
tui.disable_paste_burst
|
||||
.or(config.disable_paste_burst)
|
||||
.unwrap_or(false),
|
||||
);
|
||||
tui.session_picker_view = Some(tui.session_picker_view.unwrap_or_default());
|
||||
tui.screen_reader_detection_done = None;
|
||||
let mut settings = Self {
|
||||
audio: Ok(Default::default()),
|
||||
transcript_mode: TranscriptMode::resolve(
|
||||
tui.fullscreen_transcript,
|
||||
tui.alternate_screen != codex_config::types::AltScreenMode::Never,
|
||||
),
|
||||
tui,
|
||||
history: config.history.clone().unwrap_or_default(),
|
||||
notices: config.notice.clone().unwrap_or_default(),
|
||||
user_config_path: bootstrap
|
||||
.config_layer_stack
|
||||
.get_user_config_file()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| codex_home.join("config.toml")),
|
||||
codex_home,
|
||||
};
|
||||
settings.apply_host_preferences(
|
||||
&bootstrap.config_layer_stack,
|
||||
crate::system_motion::mode(),
|
||||
crate::screen_reader::animation_default(),
|
||||
);
|
||||
Ok(settings)
|
||||
}
|
||||
|
||||
fn apply_host_preferences(
|
||||
&mut self,
|
||||
layers: &ConfigLayerStack,
|
||||
system_motion: crate::motion::MotionMode,
|
||||
screen_reader_default: crate::motion::MotionMode,
|
||||
) {
|
||||
if screen_reader_default == crate::motion::MotionMode::Reduced {
|
||||
// Consult the current layers so preferences edited after startup still win.
|
||||
self.tui.animations &= layers
|
||||
.effective_config()
|
||||
.get("tui")
|
||||
.and_then(|tui| tui.get("animations"))
|
||||
.is_some();
|
||||
}
|
||||
self.tui.animations &= system_motion == crate::motion::MotionMode::Animated;
|
||||
let mut audio = toml::Value::Table(Default::default());
|
||||
for layer in layers.layers_low_to_high() {
|
||||
if !matches!(layer.name, codex_config::ConfigLayerSource::Project { .. })
|
||||
&& let Some(value) = layer.config.get("audio")
|
||||
{
|
||||
codex_config::merge_toml_values(&mut audio, value);
|
||||
}
|
||||
}
|
||||
self.audio = audio
|
||||
.try_into()
|
||||
.map_err(|error: toml::de::Error| format!("Invalid machine audio settings: {error}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,34 +145,31 @@ fast_default_opt_out = true
|
||||
.build()
|
||||
.await?;
|
||||
assert_eq!(config.startup_warnings, Vec::<String>::new());
|
||||
let local = LocalSettings::from(&config);
|
||||
let mut expected: Tui = toml::from_str("")?;
|
||||
expected.disable_paste_burst = Some(true);
|
||||
expected.right_click_paste = RightClickPaste::On;
|
||||
expected.session_picker_view = Some(SessionPickerViewMode::Dense);
|
||||
if !config_text.is_empty() {
|
||||
expected.animations = false;
|
||||
expected.effects.shimmer = false;
|
||||
expected.rendering = codex_config::types::TuiRendering {
|
||||
mermaid: false,
|
||||
math: false,
|
||||
tables: false,
|
||||
lists: false,
|
||||
};
|
||||
expected.show_tooltips = false;
|
||||
expected.show_server_version_notice = false;
|
||||
expected.auto_recap = false;
|
||||
expected.fullscreen_transcript = true;
|
||||
expected.copy_on_select = CopyOnSelect::Never;
|
||||
expected.vim_mode_default = true;
|
||||
expected.terminal_resize_reflow_max_rows = Some(0);
|
||||
expected.session_picker_view = Some(SessionPickerViewMode::Comfortable);
|
||||
}
|
||||
let bootstrap = crate::legacy_core::config::load_config_toml_with_layer_stack(
|
||||
home.path(),
|
||||
/*cwd*/ None,
|
||||
vec![
|
||||
("tui.disable_paste_burst".into(), true.into()),
|
||||
("tui.right_click_paste".into(), "on".into()),
|
||||
(
|
||||
"features.transcript_v2".into(),
|
||||
config_text.is_empty().into(),
|
||||
),
|
||||
],
|
||||
codex_config::ConfigLoadOptions {
|
||||
loader_overrides: LoaderOverrides {
|
||||
ignore_project_config: true,
|
||||
..LoaderOverrides::without_managed_config_for_tests()
|
||||
},
|
||||
strict_config: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(
|
||||
local.transcript_mode.is_owned(),
|
||||
expected.fullscreen_transcript
|
||||
LocalSettings::from_bootstrap(&bootstrap, config.codex_home.clone())?,
|
||||
LocalSettings::from(&config),
|
||||
);
|
||||
assert_eq!(local.tui, expected);
|
||||
assert_eq!(
|
||||
config
|
||||
.features
|
||||
@@ -181,14 +178,6 @@ fast_default_opt_out = true
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["features.transcript_v2"],
|
||||
);
|
||||
assert_eq!(
|
||||
local.terminal_resize_reflow(),
|
||||
config.terminal_resize_reflow
|
||||
);
|
||||
assert_eq!(
|
||||
(&local.history, &local.notices),
|
||||
(&config.history, &config.notices)
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+11
@@ -1,5 +1,6 @@
|
||||
---
|
||||
source: tui/src/startup_draft_tests.rs
|
||||
assertion_line: 144
|
||||
expression: "snapshots.join(\"\\n---\\n\")"
|
||||
---
|
||||
empty (48 columns):
|
||||
@@ -8,6 +9,16 @@ empty (48 columns):
|
||||
loading
|
||||
|
||||
|
||||
› Ask Codex to do anything
|
||||
|
||||
? for shortcuts
|
||||
---
|
||||
configured (48 columns):
|
||||
|
||||
>_ OpenAI Codex (v<VERSION>)
|
||||
workspace
|
||||
|
||||
|
||||
› Ask Codex to do anything
|
||||
|
||||
? for shortcuts
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
//! Keep the first composer editable and bottom-anchored while startup work continues.
|
||||
//! Submit keys confirm one draft locally; session dispatch waits for the protected handoff.
|
||||
//! Presentation accepts client preferences and cwd; effective permissions remain unknown here.
|
||||
|
||||
use std::future::Future;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::pin::Pin;
|
||||
use std::task::Poll;
|
||||
@@ -28,7 +30,7 @@ use crate::bottom_pane::ComposerDraftSnapshot;
|
||||
use crate::history_cell;
|
||||
use crate::history_cell::HistoryCell;
|
||||
use crate::keymap::RuntimeKeymap;
|
||||
use crate::legacy_core::config::Config;
|
||||
use crate::local_settings::LocalSettings;
|
||||
use crate::render::Insets;
|
||||
use crate::render::renderable::FlexRenderable;
|
||||
use crate::render::renderable::Renderable;
|
||||
@@ -172,8 +174,8 @@ impl StartupDraft {
|
||||
}
|
||||
|
||||
/// Apply the loaded editing preferences without enabling startup actions or submission.
|
||||
pub(crate) fn apply_config(&mut self, config: &Config) {
|
||||
self.pump.apply_config(config);
|
||||
pub(crate) fn apply_settings(&mut self, settings: &LocalSettings, cwd: &Path) {
|
||||
self.pump.apply_settings(settings, cwd);
|
||||
}
|
||||
|
||||
/// Lend the original terminal to an existing interactive startup screen.
|
||||
@@ -202,7 +204,7 @@ impl StartupDraftPump {
|
||||
) {
|
||||
blossom.start_fresh();
|
||||
}
|
||||
let header = startup_session_header(/*config*/ None);
|
||||
let header = startup_session_header(/*cwd*/ None);
|
||||
Self {
|
||||
header,
|
||||
blossom: std::cell::RefCell::new(blossom),
|
||||
@@ -247,20 +249,19 @@ impl StartupDraftPump {
|
||||
}
|
||||
|
||||
/// Refresh the session header and safe editor shortcuts without enabling modal editing.
|
||||
pub(crate) fn apply_config(&mut self, config: &Config) {
|
||||
pub(crate) fn apply_settings(&mut self, local_settings: &LocalSettings, cwd: &Path) {
|
||||
if self
|
||||
.configured_cwd
|
||||
.as_deref()
|
||||
.is_some_and(|cwd| cwd != config.cwd.as_path())
|
||||
.is_some_and(|previous_cwd| previous_cwd != cwd)
|
||||
{
|
||||
self.cancel_submission();
|
||||
}
|
||||
self.configured_cwd = Some(config.cwd.to_path_buf());
|
||||
let local_settings = crate::local_settings::LocalSettings::from(config);
|
||||
self.configured_cwd = Some(cwd.to_path_buf());
|
||||
self.motion = crate::motion::MotionMode::from_animations_enabled(
|
||||
local_settings.tui.animations && local_settings.tui.effects.welcome,
|
||||
);
|
||||
self.header = startup_session_header(Some(config));
|
||||
self.header = startup_session_header(Some(cwd));
|
||||
self.bottom_pane.set_status_line_enabled(
|
||||
local_settings
|
||||
.tui
|
||||
@@ -463,20 +464,14 @@ impl StartupDraftPump {
|
||||
}
|
||||
}
|
||||
|
||||
fn startup_session_header(config: Option<&Config>) -> Box<dyn HistoryCell> {
|
||||
let directory = config.map_or_else(
|
||||
|| PathBuf::from("loading"),
|
||||
|config| config.cwd.to_path_buf(),
|
||||
);
|
||||
Box::new(
|
||||
history_cell::SessionHeaderHistoryCell::new(
|
||||
"loading".to_string(),
|
||||
/*reasoning_effort*/ None,
|
||||
directory,
|
||||
CODEX_CLI_VERSION,
|
||||
)
|
||||
.with_yolo_mode(config.is_some_and(history_cell::is_yolo_mode)),
|
||||
)
|
||||
fn startup_session_header(cwd: Option<&Path>) -> Box<dyn HistoryCell> {
|
||||
// Execution permissions are unknown until the server initializes the thread.
|
||||
Box::new(history_cell::SessionHeaderHistoryCell::new(
|
||||
"loading".to_string(),
|
||||
/*reasoning_effort*/ None,
|
||||
cwd.map_or_else(|| PathBuf::from("loading"), Path::to_path_buf),
|
||||
CODEX_CLI_VERSION,
|
||||
))
|
||||
}
|
||||
|
||||
fn startup_draft_renderable<'a>(
|
||||
|
||||
@@ -108,16 +108,12 @@ async fn configured_welcome_opt_out_disables_blossom_and_clicks() -> anyhow::Res
|
||||
/*config_cwd*/ None,
|
||||
)
|
||||
.await?;
|
||||
let config = crate::legacy_core::config::ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.build()
|
||||
.await?;
|
||||
let mut pump = crate::startup_draft::tests::quiet_startup_test_pump();
|
||||
// The provisional frame uses the bootstrap value; subsequent frames use effective config.
|
||||
pump.motion = presentation.screen.welcome_motion;
|
||||
for effective in [false, true] {
|
||||
if effective {
|
||||
pump.apply_config(&config);
|
||||
pump.apply_settings(&presentation.local_settings, codex_home.path());
|
||||
}
|
||||
let mut buffer = Buffer::empty(area);
|
||||
OwnedStartupLayout::new(&pump).render(area, &mut buffer);
|
||||
|
||||
@@ -30,7 +30,7 @@ where
|
||||
let (tx, rx) = unbounded_channel();
|
||||
let mut blossom = crate::empty_state_animation::EmptyStateAnimation::default();
|
||||
blossom.start_fresh();
|
||||
let header = startup_session_header(/*config*/ None);
|
||||
let header = startup_session_header(/*cwd*/ None);
|
||||
StartupDraftPump {
|
||||
header,
|
||||
blossom: std::cell::RefCell::new(blossom),
|
||||
@@ -71,6 +71,7 @@ fn startup_draft_renders_full_empty_and_multiline_composer_frames() {
|
||||
|
||||
for (label, width, text, session_action) in [
|
||||
("empty", 48, "", StartupDraftSessionAction::New),
|
||||
("configured", 48, "", StartupDraftSessionAction::New),
|
||||
("resuming", 48, "", StartupDraftSessionAction::Resume),
|
||||
(
|
||||
"forking",
|
||||
@@ -93,6 +94,9 @@ fn startup_draft_renders_full_empty_and_multiline_composer_frames() {
|
||||
] {
|
||||
let mut pump = startup_test_pump(std::iter::empty());
|
||||
pump.session_action = session_action;
|
||||
if label == "configured" {
|
||||
pump.header = startup_session_header(Some(std::path::Path::new("workspace")));
|
||||
}
|
||||
pump.bottom_pane
|
||||
.set_composer_text(text.to_string(), Vec::new(), Vec::new());
|
||||
let renderable =
|
||||
@@ -301,7 +305,10 @@ async fn startup_draft_hydrates_its_header_without_moving_the_composer() {
|
||||
.desired_height(width);
|
||||
|
||||
assert_eq!(pump.header.raw_lines()[2].to_string(), "directory: loading");
|
||||
pump.apply_config(&config);
|
||||
pump.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
let expected_directory = crate::history_cell::SessionHeaderHistoryCell::format_directory_inner(
|
||||
config.cwd.as_path(),
|
||||
/*max_width*/ None,
|
||||
@@ -630,11 +637,12 @@ fn startup_draft_preserves_windows_altgr_text_input() {
|
||||
#[tokio::test]
|
||||
async fn startup_draft_applies_paste_burst_preferences_without_losing_buffered_input() {
|
||||
let codex_home = tempfile::tempdir().expect("create temporary Codex home");
|
||||
let mut config = ConfigBuilder::default()
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.build()
|
||||
.await
|
||||
.expect("build startup configuration");
|
||||
let mut settings = crate::local_settings::LocalSettings::from(&config);
|
||||
let mut pump = startup_test_pump(std::iter::empty());
|
||||
|
||||
handle_startup_draft_key(
|
||||
@@ -645,8 +653,8 @@ async fn startup_draft_applies_paste_burst_preferences_without_losing_buffered_i
|
||||
assert!(pump.bottom_pane.is_in_paste_burst());
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "");
|
||||
|
||||
config.disable_paste_burst = true;
|
||||
pump.apply_config(&config);
|
||||
settings.tui.disable_paste_burst = Some(true);
|
||||
pump.apply_settings(&settings, config.cwd.as_path());
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "a");
|
||||
assert!(!pump.bottom_pane.is_in_paste_burst());
|
||||
|
||||
@@ -658,8 +666,8 @@ async fn startup_draft_applies_paste_burst_preferences_without_losing_buffered_i
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "ab");
|
||||
assert!(!pump.bottom_pane.is_in_paste_burst());
|
||||
|
||||
config.disable_paste_burst = false;
|
||||
pump.apply_config(&config);
|
||||
settings.tui.disable_paste_burst = Some(false);
|
||||
pump.apply_settings(&settings, config.cwd.as_path());
|
||||
handle_startup_draft_key(
|
||||
&mut pump.bottom_pane,
|
||||
KeyEvent::new(KeyCode::Char('c'), KeyModifiers::NONE),
|
||||
@@ -668,8 +676,8 @@ async fn startup_draft_applies_paste_burst_preferences_without_losing_buffered_i
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "ab");
|
||||
assert!(pump.bottom_pane.is_in_paste_burst());
|
||||
|
||||
config.disable_paste_burst = true;
|
||||
pump.apply_config(&config);
|
||||
settings.tui.disable_paste_burst = Some(true);
|
||||
pump.apply_settings(&settings, config.cwd.as_path());
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "abc");
|
||||
assert!(!pump.bottom_pane.is_in_paste_burst());
|
||||
assert!(pump.app_event_rx.try_recv().is_err());
|
||||
@@ -678,18 +686,19 @@ async fn startup_draft_applies_paste_burst_preferences_without_losing_buffered_i
|
||||
#[tokio::test]
|
||||
async fn startup_draft_applies_editor_keymap_without_enabling_vim() {
|
||||
let codex_home = tempfile::tempdir().expect("create temporary Codex home");
|
||||
let mut config = ConfigBuilder::default()
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.build()
|
||||
.await
|
||||
.expect("build startup configuration");
|
||||
config.tui_vim_mode_default = true;
|
||||
config.tui_keymap.editor.move_line_start = Some(codex_config::types::KeybindingsSpec::One(
|
||||
let mut settings = crate::local_settings::LocalSettings::from(&config);
|
||||
settings.tui.vim_mode_default = true;
|
||||
settings.tui.keymap.editor.move_line_start = Some(codex_config::types::KeybindingsSpec::One(
|
||||
codex_config::types::KeybindingSpec("ctrl-z".to_string()),
|
||||
));
|
||||
let mut pump = startup_test_pump(std::iter::empty());
|
||||
pump.bottom_pane.insert_str("draft");
|
||||
pump.apply_config(&config);
|
||||
pump.apply_settings(&settings, config.cwd.as_path());
|
||||
assert!(!pump.bottom_pane.composer_is_vim_enabled());
|
||||
handle_startup_draft_key(
|
||||
&mut pump.bottom_pane,
|
||||
@@ -707,11 +716,11 @@ async fn startup_draft_applies_editor_keymap_without_enabling_vim() {
|
||||
let mut tui = crate::tui::test_support::make_test_tui().expect("create test terminal");
|
||||
pump.handle_event(&mut tui, TuiEvent::Key(KeyEvent::from(KeyCode::Enter)))
|
||||
.expect("confirm draft");
|
||||
pump.apply_config(&config);
|
||||
pump.apply_settings(&settings, config.cwd.as_path());
|
||||
assert!(pump.submission_pending);
|
||||
config.tui_keymap.composer.submit =
|
||||
settings.tui.keymap.composer.submit =
|
||||
Some(codex_config::types::KeybindingsSpec::Many(Vec::new()));
|
||||
pump.apply_config(&config);
|
||||
pump.apply_settings(&settings, config.cwd.as_path());
|
||||
assert!(!pump.submission_pending);
|
||||
assert_eq!(pump.bottom_pane.composer_text(), "draftx");
|
||||
}
|
||||
|
||||
@@ -289,15 +289,11 @@ pub(super) async fn run_main_inner(
|
||||
bootstrap_config,
|
||||
config_cwd,
|
||||
mut screen,
|
||||
local_settings,
|
||||
} = presentation;
|
||||
screen.use_alt_screen = determine_alt_screen_mode(
|
||||
cli.no_alt_screen,
|
||||
bootstrap_config
|
||||
.config_toml
|
||||
.tui
|
||||
.as_ref()
|
||||
.map(|tui| tui.alternate_screen)
|
||||
.unwrap_or_default(),
|
||||
local_settings.tui.alternate_screen,
|
||||
initialized_terminal.terminal_app_over_ssh,
|
||||
);
|
||||
screen.transcript_mode = crate::transcript_mode::TranscriptMode::resolve(
|
||||
@@ -464,7 +460,10 @@ pub(super) async fn run_main_inner(
|
||||
if app_server_target.uses_embedded_network_policy() {
|
||||
embedded_network_policy.activate(&mut config);
|
||||
}
|
||||
startup_draft.apply_config(&config);
|
||||
startup_draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
|
||||
let mut cloud_config_bundle = if workload_identity_selected {
|
||||
cloud_config_bundle
|
||||
@@ -499,7 +498,10 @@ pub(super) async fn run_main_inner(
|
||||
if app_server_target.uses_embedded_network_policy() {
|
||||
embedded_network_policy.activate(&mut config);
|
||||
}
|
||||
startup_draft.apply_config(&config);
|
||||
startup_draft.apply_settings(
|
||||
&crate::local_settings::LocalSettings::from(&config),
|
||||
config.cwd.as_path(),
|
||||
);
|
||||
Some(worktree)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -25,6 +25,7 @@ pub(super) struct StartupPresentation {
|
||||
pub(super) bootstrap_config: ConfigTomlLoadResult,
|
||||
pub(super) config_cwd: Option<AbsolutePathBuf>,
|
||||
pub(super) screen: StartupScreen,
|
||||
pub(super) local_settings: crate::local_settings::LocalSettings,
|
||||
}
|
||||
|
||||
/// Load client presentation settings without session setup or remote app-server connections.
|
||||
@@ -50,47 +51,35 @@ pub(super) async fn load(
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
let config_toml = &bootstrap_config.config_toml;
|
||||
let alternate_screen = config_toml
|
||||
.tui
|
||||
.as_ref()
|
||||
.map(|tui| tui.alternate_screen)
|
||||
.unwrap_or_default();
|
||||
let local_settings = crate::local_settings::LocalSettings::from_bootstrap(
|
||||
&bootstrap_config,
|
||||
AbsolutePathBuf::from_absolute_path(codex_home)?,
|
||||
)
|
||||
.map_err(io::Error::other)?;
|
||||
let settings = &local_settings.tui;
|
||||
// Terminal probing happens after configuration loads; startup finalizes this before painting.
|
||||
let use_alt_screen = crate::determine_alt_screen_mode(
|
||||
cli.no_alt_screen,
|
||||
alternate_screen,
|
||||
settings.alternate_screen,
|
||||
/*terminal_app_over_ssh*/ false,
|
||||
);
|
||||
let transcript_mode = crate::transcript_mode::TranscriptMode::resolve(
|
||||
config_toml
|
||||
.tui
|
||||
.as_ref()
|
||||
.is_none_or(|tui| tui.fullscreen_transcript),
|
||||
settings.fullscreen_transcript,
|
||||
use_alt_screen,
|
||||
);
|
||||
let status_line_enabled = config_toml
|
||||
.tui
|
||||
let status_line_enabled = settings
|
||||
.status_line
|
||||
.as_ref()
|
||||
.and_then(|tui| tui.status_line.as_ref())
|
||||
.is_none_or(|items| !items.is_empty());
|
||||
let default_tui_settings = codex_config::types::Tui::default();
|
||||
let tui_settings = config_toml.tui.as_ref().unwrap_or(&default_tui_settings);
|
||||
let keymap = RuntimeKeymap::from_config(&tui_settings.keymap).map_err(io::Error::other)?;
|
||||
let disable_paste_burst = tui_settings
|
||||
.disable_paste_burst
|
||||
.or(config_toml.disable_paste_burst)
|
||||
.unwrap_or(/*default*/ false);
|
||||
let keymap = RuntimeKeymap::from_config(&settings.keymap).map_err(io::Error::other)?;
|
||||
let disable_paste_burst = settings.disable_paste_burst.unwrap_or(false);
|
||||
let welcome_motion = crate::motion::MotionMode::from_animations_enabled(
|
||||
config_toml
|
||||
.tui
|
||||
.as_ref()
|
||||
.is_none_or(|tui| tui.animations && tui.effects.welcome)
|
||||
&& crate::system_motion::mode() == crate::motion::MotionMode::Animated,
|
||||
settings.animations && settings.effects.welcome,
|
||||
);
|
||||
Ok(StartupPresentation {
|
||||
bootstrap_config,
|
||||
config_cwd,
|
||||
local_settings,
|
||||
screen: StartupScreen {
|
||||
use_alt_screen,
|
||||
transcript_mode,
|
||||
|
||||
@@ -20,7 +20,10 @@ async fn selected_profile_controls_submit_before_the_first_frame() -> anyhow::Re
|
||||
] {
|
||||
std::fs::write(
|
||||
&selected,
|
||||
format!("disable_paste_burst = true\n[tui.keymap.composer]\nsubmit = {submit}\n"),
|
||||
// Presentation must not compile the local execution profile.
|
||||
format!(
|
||||
"default_permissions = \"server-only\"\ndisable_paste_burst = true\n[permissions.server-only]\nextends = \"missing-local-parent\"\n[tui.keymap.composer]\nsubmit = {submit}\n"
|
||||
),
|
||||
)?;
|
||||
let presentation = load(
|
||||
&cli,
|
||||
|
||||
Reference in New Issue
Block a user