Files
codex/codex-rs/tui/src/test_support.rs
Eric Traut f2bc2f26a9 Remove core protocol dependency [2/2] (#20325)
## Why

With the local model layer and app-server routing in place from PR1,
this PR moves the active TUI runtime onto app-server notifications. The
affected pieces share the same event flow, so the command surface,
session state, bottom-pane prompts, chat rendering, history/status
views, and tests move together to keep the stacked branch buildable.

This PR also removes the obsolete compatibility surface that is no
longer used after the migration. The proposed protocol-boundary verifier
layer was dropped from the stack; enforcing that final boundary will be
simpler once `codex-tui` no longer needs any `codex_protocol`
references.

This PR is part 2 of a 2-PR stack:

1. Add TUI-owned replacement models and extract app-server event
routing.
2. Move the active TUI flow to app-server notifications and delete
obsolete adapter code.

## What changed

- Rewired app command and session handling to use app-server request and
notification shapes.
- Moved approval overlays, request-user-input flows, MCP elicitation,
realtime events, and review commands onto the app-server-facing model
surface.
- Updated chat rendering, history cells, status views, multi-agent UI,
replay state, and TUI tests to use app-server notifications plus the
local models introduced in PR1.
- Deleted `codex-rs/tui/src/app/app_server_adapter.rs` and the
superseded `chatwidget/tests/background_events.rs` fixture path.

## Verification

- `cargo check -p codex-tui --tests`
- Top of stack: `cargo test -p codex-tui`
2026-04-30 11:34:34 -07:00

41 lines
1.0 KiB
Rust

pub(crate) use codex_utils_absolute_path::test_support::PathBufExt;
pub(crate) use codex_utils_absolute_path::test_support::test_path_buf;
use serde::Serialize;
use serde::de::DeserializeOwned;
pub(crate) fn test_path_display(path: &str) -> String {
test_path_buf(path).display().to_string()
}
pub(crate) fn session_source_cli<T>() -> T
where
T: DeserializeOwned,
{
from_app_server_wire(codex_app_server_protocol::SessionSource::Cli)
}
pub(crate) fn skill_scope_user<T>() -> T
where
T: DeserializeOwned,
{
from_app_server_wire(codex_app_server_protocol::SkillScope::User)
}
pub(crate) fn skill_scope_repo<T>() -> T
where
T: DeserializeOwned,
{
from_app_server_wire(codex_app_server_protocol::SkillScope::Repo)
}
fn from_app_server_wire<T>(value: impl Serialize) -> T
where
T: DeserializeOwned,
{
serde_json::to_value(value)
.and_then(serde_json::from_value)
.unwrap_or_else(|err| {
panic!("app-server wire value should map to legacy helper type: {err}")
})
}