2025-05-28 14:03:19 -07:00
|
|
|
|
use crate::cell_widget::CellWidget;
|
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 crate::history_cell::CommandOutput;
|
|
|
|
|
|
use crate::history_cell::HistoryCell;
|
|
|
|
|
|
use crate::history_cell::PatchEventType;
|
2025-04-27 21:47:50 -07:00
|
|
|
|
use codex_core::config::Config;
|
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::FileChange;
|
2025-05-13 19:22:16 -07:00
|
|
|
|
use codex_core::protocol::SessionConfiguredEvent;
|
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 crossterm::event::KeyCode;
|
|
|
|
|
|
use crossterm::event::KeyEvent;
|
|
|
|
|
|
use ratatui::prelude::*;
|
|
|
|
|
|
use ratatui::style::Style;
|
|
|
|
|
|
use ratatui::widgets::*;
|
2025-05-06 16:12:15 -07:00
|
|
|
|
use serde_json::Value as JsonValue;
|
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 std::cell::Cell as StdCell;
|
2025-05-14 16:51:41 -07:00
|
|
|
|
use std::cell::Cell;
|
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 std::collections::HashMap;
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
2025-05-14 16:51:41 -07:00
|
|
|
|
/// A single history entry plus its cached wrapped-line count.
|
|
|
|
|
|
struct Entry {
|
|
|
|
|
|
cell: HistoryCell,
|
|
|
|
|
|
line_count: Cell<usize>,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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 struct ConversationHistoryWidget {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
entries: Vec<Entry>,
|
|
|
|
|
|
/// The width (in terminal cells/columns) that [`Entry::line_count`] was
|
|
|
|
|
|
/// computed for. When the available width changes we recompute counts.
|
|
|
|
|
|
cached_width: StdCell<u16>,
|
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
|
|
|
|
scroll_position: usize,
|
|
|
|
|
|
/// Number of lines the last time render_ref() was called
|
|
|
|
|
|
num_rendered_lines: StdCell<usize>,
|
|
|
|
|
|
/// The height of the viewport last time render_ref() was called
|
|
|
|
|
|
last_viewport_height: StdCell<usize>,
|
|
|
|
|
|
has_input_focus: bool,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ConversationHistoryWidget {
|
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
|
Self {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
entries: Vec::new(),
|
|
|
|
|
|
cached_width: StdCell::new(0),
|
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
|
|
|
|
scroll_position: usize::MAX,
|
|
|
|
|
|
num_rendered_lines: StdCell::new(0),
|
|
|
|
|
|
last_viewport_height: StdCell::new(0),
|
|
|
|
|
|
has_input_focus: false,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) fn set_input_focus(&mut self, has_input_focus: bool) {
|
|
|
|
|
|
self.has_input_focus = has_input_focus;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns true if it needs a redraw.
|
|
|
|
|
|
pub(crate) fn handle_key_event(&mut self, key_event: KeyEvent) -> bool {
|
|
|
|
|
|
match key_event.code {
|
|
|
|
|
|
KeyCode::Up | KeyCode::Char('k') => {
|
2025-04-25 12:01:52 -07:00
|
|
|
|
self.scroll_up(1);
|
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
|
|
|
|
true
|
|
|
|
|
|
}
|
|
|
|
|
|
KeyCode::Down | KeyCode::Char('j') => {
|
2025-04-25 12:01:52 -07:00
|
|
|
|
self.scroll_down(1);
|
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
|
|
|
|
true
|
|
|
|
|
|
}
|
2025-04-28 10:39:58 -07:00
|
|
|
|
KeyCode::PageUp | KeyCode::Char('b') => {
|
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
|
|
|
|
self.scroll_page_up();
|
|
|
|
|
|
true
|
|
|
|
|
|
}
|
2025-04-28 10:39:58 -07:00
|
|
|
|
KeyCode::PageDown | KeyCode::Char(' ') => {
|
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
|
|
|
|
self.scroll_page_down();
|
|
|
|
|
|
true
|
|
|
|
|
|
}
|
|
|
|
|
|
_ => false,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-25 12:01:52 -07:00
|
|
|
|
/// Negative delta scrolls up; positive delta scrolls down.
|
|
|
|
|
|
pub(crate) fn scroll(&mut self, delta: i32) {
|
|
|
|
|
|
match delta.cmp(&0) {
|
|
|
|
|
|
std::cmp::Ordering::Less => self.scroll_up(-delta as u32),
|
|
|
|
|
|
std::cmp::Ordering::Greater => self.scroll_down(delta as u32),
|
|
|
|
|
|
std::cmp::Ordering::Equal => {}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn scroll_up(&mut self, num_lines: u32) {
|
|
|
|
|
|
// If a user is scrolling up from the "stick to bottom" mode, we need to
|
2025-05-14 16:51:41 -07:00
|
|
|
|
// map this to a specific scroll position so we can calculate the delta.
|
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
|
|
|
|
// This requires us to care about how tall the screen is.
|
|
|
|
|
|
if self.scroll_position == usize::MAX {
|
|
|
|
|
|
self.scroll_position = self
|
|
|
|
|
|
.num_rendered_lines
|
|
|
|
|
|
.get()
|
|
|
|
|
|
.saturating_sub(self.last_viewport_height.get());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-25 12:01:52 -07:00
|
|
|
|
self.scroll_position = self.scroll_position.saturating_sub(num_lines as usize);
|
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-04-25 12:01:52 -07:00
|
|
|
|
fn scroll_down(&mut self, num_lines: u32) {
|
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
|
|
|
|
// If we're already pinned to the bottom there's nothing to do.
|
|
|
|
|
|
if self.scroll_position == usize::MAX {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let viewport_height = self.last_viewport_height.get().max(1);
|
2025-04-25 12:01:52 -07:00
|
|
|
|
let num_rendered_lines = self.num_rendered_lines.get();
|
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
|
|
|
|
|
|
|
|
|
|
// Compute the maximum explicit scroll offset that still shows a full
|
|
|
|
|
|
// viewport. This mirrors the calculation in `scroll_page_down()` and
|
|
|
|
|
|
// in the render path.
|
2025-05-14 16:51:41 -07:00
|
|
|
|
let max_scroll = num_rendered_lines.saturating_sub(viewport_height);
|
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-04-25 12:01:52 -07:00
|
|
|
|
let new_pos = self.scroll_position.saturating_add(num_lines as usize);
|
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
|
|
|
|
|
|
|
|
|
|
if new_pos >= max_scroll {
|
|
|
|
|
|
// Reached (or passed) the bottom – switch to stick‑to‑bottom mode
|
|
|
|
|
|
// so that additional output keeps the view pinned automatically.
|
|
|
|
|
|
self.scroll_position = usize::MAX;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.scroll_position = new_pos;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Scroll up by one full viewport height (Page Up).
|
|
|
|
|
|
fn scroll_page_up(&mut self) {
|
|
|
|
|
|
let viewport_height = self.last_viewport_height.get().max(1);
|
|
|
|
|
|
|
|
|
|
|
|
// If we are currently in the "stick to bottom" mode, first convert the
|
|
|
|
|
|
// implicit scroll position (`usize::MAX`) into an explicit offset that
|
|
|
|
|
|
// represents the very bottom of the scroll region. This mirrors the
|
|
|
|
|
|
// logic from `scroll_up()`.
|
|
|
|
|
|
if self.scroll_position == usize::MAX {
|
|
|
|
|
|
self.scroll_position = self
|
|
|
|
|
|
.num_rendered_lines
|
|
|
|
|
|
.get()
|
|
|
|
|
|
.saturating_sub(viewport_height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Move up by a full page.
|
|
|
|
|
|
self.scroll_position = self.scroll_position.saturating_sub(viewport_height);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Scroll down by one full viewport height (Page Down).
|
|
|
|
|
|
fn scroll_page_down(&mut self) {
|
|
|
|
|
|
// Nothing to do if we're already stuck to the bottom.
|
|
|
|
|
|
if self.scroll_position == usize::MAX {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let viewport_height = self.last_viewport_height.get().max(1);
|
|
|
|
|
|
let num_lines = self.num_rendered_lines.get();
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate the maximum explicit scroll offset that is still within
|
|
|
|
|
|
// range. This matches the logic in `scroll_down()` and the render
|
|
|
|
|
|
// method.
|
2025-05-14 16:51:41 -07:00
|
|
|
|
let max_scroll = num_lines.saturating_sub(viewport_height);
|
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
|
|
|
|
|
|
|
|
|
|
// Attempt to move down by a full page.
|
|
|
|
|
|
let new_pos = self.scroll_position.saturating_add(viewport_height);
|
|
|
|
|
|
|
|
|
|
|
|
if new_pos >= max_scroll {
|
|
|
|
|
|
// We have reached (or passed) the bottom – switch back to
|
|
|
|
|
|
// automatic stick‑to‑bottom mode so that subsequent output keeps
|
|
|
|
|
|
// the viewport pinned.
|
|
|
|
|
|
self.scroll_position = usize::MAX;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.scroll_position = new_pos;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn scroll_to_bottom(&mut self) {
|
|
|
|
|
|
self.scroll_position = usize::MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-13 19:22:16 -07:00
|
|
|
|
/// Note `model` could differ from `config.model` if the agent decided to
|
|
|
|
|
|
/// use a different model than the one requested by the user.
|
|
|
|
|
|
pub fn add_session_info(&mut self, config: &Config, event: SessionConfiguredEvent) {
|
2025-05-17 09:00:23 -07:00
|
|
|
|
// In practice, SessionConfiguredEvent should always be the first entry
|
|
|
|
|
|
// in the history, but it is possible that an error could be sent
|
|
|
|
|
|
// before the session info.
|
|
|
|
|
|
let has_welcome_message = self
|
|
|
|
|
|
.entries
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.any(|entry| matches!(entry.cell, HistoryCell::WelcomeMessage { .. }));
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_session_info(
|
|
|
|
|
|
config,
|
|
|
|
|
|
event,
|
|
|
|
|
|
!has_welcome_message,
|
|
|
|
|
|
));
|
2025-05-08 21:46:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
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 fn add_user_message(&mut self, message: String) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_user_prompt(message));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-16 11:33:08 -07:00
|
|
|
|
pub fn add_agent_message(&mut self, config: &Config, message: String) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_agent_message(config, message));
|
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-05-16 11:33:08 -07:00
|
|
|
|
pub fn add_agent_reasoning(&mut self, config: &Config, text: String) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_agent_reasoning(config, text));
|
2025-05-10 21:43:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
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 fn add_background_event(&mut self, message: String) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_background_event(message));
|
2025-05-08 21:46:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn add_error(&mut self, message: String) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_error_event(message));
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Add a pending patch entry (before user approval).
|
|
|
|
|
|
pub fn add_patch_event(
|
|
|
|
|
|
&mut self,
|
|
|
|
|
|
event_type: PatchEventType,
|
|
|
|
|
|
changes: HashMap<PathBuf, FileChange>,
|
|
|
|
|
|
) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_patch_event(event_type, changes));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn add_active_exec_command(&mut self, call_id: String, command: Vec<String>) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_active_exec_command(call_id, command));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 16:12:15 -07:00
|
|
|
|
pub fn add_active_mcp_tool_call(
|
|
|
|
|
|
&mut self,
|
|
|
|
|
|
call_id: String,
|
|
|
|
|
|
server: String,
|
|
|
|
|
|
tool: String,
|
|
|
|
|
|
arguments: Option<JsonValue>,
|
|
|
|
|
|
) {
|
|
|
|
|
|
self.add_to_history(HistoryCell::new_active_mcp_tool_call(
|
|
|
|
|
|
call_id, server, tool, arguments,
|
|
|
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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
|
|
|
|
fn add_to_history(&mut self, cell: HistoryCell) {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
let width = self.cached_width.get();
|
2025-05-28 14:03:19 -07:00
|
|
|
|
let count = if width > 0 { cell.height(width) } else { 0 };
|
2025-05-14 16:51:41 -07:00
|
|
|
|
|
|
|
|
|
|
self.entries.push(Entry {
|
|
|
|
|
|
cell,
|
|
|
|
|
|
line_count: Cell::new(count),
|
|
|
|
|
|
});
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Remove all history entries and reset scrolling.
|
|
|
|
|
|
pub fn clear(&mut self) {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
self.entries.clear();
|
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
|
|
|
|
self.scroll_position = usize::MAX;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn record_completed_exec_command(
|
|
|
|
|
|
&mut self,
|
|
|
|
|
|
call_id: String,
|
|
|
|
|
|
stdout: String,
|
|
|
|
|
|
stderr: String,
|
|
|
|
|
|
exit_code: i32,
|
|
|
|
|
|
) {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
let width = self.cached_width.get();
|
|
|
|
|
|
for entry in self.entries.iter_mut() {
|
|
|
|
|
|
let cell = &mut entry.cell;
|
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
|
|
|
|
if let HistoryCell::ActiveExecCommand {
|
|
|
|
|
|
call_id: history_id,
|
|
|
|
|
|
command,
|
|
|
|
|
|
start,
|
|
|
|
|
|
..
|
|
|
|
|
|
} = cell
|
|
|
|
|
|
{
|
|
|
|
|
|
if &call_id == history_id {
|
|
|
|
|
|
*cell = HistoryCell::new_completed_exec_command(
|
|
|
|
|
|
command.clone(),
|
|
|
|
|
|
CommandOutput {
|
|
|
|
|
|
exit_code,
|
|
|
|
|
|
stdout,
|
|
|
|
|
|
stderr,
|
|
|
|
|
|
duration: start.elapsed(),
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
2025-05-14 16:51:41 -07:00
|
|
|
|
|
|
|
|
|
|
// Update cached line count.
|
|
|
|
|
|
if width > 0 {
|
2025-05-28 14:03:19 -07:00
|
|
|
|
entry.line_count.set(cell.height(width));
|
2025-05-14 16:51:41 -07:00
|
|
|
|
}
|
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
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-06 16:12:15 -07:00
|
|
|
|
|
|
|
|
|
|
pub fn record_completed_mcp_tool_call(
|
|
|
|
|
|
&mut self,
|
|
|
|
|
|
call_id: String,
|
|
|
|
|
|
success: bool,
|
|
|
|
|
|
result: Option<mcp_types::CallToolResult>,
|
|
|
|
|
|
) {
|
|
|
|
|
|
// Convert result into serde_json::Value early so we don't have to
|
|
|
|
|
|
// worry about lifetimes inside the match arm.
|
|
|
|
|
|
let result_val = result.map(|r| {
|
|
|
|
|
|
serde_json::to_value(r)
|
|
|
|
|
|
.unwrap_or_else(|_| serde_json::Value::String("<serialization error>".into()))
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-05-14 16:51:41 -07:00
|
|
|
|
let width = self.cached_width.get();
|
|
|
|
|
|
for entry in self.entries.iter_mut() {
|
2025-05-06 16:12:15 -07:00
|
|
|
|
if let HistoryCell::ActiveMcpToolCall {
|
|
|
|
|
|
call_id: history_id,
|
|
|
|
|
|
fq_tool_name,
|
|
|
|
|
|
invocation,
|
|
|
|
|
|
start,
|
|
|
|
|
|
..
|
2025-05-14 16:51:41 -07:00
|
|
|
|
} = &entry.cell
|
2025-05-06 16:12:15 -07:00
|
|
|
|
{
|
|
|
|
|
|
if &call_id == history_id {
|
|
|
|
|
|
let completed = HistoryCell::new_completed_mcp_tool_call(
|
|
|
|
|
|
fq_tool_name.clone(),
|
|
|
|
|
|
invocation.clone(),
|
|
|
|
|
|
*start,
|
|
|
|
|
|
success,
|
|
|
|
|
|
result_val,
|
|
|
|
|
|
);
|
2025-05-14 16:51:41 -07:00
|
|
|
|
entry.cell = completed;
|
|
|
|
|
|
|
|
|
|
|
|
if width > 0 {
|
2025-05-28 14:03:19 -07:00
|
|
|
|
entry.line_count.set(entry.cell.height(width));
|
2025-05-14 16:51:41 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-06 16:12:15 -07:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl WidgetRef for ConversationHistoryWidget {
|
|
|
|
|
|
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
|
|
|
|
|
|
let (title, border_style) = if self.has_input_focus {
|
|
|
|
|
|
(
|
2025-04-28 10:39:58 -07:00
|
|
|
|
"Messages (↑/↓ or j/k = line, b/space = page)",
|
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
|
|
|
|
Style::default().fg(Color::LightYellow),
|
|
|
|
|
|
)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
("Messages (tab to focus)", Style::default().dim())
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let block = Block::default()
|
|
|
|
|
|
.title(title)
|
|
|
|
|
|
.borders(Borders::ALL)
|
|
|
|
|
|
.border_type(BorderType::Rounded)
|
|
|
|
|
|
.border_style(border_style);
|
|
|
|
|
|
|
|
|
|
|
|
// Compute the inner area that will be available for the list after
|
|
|
|
|
|
// the surrounding `Block` is drawn.
|
|
|
|
|
|
let inner = block.inner(area);
|
|
|
|
|
|
let viewport_height = inner.height as usize;
|
|
|
|
|
|
|
2025-05-17 10:51:11 -07:00
|
|
|
|
// Cache (and if necessary recalculate) the wrapped line counts for every
|
|
|
|
|
|
// [`HistoryCell`] so that our scrolling math accounts for text
|
|
|
|
|
|
// wrapping. We always reserve one column on the right-hand side for the
|
|
|
|
|
|
// scrollbar so that the content never renders "under" the scrollbar.
|
|
|
|
|
|
let effective_width = inner.width.saturating_sub(1);
|
|
|
|
|
|
|
|
|
|
|
|
if effective_width == 0 {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
return; // Nothing to draw – avoid division by zero.
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-17 10:51:11 -07:00
|
|
|
|
// Recompute cache if the effective width changed.
|
|
|
|
|
|
let num_lines: usize = if self.cached_width.get() != effective_width {
|
|
|
|
|
|
self.cached_width.set(effective_width);
|
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-05-14 16:51:41 -07:00
|
|
|
|
let mut num_lines: usize = 0;
|
|
|
|
|
|
for entry in &self.entries {
|
2025-05-28 14:03:19 -07:00
|
|
|
|
let count = entry.cell.height(effective_width);
|
2025-05-14 16:51:41 -07:00
|
|
|
|
num_lines += count;
|
|
|
|
|
|
entry.line_count.set(count);
|
|
|
|
|
|
}
|
|
|
|
|
|
num_lines
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.entries.iter().map(|e| e.line_count.get()).sum()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Determine the scroll position. Note the existing value of
|
|
|
|
|
|
// `self.scroll_position` could exceed the maximum scroll offset if the
|
|
|
|
|
|
// user made the window wider since the last render.
|
|
|
|
|
|
let max_scroll = num_lines.saturating_sub(viewport_height);
|
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
|
|
|
|
let scroll_pos = if self.scroll_position == usize::MAX {
|
|
|
|
|
|
max_scroll
|
|
|
|
|
|
} else {
|
|
|
|
|
|
self.scroll_position.min(max_scroll)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-05-14 16:51:41 -07:00
|
|
|
|
// ------------------------------------------------------------------
|
2025-05-28 14:03:19 -07:00
|
|
|
|
// Render order:
|
|
|
|
|
|
// 1. Clear full widget area (avoid artifacts from prior frame).
|
|
|
|
|
|
// 2. Draw the surrounding Block (border and title).
|
|
|
|
|
|
// 3. Render *each* visible HistoryCell into its own sub-Rect while
|
|
|
|
|
|
// respecting partial visibility at the top and bottom.
|
|
|
|
|
|
// 4. Draw the scrollbar track / thumb in the reserved column.
|
2025-05-14 16:51:41 -07:00
|
|
|
|
// ------------------------------------------------------------------
|
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-05-28 14:03:19 -07:00
|
|
|
|
// Clear entire widget area first.
|
|
|
|
|
|
Clear.render(area, buf);
|
2025-05-14 16:51:41 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
// Draw border + title.
|
|
|
|
|
|
block.render(area, buf);
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
// Calculate which cells are visible for the current scroll position
|
|
|
|
|
|
// and paint them one by one.
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
let mut y_cursor = inner.y; // first line inside viewport
|
|
|
|
|
|
let mut remaining_height = inner.height as usize;
|
|
|
|
|
|
let mut lines_to_skip = scroll_pos; // number of wrapped lines to skip (above viewport)
|
2025-05-14 16:51:41 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
for entry in &self.entries {
|
|
|
|
|
|
let cell_height = entry.line_count.get();
|
2025-05-14 16:51:41 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
// Completely above viewport? Skip whole cell.
|
|
|
|
|
|
if lines_to_skip >= cell_height {
|
|
|
|
|
|
lines_to_skip -= cell_height;
|
|
|
|
|
|
continue;
|
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-05-28 14:03:19 -07:00
|
|
|
|
// Determine how much of this cell is visible.
|
|
|
|
|
|
let visible_height = (cell_height - lines_to_skip).min(remaining_height);
|
2025-05-17 10:51:11 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
if visible_height == 0 {
|
|
|
|
|
|
break; // no space left
|
|
|
|
|
|
}
|
2025-05-17 10:51:11 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
let cell_rect = Rect {
|
|
|
|
|
|
x: inner.x,
|
|
|
|
|
|
y: y_cursor,
|
|
|
|
|
|
width: effective_width,
|
|
|
|
|
|
height: visible_height as u16,
|
|
|
|
|
|
};
|
2025-05-17 10:51:11 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
entry.cell.render_window(lines_to_skip, cell_rect, buf);
|
2025-05-17 10:51:11 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
// Advance cursor inside viewport.
|
|
|
|
|
|
y_cursor += visible_height as u16;
|
|
|
|
|
|
remaining_height -= visible_height;
|
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-05-28 14:03:19 -07:00
|
|
|
|
// After the first (possibly partially skipped) cell, we no longer
|
|
|
|
|
|
// need to skip lines at the top.
|
|
|
|
|
|
lines_to_skip = 0;
|
2025-05-17 10:51:11 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
if remaining_height == 0 {
|
|
|
|
|
|
break; // viewport filled
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-17 10:51:11 -07:00
|
|
|
|
|
2025-05-28 14:03:19 -07:00
|
|
|
|
// Always render a scrollbar *track* so the reserved column is filled.
|
2025-05-17 10:51:11 -07:00
|
|
|
|
let overflow = num_lines.saturating_sub(viewport_height);
|
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-05-17 10:51:11 -07:00
|
|
|
|
let mut scroll_state = ScrollbarState::default()
|
|
|
|
|
|
// The Scrollbar widget expects the *content* height minus the
|
|
|
|
|
|
// viewport height. When there is no overflow we still provide 0
|
|
|
|
|
|
// so that the widget renders only the track without a thumb.
|
|
|
|
|
|
.content_length(overflow)
|
|
|
|
|
|
.position(scroll_pos);
|
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-05-17 10:51:11 -07:00
|
|
|
|
{
|
2025-05-14 16:51:41 -07:00
|
|
|
|
// Choose a thumb color that stands out only when this pane has focus so that the
|
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
|
|
|
|
// user’s attention is naturally drawn to the active viewport. When unfocused we show
|
2025-05-17 10:51:11 -07:00
|
|
|
|
// a low-contrast thumb so the scrollbar fades into the background without becoming
|
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
|
|
|
|
// invisible.
|
|
|
|
|
|
let thumb_style = if self.has_input_focus {
|
|
|
|
|
|
Style::reset().fg(Color::LightYellow)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
Style::reset().fg(Color::Gray)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-05-17 10:51:11 -07:00
|
|
|
|
// By default the Scrollbar widget inherits any style that was
|
|
|
|
|
|
// present in the underlying buffer cells. That means if a colored
|
|
|
|
|
|
// line happens to be underneath the scrollbar, the track (and
|
|
|
|
|
|
// potentially the thumb) adopt that color. Explicitly setting the
|
|
|
|
|
|
// track/thumb styles ensures we always draw the scrollbar with a
|
|
|
|
|
|
// consistent palette regardless of what content is behind it.
|
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
|
|
|
|
StatefulWidget::render(
|
|
|
|
|
|
Scrollbar::new(ScrollbarOrientation::VerticalRight)
|
|
|
|
|
|
.begin_symbol(Some("↑"))
|
|
|
|
|
|
.end_symbol(Some("↓"))
|
|
|
|
|
|
.begin_style(Style::reset().fg(Color::DarkGray))
|
|
|
|
|
|
.end_style(Style::reset().fg(Color::DarkGray))
|
|
|
|
|
|
.thumb_symbol("█")
|
|
|
|
|
|
.thumb_style(thumb_style)
|
|
|
|
|
|
.track_symbol(Some("│"))
|
|
|
|
|
|
.track_style(Style::reset().fg(Color::DarkGray)),
|
|
|
|
|
|
inner,
|
|
|
|
|
|
buf,
|
|
|
|
|
|
&mut scroll_state,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2025-05-14 16:51:41 -07:00
|
|
|
|
|
|
|
|
|
|
// Update auxiliary stats that the scroll handlers rely on.
|
|
|
|
|
|
self.num_rendered_lines.set(num_lines);
|
|
|
|
|
|
self.last_viewport_height.set(viewport_height);
|
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-05-14 16:51:41 -07:00
|
|
|
|
|
|
|
|
|
|
/// Common [`Wrap`] configuration used for both measurement and rendering so
|
|
|
|
|
|
/// they stay in sync.
|
|
|
|
|
|
#[inline]
|
2025-05-28 14:03:19 -07:00
|
|
|
|
pub(crate) const fn wrap_cfg() -> ratatui::widgets::Wrap {
|
2025-05-14 16:51:41 -07:00
|
|
|
|
ratatui::widgets::Wrap { trim: false }
|
|
|
|
|
|
}
|