Commit Graph

3 Commits

  • Improve handling of config and rules errors for app server clients (#9182)
    When an invalid config.toml key or value is detected, the CLI currently
    just quits. This leaves the VSCE in a dead state.
    
    This PR changes the behavior to not quit and bubble up the config error
    to users to make it actionable. It also surfaces errors related to
    "rules" parsing.
    
    This allows us to surface these errors to users in the VSCE, like this:
    
    <img width="342" height="129" alt="Screenshot 2026-01-13 at 4 29 22 PM"
    src="https://github.com/user-attachments/assets/a79ffbe7-7604-400c-a304-c5165b6eebc4"
    />
    
    <img width="346" height="244" alt="Screenshot 2026-01-13 at 4 45 06 PM"
    src="https://github.com/user-attachments/assets/de874f7c-16a2-4a95-8c6d-15f10482e67b"
    />
  • fix: integration test for #9011 (#9166)
    Adds an integration test for the new behavior introduced in
    https://github.com/openai/codex/pull/9011. The work to create the test
    setup was substantial enough that I thought it merited a separate PR.
    
    This integration test spawns `codex` in TUI mode, which requires
    spawning a PTY to run successfully, so I had to introduce quite a bit of
    scaffolding in `run_codex_cli()`. I was surprised to discover that we
    have not done this in our codebase before, so perhaps this should get
    moved to a common location so it can be reused.
    
    The test itself verifies that a malformed `rules` in `$CODEX_HOME`
    prints a human-readable error message and exits nonzero.
  • Sync tui2 with tui and keep dual-run glue (#7965)
    - Copy latest tui sources into tui2
    - Restore notifications, tests, and styles
    - Keep codex-tui interop conversions and snapshots
    
    The expected changes that are necessary to make this work are still in
    place:
    
    diff -ru codex-rs/tui codex-rs/tui2 --exclude='*.snap'
    --exclude='*.snap.new'
    
    ```diff
    diff -ru --ex codex-rs/tui/Cargo.toml codex-rs/tui2/Cargo.toml
    --- codex-rs/tui/Cargo.toml	2025-12-12 16:39:12
    +++ codex-rs/tui2/Cargo.toml	2025-12-12 17:31:01
    @@ -1,15 +1,15 @@
     [package]
    -name = "codex-tui"
    +name = "codex-tui2"
     version.workspace = true
     edition.workspace = true
     license.workspace = true
     
     [[bin]]
    -name = "codex-tui"
    +name = "codex-tui2"
     path = "src/main.rs"
     
     [lib]
    -name = "codex_tui"
    +name = "codex_tui2"
     path = "src/lib.rs"
     
     [features]
    @@ -42,6 +42,7 @@
     codex-login = { workspace = true }
     codex-protocol = { workspace = true }
     codex-utils-absolute-path = { workspace = true }
    +codex-tui = { workspace = true }
     color-eyre = { workspace = true }
     crossterm = { workspace = true, features = ["bracketed-paste", "event-stream"] }
     derive_more = { workspace = true, features = ["is_variant"] }
    diff -ru --ex codex-rs/tui/src/app.rs codex-rs/tui2/src/app.rs
    --- codex-rs/tui/src/app.rs	2025-12-12 16:39:05
    +++ codex-rs/tui2/src/app.rs	2025-12-12 17:30:36
    @@ -69,6 +69,16 @@
         pub update_action: Option<UpdateAction>,
     }
     
    +impl From<AppExitInfo> for codex_tui::AppExitInfo {
    +    fn from(info: AppExitInfo) -> Self {
    +        codex_tui::AppExitInfo {
    +            token_usage: info.token_usage,
    +            conversation_id: info.conversation_id,
    +            update_action: info.update_action.map(Into::into),
    +        }
    +    }
    +}
    +
     fn session_summary(
         token_usage: TokenUsage,
         conversation_id: Option<ConversationId>,
    Only in codex-rs/tui/src/bin: md-events.rs
    Only in codex-rs/tui2/src/bin: md-events2.rs
    diff -ru --ex codex-rs/tui/src/cli.rs codex-rs/tui2/src/cli.rs
    --- codex-rs/tui/src/cli.rs	2025-11-19 13:40:42
    +++ codex-rs/tui2/src/cli.rs	2025-12-12 17:30:43
    @@ -88,3 +88,28 @@
         #[clap(skip)]
         pub config_overrides: CliConfigOverrides,
     }
    +
    +impl From<codex_tui::Cli> for Cli {
    +    fn from(cli: codex_tui::Cli) -> Self {
    +        Self {
    +            prompt: cli.prompt,
    +            images: cli.images,
    +            resume_picker: cli.resume_picker,
    +            resume_last: cli.resume_last,
    +            resume_session_id: cli.resume_session_id,
    +            resume_show_all: cli.resume_show_all,
    +            model: cli.model,
    +            oss: cli.oss,
    +            oss_provider: cli.oss_provider,
    +            config_profile: cli.config_profile,
    +            sandbox_mode: cli.sandbox_mode,
    +            approval_policy: cli.approval_policy,
    +            full_auto: cli.full_auto,
    +            dangerously_bypass_approvals_and_sandbox: cli.dangerously_bypass_approvals_and_sandbox,
    +            cwd: cli.cwd,
    +            web_search: cli.web_search,
    +            add_dir: cli.add_dir,
    +            config_overrides: cli.config_overrides,
    +        }
    +    }
    +}
    diff -ru --ex codex-rs/tui/src/main.rs codex-rs/tui2/src/main.rs
    --- codex-rs/tui/src/main.rs	2025-12-12 16:39:05
    +++ codex-rs/tui2/src/main.rs	2025-12-12 16:39:06
    @@ -1,8 +1,8 @@
     use clap::Parser;
     use codex_arg0::arg0_dispatch_or_else;
     use codex_common::CliConfigOverrides;
    -use codex_tui::Cli;
    -use codex_tui::run_main;
    +use codex_tui2::Cli;
    +use codex_tui2::run_main;
     
     #[derive(Parser, Debug)]
     struct TopCli {
    diff -ru --ex codex-rs/tui/src/update_action.rs codex-rs/tui2/src/update_action.rs
    --- codex-rs/tui/src/update_action.rs	2025-11-19 11:11:47
    +++ codex-rs/tui2/src/update_action.rs	2025-12-12 17:30:48
    @@ -9,6 +9,20 @@
         BrewUpgrade,
     }
     
    +impl From<UpdateAction> for codex_tui::update_action::UpdateAction {
    +    fn from(action: UpdateAction) -> Self {
    +        match action {
    +            UpdateAction::NpmGlobalLatest => {
    +                codex_tui::update_action::UpdateAction::NpmGlobalLatest
    +            }
    +            UpdateAction::BunGlobalLatest => {
    +                codex_tui::update_action::UpdateAction::BunGlobalLatest
    +            }
    +            UpdateAction::BrewUpgrade => codex_tui::update_action::UpdateAction::BrewUpgrade,
    +        }
    +    }
    +}
    +
     impl UpdateAction {
         /// Returns the list of command-line arguments for invoking the update.
         pub fn command_args(self) -> (&'static str, &'static [&'static str]) {
    ```