mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
## What changed - Probe for screen readers at startup on macOS, Windows, and Linux, with a 450 ms timeout. Include Windows Narrator detection in the current login session. - Save `tui.animations = false` when a screen reader is detected and no user animation preference is configured. Preserve explicit preferences and config comments, and retain a session default if saving fails. - Record the attempt in `tui.screen_reader_detection_done`; either boolean value skips future detection. Allow explicit animation preferences to override the screen-reader default on reload. ## Testing Add tests for one-time detection, timeouts, preference preservation, temporary CLI overrides, persistence failures, and preference reloads. Verify rendering without animation frame requests and interactive startup that records detection without replacing an explicit preference. GitOrigin-RevId: f61c19dfd053f97e8cfed68dce7389fa7601120d
40 lines
1.4 KiB
Rust
40 lines
1.4 KiB
Rust
//! Checks that interactive startup persists detection without replacing a user preference.
|
|
|
|
use super::focus_palette::PtyCodex;
|
|
use super::focus_palette::write_test_config;
|
|
use anyhow::Result;
|
|
use pretty_assertions::assert_eq;
|
|
use std::time::Duration;
|
|
use std::time::Instant;
|
|
|
|
#[test]
|
|
fn startup_records_screen_reader_detection() -> Result<()> {
|
|
let repo_root = codex_utils_cargo_bin::repo_root()?;
|
|
let home = tempfile::tempdir()?;
|
|
write_test_config(home.path(), &repo_root)?;
|
|
let path = home.path().join("config.toml");
|
|
let contents = std::fs::read_to_string(&path)?;
|
|
std::fs::write(&path, format!("{contents}\n[tui]\nanimations = true\n"))?;
|
|
let mut terminal = PtyCodex::start(&repo_root, home, &[])?;
|
|
terminal.wait_for_startup()?;
|
|
let deadline = Instant::now() + Duration::from_secs(/*secs*/ 30);
|
|
loop {
|
|
let config: toml::Value = toml::from_str(&std::fs::read_to_string(&path)?)?;
|
|
if config["tui"].get("screen_reader_detection_done").is_some() {
|
|
assert_eq!(
|
|
config["tui"],
|
|
toml::Value::Table(toml::toml! {
|
|
animations = true
|
|
screen_reader_detection_done = true
|
|
})
|
|
);
|
|
return Ok(());
|
|
}
|
|
anyhow::ensure!(
|
|
Instant::now() < deadline,
|
|
"startup did not record detection"
|
|
);
|
|
terminal.read_output(Duration::from_millis(/*millis*/ 50))?;
|
|
}
|
|
}
|