From b8e0d7594fdf4a6c5132c1f34cea2b6733de33d2 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Wed, 11 Feb 2026 20:03:19 -0800 Subject: [PATCH] Teach codex to test itself (#11531) For fun and profit! --- .codex/skills/test-tui/SKILL.md | 14 ++++++++++++++ codex-rs/tui/src/custom_terminal.rs | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .codex/skills/test-tui/SKILL.md diff --git a/.codex/skills/test-tui/SKILL.md b/.codex/skills/test-tui/SKILL.md new file mode 100644 index 0000000000..e58e67730e --- /dev/null +++ b/.codex/skills/test-tui/SKILL.md @@ -0,0 +1,14 @@ +--- +name: test-tui +description: Guide for testing Codex TUI interactively +--- + +You can start and use Codex TUI to verify changes. + +Important notes: + +Start interactively. +Always set RUST_LOG="trace" when starting the process. +Pass `-c log_dir=` argument to have logs written to a specific directory to help with debugging. +When sending a test message programmatically, send text first, then send Enter in a separate write (do not send text + Enter in one burst). +Use `just codex` target to run - `just codex -c ...` diff --git a/codex-rs/tui/src/custom_terminal.rs b/codex-rs/tui/src/custom_terminal.rs index da2f6d5f2e..26284a7fa1 100644 --- a/codex-rs/tui/src/custom_terminal.rs +++ b/codex-rs/tui/src/custom_terminal.rs @@ -147,7 +147,12 @@ where /// Creates a new [`Terminal`] with the given [`Backend`] and [`TerminalOptions`]. pub fn with_options(mut backend: B) -> io::Result { let screen_size = backend.size()?; - let cursor_pos = backend.get_cursor_position()?; + let cursor_pos = backend.get_cursor_position().unwrap_or_else(|err| { + // Some PTYs do not answer CPR (`ESC[6n`); continue with a safe default instead + // of failing TUI startup. + tracing::warn!("failed to read initial cursor position; defaulting to origin: {err}"); + Position { x: 0, y: 0 } + }); Ok(Self { backend, buffers: [Buffer::empty(Rect::ZERO), Buffer::empty(Rect::ZERO)],