Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions codex-rs/acp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub use backend::AcpBackendConfig;
pub use connection::AcpConnection;
pub use connection::ApprovalRequest;
pub use registry::AcpAgentConfig;
pub use registry::AcpAgentInfo;
pub use registry::AcpProviderInfo;
pub use registry::get_agent_config;
pub use registry::list_available_agents;
pub use tracing_setup::init_file_tracing;
pub use translator::TranslatedEvent;
pub use translator::translate_session_update;
Expand Down
43 changes: 43 additions & 0 deletions codex-rs/acp/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,49 @@
use anyhow::Result;
use std::time::Duration;

/// Information about an available ACP agent for display in the picker
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AcpAgentInfo {
/// Model name used to select this agent (e.g., "mock-model", "gemini-2.5-flash")
pub model_name: String,
/// Display name shown in the picker
pub display_name: String,
/// Description of the agent
pub description: String,
/// Provider slug for this agent
pub provider_slug: String,
}

/// Get list of all available ACP agents for the agent picker
pub fn list_available_agents() -> Vec<AcpAgentInfo> {
vec![
AcpAgentInfo {
model_name: "mock-model".to_string(),
display_name: "Mock ACP".to_string(),
description: "Mock agent for testing".to_string(),
provider_slug: "mock-acp".to_string(),
},
AcpAgentInfo {
model_name: "mock-model-alt".to_string(),
display_name: "Mock ACP Alt".to_string(),
description: "Alternate mock agent for testing".to_string(),
provider_slug: "mock-acp-alt".to_string(),
},
AcpAgentInfo {
model_name: "gemini-2.5-flash".to_string(),
display_name: "Gemini 2.5 Flash".to_string(),
description: "Google Gemini via ACP".to_string(),
provider_slug: "gemini-acp".to_string(),
},
AcpAgentInfo {
model_name: "claude-4.5".to_string(),
display_name: "Claude 4.5".to_string(),
description: "Anthropic Claude via ACP".to_string(),
provider_slug: "claude-acp".to_string(),
},
]
}

/// Default idle timeout for ACP streaming (5 minutes)
const DEFAULT_STREAM_IDLE_TIMEOUT: Duration = Duration::from_secs(300);

Expand Down
11 changes: 9 additions & 2 deletions codex-rs/tui-pty-e2e/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ This delay allows the PTY subprocess time to process input and update the displa
| `@/codex-rs/tui-pty-e2e/tests/input_handling.rs` | Text editing, backspace, Ctrl-C clearing, arrow key navigation with snapshot testing |
| `@/codex-rs/tui-pty-e2e/tests/streaming.rs` | Prompt submission with timing delays, agent response streaming |
| `@/codex-rs/tui-pty-e2e/tests/acp_mode.rs` | ACP mode startup, response flow, and approval bridging - validates TUI works with ACP wire API and mock agent; includes test for permission request display |
| `@/codex-rs/tui-pty-e2e/tests/agent_switching.rs` | ACP agent subprocess lifecycle - verifies subprocess spawning, cleanup on session switch, and different agents use different processes (Linux only) |
| `@/codex-rs/tui-pty-e2e/tests/agent_switching.rs` | ACP agent subprocess lifecycle and event isolation - verifies subprocess spawning, cleanup on session switch, different agents use different processes, and event filtering prevents cross-agent contamination (Linux only) |
| `@/codex-rs/tui-pty-e2e/tests/live_acp.rs` | Live authenticated ACP tests for Gemini and Claude with real API connections (opt-in, marked `#[ignore]`) |

**Snapshot Files:**
Expand Down Expand Up @@ -237,7 +237,9 @@ See `@/codex-rs/mock-acp-agent/docs.md` for full list of env vars.

**Agent Subprocess Lifecycle Testing (`agent_switching.rs`):**

Linux-only tests that verify ACP subprocess lifecycle management by parsing the `.codex-acp.log` file for PID entries:
Linux-only tests that verify ACP subprocess lifecycle management and event isolation:

*Subprocess Management Tests:*
- `acp_log_path()` method on `TuiSession` returns the path to the ACP tracing log file
- Tests extract PIDs from log lines matching `"ACP agent spawned (pid: Some(...))"`
- Uses `/proc/{pid}` filesystem to verify process existence and zombie state
Expand All @@ -248,6 +250,11 @@ Linux-only tests that verify ACP subprocess lifecycle management by parsing the
- Cleanup happens when session switches, not when individual prompt turns end
- Different models (`mock-model` vs `mock-model-alt`) spawn different subprocesses

*Event Isolation Tests:*
- `extract_agent_messages_from_log()` helper parses `Mock agent:` log entries from ACP log file
- `test_agent_switch_message_flow_mock_to_mock_alt` verifies that after switching agents, the NEW agent receives and responds to prompts (catches race conditions where OLD agent events could leak)
- `test_agent_switch_logs_correct_sequence` verifies the expected log sequence during agent switch: agent receives prompt, logs receipt, sends response

**Binary Discovery:**

`codex_binary_path()` locates the compiled binary:
Expand Down
Loading
Loading