Commit Graph

188 Commits

Author SHA1 Message Date
Rai (Michael Pokorny)
9f30c4df50 Merge branch 'agentydragon-19-bash-command-rendering-improvements' into agentydragon
# Conflicts:
#	agentydragon/tasks/19-bash-command-rendering-improvements.md
2025-06-24 22:35:11 -07:00
Rai (Michael Pokorny)
8280bd1f9d Merge branch 'agentydragon-18-chat-ui-textarea-overlay-border-fix' into agentydragon
# Conflicts:
#	agentydragon/tasks/18-chat-ui-textarea-overlay-border-fix.md
2025-06-24 22:34:25 -07:00
Rai (Michael Pokorny)
928afbb87e Merge branch 'agentydragon-16-confirm-on-ctrl-d' into agentydragon 2025-06-24 22:33:52 -07:00
Rai (Michael Pokorny)
7f7582d68d Merge branch 'agentydragon-03-live-config-reload' into agentydragon
# Conflicts:
#	agentydragon/tasks/03-live-config-reload.md
2025-06-24 22:33:39 -07:00
Rai (Michael Pokorny)
2f254365e0 agentydragon(tasks): implement bash command rendering improvements in Rust TUI 2025-06-24 22:27:48 -07:00
Rai (Michael Pokorny)
40f784e5c3 agentydragon(tasks): implement double Ctrl+D confirmation on TUI exit 2025-06-24 22:26:58 -07:00
Rai (Michael Pokorny)
b352146912 agentydragon(tasks): implement live config reload with diff prompt and apply/ignore support 2025-06-24 22:25:32 -07:00
Rai (Michael Pokorny)
2ce7ba7257 agentydragon(tasks): add compact markdown rendering option to TUI 2025-06-24 22:23:08 -07:00
Rai (Michael Pokorny)
734ba5ae6a agentydragon(tasks): implement chat UI border merge & status overlay reposition 2025-06-24 22:21:41 -07:00
Rai (Michael Pokorny)
158d8a21f8 agentydragon(tasks): avoid private API call in tests 2025-06-24 21:26:43 -07:00
Rai (Michael Pokorny)
a07b897c34 agentydragon(tasks): expose Prompt and FunctionCallOutputPayload; fix test imports 2025-06-24 21:26:43 -07:00
Rai (Michael Pokorny)
332b6666b8 agentydragon(tasks): add cancellation logic and unit tests for message buffering 2025-06-24 21:26:43 -07:00
Rai (Michael Pokorny)
801eeb5841 agentydragon(tasks): mark in-progress and plan buffer guard in chat_completions 2025-06-24 21:26:43 -07:00
Rai (Michael Pokorny)
fd0dc1be88 agentydragon(tasks): merge task 10 inspect-container-state 2025-06-24 21:07:47 -07:00
Rai (Michael Pokorny)
e901754d14 agentydragon(tasks): merge task 08 set-shell-title 2025-06-24 21:06:45 -07:00
Rai (Michael Pokorny)
e7f7847a49 agentydragon(tasks): merge task 28 include command snippet in approval label 2025-06-24 21:04:43 -07:00
Rai (Michael Pokorny)
fca6766935 agentydragon(tasks): implement command snippet truncation in session approval labels 2025-06-24 20:55:43 -07:00
Rai (Michael Pokorny)
624deb4158 Merge task 31-display-context-remaining-percentage into integration branch (ours) 2025-06-24 20:53:02 -07:00
Rai (Michael Pokorny)
2a015a2464 wip 2025-06-24 20:40:10 -07:00
Rai (Michael Pokorny)
1fb774909d wip 2025-06-24 20:32:13 -07:00
Rai (Michael Pokorny)
b1eb965839 agentydragon(tasks): implement set-shell-title feature 2025-06-24 20:08:16 -07:00
Rai (Michael Pokorny)
723c2452e0 agentydragon(tasks): implement context-left indicator in TUI 2025-06-24 20:03:03 -07:00
Rai (Michael Pokorny)
9670cfdef8 wip 2025-06-24 19:10:40 -07:00
Rai (Michael Pokorny)
f26875b5d8 Merge remote-tracking branch 'origin/agentydragon' into agentydragon 2025-06-24 18:30:49 -07:00
Rai (Michael Pokorny)
d5668f158d codex-rs(tui): restore EditPrompt arm and clear merge conflict markers in chat_composer 2025-06-24 18:21:53 -07:00
Rai (Michael Pokorny)
d7d15f5fd3 remove session-scoped approval option for patches; update command approve label to B variant 2025-06-24 16:57:40 -07:00
Rai (Michael Pokorny)
4851101038 codex-rs: correct approval label to reference 'patch' instead of 'command' 2025-06-24 16:51:25 -07:00
Rai (Michael Pokorny)
9dc939721c codex-rs: resolve merge conflict in README.md 2025-06-24 16:49:16 -07:00
Rai (Michael Pokorny)
1d16069948 agentydragon(tasks): implement inspect-env command and update task plan for Task 10 2025-06-24 16:33:57 -07:00
Rai (Michael Pokorny)
648301613c lint fix 2025-06-24 16:11:35 -07:00
Rai (Michael Pokorny)
056f818002 Add Rust install instructions and pre-commit cargo build hook 2025-06-24 16:07:27 -07:00
Rai (Michael Pokorny)
11fabccebb wip 2025-06-24 15:47:10 -07:00
Rai (Michael Pokorny)
09e4a3b4b8 wip 2025-06-24 15:10:28 -07:00
Rai (Michael Pokorny)
669aa3ef39 merge fix 2025-06-24 15:06:06 -07:00
Rai (Michael Pokorny)
44ea1cf73f Merge Tasks 01, 07, 13 2025-06-24 14:39:54 -07:00
Rai (Michael Pokorny)
22d7b327a0 Auto-commit pending changes on agentydragon-task/13-interactive-prompt-during-execution 2025-06-24 14:31:38 -07:00
Rai (Michael Pokorny)
df9e65127f Auto-commit pending changes on agentydragon-task/07-undo-feedback-decision 2025-06-24 14:31:35 -07:00
Rai (Michael Pokorny)
b23d44cb5c 01 dynamic mount commands 2025-06-24 14:30:34 -07:00
Rai (Michael Pokorny)
a527582e32 codex-rs: enable config tests, expose find_codex_home, add auto‑mount repo sandbox logic 2025-06-24 13:21:01 -07:00
Rai (Michael Pokorny)
62dda0b041 cli(config): implement 'codex config' subcommand and document it 2025-06-24 13:14:51 -07:00
Rai (Michael Pokorny)
65e5d926ab tui session load 2025-06-21 06:38:29 -07:00
Rai (Michael Pokorny)
bb19ef1434 botom pane height, restore cmd 2025-06-21 03:49:22 -07:00
Rai (Michael Pokorny)
e585e6c8cd docs: clarify 'exact command' wording in approval prompts and config 2025-06-21 03:01:47 -07:00
Michael Bolin
b73426c1c4 docs: update codex-rs/README.md to list new features in the Rust CLI (#1267)
Let users know about what the Rust CLI supports that the TypeScript CLI
doesn't!
2025-06-06 18:32:10 -07:00
Reilly Wood
345a38502d codex-rs: Rename /clear to /new, make it start an entirely new chat (#1264)
I noticed that `/clear` wasn't fully clearing chat history; it would
clear the chat history widgets _in the UI_, but the LLM still had access
to information from previous messages.

This PR renames `/clear` to `/new` for clarity as per Michael's
suggestion, resetting `app_state` to a fresh `ChatWidget`.
2025-06-06 16:29:37 -07:00
Michael Bolin
029f39b9da feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_chatgpt.py (#1221)
This builds on https://github.com/openai/codex/pull/1212 and ports the
`maybeRedeemCredits()` function from `get-api-key.ts` to
`login_with_chatgpt.py`:


a80240cfdc/codex-cli/src/utils/get-api-key.tsx (L84-L89)
2025-06-05 23:34:10 -07:00
Michael Bolin
77b017f67d fix: truncate auth.json file before rewriting it (#1231)
This was missed in https://github.com/openai/codex/pull/1212. Caught by
@rizwankce in
https://github.com/openai/codex/discussions/1174#discussioncomment-13377475.
2025-06-05 22:11:02 -07:00
Michael Bolin
9db53b33aa fix: support arm64 build for Linux (#1225)
Users were running into issues with glibc mismatches on arm64 linux. In
the past, we did not provide a musl build for arm64 Linux because we had
trouble getting the openssl dependency to build correctly. Though today
I just tried the same trick in `Cargo.toml` that we were doing for
`x86_64-unknown-linux-musl` (using `openssl-sys` with `features =
["vendored"]`), so I'm not sure what problem we had in the past the
builds "just worked" today!

Though one tweak that did have to be made is that the integration tests
for Seccomp/Landlock empirically require longer timeouts on arm64 linux,
or at least on the `ubuntu-24.04-arm` GitHub Runner. As such, we change
the timeouts for arm64 in `codex-rs/linux-sandbox/tests/landlock.rs`.

Though in solving this problem, I decided I needed a turnkey solution
for testing the Linux build(s) from my Mac laptop, so this PR introduces
`.devcontainer/Dockerfile` and `.devcontainer/devcontainer.json` to
facilitate this. Detailed instructions are in `.devcontainer/README.md`.

We will update `dotslash-config.json` and other release-related scripts
in a follow-up PR.
2025-06-05 20:29:46 -07:00
Michael Bolin
515b6331bd feat: add support for login with ChatGPT (#1212)
This does not implement the full Login with ChatGPT experience, but it
should unblock people.

**What works**

* The `codex` multitool now has a `login` subcommand, so you can run
`codex login`, which should write `CODEX_HOME/auth.json` if you complete
the flow successfully. The TUI will now read the `OPENAI_API_KEY` from
`auth.json`.
* The TUI should refresh the token if it has expired and the necessary
information is in `auth.json`.
* There is a `LoginScreen` in the TUI that tells you to run `codex
login` if both (1) your model provider expects to use `OPENAI_API_KEY`
as its env var, and (2) `OPENAI_API_KEY` is not set.

**What does not work**

* The `LoginScreen` does not support the login flow from within the TUI.
Instead, it tells you to quit, run `codex login`, and then run `codex`
again.
* `codex exec` does read from `auth.json` yet, nor does it direct the
user to go through the login flow if `OPENAI_API_KEY` is not be found.
* The `maybeRedeemCredits()` function from `get-api-key.tsx` has not
been ported from TypeScript to `login_with_chatgpt.py` yet:


a67a67f325/codex-cli/src/utils/get-api-key.tsx (L84-L89)

**Implementation**

Currently, the OAuth flow requires running a local webserver on
`127.0.0.1:1455`. It seemed wasteful to incur the additional binary cost
of a webserver dependency in the Rust CLI just to support login, so
instead we implement this logic in Python, as Python has a `http.server`
module as part of its standard library. Specifically, we bundle the
contents of a single Python file as a string in the Rust CLI and then
use it to spawn a subprocess as `python3 -c
{{SOURCE_FOR_PYTHON_SERVER}}`.

As such, the most significant files in this PR are:

```
codex-rs/login/src/login_with_chatgpt.py
codex-rs/login/src/lib.rs
```

Now that the CLI may load `OPENAI_API_KEY` from the environment _or_
`CODEX_HOME/auth.json`, we need a new abstraction for reading/writing
this variable, so we introduce:

```
codex-rs/core/src/openai_api_key.rs
```

Note that `std::env::set_var()` is [rightfully] `unsafe` in Rust 2024,
so we use a LazyLock<RwLock<Option<String>>> to store `OPENAI_API_KEY`
so it is read in a thread-safe manner.

Ultimately, it should be possible to go through the entire login flow
from the TUI. This PR introduces a placeholder `LoginScreen` UI for that
right now, though the new `codex login` subcommand introduced in this PR
should be a viable workaround until the UI is ready.

**Testing**

Because the login flow is currently implemented in a standalone Python
file, you can test it without building any Rust code as follows:

```
rm -rf /tmp/codex_home && mkdir /tmp/codex_home
CODEX_HOME=/tmp/codex_home python3 codex-rs/login/src/login_with_chatgpt.py
```

For reference:

* the original TypeScript implementation was introduced in
https://github.com/openai/codex/pull/963
* support for redeeming credits was later added in
https://github.com/openai/codex/pull/974
2025-06-04 08:44:17 -07:00
Reilly Wood
a67a67f325 codex-rs: make tool calls prettier (#1211)
This PR overhauls how active tool calls and completed tool calls are
displayed:

1. More use of colour to indicate success/failure and distinguish
between components like tool name+arguments
2. Previously, the entire `CallToolResult` was serialized to JSON and
pretty-printed. Now, we extract each individual `CallToolResultContent`
and print those
1. The previous solution was wasting space by unnecessarily showing
details of the `CallToolResult` struct to users, without formatting the
actual tool call results nicely
2. We're now able to show users more information from tool results in
less space, with nicer formatting when tools return JSON results

### Before:

<img width="1251" alt="Screenshot 2025-06-03 at 11 24 26"
src="https://github.com/user-attachments/assets/5a58f222-219c-4c53-ace7-d887194e30cf"
/>

### After:

<img width="1265" alt="image"
src="https://github.com/user-attachments/assets/99fe54d0-9ebe-406a-855b-7aa529b91274"
/>

## Future Work

1. Integrate image tool result handling better. We should be able to
display images even if they're not the first `CallToolResultContent`
2. Users should have some way to view the full version of truncated tool
results
3. It would be nice to add some left padding for tool results, make it
more clear that they are results. This is doable, just a little fiddly
due to the way `first_visible_line` scrolling works
4. There's almost certainly a better way to format JSON than "all on 1
line with spaces to make Ratatui wrapping work". But I think that works
OK for now.
2025-06-03 14:29:26 -07:00