mirror of
https://github.com/openai/codex.git
synced 2026-05-24 21:14:51 +00:00
## Why This stack moves `codex-tui` away from the core protocol event surface and toward app-server API shapes plus TUI-owned local models. This first PR sets up the lower-risk foundation: it introduces the local model surface and extracts app-server event routing into focused TUI modules while preserving the existing behavior for the larger migration in PR2. This PR is part 1 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 - Added TUI-owned approval, diff, session state, session resume, token usage, and user-message models. - Added `app/app_server_event_targets.rs` and `app/app_server_events.rs` to hold app-server event targeting and dispatch logic outside `app.rs`. - Updated app/status tests to use the local model layer and added focused routing coverage. - Boxed a few large async TUI test futures so this base layer remains checkable without overflowing the default test stack. ## Verification - `cargo check -p codex-tui --tests`
46 lines
2.0 KiB
Rust
46 lines
2.0 KiB
Rust
//! Canonical TUI session state shared across app-server routing, chat display, and status UI.
|
|
//!
|
|
//! The app-server API is the boundary for session lifecycle events. Once those responses enter
|
|
//! TUI, this module holds the small internal state shape used by app orchestration and widgets.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use codex_app_server_protocol::AskForApproval;
|
|
use codex_protocol::ThreadId;
|
|
use codex_protocol::models::ActivePermissionProfile;
|
|
use codex_protocol::models::PermissionProfile;
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub(crate) struct SessionNetworkProxyRuntime {
|
|
pub(crate) http_addr: String,
|
|
pub(crate) socks_addr: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub(crate) struct ThreadSessionState {
|
|
pub(crate) thread_id: ThreadId,
|
|
pub(crate) forked_from_id: Option<ThreadId>,
|
|
pub(crate) fork_parent_title: Option<String>,
|
|
pub(crate) thread_name: Option<String>,
|
|
pub(crate) model: String,
|
|
pub(crate) model_provider_id: String,
|
|
pub(crate) service_tier: Option<codex_protocol::config_types::ServiceTier>,
|
|
pub(crate) approval_policy: AskForApproval,
|
|
pub(crate) approvals_reviewer: codex_protocol::config_types::ApprovalsReviewer,
|
|
/// Canonical active permissions for this session. Legacy app-server
|
|
/// responses are converted to a profile at ingestion time using the
|
|
/// response cwd so cached sessions do not reinterpret cwd-bound grants.
|
|
pub(crate) permission_profile: PermissionProfile,
|
|
/// Named or implicit built-in profile that produced `permission_profile`,
|
|
/// when the server knows it.
|
|
pub(crate) active_permission_profile: Option<ActivePermissionProfile>,
|
|
pub(crate) cwd: AbsolutePathBuf,
|
|
pub(crate) instruction_source_paths: Vec<AbsolutePathBuf>,
|
|
pub(crate) reasoning_effort: Option<codex_protocol::openai_models::ReasoningEffort>,
|
|
pub(crate) history_log_id: u64,
|
|
pub(crate) history_entry_count: u64,
|
|
pub(crate) network_proxy: Option<SessionNetworkProxyRuntime>,
|
|
pub(crate) rollout_path: Option<PathBuf>,
|
|
}
|