mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Add a structured status-line snapshot for the displayed thread (#61403)
## What changed Add a serializable `StatuslineState` containing app and status-line configuration, thread identity, agent state, model settings, approvals, and permissions. Reuse the displayed status line's run-state and profile logic, and serialize status-line items with their canonical configuration IDs. Omit the snapshot for read-only history or when no thread is attached. Omit service-tier, approval, and permission fields until thread settings are confirmed. Use an inferred child thread's reported model and reasoning effort without inheriting the parent's collaboration mode. ## Testing Add coverage for serialized settings and canonical item IDs, inferred child-thread values, settings confirmation, and snapshot availability before and after interactive resume. GitOrigin-RevId: 512bdff9b92d886a7764f16955206109f56437d3
This commit is contained in:
@@ -1943,6 +1943,7 @@ enabled = false
|
||||
app.chat_widget
|
||||
.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
|
||||
@@ -36,6 +36,7 @@ pub(in crate::app) fn user_cell(message: &str) -> Arc<dyn HistoryCell> {
|
||||
pub(in crate::app) fn attach_thread(app: &mut App, thread_id: ThreadId) {
|
||||
app.chat_widget.handle_thread_session(ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -7464,6 +7464,15 @@ async fn inactive_thread_approval_badge_clears_after_turn_completion_notificatio
|
||||
#[tokio::test]
|
||||
async fn inactive_thread_started_notification_initializes_replay_session() -> Result<()> {
|
||||
let mut app = make_test_app().await;
|
||||
app.chat_widget
|
||||
.set_feature_enabled(Feature::CliDaybreak, /*enabled*/ true);
|
||||
set_chatgpt_auth(&mut app.chat_widget);
|
||||
let mut model = crate::test_support::TEST_MODEL_PRESETS[0].clone();
|
||||
model.model = "gpt-agent".into();
|
||||
model.available_access_programs = Some(codex_protocol::openai_models::ModelAccessPrograms {
|
||||
cyber: vec![codex_protocol::turn_input::CyberAccessProgram::DaybreakBlue],
|
||||
});
|
||||
crate::chatwidget::tests::helpers::set_test_model_catalog(&mut app.chat_widget, vec![model]);
|
||||
let temp_dir = tempdir()?;
|
||||
let main_thread_id =
|
||||
ThreadId::from_string("00000000-0000-0000-0000-000000000101").expect("valid thread");
|
||||
@@ -7473,6 +7482,14 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
let shared_root = test_path_buf("/tmp/shared").abs();
|
||||
let primary_session = ThreadSessionState {
|
||||
read_only_history: true,
|
||||
collaboration_mode: Some(Box::new(CollaborationMode {
|
||||
mode: codex_protocol::config_types::ModeKind::Plan,
|
||||
settings: codex_protocol::config_types::Settings {
|
||||
model: "parent-model".into(),
|
||||
reasoning_effort: Some(ReasoningEffortConfig::High),
|
||||
developer_instructions: None,
|
||||
},
|
||||
})),
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: WindowsSandboxHost::Local,
|
||||
approval_policy: AskForApproval::OnRequest,
|
||||
@@ -7517,9 +7534,9 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
project_id: None,
|
||||
daybreak_enabled: Some(true),
|
||||
history_mode: Default::default(),
|
||||
model_provider: "agent-provider".to_string(),
|
||||
model_provider: "openai".to_string(),
|
||||
model: Some("gpt-agent".to_string()),
|
||||
reasoning_effort: None,
|
||||
reasoning_effort: Some(ReasoningEffortConfig::Low),
|
||||
created_at: 1,
|
||||
updated_at: 2,
|
||||
recency_at: Some(2),
|
||||
@@ -7540,15 +7557,16 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
)
|
||||
.await?;
|
||||
|
||||
let store = app
|
||||
let session = app
|
||||
.thread_event_channels
|
||||
.get(&agent_thread_id)
|
||||
.expect("agent thread channel")
|
||||
.store
|
||||
.lock()
|
||||
.await;
|
||||
let session = store.session.clone().expect("inferred session");
|
||||
drop(store);
|
||||
.await
|
||||
.session
|
||||
.take()
|
||||
.expect("inferred session");
|
||||
|
||||
assert!(!session.read_only_history);
|
||||
assert_eq!(session.thread_id, agent_thread_id);
|
||||
@@ -7556,7 +7574,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
assert_eq!(session.windows_sandbox_host, WindowsSandboxHost::Remote);
|
||||
assert_eq!(session.thread_name, Some("agent thread".to_string()));
|
||||
assert_eq!(session.model, "gpt-agent");
|
||||
assert_eq!(session.model_provider_id, "agent-provider");
|
||||
assert_eq!(session.model_provider_id, "openai");
|
||||
assert_eq!(session.approval_policy, primary_session.approval_policy);
|
||||
assert_eq!(session.cwd.as_path(), test_path_buf("/tmp/agent").as_path());
|
||||
assert_eq!(
|
||||
@@ -7575,6 +7593,16 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
})
|
||||
);
|
||||
|
||||
app.chat_widget.handle_thread_session(session);
|
||||
let state = serde_json::to_value(app.chat_widget.statusline_state())?;
|
||||
let thread = &state["thread"];
|
||||
assert_eq!(thread["model"]["id"], "gpt-agent");
|
||||
assert_eq!(thread["model"]["reasoning_level"], "low");
|
||||
assert_eq!(thread["model"]["access_program"], "daybreak_blue");
|
||||
assert!(thread["model"].get("service_tier").is_none());
|
||||
assert!(thread.get("approval").is_none());
|
||||
assert!(thread.get("permissions").is_none());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -7648,17 +7676,21 @@ async fn inactive_thread_started_notification_preserves_primary_model_when_path_
|
||||
)
|
||||
.await?;
|
||||
|
||||
let store = app
|
||||
let session = app
|
||||
.thread_event_channels
|
||||
.get(&agent_thread_id)
|
||||
.expect("agent thread channel")
|
||||
.store
|
||||
.lock()
|
||||
.await;
|
||||
let session = store.session.clone().expect("inferred session");
|
||||
|
||||
.await
|
||||
.session
|
||||
.take()
|
||||
.expect("inferred session");
|
||||
assert_eq!(session.model, primary_session.model);
|
||||
|
||||
app.chat_widget.handle_thread_session(session);
|
||||
let state = serde_json::to_value(app.chat_widget.statusline_state())?;
|
||||
assert_eq!(state["thread"]["model"]["id"], primary_session.model);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -8838,6 +8870,7 @@ async fn render_clear_ui_header_after_long_transcript_for_snapshot() -> String {
|
||||
let make_header = |is_first| -> Arc<dyn HistoryCell> {
|
||||
let session = ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -9552,6 +9585,7 @@ async fn replace_goal_confirmation_snapshot() {
|
||||
pub(super) fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -10869,6 +10903,7 @@ async fn backtrack_selection_preserves_selected_prompt_and_requests_branch() {
|
||||
let make_header = |is_first| {
|
||||
let session = ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -10943,6 +10978,7 @@ async fn backtrack_selection_preserves_selected_prompt_and_requests_branch() {
|
||||
app.chat_widget
|
||||
.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: base_id,
|
||||
@@ -12340,6 +12376,7 @@ async fn new_session_requests_shutdown_for_previous_conversation() {
|
||||
let thread_id = ThreadId::new();
|
||||
let event = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -13120,6 +13157,7 @@ async fn clear_only_ui_reset_preserves_chat_session_state() {
|
||||
app.chat_widget
|
||||
.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -1898,6 +1898,7 @@ async fn read_only_history_hides_the_statusline_until_interactive_resume() -> Re
|
||||
.await?;
|
||||
app.enqueue_primary_thread_session(view.session, view.turns)
|
||||
.await?;
|
||||
assert!(app.chat_widget.statusline_state().is_none());
|
||||
let footer = render_bottom_popup(&app.chat_widget, /*width*/ 100);
|
||||
insta::assert_snapshot!(footer, @r"
|
||||
› Ask Codex to do anything
|
||||
@@ -1927,6 +1928,7 @@ async fn read_only_history_hides_the_statusline_until_interactive_resume() -> Re
|
||||
);
|
||||
app.enqueue_primary_thread_session(live.session, live.turns)
|
||||
.await?;
|
||||
assert!(app.chat_widget.statusline_state().is_some());
|
||||
let footer = render_bottom_popup(&app.chat_widget, /*width*/ 100);
|
||||
assert!(footer.contains(&thread_id.to_string()), "{footer}");
|
||||
app.chat_widget
|
||||
|
||||
@@ -745,6 +745,7 @@ mod tests {
|
||||
fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -1431,6 +1431,7 @@ impl App {
|
||||
) -> Option<ThreadSessionState> {
|
||||
let mut session = self.primary_session_configured.clone()?;
|
||||
session.read_only_history = false;
|
||||
session.thread_settings_confirmed = false;
|
||||
session.thread_id = thread_id;
|
||||
// The primary session supplies defaults. The new thread supplies its own fork parent.
|
||||
session.set_fork_parent(notification.thread.forked_from_id.as_deref());
|
||||
@@ -1438,6 +1439,11 @@ impl App {
|
||||
session.windows_sandbox_host = crate::windows_sandbox::host_from_environments(
|
||||
notification.thread.environments.as_deref(),
|
||||
);
|
||||
// A parent’s collaboration mode can override the child’s reported model and effort.
|
||||
session.collaboration_mode = None;
|
||||
session
|
||||
.reasoning_effort
|
||||
.clone_from(¬ification.thread.reasoning_effort);
|
||||
session.thread_name = notification.thread.name.clone();
|
||||
session.model_provider_id = notification.thread.model_provider.clone();
|
||||
session
|
||||
|
||||
@@ -82,6 +82,7 @@ impl App {
|
||||
if session.thread_id != thread_id {
|
||||
// `thread/read` does not include all thread settings, so do not carry
|
||||
// thread-scoped state from the currently active session.
|
||||
session.thread_settings_confirmed = false;
|
||||
session.collaboration_mode = None;
|
||||
session.daybreak_enabled = false;
|
||||
}
|
||||
@@ -89,6 +90,7 @@ impl App {
|
||||
} else {
|
||||
ThreadSessionState {
|
||||
read_only_history: true,
|
||||
thread_settings_confirmed: false,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -177,6 +179,7 @@ mod tests {
|
||||
fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -298,6 +298,7 @@ pub(super) fn apply_thread_settings_to_session(
|
||||
.clone_from(&settings.model);
|
||||
collaboration_mode.settings.reasoning_effort = settings.effort.clone();
|
||||
session.collaboration_mode = Some(Box::new(collaboration_mode));
|
||||
session.thread_settings_confirmed = true;
|
||||
}
|
||||
|
||||
fn thread_settings_update_has_changes(params: &ThreadSettingsUpdateParams) -> bool {
|
||||
|
||||
@@ -3132,6 +3132,7 @@ async fn thread_session_state_from_thread_response(
|
||||
let (log_id, entry_count) = codex_message_history::history_metadata(&history_config).await;
|
||||
Ok(ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host,
|
||||
thread_id,
|
||||
|
||||
@@ -168,6 +168,13 @@ pub(crate) enum StatusLineItem {
|
||||
Provider,
|
||||
}
|
||||
|
||||
impl serde::Serialize for StatusLineItem {
|
||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
// Display emits the canonical config ID even when the item was parsed from an alias.
|
||||
serializer.collect_str(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl StatusLineItem {
|
||||
/// User-visible description shown in the popup.
|
||||
pub(crate) fn description(self) -> &'static str {
|
||||
|
||||
@@ -400,6 +400,7 @@ use self::status_state::TerminalTitleStatusKind;
|
||||
mod status_controls;
|
||||
mod status_surface_commands;
|
||||
mod status_surfaces;
|
||||
pub(crate) mod statusline_state;
|
||||
use self::status_surface_commands::StatusSurfaceOverrides;
|
||||
mod streaming;
|
||||
use self::status_surfaces::CachedProjectRootName;
|
||||
@@ -690,6 +691,7 @@ pub(crate) struct ChatWidget {
|
||||
blocks_direct_input: bool,
|
||||
external_writer_view: bool,
|
||||
read_only_history: bool,
|
||||
thread_settings_confirmed: bool,
|
||||
provider_error: Option<codex_app_server_protocol::ModelProviderError>,
|
||||
/// Covers both queued and executing forks so repeated shortcuts cannot queue another one.
|
||||
pub(crate) fork_in_progress: bool,
|
||||
|
||||
@@ -247,6 +247,7 @@ impl ChatWidget {
|
||||
blocks_direct_input: false,
|
||||
external_writer_view: false,
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: false,
|
||||
provider_error: None,
|
||||
fork_in_progress: false,
|
||||
misalignment_policy_violation: None,
|
||||
|
||||
@@ -97,6 +97,7 @@ impl ChatWidget {
|
||||
|| self.config.cwd.as_path() != session.cwd.as_path();
|
||||
self.thread_id = Some(session.thread_id);
|
||||
self.read_only_history = session.read_only_history;
|
||||
self.thread_settings_confirmed = session.thread_settings_confirmed;
|
||||
self.sync_context_window_visibility();
|
||||
self.daybreak_enabled = self.config.features.enabled(Feature::CliDaybreak)
|
||||
&& session.daybreak_enabled
|
||||
|
||||
@@ -576,6 +576,7 @@ impl ChatWidget {
|
||||
}
|
||||
settings.collaboration_mode.settings.model = settings.model;
|
||||
settings.collaboration_mode.settings.reasoning_effort = settings.effort;
|
||||
self.thread_settings_confirmed = true;
|
||||
self.set_effective_collaboration_mode(settings.collaboration_mode);
|
||||
self.refresh_effective_service_tier();
|
||||
self.refresh_status_surfaces();
|
||||
|
||||
@@ -23,8 +23,6 @@ use codex_protocol::config_types::ServiceTier;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_utils_sandbox_summary::summarize_permission_profile;
|
||||
|
||||
use super::status_state::TerminalTitleStatusKind;
|
||||
|
||||
/// Items shown in the terminal title when the user has not configured a
|
||||
/// custom selection. Unnamed threads omit the name until one is available.
|
||||
pub(super) const DEFAULT_TERMINAL_TITLE_ITEMS: [&str; 3] =
|
||||
@@ -464,7 +462,7 @@ impl ChatWidget {
|
||||
/// Parses configured status-line ids into known items and collects unknown ids.
|
||||
///
|
||||
/// Unknown ids are deduplicated in insertion order for warning messages.
|
||||
fn status_line_items_with_invalids(&self) -> (Vec<StatusLineItem>, Vec<String>) {
|
||||
pub(super) fn status_line_items_with_invalids(&self) -> (Vec<StatusLineItem>, Vec<String>) {
|
||||
if self.read_only_history {
|
||||
return Default::default();
|
||||
}
|
||||
@@ -731,13 +729,9 @@ impl ChatWidget {
|
||||
Some(self.model_with_reasoning_display_name(service_tier.as_deref()))
|
||||
}
|
||||
StatusLineItem::Reasoning => Some(self.reasoning_display_name()),
|
||||
StatusLineItem::Profile => {
|
||||
let layer = self.config.config_layer_stack.get_active_user_layer()?;
|
||||
let ConfigLayerSource::User { profile, .. } = &layer.name else {
|
||||
return None;
|
||||
};
|
||||
profile.as_ref().map(|name| format!("profile: {name}"))
|
||||
}
|
||||
StatusLineItem::Profile => self
|
||||
.status_line_config_profile()
|
||||
.map(|name| format!("profile: {name}")),
|
||||
StatusLineItem::Provider => self
|
||||
.thread_id
|
||||
.map(|_| format!("provider: {}", self.config.model_provider_id)),
|
||||
@@ -1015,7 +1009,7 @@ impl ChatWidget {
|
||||
format!("{model} {label}{service_tier_label}")
|
||||
}
|
||||
|
||||
fn processing_tier_display_name(&self) -> Option<&str> {
|
||||
pub(super) fn processing_tier_display_name(&self) -> Option<&str> {
|
||||
let id = self.current_service_tier()?;
|
||||
self.model_catalog
|
||||
.models
|
||||
@@ -1039,26 +1033,15 @@ impl ChatWidget {
|
||||
/// Startup takes precedence over normal task states, and idle state renders
|
||||
/// as `Ready` regardless of the last active status bucket.
|
||||
pub(super) fn run_state_status_text(&self) -> String {
|
||||
if self.mcp_startup_status.is_some() {
|
||||
return "Starting".to_string();
|
||||
}
|
||||
self.status_line_run_state().to_string()
|
||||
}
|
||||
|
||||
match self.status_state.terminal_title_status_kind {
|
||||
TerminalTitleStatusKind::Working if !self.bottom_pane.is_task_running() => {
|
||||
"Ready".to_string()
|
||||
}
|
||||
TerminalTitleStatusKind::WaitingForBackgroundTerminal
|
||||
if !self.bottom_pane.is_task_running() =>
|
||||
{
|
||||
"Ready".to_string()
|
||||
}
|
||||
TerminalTitleStatusKind::Thinking if !self.bottom_pane.is_task_running() => {
|
||||
"Ready".to_string()
|
||||
}
|
||||
TerminalTitleStatusKind::Working => "Working".to_string(),
|
||||
TerminalTitleStatusKind::WaitingForBackgroundTerminal => "Waiting".to_string(),
|
||||
TerminalTitleStatusKind::Thinking => "Thinking".to_string(),
|
||||
}
|
||||
pub(super) fn status_line_config_profile(&self) -> Option<String> {
|
||||
let layer = self.config.config_layer_stack.get_active_user_layer()?;
|
||||
let ConfigLayerSource::User { profile, .. } = &layer.name else {
|
||||
return None;
|
||||
};
|
||||
profile.clone()
|
||||
}
|
||||
|
||||
pub(super) fn terminal_title_spinner_text_at(&self, now: Instant) -> Option<String> {
|
||||
@@ -1251,7 +1234,7 @@ fn matches_window_label(window: &RateLimitWindowDisplay, label: &str) -> bool {
|
||||
== Some(label)
|
||||
}
|
||||
|
||||
fn permissions_display(config: &Config) -> String {
|
||||
pub(super) fn permissions_display(config: &Config) -> String {
|
||||
let active_permission_profile = config.permissions.active_permission_profile();
|
||||
if let Some(active_permission_profile) = active_permission_profile.as_ref()
|
||||
&& !active_permission_profile.id.starts_with(':')
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
//! Projects the displayed conversation into the provider-facing statusline snapshot.
|
||||
|
||||
use super::ChatWidget;
|
||||
use super::normalize_thread_name;
|
||||
use super::status_state::TerminalTitleStatusKind as TerminalTitleStatus;
|
||||
use super::status_surfaces::permissions_display;
|
||||
use crate::bottom_pane::StatusLineItem;
|
||||
use crate::version::CODEX_CLI_VERSION;
|
||||
use codex_protocol::config_types::ApprovalsReviewer as ConfigReviewer;
|
||||
use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;
|
||||
use codex_protocol::models::ManagedFileSystemPermissions as ManagedFileSystem;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::permissions::NetworkSandboxPolicy;
|
||||
use codex_protocol::protocol::AskForApproval;
|
||||
use codex_protocol::turn_input::CyberAccessProgram;
|
||||
use serde::Serialize;
|
||||
use strum_macros::Display;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct StatuslineState {
|
||||
app: StatuslineStateApp,
|
||||
config: StatuslineStateConfig,
|
||||
thread: StatuslineStateThread,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStateApp {
|
||||
cli_version: &'static str,
|
||||
display_mode: crate::history_cell::HistoryRenderMode,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStateConfig {
|
||||
statusline_items: Vec<StatusLineItem>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
profile: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStateThread {
|
||||
id: codex_protocol::ThreadId,
|
||||
name: Option<String>,
|
||||
agent: StatuslineStateAgent,
|
||||
model: StatuslineStateModel,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
approval: Option<StatuslineStateApproval>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
permissions: Option<StatuslineStatePermissions>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStateAgent {
|
||||
state: StatuslineStateRunState,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Display)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub(super) enum StatuslineStateRunState {
|
||||
Starting,
|
||||
Ready,
|
||||
Working,
|
||||
Waiting,
|
||||
Thinking,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStateModel {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
access_program: Option<CyberAccessProgram>,
|
||||
display_name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
provider: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
reasoning_level: Option<ReasoningEffort>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
service_tier: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
service_tier_display_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStateApproval {
|
||||
policy: StatuslineStateApprovalPolicy,
|
||||
reviewer: StatuslineStateApprovalReviewer,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
enum StatuslineStateApprovalPolicy {
|
||||
Untrusted,
|
||||
OnRequest,
|
||||
Granular,
|
||||
Never,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
enum StatuslineStateApprovalReviewer {
|
||||
User,
|
||||
AutoReview,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct StatuslineStatePermissions {
|
||||
display_name: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
profile_id: Option<String>,
|
||||
#[serde(flatten)]
|
||||
enforcement: StatuslineStateEnforcement,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(tag = "type", rename_all = "lowercase")]
|
||||
enum StatuslineStateEnforcement {
|
||||
Managed {
|
||||
file_system: StatuslineStateFileSystem,
|
||||
network: NetworkSandboxPolicy,
|
||||
},
|
||||
Disabled,
|
||||
External {
|
||||
network: NetworkSandboxPolicy,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(tag = "type", rename_all = "lowercase")]
|
||||
enum StatuslineStateFileSystem {
|
||||
Restricted,
|
||||
Unrestricted,
|
||||
}
|
||||
|
||||
impl From<PermissionProfile> for StatuslineStateEnforcement {
|
||||
fn from(profile: PermissionProfile) -> Self {
|
||||
match profile {
|
||||
PermissionProfile::Managed {
|
||||
file_system,
|
||||
network,
|
||||
} => Self::Managed {
|
||||
file_system: match file_system {
|
||||
ManagedFileSystem::Restricted { .. } => StatuslineStateFileSystem::Restricted,
|
||||
ManagedFileSystem::Unrestricted => StatuslineStateFileSystem::Unrestricted,
|
||||
},
|
||||
network,
|
||||
},
|
||||
PermissionProfile::Disabled => Self::Disabled,
|
||||
PermissionProfile::External { network } => Self::External { network },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ChatWidget {
|
||||
pub(super) fn status_line_run_state(&self) -> StatuslineStateRunState {
|
||||
if self.mcp_startup_status.is_some() {
|
||||
return StatuslineStateRunState::Starting;
|
||||
}
|
||||
if !self.bottom_pane.is_task_running() {
|
||||
return StatuslineStateRunState::Ready;
|
||||
}
|
||||
match self.status_state.terminal_title_status_kind {
|
||||
TerminalTitleStatus::Working => StatuslineStateRunState::Working,
|
||||
TerminalTitleStatus::WaitingForBackgroundTerminal => StatuslineStateRunState::Waiting,
|
||||
TerminalTitleStatus::Thinking => StatuslineStateRunState::Thinking,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(test), expect(dead_code, reason = "staged for provider reads"))]
|
||||
pub(crate) fn statusline_state(&self) -> Option<StatuslineState> {
|
||||
if self.read_only_history {
|
||||
return None;
|
||||
}
|
||||
let id = self.thread_id?;
|
||||
let permissions = &self.config.permissions;
|
||||
let selected_model = self.current_model();
|
||||
let app = StatuslineStateApp {
|
||||
cli_version: CODEX_CLI_VERSION,
|
||||
display_mode: self.history_render_mode(),
|
||||
};
|
||||
let config = StatuslineStateConfig {
|
||||
statusline_items: self.status_line_items_with_invalids().0,
|
||||
profile: self.status_line_config_profile(),
|
||||
};
|
||||
let name = self.thread_name.as_deref().and_then(normalize_thread_name);
|
||||
let agent = StatuslineStateAgent {
|
||||
state: self.status_line_run_state(),
|
||||
};
|
||||
let model = StatuslineStateModel {
|
||||
access_program: crate::daybreak::program_for_turn(
|
||||
&self.model_catalog.models,
|
||||
selected_model,
|
||||
self.daybreak_account_eligible(),
|
||||
self.daybreak_enabled && !self.side_conversation_active(),
|
||||
)
|
||||
.ok()
|
||||
.flatten(),
|
||||
display_name: self.model_display_name().to_owned(),
|
||||
id: (!selected_model.is_empty()).then(|| selected_model.to_owned()),
|
||||
provider: self.config.model_provider_id.clone(),
|
||||
reasoning_level: self.effective_reasoning_effort(),
|
||||
service_tier: self.thread_settings_confirmed.then(|| {
|
||||
match self.current_service_tier() {
|
||||
None | Some(SERVICE_TIER_DEFAULT_REQUEST_VALUE) => "normal",
|
||||
Some("priority") => "fast",
|
||||
Some(tier) => tier,
|
||||
}
|
||||
.to_owned()
|
||||
}),
|
||||
service_tier_display_name: self
|
||||
.processing_tier_display_name()
|
||||
.filter(|_| self.thread_settings_confirmed)
|
||||
.map(str::to_owned),
|
||||
};
|
||||
let approval = self
|
||||
.thread_settings_confirmed
|
||||
.then(|| StatuslineStateApproval {
|
||||
policy: match permissions.approval_policy.value() {
|
||||
AskForApproval::UnlessTrusted => StatuslineStateApprovalPolicy::Untrusted,
|
||||
AskForApproval::OnRequest => StatuslineStateApprovalPolicy::OnRequest,
|
||||
AskForApproval::Granular(_) => StatuslineStateApprovalPolicy::Granular,
|
||||
AskForApproval::Never => StatuslineStateApprovalPolicy::Never,
|
||||
},
|
||||
reviewer: match self.config.approvals_reviewer {
|
||||
ConfigReviewer::User => StatuslineStateApprovalReviewer::User,
|
||||
ConfigReviewer::AutoReview => StatuslineStateApprovalReviewer::AutoReview,
|
||||
},
|
||||
});
|
||||
let permissions = self
|
||||
.thread_settings_confirmed
|
||||
.then(|| StatuslineStatePermissions {
|
||||
display_name: permissions_display(&self.config),
|
||||
profile_id: permissions
|
||||
.active_permission_profile()
|
||||
.map(|profile| profile.id),
|
||||
enforcement: permissions.effective_permission_profile().into(),
|
||||
});
|
||||
Some(StatuslineState {
|
||||
app,
|
||||
config,
|
||||
thread: StatuslineStateThread {
|
||||
id,
|
||||
name,
|
||||
agent,
|
||||
model,
|
||||
approval,
|
||||
permissions,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -301,6 +301,8 @@ mod status_command_tests;
|
||||
#[path = "tests/status_surface_command_tests.rs"]
|
||||
mod status_surface_command_tests;
|
||||
mod status_surface_previews;
|
||||
#[path = "tests/statusline_state_tests.rs"]
|
||||
mod statusline_state;
|
||||
#[path = "tests/subagent_activity_tests.rs"]
|
||||
mod subagent_activity;
|
||||
#[path = "tests/terminal_program_status.rs"]
|
||||
|
||||
@@ -45,9 +45,12 @@ fn thread_settings_for_test(
|
||||
}
|
||||
}
|
||||
|
||||
fn configured_thread_session(thread_id: ThreadId) -> crate::session_state::ThreadSessionState {
|
||||
pub(super) fn configured_thread_session(
|
||||
thread_id: ThreadId,
|
||||
) -> crate::session_state::ThreadSessionState {
|
||||
crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -692,6 +695,7 @@ async fn thread_settings_updated_updates_visible_state_without_transcript() {
|
||||
let thread_id = ThreadId::new();
|
||||
let mut session = configured_thread_session(thread_id);
|
||||
session.cwd = test_path_buf("/tmp/original-workspace").abs();
|
||||
session.thread_settings_confirmed = false;
|
||||
chat.handle_thread_session(session);
|
||||
chat.config.permissions.approval_policy =
|
||||
Constrained::allow_only(AskForApproval::Never.to_core());
|
||||
@@ -712,6 +716,9 @@ async fn thread_settings_updated_updates_visible_state_without_transcript() {
|
||||
assert!(chat.connectors_for_mentions().is_none());
|
||||
assert!(chat.connectors.mention_refresh_in_flight);
|
||||
assert_eq!(chat.current_model(), "gpt-5.4");
|
||||
let state = serde_json::to_value(chat.statusline_state()).unwrap();
|
||||
assert_eq!(state["thread"]["approval"]["policy"], "on-request");
|
||||
assert_eq!(state["thread"]["model"]["service_tier"], "fast");
|
||||
assert_eq!(
|
||||
chat.current_reasoning_effort(),
|
||||
Some(ReasoningEffortConfig::High)
|
||||
|
||||
@@ -630,6 +630,7 @@ async fn submission_preserves_text_elements_and_local_images() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -741,6 +742,7 @@ async fn submission_includes_configured_active_permission_profile() {
|
||||
let expected_active_permission_profile = ActivePermissionProfile::new("custom");
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -798,6 +800,7 @@ async fn submission_omits_active_permission_profile_for_legacy_snapshot() {
|
||||
};
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -845,6 +848,7 @@ async fn submission_with_remote_and_local_images_keeps_local_placeholder_numberi
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -947,6 +951,7 @@ async fn enter_with_only_remote_images_submits_user_turn() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -1018,6 +1023,7 @@ async fn shift_enter_with_only_remote_images_does_not_submit_user_turn() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -1061,6 +1067,7 @@ async fn enter_with_only_remote_images_does_not_submit_when_modal_is_active() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -1104,6 +1111,7 @@ async fn enter_with_only_remote_images_does_not_submit_when_input_disabled() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -1150,6 +1158,7 @@ async fn submission_prefers_selected_duplicate_skill_path() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -1272,6 +1272,7 @@ async fn bang_shell_enter_while_task_running_submits_run_user_shell_command() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -324,6 +324,10 @@ pub(crate) fn set_chatgpt_auth(chat: &mut ChatWidget) {
|
||||
chat.model_catalog = test_model_catalog(&chat.config);
|
||||
}
|
||||
|
||||
pub(crate) fn set_test_model_catalog(chat: &mut ChatWidget, models: Vec<ModelPreset>) {
|
||||
chat.model_catalog = Arc::new(ModelCatalog::new(models));
|
||||
}
|
||||
|
||||
fn test_model_info(slug: &str, priority: i32, supports_fast_mode: bool) -> ModelInfo {
|
||||
let mut service_tiers = Vec::new();
|
||||
if supports_fast_mode {
|
||||
|
||||
@@ -21,6 +21,7 @@ async fn resumed_initial_messages_render_history() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let mut configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: true,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -184,6 +185,7 @@ async fn restored_conversation_ultra_remains_selected_after_switching_to_plan()
|
||||
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -508,6 +510,7 @@ async fn replayed_user_message_preserves_text_elements_and_local_images() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -582,6 +585,7 @@ async fn replayed_user_message_preserves_remote_image_urls() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -686,6 +690,7 @@ async fn session_configured_syncs_widget_config_permissions_and_cwd() {
|
||||
let expected_permission_profile = expected_app_server_permission_profile.clone();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -766,6 +771,7 @@ async fn session_configured_preserves_profile_workspace_roots() {
|
||||
.materialize_project_roots_with_workspace_roots(&session_effective_workspace_roots);
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -812,6 +818,7 @@ async fn session_configured_external_sandbox_keeps_external_runtime_policy() {
|
||||
let expected_permission_profile = expected_app_server_permission_profile.clone();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -853,6 +860,7 @@ async fn replayed_user_message_with_only_remote_images_renders_history_cell() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -915,6 +923,7 @@ async fn replayed_user_message_with_only_local_images_renders_history_cell() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -1274,6 +1283,7 @@ async fn replayed_reasoning_item_preserves_summary_parts_and_hides_raw_reasoning
|
||||
chat.config.show_raw_agent_reasoning = false;
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -1327,6 +1337,7 @@ async fn replayed_reasoning_item_shows_raw_reasoning_when_enabled() {
|
||||
chat.config.show_raw_agent_reasoning = true;
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
|
||||
@@ -1163,6 +1163,7 @@ async fn required_windows_sandbox_setup_defers_configured_initial_prompt() {
|
||||
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -1614,6 +1615,7 @@ async fn permissions_selection_marks_auto_review_current_after_session_configure
|
||||
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
@@ -1669,6 +1671,7 @@ async fn permissions_selection_marks_auto_review_current_with_custom_workspace_w
|
||||
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
|
||||
@@ -17,6 +17,7 @@ fn paste_hidden_plan_shell_payload(chat: &mut ChatWidget) -> String {
|
||||
fn plan_test_session(thread_id: ThreadId) -> crate::session_state::ThreadSessionState {
|
||||
crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
@@ -1231,6 +1232,7 @@ async fn submit_user_message_emits_structured_plugin_mentions_from_bindings() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
let configured = crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id,
|
||||
|
||||
@@ -4720,6 +4720,7 @@ async fn session_configured_clears_goal_status_footer() {
|
||||
let rollout_file = NamedTempFile::new().unwrap();
|
||||
chat.handle_thread_session(crate::session_state::ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#![cfg(test)]
|
||||
//! Check the provider-facing values for the displayed conversation.
|
||||
|
||||
use super::app_server::configured_thread_session;
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
|
||||
#[tokio::test]
|
||||
async fn statusline_state_projects_the_displayed_settings() {
|
||||
let (mut chat, _events, _ops) = make_chatwidget_manual(Some("gpt-5.5")).await;
|
||||
let id = ThreadId::new();
|
||||
let mut session = configured_thread_session(id);
|
||||
session.model = "gpt-5.5".into();
|
||||
session.thread_name = Some("Saved carts".into());
|
||||
chat.handle_thread_session(session);
|
||||
chat.local_settings.tui.status_line = Some(vec!["status".into()]);
|
||||
let mut model = get_available_model(&chat, "gpt-5.5");
|
||||
model.display_name = "Test model".into();
|
||||
model.service_tiers = vec![codex_protocol::openai_models::ModelServiceTier {
|
||||
id: "acme-priority".into(),
|
||||
name: "Turbo".into(),
|
||||
description: String::new(),
|
||||
}];
|
||||
helpers::set_test_model_catalog(&mut chat, vec![model]);
|
||||
chat.set_service_tier(Some("acme-priority".into()));
|
||||
chat.set_reasoning_effort(Some(ReasoningEffortConfig::None));
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_value(chat.statusline_state()).unwrap(),
|
||||
json!({
|
||||
"app": {"cli_version": CODEX_CLI_VERSION, "display_mode": "standard"},
|
||||
"config": {"statusline_items": ["run-state"]},
|
||||
"thread": {
|
||||
"id": id, "name": "Saved carts", "agent": {"state": "ready"},
|
||||
"model": {"id": "gpt-5.5", "display_name": "Test model", "provider": "openai",
|
||||
"reasoning_level": "none", "service_tier": "acme-priority", "service_tier_display_name": "Turbo"},
|
||||
"approval": {"policy": "never", "reviewer": "user"},
|
||||
"permissions": {"display_name": "Read Only", "type": "managed", "file_system": {"type":"restricted"}, "network": "restricted"}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
chat.set_reasoning_effort(Some(ReasoningEffortConfig::Custom("default".into())));
|
||||
let state = serde_json::to_value(chat.statusline_state()).unwrap();
|
||||
assert_eq!(state["thread"]["model"]["reasoning_level"], "default");
|
||||
}
|
||||
@@ -155,9 +155,11 @@ pub(crate) use warnings::warning_entries;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize)]
|
||||
pub(crate) enum HistoryRenderMode {
|
||||
#[serde(rename = "standard")]
|
||||
Rich,
|
||||
#[serde(rename = "raw")]
|
||||
Raw,
|
||||
}
|
||||
|
||||
|
||||
@@ -625,6 +625,7 @@ fn image_generation_call_renders_saved_path() {
|
||||
fn session_configured_event(model: &str) -> ThreadSessionState {
|
||||
ThreadSessionState {
|
||||
read_only_history: false,
|
||||
thread_settings_confirmed: true,
|
||||
daybreak_enabled: false,
|
||||
windows_sandbox_host: crate::app::WindowsSandboxHost::Local,
|
||||
thread_id: ThreadId::new(),
|
||||
|
||||
@@ -29,6 +29,8 @@ pub(crate) struct MessageHistoryMetadata {
|
||||
pub(crate) struct ThreadSessionState {
|
||||
/// This TUI opened saved history without a live attachment.
|
||||
pub(crate) read_only_history: bool,
|
||||
/// Inferred child sessions can carry settings copied from the primary thread.
|
||||
pub(crate) thread_settings_confirmed: bool,
|
||||
pub(crate) daybreak_enabled: bool,
|
||||
pub(crate) windows_sandbox_host: crate::app::WindowsSandboxHost,
|
||||
pub(crate) thread_id: ThreadId,
|
||||
|
||||
Reference in New Issue
Block a user