2025-09-21 20:18:35 -07:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
2025-10-02 12:38:24 -07:00
|
|
|
use codex_common::model_presets::ModelPreset;
|
2025-09-10 17:42:54 -07:00
|
|
|
use codex_core::protocol::ConversationPathResponseEvent;
|
feat: initial import of Rust implementation of Codex CLI in codex-rs/ (#629)
As stated in `codex-rs/README.md`:
Today, Codex CLI is written in TypeScript and requires Node.js 22+ to
run it. For a number of users, this runtime requirement inhibits
adoption: they would be better served by a standalone executable. As
maintainers, we want Codex to run efficiently in a wide range of
environments with minimal overhead. We also want to take advantage of
operating system-specific APIs to provide better sandboxing, where
possible.
To that end, we are moving forward with a Rust implementation of Codex
CLI contained in this folder, which has the following benefits:
- The CLI compiles to small, standalone, platform-specific binaries.
- Can make direct, native calls to
[seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html) and
[landlock](https://man7.org/linux/man-pages/man7/landlock.7.html) in
order to support sandboxing on Linux.
- No runtime garbage collection, resulting in lower memory consumption
and better, more predictable performance.
Currently, the Rust implementation is materially behind the TypeScript
implementation in functionality, so continue to use the TypeScript
implmentation for the time being. We will publish native executables via
GitHub Releases as soon as we feel the Rust version is usable.
2025-04-24 13:31:40 -07:00
|
|
|
use codex_core::protocol::Event;
|
2025-06-28 15:04:23 -07:00
|
|
|
use codex_file_search::FileMatch;
|
feat: initial import of Rust implementation of Codex CLI in codex-rs/ (#629)
As stated in `codex-rs/README.md`:
Today, Codex CLI is written in TypeScript and requires Node.js 22+ to
run it. For a number of users, this runtime requirement inhibits
adoption: they would be better served by a standalone executable. As
maintainers, we want Codex to run efficiently in a wide range of
environments with minimal overhead. We also want to take advantage of
operating system-specific APIs to provide better sandboxing, where
possible.
To that end, we are moving forward with a Rust implementation of Codex
CLI contained in this folder, which has the following benefits:
- The CLI compiles to small, standalone, platform-specific binaries.
- Can make direct, native calls to
[seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html) and
[landlock](https://man7.org/linux/man-pages/man7/landlock.7.html) in
order to support sandboxing on Linux.
- No runtime garbage collection, resulting in lower memory consumption
and better, more predictable performance.
Currently, the Rust implementation is materially behind the TypeScript
implementation in functionality, so continue to use the TypeScript
implmentation for the time being. We will publish native executables via
GitHub Releases as soon as we feel the Rust version is usable.
2025-04-24 13:31:40 -07:00
|
|
|
|
2025-10-01 14:29:05 -07:00
|
|
|
use crate::bottom_pane::ApprovalRequest;
|
2025-08-20 17:09:46 -07:00
|
|
|
use crate::history_cell::HistoryCell;
|
|
|
|
|
|
2025-08-19 22:34:37 -07:00
|
|
|
use codex_core::protocol::AskForApproval;
|
|
|
|
|
use codex_core::protocol::SandboxPolicy;
|
2025-08-19 10:55:07 -07:00
|
|
|
use codex_core::protocol_config_types::ReasoningEffort;
|
feat: add support for commands in the Rust TUI (#935)
Introduces support for slash commands like in the TypeScript CLI. We do
not support the full set of commands yet, but the core abstraction is
there now.
In particular, we have a `SlashCommand` enum and due to thoughtful use
of the [strum](https://crates.io/crates/strum) crate, it requires
minimal boilerplate to add a new command to the list.
The key new piece of UI is `CommandPopup`, though the keyboard events
are still handled by `ChatComposer`. The behavior is roughly as follows:
* if the first character in the composer is `/`, the command popup is
displayed (if you really want to send a message to Codex that starts
with a `/`, simply put a space before the `/`)
* while the popup is displayed, up/down can be used to change the
selection of the popup
* if there is a selection, hitting tab completes the command, but does
not send it
* if there is a selection, hitting enter sends the command
* if the prefix of the composer matches a command, the command will be
visible in the popup so the user can see the description (commands could
take arguments, so additional text may appear after the command name
itself)
https://github.com/user-attachments/assets/39c3e6ee-eeb7-4ef7-a911-466d8184975f
Incidentally, Codex wrote almost all the code for this PR!
2025-05-14 12:55:49 -07:00
|
|
|
|
2025-05-08 21:46:06 -07:00
|
|
|
#[allow(clippy::large_enum_variant)]
|
2025-08-12 17:37:28 -07:00
|
|
|
#[derive(Debug)]
|
feat: initial import of Rust implementation of Codex CLI in codex-rs/ (#629)
As stated in `codex-rs/README.md`:
Today, Codex CLI is written in TypeScript and requires Node.js 22+ to
run it. For a number of users, this runtime requirement inhibits
adoption: they would be better served by a standalone executable. As
maintainers, we want Codex to run efficiently in a wide range of
environments with minimal overhead. We also want to take advantage of
operating system-specific APIs to provide better sandboxing, where
possible.
To that end, we are moving forward with a Rust implementation of Codex
CLI contained in this folder, which has the following benefits:
- The CLI compiles to small, standalone, platform-specific binaries.
- Can make direct, native calls to
[seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html) and
[landlock](https://man7.org/linux/man-pages/man7/landlock.7.html) in
order to support sandboxing on Linux.
- No runtime garbage collection, resulting in lower memory consumption
and better, more predictable performance.
Currently, the Rust implementation is materially behind the TypeScript
implementation in functionality, so continue to use the TypeScript
implmentation for the time being. We will publish native executables via
GitHub Releases as soon as we feel the Rust version is usable.
2025-04-24 13:31:40 -07:00
|
|
|
pub(crate) enum AppEvent {
|
|
|
|
|
CodexEvent(Event),
|
2025-04-25 12:01:52 -07:00
|
|
|
|
2025-08-21 10:36:58 -07:00
|
|
|
/// Start a new session.
|
|
|
|
|
NewSession,
|
|
|
|
|
|
feat: initial import of Rust implementation of Codex CLI in codex-rs/ (#629)
As stated in `codex-rs/README.md`:
Today, Codex CLI is written in TypeScript and requires Node.js 22+ to
run it. For a number of users, this runtime requirement inhibits
adoption: they would be better served by a standalone executable. As
maintainers, we want Codex to run efficiently in a wide range of
environments with minimal overhead. We also want to take advantage of
operating system-specific APIs to provide better sandboxing, where
possible.
To that end, we are moving forward with a Rust implementation of Codex
CLI contained in this folder, which has the following benefits:
- The CLI compiles to small, standalone, platform-specific binaries.
- Can make direct, native calls to
[seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html) and
[landlock](https://man7.org/linux/man-pages/man7/landlock.7.html) in
order to support sandboxing on Linux.
- No runtime garbage collection, resulting in lower memory consumption
and better, more predictable performance.
Currently, the Rust implementation is materially behind the TypeScript
implementation in functionality, so continue to use the TypeScript
implmentation for the time being. We will publish native executables via
GitHub Releases as soon as we feel the Rust version is usable.
2025-04-24 13:31:40 -07:00
|
|
|
/// Request to exit the application gracefully.
|
|
|
|
|
ExitRequest,
|
|
|
|
|
|
|
|
|
|
/// Forward an `Op` to the Agent. Using an `AppEvent` for this avoids
|
|
|
|
|
/// bubbling channels through layers of widgets.
|
|
|
|
|
CodexOp(codex_core::protocol::Op),
|
|
|
|
|
|
feat: add support for @ to do file search (#1401)
Introduces support for `@` to trigger a fuzzy-filename search in the
composer. Under the hood, this leverages
https://crates.io/crates/nucleo-matcher to do the fuzzy matching and
https://crates.io/crates/ignore to build up the list of file candidates
(so that it respects `.gitignore`).
For simplicity (at least for now), we do not do any caching between
searches like VS Code does for its file search:
https://github.com/microsoft/vscode/blob/1d89ed699b2e924d418c856318a3e12bca67ff3a/src/vs/workbench/services/search/node/rawSearchService.ts#L212-L218
Because we do not do any caching, I saw queries take up to three seconds
on large repositories with hundreds of thousands of files. To that end,
we do not perform searches synchronously on each keystroke, but instead
dispatch an event to do the search on a background thread that
asynchronously reports back to the UI when the results are available.
This is largely handled by the `FileSearchManager` introduced in this
PR, which also has logic for debouncing requests so there is at most one
search in flight at a time.
While we could potentially polish and tune this feature further, it may
already be overengineered for how it will be used, in practice, so we
can improve things going forward if it turns out that this is not "good
enough" in the wild.
Note this feature does not work like `@` in the TypeScript CLI, which
was more like directory-based tab completion. In the Rust CLI, `@`
triggers a full-repo fuzzy-filename search.
Fixes https://github.com/openai/codex/issues/1261.
2025-06-28 13:47:42 -07:00
|
|
|
/// Kick off an asynchronous file search for the given query (text after
|
|
|
|
|
/// the `@`). Previous searches may be cancelled by the app layer so there
|
|
|
|
|
/// is at most one in-flight search.
|
|
|
|
|
StartFileSearch(String),
|
|
|
|
|
|
|
|
|
|
/// Result of a completed asynchronous file search. The `query` echoes the
|
|
|
|
|
/// original search term so the UI can decide whether the results are
|
|
|
|
|
/// still relevant.
|
|
|
|
|
FileSearchResult {
|
|
|
|
|
query: String,
|
2025-06-28 15:04:23 -07:00
|
|
|
matches: Vec<FileMatch>,
|
feat: add support for @ to do file search (#1401)
Introduces support for `@` to trigger a fuzzy-filename search in the
composer. Under the hood, this leverages
https://crates.io/crates/nucleo-matcher to do the fuzzy matching and
https://crates.io/crates/ignore to build up the list of file candidates
(so that it respects `.gitignore`).
For simplicity (at least for now), we do not do any caching between
searches like VS Code does for its file search:
https://github.com/microsoft/vscode/blob/1d89ed699b2e924d418c856318a3e12bca67ff3a/src/vs/workbench/services/search/node/rawSearchService.ts#L212-L218
Because we do not do any caching, I saw queries take up to three seconds
on large repositories with hundreds of thousands of files. To that end,
we do not perform searches synchronously on each keystroke, but instead
dispatch an event to do the search on a background thread that
asynchronously reports back to the UI when the results are available.
This is largely handled by the `FileSearchManager` introduced in this
PR, which also has logic for debouncing requests so there is at most one
search in flight at a time.
While we could potentially polish and tune this feature further, it may
already be overengineered for how it will be used, in practice, so we
can improve things going forward if it turns out that this is not "good
enough" in the wild.
Note this feature does not work like `@` in the TypeScript CLI, which
was more like directory-based tab completion. In the Rust CLI, `@`
triggers a full-repo fuzzy-filename search.
Fixes https://github.com/openai/codex/issues/1261.
2025-06-28 13:47:42 -07:00
|
|
|
},
|
2025-07-25 01:56:40 -07:00
|
|
|
|
2025-08-15 15:32:41 -07:00
|
|
|
/// Result of computing a `/diff` command.
|
|
|
|
|
DiffResult(String),
|
|
|
|
|
|
2025-08-20 17:09:46 -07:00
|
|
|
InsertHistoryCell(Box<dyn HistoryCell>),
|
2025-08-06 15:22:14 -07:00
|
|
|
|
2025-08-12 17:37:28 -07:00
|
|
|
StartCommitAnimation,
|
|
|
|
|
StopCommitAnimation,
|
|
|
|
|
CommitTick,
|
|
|
|
|
|
2025-08-19 10:55:07 -07:00
|
|
|
/// Update the current reasoning effort in the running app and widget.
|
2025-09-12 12:06:33 -07:00
|
|
|
UpdateReasoningEffort(Option<ReasoningEffort>),
|
2025-08-19 10:55:07 -07:00
|
|
|
|
|
|
|
|
/// Update the current model slug in the running app and widget.
|
|
|
|
|
UpdateModel(String),
|
2025-08-19 22:34:37 -07:00
|
|
|
|
2025-09-15 00:25:43 +01:00
|
|
|
/// Persist the selected model and reasoning effort to the appropriate config.
|
|
|
|
|
PersistModelSelection {
|
|
|
|
|
model: String,
|
|
|
|
|
effort: Option<ReasoningEffort>,
|
|
|
|
|
},
|
|
|
|
|
|
2025-10-02 12:38:24 -07:00
|
|
|
/// Open the reasoning selection popup after picking a model.
|
|
|
|
|
OpenReasoningPopup {
|
|
|
|
|
model: String,
|
|
|
|
|
presets: Vec<ModelPreset>,
|
|
|
|
|
},
|
|
|
|
|
|
2025-08-19 22:34:37 -07:00
|
|
|
/// Update the current approval policy in the running app and widget.
|
|
|
|
|
UpdateAskForApprovalPolicy(AskForApproval),
|
|
|
|
|
|
|
|
|
|
/// Update the current sandbox policy in the running app and widget.
|
|
|
|
|
UpdateSandboxPolicy(SandboxPolicy),
|
2025-08-23 23:23:15 -07:00
|
|
|
|
|
|
|
|
/// Forwarded conversation history snapshot from the current conversation.
|
2025-09-10 17:42:54 -07:00
|
|
|
ConversationHistory(ConversationPathResponseEvent),
|
2025-09-21 20:18:35 -07:00
|
|
|
|
|
|
|
|
/// Open the branch picker option from the review popup.
|
|
|
|
|
OpenReviewBranchPicker(PathBuf),
|
|
|
|
|
|
|
|
|
|
/// Open the commit picker option from the review popup.
|
|
|
|
|
OpenReviewCommitPicker(PathBuf),
|
|
|
|
|
|
|
|
|
|
/// Open the custom prompt option from the review popup.
|
|
|
|
|
OpenReviewCustomPrompt,
|
2025-10-01 14:29:05 -07:00
|
|
|
|
|
|
|
|
/// Open the approval popup.
|
|
|
|
|
FullScreenApprovalRequest(ApprovalRequest),
|
feat: initial import of Rust implementation of Codex CLI in codex-rs/ (#629)
As stated in `codex-rs/README.md`:
Today, Codex CLI is written in TypeScript and requires Node.js 22+ to
run it. For a number of users, this runtime requirement inhibits
adoption: they would be better served by a standalone executable. As
maintainers, we want Codex to run efficiently in a wide range of
environments with minimal overhead. We also want to take advantage of
operating system-specific APIs to provide better sandboxing, where
possible.
To that end, we are moving forward with a Rust implementation of Codex
CLI contained in this folder, which has the following benefits:
- The CLI compiles to small, standalone, platform-specific binaries.
- Can make direct, native calls to
[seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html) and
[landlock](https://man7.org/linux/man-pages/man7/landlock.7.html) in
order to support sandboxing on Linux.
- No runtime garbage collection, resulting in lower memory consumption
and better, more predictable performance.
Currently, the Rust implementation is materially behind the TypeScript
implementation in functionality, so continue to use the TypeScript
implmentation for the time being. We will publish native executables via
GitHub Releases as soon as we feel the Rust version is usable.
2025-04-24 13:31:40 -07:00
|
|
|
}
|