Commit Graph
1530 Commits
Author SHA1 Message Date
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 MoonandThibault Sottiaux 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 CuprandThibault Sottiaux 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
Michael Bolin 66ae9fd234 re-enable Prettier check for codex-cli in CI 2025-04-19 10:01:18 -07:00
Michael Bolin 832b98a557 use spawn instead of exec to avoid injection vulnerability 2025-04-19 09:52:49 -07:00
081786eaa6 feat: add /command autocomplete (#317)
Add interactive slash‑command autocomplete & navigation in chat input

    Description
This PR enhances the chat input component by adding first‑class support
for slash commands (/help, /clear, /compact, etc.)
    with:

* **Live filtering:** As soon as the user types leading `/`, a list of
matching commands is shown below the prompt.
* **Arrow‑key navigation:** Up/Down arrows cycle through suggestions.
* **Enter to autocomplete:** Pressing Enter on a partial command will
fill it (without submitting) so you can add
    arguments or simply press Enter again to execute.
* **Type‑safe registry:** A new `slash‑commands.ts` file declares all
supported commands in one place, along with
    TypeScript types to prevent drift.
* **Validation:** Only registered commands will ever autocomplete or be
suggested; unknown single‑word slash inputs still
    show an “Invalid command” system message.
        * **Automated tests:**
            * Unit tests for the command registry and prefix filtering

            * Existing tests continue passing with no regressions

    Motivation
Slash commands provide a quick, discoverable way to control the agent
(clearing history, compacting context, opening overlays,
etc.). Before, users had to memorize the exact command or rely on the
generic /help list—autocomplete makes them far more
    accessible and reduces typos.

    Changes

* `src/utils/slash‑commands.ts` – defines `SlashCommand` and exports a
flat list of supported commands + descriptions
        * `terminal‑chat‑input.tsx`
            * Import and type the command registry

* Render filtered suggestions under the prompt when input starts with
`/`

* Hook into `useInput` to handle Up/Down and Enter for selection & fill

* Flag to swallow the first Enter (autocomplete) and only submit on the
next
* Updated tests in `tests/slash‑commands.test.ts` to cover registry
contents and filtering logic
        * Removed old JS version and fixed stray `@ts‑expect‑error`

    How to test locally

        1. Type `/` in the prompt—you should see matching commands.
2. Use arrows to move the highlight, press Enter to fill, then Enter
again to execute.
3. Run the full test suite (`npm test`) to verify no regressions.

    Notes

* Future work could include fuzzy matching, paging long lists, or more
visual styling.
* This change is purely additive and does not affect non‑slash inputs or
existing slash handlers.

---------

Co-authored-by: Fouad Matin <169186268+fouad-openai@users.noreply.github.com>
Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-19 07:25:46 -07:00
John Gardner 965420cfc5 feat: read approvalMode from config file (#298)
This PR implements support for reading the approvalMode setting from the
user's config file (`~/.codex/config.json` or `~/.codex/config.yaml`),
allowing users to set a persistent default approval mode without needing
to specify command-line flags for each session.

Changes:
- Added approvalMode to the AppConfig type in config.ts
- Updated loadConfig() to read the approval mode from the config file
- Modified saveConfig() to persist the approval mode setting
- Updated CLI logic to respect the config-defined approval mode (while
maintaining CLI flag priority)
- Added comprehensive tests for approval mode config functionality
- Updated README to document the new config option in both YAML and JSON
formats
- additions to `.gitignore` for other CLI tools

Motivation:
As a user who regularly works with CLI-tools, I found it odd to have to
alias this with the command flags I wanted when `approvalMode` simply
wasn't being parsed even though it was an optional prop in `config.ts`.
This change allows me (and other users) to set the preference once in
the config file, streamlining daily usage while maintaining the ability
to override via command-line flags when needed.

Testing:
I've added a new test case loads and saves approvalMode correctly that
verifies:
- Reading the approvalMode from the config file works correctly
- Saving the approvalMode to the config file works as expected
- The value persists through load/save operations

All tests related to the implementation are passing.
2025-04-19 07:25:25 -07:00