Commit Graph

8634 Commits

Author SHA1 Message Date
Michael Bolin
2d190ae8c5 chore: split apply_patch logic out of codex.rs and into apply_patch.rs 2025-07-28 08:32:57 -07:00
Michael Bolin
bdb7f8e138 fix: support special --codex-run-as-apply-patch arg 2025-07-28 08:32:57 -07:00
Michael Bolin
fc25aa6e05 fix: use std::env::args_os instead of std::env::args 2025-07-28 08:32:57 -07:00
Michael Bolin
9102255854 fix: move arg0 handling out of codex-linux-sandbox and into its own crate (#1697) 2025-07-28 08:31:24 -07:00
Jeremy Rose
7ecd3153a8 fix: correctly wrap history items (#1685)
The overall idea here is: skip ratatui for writing into scrollback,
because its primitives are wrong. We want to render full lines of text,
that will be wrapped natively by the terminal, and which we never plan
to update using ratatui (so the `Buffer` struct is overhead and in fact
an inhibition).

Instead, we use ANSI scrolling regions (link reference doc to come).
Essentially, we:
1. Define a scrolling region that extends from the top of the prompt
area all the way to the top of scrollback
2. Scroll that region up by N < (screen_height - viewport_height) lines,
in this PR N=1
3. Put our cursor at the top of the newly empty region
4. Print out our new text like normal

The terminal interactions here (write_spans and its dependencies) are
mostly extracted from ratatui.
2025-07-28 14:45:49 +00:00
Michael Bolin
a27311ab62 Merge 68076e61f3 into sapling-pr-archive-bolinfest 2025-07-28 00:05:02 -07:00
Michael Bolin
68076e61f3 fix: run apply_patch calls through the sandbox 2025-07-28 00:04:35 -07:00
Michael Bolin
2011143443 Merge 4bb86857c1 into sapling-pr-archive-bolinfest 2025-07-27 23:01:05 -07:00
Michael Bolin
4bb86857c1 chore: split apply_patch logic out of codex.rs and into apply_patch.rs 2025-07-27 23:00:46 -07:00
Michael Bolin
a05a3c7daa merge commit for archive created by Sapling 2025-07-27 22:46:00 -07:00
Michael Bolin
d48e2abe9a fix: support special --codex-run-as-apply-patch arg 2025-07-27 22:45:43 -07:00
Michael Bolin
0f314f2490 merge commit for archive created by Sapling 2025-07-27 22:28:58 -07:00
Michael Bolin
207aae4671 fix: support special --codex-run-as-apply-patch arg 2025-07-27 22:28:30 -07:00
Michael Bolin
0649ec9ad3 fix: use std::env::args_os instead of std::env::args 2025-07-27 21:58:43 -07:00
Michael Bolin
ec40bc516b Merge c26b617754 into sapling-pr-archive-bolinfest 2025-07-27 21:37:16 -07:00
Michael Bolin
c26b617754 fix: use std::env::args_os instead of std::env::args 2025-07-27 21:37:05 -07:00
Michael Bolin
77066196eb Merge c33762dd94 into sapling-pr-archive-bolinfest 2025-07-27 21:21:56 -07:00
Michael Bolin
c33762dd94 fix: use std::env::args_os instead of std::env::args 2025-07-27 21:21:27 -07:00
Michael Bolin
cb9b804992 merge commit for archive created by Sapling 2025-07-27 21:12:32 -07:00
Michael Bolin
d75c131584 fix: move arg0 handling out of codex-linux-sandbox and into its own crate 2025-07-27 21:12:17 -07:00
Michael Bolin
6438fd126e merge commit for archive created by Sapling 2025-07-27 21:12:04 -07:00
Michael Bolin
66309d9f0e fix: move arg0 handling out of codex-linux-sandbox and into its own crate 2025-07-27 21:11:44 -07:00
Michael Bolin
9090a43c5d merge commit for archive created by Sapling 2025-07-27 20:33:27 -07:00
Michael Bolin
f07838112a fix: move arg0 handling out of codex-linux-sandbox and into its own crate 2025-07-27 20:33:08 -07:00
Michael Bolin
9742bd1cd3 Merge aa8fa29be3 into sapling-pr-archive-bolinfest 2025-07-27 20:07:40 -07:00
Michael Bolin
aa8fa29be3 fix: move arg0 handling out of codex-linux-sandbox and into its own crate 2025-07-27 20:07:24 -07:00
Michael Bolin
8ef8f1e844 Merge 0633a09184 into sapling-pr-archive-bolinfest 2025-07-27 20:05:36 -07:00
Michael Bolin
0633a09184 fix: move arg0 handling out of codex-linux-sandbox and into its own crate 2025-07-27 20:05:19 -07:00
Michael Bolin
2405c40026 chore: update Codex::spawn() to return a struct instead of a tuple (#1677)
Also update `init_codex()` to return a `struct` instead of a tuple, as well.
2025-07-27 20:01:35 -07:00
easong-openai
58bed77ba7 Remove tab focus switching (#1694)
Previously pressing tab would switch TUI focus to the history scrollbox - no longer necessary.
2025-07-27 11:04:09 -07:00
Michael Bolin
add023895f merge commit for archive created by Sapling 2025-07-26 19:58:32 -07:00
Michael Bolin
073dc04190 chore: update Codex::spawn() to return a struct instead of a tuple 2025-07-26 19:57:58 -07:00
aibrahim-oai
5a0079fea2 Changing method in MCP notifications (#1684)
- Changing the codex/event type
2025-07-26 10:35:49 -07:00
Jeremy Rose
c66c99c5b5 fix: crash on resize (#1683)
Without this, resizing the terminal prints "Error: The cursor position
could not be read within a normal duration" and quits the app.
2025-07-25 14:23:38 -07:00
Jeremy Rose
75b4008094 fix: paste with newlines (#1682)
This fixes an issue where pasting multi-line content would break the
composer.
2025-07-25 19:26:40 +00:00
pakrym-oai
7ee87123a6 Optionally run using user profile (#1678) 2025-07-25 11:45:23 -07:00
Michael Bolin
994c9a874d chore: use one write call per item in rollout_writer() (#1679)
Most of the time, we expect the `String` returned by
`serde_json::to_string()` to have extra capacity, so `push('\n')` is
unlikely to allocate, which seems cheaper than an extra `write(2)` call,
on average?
2025-07-25 10:43:36 -07:00
easong-openai
480e82b00d Easily Selectable History (#1672)
This update replaces the previous ratatui history widget with an
append-only log so that the terminal can handle text selection and
scrolling. It also disables streaming responses, which we'll do our best
to bring back in a later PR. It also adds a small summary of token use
after the TUI exits.
2025-07-25 01:56:40 -07:00
Michael Bolin
0e3e98d492 Merge 90c621058a into sapling-pr-archive-bolinfest 2025-07-24 23:03:14 -07:00
Michael Bolin
90c621058a chore: use one write call per item in rollout_writer() 2025-07-24 23:02:59 -07:00
Michael Bolin
941c1e954d Merge a7638d9b31 into sapling-pr-archive-bolinfest 2025-07-24 14:50:01 -07:00
Michael Bolin
a7638d9b31 chore: update Codex::spawn() to return a struct instead of a tuple 2025-07-24 14:49:55 -07:00
Pavel Bezglasny
508abbe990 Update render name in tui for approval_policy to match with config values (#1675)
Currently, codex on start shows the value for the approval policy as
name of
[AskForApproval](2437a8d17a/codex-rs/core/src/protocol.rs (L128))
enum, which differs from
[approval_policy](2437a8d17a/codex-rs/config.md (approval_policy))
config values.
E.g. "untrusted" becomes "UnlessTrusted", "on-failure" -> "OnFailure",
"never" -> "Never".
This PR changes render names of the approval policy to match with
configuration values.
2025-07-24 14:17:57 -07:00
Michael Bolin
a1641743a8 feat: expand the set of commands that can be safely identified as "trusted" (#1668)
This PR updates `is_known_safe_command()` to account for "safe
operators" to expand the set of commands that can be run without
approval. This concept existed in the TypeScript CLI, and we are
[finally!] porting it to the Rust one:


c9e2def494/codex-cli/src/approvals.ts (L531-L541)

The idea is that if we have `EXPR1 SAFE_OP EXPR2` and `EXPR1` and
`EXPR2` are considered safe independently, then `EXPR1 SAFE_OP EXPR2`
should be considered safe. Currently, `SAFE_OP` includes `&&`, `||`,
`;`, and `|`.

In the TypeScript implementation, we relied on
https://www.npmjs.com/package/shell-quote to parse the string of Bash,
as it could provide a "lightweight" parse tree, parsing `'beep || boop >
/byte'` as:

```
[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]
```

Though in this PR, we introduce the use of
https://crates.io/crates/tree-sitter-bash for parsing (which
incidentally we were already using in
[`codex-apply-patch`](c9e2def494/codex-rs/apply-patch/Cargo.toml (L18))),
which gives us a richer parse tree. (Incidentally, if you have never
played with tree-sitter, try the
[playground](https://tree-sitter.github.io/tree-sitter/7-playground.html)
and select **Bash** from the dropdown to see how it parses various
expressions.)

As a concrete example, prior to this change, our implementation of
`is_known_safe_command()` could verify things like:

```
["bash", "-lc", "grep -R \"Cargo.toml\" -n"]
```

but not:

```
["bash", "-lc", "grep -R \"Cargo.toml\" -n || true"]
```

With this change, the version with `|| true` is also accepted.

Admittedly, this PR does not expand the safety check to support
subshells, so it would reject, e.g. `bash -lc 'ls || (pwd && echo hi)'`,
but that can be addressed in a subsequent PR.
2025-07-24 14:13:30 -07:00
Michael Bolin
71278f5c43 Merge 540f01f0ba into sapling-pr-archive-bolinfest 2025-07-24 13:00:21 -07:00
Michael Bolin
540f01f0ba feat: expand the set of commands that can be safely identified as "trusted" 2025-07-24 13:00:13 -07:00
Michael Bolin
c9e2def494 fix: add true,false,nl to the list of trusted commands (#1676)
`nl` is a line-numbering tool that should be on the _trusted _ list, as
there is nothing concerning on https://gtfobins.github.io/gtfobins/nl/
that would merit exclusion.

`true` and `false` are also safe, though not particularly useful given
how `is_known_safe_command()` works today, but that will change with
https://github.com/openai/codex/pull/1668.
2025-07-24 12:59:36 -07:00
Michael Bolin
01f0f9bad2 merge commit for archive created by Sapling 2025-07-24 12:54:07 -07:00
Michael Bolin
923f8c6af5 fix: add true,false,nl to the list of trusted commands 2025-07-24 12:53:58 -07:00
Michael Bolin
b6603b8741 Merge 18e266ebd0 into sapling-pr-archive-bolinfest 2025-07-24 12:47:43 -07:00