Files
codex/codex-rs/tui/src/session_lock/macos_tests.rs
T
Benjamin Carlsson 93b4e5b4c6 Stop TUI voice calls when the OS session locks (#59330)
## What changed

- Monitor session lock state on Linux, macOS, and Windows, checking the initial state before starting audio.
- Abort local media on lock, including while connecting, retrying, or running a parked call, and display why voice stopped.
- Keep lock monitoring across startup retries and ignore stale lock notifications after a call restarts.
- Document lock behavior and platform limitations. After unlocking, users must run `/voice` to start a new call.

## Testing

Add lifecycle tests for already-locked startup, parked-call media shutdown, stale notifications, and locks during retry cleanup, plus a macOS test for password grace-period expiry.

GitOrigin-RevId: fea4b4a7903a48727c546ee3b7bd06e957a9b885
2026-11-04 06:15:53 +00:00

23 lines
690 B
Rust

#![cfg(test)]
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn screen_saver_stops_voice_when_its_password_grace_period_expires() {
let password_required_at = 1_793_735_319_i64;
let session = CFDictionary::from_CFType_pairs(&[
(
CFString::new("CGSSessionScreenIsLocked"),
CFBoolean::true_value().as_CFType(),
),
(
CFString::new("CGSSessionScreenLockedTime"),
CFNumber::from(password_required_at).as_CFType(),
),
]);
let observed = [password_required_at - 1, password_required_at]
.map(|now| requires_authentication(&session, now));
assert_eq!(observed, [false, true]);
}