Commit Graph

8634 Commits

Author SHA1 Message Date
Jeremy Rose
45d6c74682 tui: align diff display by always showing sign char and keeping fixed gutter (#2353)
diff lines without a sign char were misaligned.
2025-08-15 09:32:45 -07:00
Michael Bolin
d3a6f30510 merge commit for archive created by Sapling 2025-08-15 09:31:09 -07:00
Michael Bolin
5510912158 feat: introduce TurnContext 2025-08-15 09:29:20 -07:00
Michael Bolin
fc979de6cd Merge fb653dc147 into sapling-pr-archive-bolinfest 2025-08-15 09:20:58 -07:00
Michael Bolin
fb653dc147 feat: introduce ClientRequest::SendUserTurn 2025-08-15 09:20:25 -07:00
Michael Bolin
ed1d34542b feat: introduce Op:UserTurn 2025-08-15 09:20:25 -07:00
Michael Bolin
c8ee33807c feat: introduce TurnContext 2025-08-15 09:20:25 -07:00
Michael Bolin
265fd89e31 fix: try to fix flakiness in test_shell_command_approval_triggers_elicitation (#2344)
I still see flakiness in
`test_shell_command_approval_triggers_elicitation()` on occasion where
`MockServer` claims it has not received all of its expected requests.

I recently introduced a similar type of test in #2264,
`test_codex_jsonrpc_conversation_flow()`, which I have not seen flake
(yet!), so this PR pulls over two things I did in that test:

- increased `worker_threads` from `2` to `4`
- added an assertion to make sure the `task_complete` notification is
received

Honestly, I'm still not sure why `MockServer` claims it sometimes does
not receive all its expected requests given that we assert that the
final `JSONRPCResponse` is read on the stream, but let's give this a
shot.

Assuming this fixes things, my hypothesis is that the increase in
`worker_threads` helps because perhaps there are async tasks in
`MockServer` that do not reliably complete fully when there are not
enough threads available? If that is correct, it seems like the test
would still be flaky, though perhaps with lower frequency?
2025-08-15 09:17:20 -07:00
Michael Bolin
6730592433 fix: introduce MutexExt::lock_unchecked() so we stop ignoring unwrap() throughout codex.rs (#2340)
This way we are sure a dangerous `unwrap()` does not sneak in!

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2340).
* #2345
* #2329
* #2343
* __->__ #2340
* #2338
2025-08-15 09:14:44 -07:00
Michael Bolin
26c8373821 fix: tighten up checks against writable folders for SandboxPolicy (#2338)
I was looking at the implementation of `Session::get_writable_roots()`,
which did not seem right, as it was a copy of writable roots, which is
not guaranteed to be in sync with the `sandbox_policy` field.

I looked at who was calling `get_writable_roots()` and its only call
site was `apply_patch()` in `codex-rs/core/src/apply_patch.rs`, which
took the roots and forwarded them to `assess_patch_safety()` in
`safety.rs`. I updated `assess_patch_safety()` to take `sandbox_policy:
&SandboxPolicy` instead of `writable_roots: &[PathBuf]` (and replaced
`Session::get_writable_roots()` with `Session::get_sandbox_policy()`).

Within `safety.rs`, it was fairly easy to update
`is_write_patch_constrained_to_writable_paths()` to work with
`SandboxPolicy`, and in particular, it is far more accurate because, for
better or worse, `SandboxPolicy::get_writable_roots_with_cwd()` _returns
an empty vec_ for `SandboxPolicy::DangerFullAccess`, suggesting that
_nothing_ is writable when in reality _everything_ is writable. With
this PR, `is_write_patch_constrained_to_writable_paths()` now does the
right thing for each variant of `SandboxPolicy`.

I thought this would be the end of the story, but it turned out that
`test_writable_roots_constraint()` in `safety.rs` needed to be updated,
as well. In particular, the test was writing to
`std::env::current_dir()` instead of a `TempDir`, which I suspect was a
holdover from earlier when `SandboxPolicy::WorkspaceWrite` would always
make `TMPDIR` writable on macOS, which made it hard to write tests to
verify `SandboxPolicy` in `TMPDIR`. Fortunately, we now have
`exclude_tmpdir_env_var` as an option on
`SandboxPolicy::WorkspaceWrite`, so I was able to update the test to
preserve the existing behavior, but to no longer write to
`std::env::current_dir()`.







---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2338).
* #2345
* #2329
* #2343
* #2340
* __->__ #2338
2025-08-15 09:06:15 -07:00
Dylan
6df8e35314 [tools] Add apply_patch tool (#2303)
## Summary
We've been seeing a number of issues and reports with our synthetic
`apply_patch` tool, e.g. #802. Let's make this a real tool - in my
anecdotal testing, it's critical for GPT-OSS models, but I'd like to
make it the standard across GPT-5 and codex models as well.

## Testing
- [x] Tested locally
- [x] Integration test
2025-08-15 11:55:53 -04:00
Michael Bolin
660d8759e2 Merge 7a156e2546 into sapling-pr-archive-bolinfest 2025-08-14 23:48:10 -07:00
Michael Bolin
7a156e2546 feat: introduce ClientRequest::SendUserTurn 2025-08-14 23:47:42 -07:00
Michael Bolin
4dd2f10051 Merge 4eda51b7a0 into sapling-pr-archive-bolinfest 2025-08-14 23:38:38 -07:00
Michael Bolin
4eda51b7a0 feat: introduce Op:UserTurn 2025-08-14 23:36:56 -07:00
Michael Bolin
59d76785d5 merge commit for archive created by Sapling 2025-08-14 23:21:13 -07:00
Michael Bolin
184741500b fix: try to fix flakiness in test_shell_command_approval_triggers_elicitation 2025-08-14 23:21:07 -07:00
Michael Bolin
24a994c160 Merge 6d92c0c0de into sapling-pr-archive-bolinfest 2025-08-14 23:10:18 -07:00
Michael Bolin
6d92c0c0de fix: try to fix flakiness in test_shell_command_approval_triggers_elicitation 2025-08-14 23:10:07 -07:00
Michael Bolin
cf3d2f81d4 merge commit for archive created by Sapling 2025-08-14 22:41:19 -07:00
Michael Bolin
39a24ff3a2 feat: introduce TurnContext 2025-08-14 22:41:02 -07:00
Michael Bolin
b4c9654c5c Merge 3ae2cdaa0c into sapling-pr-archive-bolinfest 2025-08-14 22:31:09 -07:00
Michael Bolin
3ae2cdaa0c feat: introduce TurnContext 2025-08-14 22:27:49 -07:00
Jeremy Rose
917e29803b tui: include optional full command line in history display (#2334)
Add env var to show the raw, unparsed command line under parsed
commands. When we have transcript mode we should show the full command
there, but this is useful for debugging.
2025-08-14 22:06:42 -07:00
Michael Bolin
acf0223a12 merge commit for archive created by Sapling 2025-08-14 21:53:09 -07:00
Michael Bolin
be0a82e155 fix: introduce MutexExt::lock_unchecked() so we stop ignoring unwrap() throughout codex.rs 2025-08-14 21:53:01 -07:00
Michael Bolin
6761feef07 merge commit for archive created by Sapling 2025-08-14 21:51:13 -07:00
Michael Bolin
0376c90ac2 fix: introduce MutexExt::lock_unchecked() so we stop ignoring unwrap() throughout codex.rs 2025-08-14 21:49:58 -07:00
Michael Bolin
f76b7cfa00 Merge d12b99159b into sapling-pr-archive-bolinfest 2025-08-14 21:43:39 -07:00
Michael Bolin
d12b99159b fix: prefer RwLock to Mutex 2025-08-14 21:43:11 -07:00
Michael Bolin
92fdf1a15d merge commit for archive created by Sapling 2025-08-14 21:29:07 -07:00
Michael Bolin
68716bf126 fix: tighten up checks against writable folders for SandboxPolicy 2025-08-14 21:28:54 -07:00
Michael Bolin
2909ec98a4 Merge 715446387f into sapling-pr-archive-bolinfest 2025-08-14 21:23:17 -07:00
Michael Bolin
715446387f fix: tighten up checks against writable folders for SandboxPolicy 2025-08-14 21:23:06 -07:00
pakrym-oai
5552688621 Format multiline commands (#2333)
<img width="966" height="729" alt="image"
src="https://github.com/user-attachments/assets/fa45b7e1-cd46-427f-b2bc-8501e9e4760b"
/>
<img width="797" height="530" alt="image"
src="https://github.com/user-attachments/assets/6993eec5-e157-4df7-b558-15643ad10d64"
/>
2025-08-14 19:49:42 -07:00
pakrym-oai
76df07350a Cleanup rust login server a bit more (#2331)
Remove some extra abstractions.

---------

Co-authored-by: easong-openai <easong@openai.com>
2025-08-14 19:42:14 -07:00
easong-openai
d0b907d399 re-implement session id in status (#2332)
Basically the same thing as https://github.com/openai/codex/pull/2297
2025-08-15 02:14:46 +00:00
Parker Thompson
a075424437 Added allow-expect-in-tests / allow-unwrap-in-tests (#2328)
This PR:
* Added the clippy.toml to configure allowable expect / unwrap usage in
tests
* Removed as many expect/allow lines as possible from tests
* moved a bunch of allows to expects where possible

Note: in integration tests, non `#[test]` helper functions are not
covered by this so we had to leave a few lingering `expect(expect_used`
checks around
2025-08-14 17:59:01 -07:00
Jeremy Rose
8bdb4521c9 AGENTS.md more strongly suggests running targeted tests first (#2306) 2025-08-15 00:51:32 +00:00
Michael Bolin
b0ece7f01c Merge b9e0f4741c into sapling-pr-archive-bolinfest 2025-08-14 17:45:30 -07:00
Michael Bolin
b9e0f4741c feat: introduce Op:UserTurn 2025-08-14 17:45:19 -07:00
Michael Bolin
dd63d61a59 fix: trying to simplify rust-ci.yml (#2327)
It turns out that https://github.com/openai/codex/pull/2324 did not
quite work as intended. Chat's new idea is to have this catch-all "CI
results" job and update our branch protection rules to require this
instead.
2025-08-14 17:44:10 -07:00
Michael Bolin
7b1837a47e Merge 78186db343 into sapling-pr-archive-bolinfest 2025-08-14 17:24:15 -07:00
Michael Bolin
78186db343 fix: trying to simplify rust-ci.yml 2025-08-14 17:24:09 -07:00
Michael Bolin
46a18944d8 Merge 9d4860bba4 into sapling-pr-archive-bolinfest 2025-08-14 17:24:06 -07:00
Michael Bolin
9d4860bba4 fix: trying to simplify rust-ci.yml 2025-08-14 17:24:00 -07:00
Parker Thompson
c26d42ab69 Fix AF_UNIX, sockpair, recvfrom in linux sandbox (#2309)
When using codex-tui on a linux system I was unable to run `cargo
clippy` inside of codex due to:
```
[pid 3548377] socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0,  <unfinished ...>
[pid 3548370] close(8 <unfinished ...>
[pid 3548377] <... socketpair resumed>0x7ffb97f4ed60) = -1 EPERM (Operation not permitted)
```
And
```
3611300 <... recvfrom resumed>0x708b8b5cffe0, 8, 0, NULL, NULL) = -1 EPERM (Operation not permitted)
```

This PR:
* Fixes a bug that disallowed AF_UNIX to allow it on `socket()`
* Adds recvfrom() to the syscall allow list, this should be fine since
we disable opening new sockets. But we should validate there is not a
open socket inheritance issue.
* Allow socketpair to be called for AF_UNIX
* Adds tests for AF_UNIX components
* All of which allows running `cargo clippy` within the sandbox on
linux, and possibly other tooling using a fork server model + AF_UNIX
comms.
2025-08-14 17:12:41 -07:00
easong-openai
e9b597cfa3 Port login server to rust (#2294)
Port the login server to rust.

---------

Co-authored-by: pakrym-oai <pakrym@openai.com>
2025-08-14 17:11:26 -07:00
Jeremy Rose
afc377bae5 clear running commands in various places (#2325)
we have a very unclear lifecycle for the chatwidget—this should only
have to be added in one place! but this fixes the "hanging commands"
issue where the active_exec_cell wasn't correctly cleared when commands
finished.

To repro w/o this PR:
1. prompt "run sleep 10"
2. once the command starts running, press <kbd>Esc</kbd>
3. prompt "run echo hi"

Expected: 

```
✓ Completed
  └ ⌨️ echo hi

codex
hi
```

Actual:

```
⚙︎ Working
  └ ⌨️ echo hi

▌ Ask Codex to do anything
```

i.e. the "Working" never changes to "Completed".

The bug is fixed with this PR.
2025-08-15 00:01:19 +00:00
Michael Bolin
333803ed04 fix: ensure rust-ci always "runs" when a PR is submitted (#2324)
Our existing path filters for `rust-ci.yml`:


235987843c/.github/workflows/rust-ci.yml (L1-L11)

made it so that PRs that touch only `README.md` would not trigger those
builds, which is a problem because our branch protection rules are set
as follows:

<img width="1569" height="1883" alt="Screenshot 2025-08-14 at 4 45
59 PM"
src="https://github.com/user-attachments/assets/5a61f8cc-cdaf-4341-abda-7faa7b46dbd4"
/>

With the existing setup, a change to `README.md` would get stuck in
limbo because not all the CI jobs required to merge would get run. It
turns out that we need to "run" all the jobs, but make them no-ops when
the `codex-rs` and `.github` folders are untouched to get the best of
both worlds.

I asked chat how to fix this, as we want CI to be fast for
documentation-only changes. It had two suggestions:

- Use https://github.com/dorny/paths-filter or some other third-party
action.
- Write an inline Bash script to avoid a third-party dependency.

This PR takes the latter approach so that we are clear about what we're
running in CI.
2025-08-14 17:00:19 -07:00