mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Default TUI animations off when a screen reader is detected (#46040)
## 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
This commit is contained in:
1 parent
4cf84b7603
commit
515530d9b2
15 files changed
+600
-6
No files matched your search
@@ -6,6 +6,8 @@ mod focus_palette;
|
||||
#[cfg(unix)]
|
||||
mod reconnect;
|
||||
mod resize_reflow;
|
||||
#[cfg(unix)]
|
||||
mod screen_reader;
|
||||
mod status_indicator;
|
||||
mod vt100_history;
|
||||
mod vt100_live_commit;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//! 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))?;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user