mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
## 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
104 lines
3.4 KiB
Rust
104 lines
3.4 KiB
Rust
//! Check first-frame editor and screen settings using the real client configuration loader.
|
|
|
|
use super::*;
|
|
use clap::Parser;
|
|
use crossterm::event::KeyCode;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[tokio::test]
|
|
async fn selected_profile_controls_submit_before_the_first_frame() -> anyhow::Result<()> {
|
|
let home = tempfile::tempdir()?;
|
|
std::fs::write(
|
|
home.path().join("config.toml"),
|
|
"disable_paste_burst = false\n",
|
|
)?;
|
|
let selected = AbsolutePathBuf::from_absolute_path(home.path().join("work.config.toml"))?;
|
|
let cli = Cli::try_parse_from(["codex"])?;
|
|
for (submit, expected_bindings) in [
|
|
("[]", Vec::new()),
|
|
("\"f12\"", vec![crate::key_hint::plain(KeyCode::F(12))]),
|
|
] {
|
|
std::fs::write(
|
|
&selected,
|
|
// 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,
|
|
home.path(),
|
|
LoaderOverrides {
|
|
user_config_path: Some(selected.clone()),
|
|
user_config_profile: Some("work".parse()?),
|
|
ignore_project_config: true,
|
|
..LoaderOverrides::without_managed_config_for_tests()
|
|
},
|
|
Vec::new(),
|
|
/*config_cwd*/ None,
|
|
)
|
|
.await?;
|
|
assert_eq!(
|
|
(
|
|
presentation.screen.keymap.composer.submit,
|
|
presentation.screen.disable_paste_burst,
|
|
),
|
|
(expected_bindings, true),
|
|
);
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn first_frame_respects_screen_and_status_line_overrides() -> anyhow::Result<()> {
|
|
let home = tempfile::tempdir()?;
|
|
for (config, args, expected) in [
|
|
("", vec!["codex"], (true, true, true)),
|
|
("[tui]\n", vec!["codex"], (true, true, true)),
|
|
("", vec!["codex", "--no-alt-screen"], (false, false, true)),
|
|
(
|
|
"[tui]\nfullscreen_transcript = true\n",
|
|
vec!["codex"],
|
|
(true, true, true),
|
|
),
|
|
(
|
|
"[tui]\nfullscreen_transcript = true\n",
|
|
vec!["codex", "--no-alt-screen"],
|
|
(false, false, true),
|
|
),
|
|
(
|
|
"[tui]\nfullscreen_transcript = false\n",
|
|
vec!["codex"],
|
|
(true, false, true),
|
|
),
|
|
(
|
|
"[tui]\nfullscreen_transcript = true\nalternate_screen = \"never\"\nstatus_line = []\n",
|
|
vec!["codex"],
|
|
(false, false, false),
|
|
),
|
|
] {
|
|
std::fs::write(home.path().join("config.toml"), config)?;
|
|
let cli = Cli::try_parse_from(args)?;
|
|
let presentation = load(
|
|
&cli,
|
|
home.path(),
|
|
LoaderOverrides {
|
|
ignore_project_config: true,
|
|
..LoaderOverrides::without_managed_config_for_tests()
|
|
},
|
|
Vec::new(),
|
|
/*config_cwd*/ None,
|
|
)
|
|
.await?;
|
|
assert_eq!(
|
|
(
|
|
presentation.screen.use_alt_screen,
|
|
presentation.screen.transcript_mode.is_owned(),
|
|
presentation.screen.status_line_enabled
|
|
),
|
|
expected,
|
|
);
|
|
}
|
|
Ok(())
|
|
}
|