Commit Graph
11015 Commits
Author SHA1 Message Date
Michael Bolin 467d54daf3 Merge fa49cae719 into sapling-pr-archive-bolinfest 2026-04-02 16:12:27 -07:00
Michael Bolin fa49cae719 test: use cmd.exe for provider auth scripts on Windows 2026-04-02 16:12:20 -07:00
Michael Bolin a74b81ab4c merge commit for archive created by Sapling 2026-04-02 15:27:07 -07:00
Michael Bolin 41f7ac0ade core: use native async ToolHandler trait 2026-04-02 15:26:42 -07:00
Michael Bolin 036bb657cc Merge deba695a71 into sapling-pr-archive-bolinfest 2026-04-02 15:22:33 -07:00
Michael Bolin deba695a71 test: use cmd.exe for provider auth scripts on Windows 2026-04-02 15:22:09 -07:00
Michael Bolin 6e9bf0da19 Merge 2810b26ffd into sapling-pr-archive-bolinfest 2026-04-02 15:17:06 -07:00
Michael Bolin 2810b26ffd core: type-erase ToolHandler outputs 2026-04-02 15:16:56 -07:00
Michael Bolin 1775191cb3 merge commit for archive created by Sapling 2026-04-02 15:07:29 -07:00
Michael Bolin 8030f844ea refactor: move shell and snapshot code out of codex-core 2026-04-02 14:47:07 -07:00
fcoury-oaiandClaude Opus 4.6 0bd31dc382 fix(tui): handle zellij redraw and composer rendering (#16578)
## TL;DR

Fixes the issues when using Codex CLI with Zellij multiplexer. Before
this PR there would be no scrollback when using it inside a zellij
terminal.

## Problem

Addresses #2558

Zellij does not support ANSI scroll-region manipulation (`DECSTBM` /
Reverse Index) or the alternate screen buffer in the way traditional
terminals do. When codex's TUI runs inside Zellij, two things break: (1)
inline history insertion corrupts the display because the scroll-region
escape sequences are silently dropped or mishandled, and (2) the
composer textarea renders with inherited background/foreground styles
that produce unreadable text against Zellij's pane chrome.

## Mental model

The fix introduces a **Zellij mode** — a runtime boolean detected once
at startup via `codex_terminal_detection::terminal_info().is_zellij()` —
that gates two subsystems onto Zellij-safe terminal strategies:

- **History insertion** (`insert_history.rs`): Instead of using
`DECSTBM` scroll regions and Reverse Index (`ESC M`) to slide content
above the viewport, Zellij mode scrolls the screen by emitting `\n` at
the bottom row and then writes history lines at absolute positions. This
avoids every escape sequence Zellij mishandles.
- **Viewport expansion** (`tui.rs`): When the viewport grows taller than
available space, the standard path uses `scroll_region_up` on the
backend. Zellij mode instead emits newlines at the screen bottom to push
content up, then invalidates the ratatui diff buffer so the next draw is
a full repaint.
- **Composer rendering** (`chat_composer.rs`, `textarea.rs`): All text
rendering in the input area uses an explicit `base_style` with
`Color::Reset` foreground, preventing Zellij's pane styling from
bleeding into the textarea. The prompt chevron (`›`) and placeholder
text use explicit color constants instead of relying on `.bold()` /
`.dim()` modifiers that render inconsistently under Zellij.

## Non-goals

- This change does not fix or improve Zellij's terminal emulation
itself.
- It does not rearchitect the inline viewport model; it adds a parallel
code path gated on detection.
- It does not touch the alternate-screen disable logic (that already
existed and continues to use `is_zellij` via the same detection).

## Tradeoffs

- **Code duplication in `insert_history.rs`**: The Zellij and Standard
branches share the line-rendering loop (color setup, span merging,
`write_spans`) but differ in the scrolling preamble. The duplication is
intentional — merging them would force a complex conditional state
machine that's harder to reason about than two flat sequences.
- **`invalidate_viewport` after every Zellij history flush or viewport
expansion**: This forces a full repaint on every draw cycle in Zellij,
which is more expensive than ratatui's normal diff-based rendering. This
is necessary because Zellij's lack of scroll-region support means the
diff buffer's assumptions about what's on screen are invalid after we
manually move content.
- **Explicit colors vs semantic modifiers**: Replacing `.bold()` /
`.dim()` with `Color::Cyan` / `Color::DarkGray` / `Color::White` in the
Zellij branch sacrifices theme-awareness for correctness. If the project
ever adopts a theming system, Zellij styling will need to participate.

## Architecture

The Zellij detection flag flows through three layers:

1. **`codex_terminal_detection`** — `TerminalInfo::is_zellij()` (new
convenience method) reads the already-detected `Multiplexer` variant.
2. **`Tui` struct** — caches `is_zellij` at construction; passes it into
`update_inline_viewport`, `flush_pending_history_lines`, and
`insert_history_lines_with_mode`.
3. **`ChatComposer` struct** — independently caches `is_zellij` at
construction; uses it in `render_textarea` for style decisions.

The two caches (`Tui.is_zellij` and `ChatComposer.is_zellij`) are read
from the same global `OnceLock<TerminalInfo>`, so they always agree.

## Observability

No new logging, metrics, or tracing is introduced. Diagnosis depends on:
- Whether `ZELLIJ` or `ZELLIJ_SESSION_NAME` env vars are set (the
detection heuristic).
- Visual inspection of the rendered TUI inside Zellij vs a standard
terminal.
- The insta snapshot `zellij_empty_composer` captures the Zellij-mode
render path.

## Tests

- `terminal_info_reports_is_zellij` — unit test in `terminal-detection`
confirming the convenience method.
- `zellij_empty_composer_snapshot` — insta snapshot in `chat_composer`
validating the Zellij render path for an empty composer.
- `vt100_zellij_mode_inserts_history_and_updates_viewport` — integration
test in `insert_history` verifying that Zellij-mode history insertion
writes content and shifts the viewport.

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:07:05 -03:00
Eric Traut 9bb7f0a694 Fix fork source display in /status (expose forked_from_id in app server) (#16596)
Addresses #16560

Problem: `/status` stopped showing the source thread id in forked TUI
sessions after the app-server migration.

Solution: Carry fork source ids through app-server v2 thread data and
the TUI session adapter, and update TUI fixtures so `/status` matches
the old TUI behavior.
2026-04-02 14:05:29 -07:00
Michael Bolin 93380a6fac fix: add shell fallback paths for pwsh/powershell that work on GitHub Actions Windows runners (#16617)
Recently, I merged a number of PRs to increase startup timeouts for
scripts that ran under PowerShell, but in the failure for
`suite::codex_tool::test_shell_command_approval_triggers_elicitation`, I
found this in the error logs when running on Bazel with BuildBuddy:

```
[mcp stderr] 2026-04-02T19:54:10.758951Z ERROR codex_core::tools::router: error=Exit code: 1
[mcp stderr] Wall time: 0.2 seconds
[mcp stderr] Output:
[mcp stderr] 'New-Item' is not recognized as an internal or external command,
[mcp stderr] operable program or batch file.
[mcp stderr] 
```

This error implies that the command was run under `cmd.exe` instead of
`pwsh.exe`. Under GitHub Actions, I suspect that the `%PATH%` that is
passed to our Bazel builder is scrubbed such that our tests cannot find
PowerShell where GitHub installs it. Having these explicit fallback
paths should help.

While we could enable these only for tests, I don't see any harm in
keeping them in production, as well.
2026-04-02 13:47:10 -07:00
Eric Traut 57b98bc4cd Fix stale turn steering during TUI review follow-ups (#16588)
Addresses #16389

Problem: `/review` follow-ups can crash when app-server TUI steers with
a stale active turn id; #14717 introduced the client-side race, and
#15714 only handled the “no active turn” half.

Solution: Treat turn-id mismatch as stale cached state too, sync to the
server’s current turn id, retry once, and let review turns fall into the
existing queue path.
2026-04-02 14:41:30 -06:00
Eric Traut f5d39a88ce Fixed some existing labels and added a few new ones (#16616) 2026-04-02 14:34:23 -06:00
Michael Bolin 42aa0db68d Merge c623a32174 into sapling-pr-archive-bolinfest 2026-04-02 13:26:34 -07:00
Michael Bolin c623a32174 fix: add shell fallback paths for pwsh/powershell that work on GitHub Actions Windows runners 2026-04-02 13:26:28 -07:00
Michael Bolin 1d57d2143e merge commit for archive created by Sapling 2026-04-02 13:26:14 -07:00
Michael Bolin 20ff4d1037 fix: add shell fallback paths for pwsh/powershell that work on GitHub Actions Windows runners 2026-04-02 13:26:01 -07:00
Eric Traut c0f2fed67e Fix resume picker stale thread names (#16601)
Addresses #16562

Problem: Resume picker could keep a stale backend-provided thread title
instead of the latest name from session_index.jsonl.

Solution: Always backfill/override picker row names from local
session_index.jsonl and cover stale-name replacement with a regression
test.
2026-04-02 14:22:57 -06:00
Michael Bolin 30ee9e769e fix: increase another startup timeout for PowerShell (#16613) 2026-04-02 13:16:16 -07:00
Eric Traut cb8dc18a64 Fix resume picker initial loading state (#16591)
Addresses #16514

Problem: Resume picker could show “No sessions yet” before the initial
session fetch finished.

Solution: Render a loading message while the first page is pending, and
keep the empty state for truly empty results.
2026-04-02 14:02:52 -06:00
Michael Bolin 3d28ddf174 Merge a271f357a5 into sapling-pr-archive-bolinfest 2026-04-02 12:53:54 -07:00
Michael Bolin a271f357a5 fix: increase another startup timeout for PowerShell 2026-04-02 12:53:46 -07:00
Michael Bolin 5d64e58a38 fix: increase timeout to account for slow PowerShell startup (#16608)
Similar to https://github.com/openai/codex/pull/16604, I am seeing
failures on Windows Bazel that could be due to PowerShell startup
timeouts, so try increasing.
2026-04-02 12:40:19 -07:00
Michael Bolin 1510a76a75 Merge 7d23c6668a into sapling-pr-archive-bolinfest 2026-04-02 12:34:56 -07:00
Michael Bolin 7d23c6668a fix: increase timeout to account for slow PowerShell startup 2026-04-02 12:34:47 -07:00
Michael Bolin f894c3f687 fix: add more detail to test assertion (#16606)
In https://github.com/openai/codex/pull/16528, I am trying to get tests
running under Bazel on Windows, but currently I see:

```
thread 'suite::user_shell_cmd::user_shell_command_does_not_set_network_sandbox_env_var' (10220) panicked at core/tests\suite\user_shell_cmd.rs:358:5:
assertion failed: `(left == right)`

Diff < left / right > :
<1
>0
```

This PR updates the `assert_eq!()` to provide more information to help
diagnose the failure.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/16606).
* #16608
* __->__ #16606
2026-04-02 12:34:42 -07:00
Michael Bolin 76c624dc54 Merge ab6ead9790 into sapling-pr-archive-bolinfest 2026-04-02 12:34:02 -07:00
Michael Bolin ab6ead9790 fix: increase timeout to account for slow PowerShell startup 2026-04-02 12:33:55 -07:00
Michael Bolin 2bdea7c0fc Merge b1d1c47e63 into sapling-pr-archive-bolinfest 2026-04-02 12:21:30 -07:00
Michael Bolin b1d1c47e63 fix: add more detail to test assertion 2026-04-02 12:21:24 -07:00
Michael Bolin 2146e1b82d test: deflake external bearer auth token tests on Windows (#16604)
## Why

`external_bearer_only_auth_manager_uses_cached_provider_token` can fail
on Windows when cold `powershell.exe` startup exceeds the provider-auth
helper's 1s timeout. When that happens,
`AuthManager::resolve_external_api_key_auth()` [logs the resolver error
and returns
`None`](https://github.com/openai/codex/blob/024b08b411fe/codex-rs/login/src/auth/manager.rs#L1449-L1455),
which is exactly the assertion failure from the flake.

## What

- Invoke `powershell.exe` explicitly in the Windows provider-auth test
helpers in `login/src/auth/auth_tests.rs`.
- Increase the helper timeout to `10_000` ms and document why that slack
exists.

## Verification

- `cargo test -p codex-login`
2026-04-02 12:12:18 -07:00
Michael Bolin 2c16f12a74 Merge 024b08b411 into sapling-pr-archive-bolinfest 2026-04-02 12:02:21 -07:00
Michael Bolin 024b08b411 test: deflake external bearer auth token tests on Windows 2026-04-02 12:02:09 -07:00
Michael Bolin 95ea958dfa Merge 0ba6db0d8f into sapling-pr-archive-bolinfest 2026-04-02 11:23:08 -07:00
Michael Bolin 0ba6db0d8f refactor: move shell and snapshot code out of codex-core 2026-04-02 11:21:21 -07:00
Tyler French 1d8a22e9dd Fix non-determinism in rules_rs/crate_git_repository.bzl (#16590)
Running multiple builds with no changes causes some differences, we see
that
https://app.buildbuddy.io/compare/a9719629-1660-4735-a477-d66357f234fb...df85310b-eb5c-4c10-8b79-4d0449ba6cdd#file
shows the file-differences between two Bazel builds.

These differences are caused by a non-deterministic `.git` entry in the
rules_rs crates that are created with `crate_git_repository`.

As a way to make these deterministic, we can remove this entry after we
download the git source, so that the input to the compile action is
deterministic.

### CLA

I have read the CLA Document and I hereby sign the CLA
2026-04-02 11:21:11 -07:00
Michael Bolin ece00cc49a merge commit for archive created by Sapling 2026-04-02 10:41:35 -07:00
Michael Bolin 379acefcc7 refactor: move shell and snapshot code out of codex-core 2026-04-02 10:41:23 -07:00
Michael Bolin d9a729a33b Merge 2e5beb8aad into sapling-pr-archive-bolinfest 2026-04-02 10:18:38 -07:00
Michael Bolin 2e5beb8aad testing https://github.com/tyler-french/codex/pull/2 2026-04-02 10:18:34 -07:00
Michael Bolin 39340bc279 Merge 4c13386d63 into sapling-pr-archive-bolinfest 2026-04-02 10:13:48 -07:00
Michael Bolin 4c13386d63 testing https://github.com/tyler-french/codex/pull/2 2026-04-02 10:13:41 -07:00
Michael Bolin 95b0b5a204 chore: move codex-exec unit tests into sibling files (#16581)
## Why

`codex-rs/exec/src/lib.rs` already keeps unit tests in a sibling
`lib_tests.rs` module so the implementation stays top-heavy and easier
to read. This applies that same layout to the rest of
`codex-rs/exec/src` so each production file keeps its entry points and
helpers ahead of test code.

## What

- Move inline unit tests out of `cli.rs`, `main.rs`,
`event_processor_with_human_output.rs`, and
`event_processor_with_jsonl_output.rs` into sibling `*_tests.rs` files.
- Keep test modules wired through `#[cfg(test)]` plus `#[path = "..."]
mod tests;`, matching the `lib.rs` pattern.
- Preserve the existing test coverage and assertions while making this a
source-layout-only refactor.

## Verification

- `cargo test -p codex-exec`
2026-04-02 10:01:40 -07:00
Michael Bolin 18a52f68e3 Merge e8192d87c6 into sapling-pr-archive-bolinfest 2026-04-02 09:33:06 -07:00
Michael Bolin e8192d87c6 chore: move unit tests in codex-exec into their own files 2026-04-02 09:31:48 -07:00
Michael Bolin 300fec2bfb Merge ce349df98a into sapling-pr-archive-bolinfest 2026-04-02 09:08:19 -07:00
Michael Bolin ce349df98a chore: move unit tests in codex-exec into their own files 2026-04-02 09:08:12 -07:00
Michael Bolin a098834148 ci: upload compact Bazel execution logs for bazel.yml (#16577)
## Why

The main Bazel CI lanes need compact execution logs to investigate cache
misses and unexpected rebuilds, but local users of the shared wrapper
should not pay that log-generation cost by default.

## What Changed

-
[`.github/scripts/run-bazel-ci.sh`](https://github.com/openai/codex/blob/a6ec239a24fd21507bb75a28f17277653f52e3a2/.github/scripts/run-bazel-ci.sh#L149-L153)
now appends `--execution_log_compact_file=...` only when
`CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR` is set; the caller owns creating
that directory.
-
[`.github/workflows/bazel.yml`](https://github.com/openai/codex/blob/a6ec239a24fd21507bb75a28f17277653f52e3a2/.github/workflows/bazel.yml#L66-L174)
enables that env var only for the main `test` and `clippy` jobs, creates
the temp log directory in each job, and uploads the resulting `*.zst`
files from `runner.temp`.

## Verification

- `bash -n .github/scripts/run-bazel-ci.sh`
- Parsed `.github/workflows/bazel.yml` as YAML.
- Ran a local opt-in wrapper smoke test and confirmed it writes
`execution-log-cquery-local-*.zst` when the caller pre-creates
`CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR`.
2026-04-02 08:41:04 -07:00