Commit Graph

8634 Commits

Author SHA1 Message Date
Abdelrhman Kamal Mahmoud Ali Slim
f97557f59f refactor(component): rename component to match its filename (#432)
Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-20 22:21:49 -07:00
Scott Leibrand
e3c8ce49ca fix: allow proper exit from new Switch approval mode dialog (#453)
As described in
https://github.com/openai/codex/issues/392#issuecomment-2817090022
introduced by #400

The testing I'd done worked correctly because I was using the (s)
shortcut, but selecting the same option using arrow‑key → Enter on
“Switch approval mode” was preventing the user from subsequently exiting
the Switch approval mode dialog, requiring a ^C to quit codex entirely.
With this fix, both entry methods work correctly in my testing.

Per codex:

Issue

- When you navigated down (↓) to “Switch approval mode (s)” in the Shell
Command review dialog and pressed Enter, the ApprovalModeOverlay would
open—but because the underlying `TerminalChatCommandReview` component
stayed mounted (albeit disabled), its own Ink input handlers immediately
re‑captured the same key events and re‑opened the overlay as soon as you
hit Esc or Enter again. In practice this made it impossible to exit the
submenu.

Root cause

- We only disabled the SelectInput via `isDisabled`, but never fully
unmounted the review UI when an overlay was shown, so its `useInput` and
`<Select>` hooks were still active and “stealing” keys.

Fix

- In `terminal-chat.tsx` we now only render `<TerminalChatInput>` (and
by extension `TerminalChatCommandReview`) when `overlayMode === "none"`.
That unmounts all of its key handlers whenever any overlay (history,
model, approval, help, diff) is open, so no input leaks through.

Files changed

- **src/components/chat/terminal-chat.tsx**: Wrapped the entire
`<TerminalChatInput>` block in `overlayMode === "none" && agent`

With that in place, arrow‑key → Enter on “Switch approval mode”
correctly opens the overlay, and then you can use Enter/Esc inside the
overlay without getting stuck or immediately re‑opening it.
2025-04-20 22:19:53 -07:00
Brayden Moon
8dd1125681 fix: command pipe execution by improving shell detection (#437)
## Description
This PR fixes Issue #421 where commands with pipes (e.g., `grep -R ...
-n | head -n 20`) were failing to execute properly after PR #391 was
merged.

## Changes
- Modified the `requiresShell` function to only enable shell mode when
the command is a single string containing shell operators
- Added logic to handle the case where shell operators are passed as
separate arguments
- Added comprehensive tests to verify the fix

## Root Cause
The issue was that the `requiresShell` function was detecting shell
operators like `|` even when they were passed as separate arguments,
which caused the command to be executed with `shell: true`
unnecessarily. This was causing syntax errors when running commands with
pipes.

## Testing
- Added unit tests to verify the fix
- Manually tested with real commands using pipes
- Ensured all existing tests pass

Fixes #421
2025-04-20 21:11:19 -07:00
Daniel Nakov
eafbc75612 feat: support multiple providers via Responses-Completion transformation (#247)
https://github.com/user-attachments/assets/9ecb51be-fa65-4e99-8512-abb898dda569

Implemented it as a transformation between Responses API and Completion
API so that it supports existing providers that implement the Completion
API and minimizes the changes needed to the codex repo.

---------

Co-authored-by: Thibault Sottiaux <tibo@openai.com>
Co-authored-by: Fouad Matin <169186268+fouad-openai@users.noreply.github.com>
Co-authored-by: Fouad Matin <fouad@openai.com>
2025-04-20 20:59:34 -07:00
Jordan Docherty
693bd59ecc fix(raw-exec-process-group): improve test reliability (#434)
This PR improves the reliability of `raw-exec-process-group.test`,
addressing [#415](https://github.com/openai/codex/issues/415)

Before: The test would fail sporadically in CI because it checked for
process termination immediately after abort, without accounting for the
time it takes for processes to fully terminate.

Now: We've added a robust `ensureProcessGone` helper that:
- Polls the process status with a 500ms timeout
- Retries every 50ms if the process is still alive
- Provides clear error messages if termination takes too long

We now wait for the child process to fully exit after sending abort
signals, instead of assuming instant death, fixing flakiness caused by
asynchronous process termination.

Changes:
- Added `ensureProcessGone` helper function with retry logic
- Improved error handling and timeout management

See [this bash
demo](https://gist.github.com/jdocherty/a84dbca2fbf7b47e5f95c87a07034ae8)
for a minimal reproduction of why process death is asynchronous and why
the test needs to retry after aborting.
2025-04-20 12:21:02 -07:00
Michael Bolin
b554b522f7 fix: remove unnecessary isLoggingEnabled() checks (#420)
It appears that use of `isLoggingEnabled()` was erroneously copypasta'd
in many places. This PR updates its docstring to clarify that should
only be used to avoid constructing a potentially expensive docstring.
With this change, the only function that merits/uses this check is
`execCommand()`.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/420).
* #423
* __->__ #420
* #419
2025-04-20 09:58:06 -07:00
Abdelrhman Kamal Mahmoud Ali Slim
81cf47e591 feat: auto-open model selector if user selects deprecated model (#427)
https://github.com/user-attachments/assets/d254dff6-f1f9-4492-9dfd-d185c38d3a75
2025-04-20 09:51:49 -07:00
Michael Bolin
e372e4667b Make it so CONFIG_DIR is not in the list of writable roots by default (#419)
To play it safe, let's keep `CONFIG_DIR` out of the default list of
writable roots.

This also fixes an issue where `execWithSeatbelt()` was modifying
`writableRoots` instead of creating a new array.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/419).
* #423
* #420
* __->__ #419
2025-04-20 09:37:07 -07:00
Abdelrhman Kamal Mahmoud Ali Slim
425430debb fix(cli): ensure /clear resets context and exclude system messages from approximateTokenUsed count (#443)
https://github.com/user-attachments/assets/58b8f261-a359-4cd8-8c84-90d8d91a5592
2025-04-20 08:52:14 -07:00
Brayden Moon
6d6ca454cd feat: allow multi-line input (#438)
## Description
This PR implements multi-line input support for Codex when it asks for
user feedback (Issue #344). Users can now use Shift+Enter to add new
lines in their responses, making it easier to provide formatted code
snippets, lists, or other structured content.

## Changes
- Replace the single-line TextInput component with the
MultilineTextEditor component in terminal-chat-input.tsx
- Add support for Shift+Enter to create new lines
- Update key handling logic to properly handle history navigation in a
multi-line context
- Add reference to the editor to access cursor position information
- Update help text to inform users about the Shift+Enter functionality
- Add tests for the new functionality

## Testing
- Added new test file (terminal-chat-input-multiline.test.tsx) to test
the multi-line input functionality
- All existing tests continue to pass
- Manually tested the feature to ensure it works as expected

## Fixes
Closes #344

## Screenshots
N/A

## Additional Notes
This implementation maintains backward compatibility while adding the
requested multi-line input functionality. The UI remains clean and
intuitive, with a simple hint about using Shift+Enter for new lines.

---------

Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-20 08:51:38 -07:00
Thomas
fc1e45636e feat: add support for /diff command autocomplete in TerminalChatInput (#431)
It's not working without this
2025-04-19 20:01:40 -07:00
Michael Bolin
c8946bc9ab Merge 698381bae4 into sapling-pr-archive-bolinfest 2025-04-19 18:30:15 -07:00
Michael Bolin
698381bae4 reduce max output of ExecResult 2025-04-19 18:29:11 -07:00
Michael Bolin
4025cb6909 remove unnecessary isLoggingEnabled() checks 2025-04-19 18:29:11 -07:00
Michael Bolin
a7a4a69ccc CONFIG_DIR should not be in the list of writable roots by default 2025-04-19 18:29:11 -07:00
Michael Bolin
63c99e7d82 use spawn instead of exec to avoid injection vulnerability (#416)
https://github.com/openai/codex/pull/160 introduced a call to `exec()`
that takes a format string as an argument, but it is not clear that the
expansions within the format string are escaped safely. As written, it
is possible a carefully crafted command (e.g., if `cwd` were `"; && rm
-rf` or something...) could run arbitrary code.

Moving to `spawn()` makes this a bit better, as now at least `spawn()`
itself won't run an arbitrary process, though I suppose `osascript`
itself still could if the value passed to `-e` were abused. I'm not
clear on the escaping rules for AppleScript to ensure that `safePreview`
and `cwd` are injected safely.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/416).
* #423
* #420
* #419
* __->__ #416
2025-04-19 18:29:00 -07:00
Tomas Cupr
a3889f92e4 fix: full-auto support in quiet mode (#374)
Fixes https://github.com/openai/codex/issues/292

---------

Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-19 17:00:33 -07:00
Fouad Matin
b3b195351e feat: /diff command to view git diff (#426)
Adds `/diff` command to view git diff
2025-04-19 16:23:27 -07:00
Michael Bolin
b569794440 merge commit for archive created by Sapling 2025-04-19 11:49:22 -07:00
Michael Bolin
cdef7dfddc reduce max output of ExecResult 2025-04-19 11:49:16 -07:00
Michael Bolin
5bed84450d Merge cdb7325192 into sapling-pr-archive-bolinfest 2025-04-19 11:45:30 -07:00
Michael Bolin
1757ff3eb2 remove unnecessary isLoggingEnabled() checks 2025-04-19 11:45:21 -07:00
Michael Bolin
cdb7325192 reduce max output of ExecResult 2025-04-19 11:45:21 -07:00
Michael Bolin
507bc768bd CONFIG_DIR should not be in the list of writable roots by default 2025-04-19 11:45:21 -07:00
Michael Bolin
c392752867 Merge c03bb96438 into sapling-pr-archive-bolinfest 2025-04-19 11:41:56 -07:00
Michael Bolin
c03bb96438 reduce max output of ExecResult 2025-04-19 11:41:49 -07:00
Michael Bolin
52f805d3f8 Merge 7a16e239fc into sapling-pr-archive-bolinfest 2025-04-19 11:24:07 -07:00
Michael Bolin
70138aed17 use spawn instead of exec to avoid injection vulnerability 2025-04-19 11:23:58 -07:00
Michael Bolin
7a16e239fc remove unnecessary isLoggingEnabled() checks 2025-04-19 11:23:58 -07:00
Michael Bolin
75919d78fc CONFIG_DIR should not be in the list of writable roots by default 2025-04-19 11:23:58 -07:00
Michael Bolin
419f085cc4 re-enable Prettier check for codex-cli in CI (#417)
This check was lost in https://github.com/openai/codex/pull/287. Both
the root folder and `codex-cli/` have their own `pnpm format` commands
that check the formatting of different things.

Also ran `pnpm format:fix` to fix the formatting violations that got in
while this was disabled in CI.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/417).
* #420
* #419
* #416
* __->__ #417
2025-04-19 11:22:45 -07:00
Michael Bolin
8c8b1c7787 merge commit for archive created by Sapling 2025-04-19 11:12:54 -07:00
Michael Bolin
bce7ab2fea remove unnecessary isLoggingEnabled() checks 2025-04-19 11:12:49 -07:00
Michael Bolin
40dfb7053e merge commit for archive created by Sapling 2025-04-19 11:09:58 -07:00
Michael Bolin
f77625ea88 remove unnecessary isLoggingEnabled() checks 2025-04-19 11:09:52 -07:00
Michael Bolin
3aa51bf393 Merge 6ac0fd5fc1 into sapling-pr-archive-bolinfest 2025-04-19 11:07:44 -07:00
Michael Bolin
6ac0fd5fc1 remove unnecessary isLoggingEnabled() checks 2025-04-19 11:07:35 -07:00
Michael Bolin
79cee3982c merge commit for archive created by Sapling 2025-04-19 10:29:40 -07:00
Michael Bolin
5333ea726f CONFIG_DIR should not be in the list of writable roots by default 2025-04-19 10:29:18 -07:00
Michael Bolin
0430ab327b use spawn instead of exec to avoid injection vulnerability 2025-04-19 10:29:18 -07:00
Michael Bolin
8a4968ae9f re-enable Prettier check for codex-cli in CI 2025-04-19 10:29:18 -07:00
Michael Bolin
6f3e126388 Merge 3bbeba28ce into sapling-pr-archive-bolinfest 2025-04-19 10:26:39 -07:00
Michael Bolin
3bbeba28ce CONFIG_DIR should not be in the list of writable roots by default 2025-04-19 10:26:23 -07:00
Michael Bolin
75ea97455f Merge 19a43ad15b into sapling-pr-archive-bolinfest 2025-04-19 10:03:37 -07:00
Michael Bolin
19a43ad15b use spawn instead of exec to avoid injection vulnerability 2025-04-19 10:03:17 -07:00
Michael Bolin
896b05ba27 Merge be9d216aab into sapling-pr-archive-bolinfest 2025-04-19 10:03:07 -07:00
Michael Bolin
be9d216aab re-enable Prettier check for codex-cli in CI 2025-04-19 10:03:01 -07:00
Michael Bolin
da6410668a Merge ede10c1247 into sapling-pr-archive-bolinfest 2025-04-19 10:01:49 -07:00
Michael Bolin
ede10c1247 re-enable Prettier check for codex-cli in CI 2025-04-19 10:01:42 -07:00
Michael Bolin
37b878e933 Merge 66ae9fd234 into sapling-pr-archive-bolinfest 2025-04-19 10:01:29 -07:00