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
8 changes: 3 additions & 5 deletions codex-rs/tui/src/app/config_persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ impl App {
#[cfg(target_os = "windows")]
{
let windows_sandbox_level = WindowsSandboxLevel::from_config(&self.config);
self.app_event_tx.send(AppEvent::CodexOp(
AppCommand::override_turn_context(
self.app_event_tx
.send(AppEvent::CodexOp(AppCommand::override_turn_context(
/*cwd*/ None,
/*approval_policy*/ None,
/*approvals_reviewer*/ None,
Expand All @@ -365,9 +365,7 @@ impl App {
/*service_tier*/ None,
/*collaboration_mode*/ None,
/*personality*/ None,
)
.into_core(),
));
)));
}
}

Expand Down
11 changes: 4 additions & 7 deletions codex-rs/tui/src/app/event_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,14 @@ impl App {
return Ok(AppRunControl::Exit(ExitReason::Fatal(message)));
}
AppEvent::CodexOp(op) => {
self.submit_active_thread_op(app_server, op.into()).await?;
self.submit_active_thread_op(app_server, op).await?;
}
AppEvent::ApproveRecentAutoReviewDenial { thread_id, id } => {
self.chat_widget
.approve_recent_auto_review_denial(thread_id, id);
}
AppEvent::SubmitThreadOp { thread_id, op } => {
self.submit_thread_op(app_server, thread_id, op.into())
.await?;
self.submit_thread_op(app_server, thread_id, op).await?;
}
AppEvent::ThreadHistoryEntryResponse { thread_id, event } => {
self.enqueue_thread_history_entry_response(thread_id, event)
Expand Down Expand Up @@ -989,8 +988,7 @@ impl App {
/*service_tier*/ None,
/*collaboration_mode*/ None,
/*personality*/ None,
)
.into(),
),
));
self.app_event_tx.send(
AppEvent::OpenWorldWritableWarningConfirmation {
Expand All @@ -1015,8 +1013,7 @@ impl App {
/*service_tier*/ None,
/*collaboration_mode*/ None,
/*personality*/ None,
)
.into(),
),
));
self.app_event_tx
.send(AppEvent::UpdateAskForApprovalPolicy(preset.approval));
Expand Down
5 changes: 3 additions & 2 deletions codex-rs/tui/src/app/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use super::*;
use crate::app_backtrack::BacktrackSelection;
use crate::app_backtrack::BacktrackState;
use crate::app_backtrack::user_count;
use crate::app_command::AppCommand;

use crate::chatwidget::ChatWidgetInit;
use crate::chatwidget::create_initial_user_message;
Expand Down Expand Up @@ -441,12 +442,12 @@ async fn enqueue_primary_thread_session_replays_turns_before_initial_prompt_subm
}
AppEvent::SubmitThreadOp {
thread_id: op_thread_id,
op: Op::UserTurn { items, .. },
op: AppCommand::UserTurn { items, .. },
} => {
assert_eq!(op_thread_id, thread_id);
submitted_items = Some(items);
}
AppEvent::CodexOp(Op::UserTurn { items, .. }) => {
AppEvent::CodexOp(AppCommand::UserTurn { items, .. }) => {
submitted_items = Some(items);
}
_ => {}
Expand Down
3 changes: 2 additions & 1 deletion codex-rs/tui/src/app/thread_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,8 @@ impl App {
Ok(true)
}
AppCommandView::OverrideTurnContext { .. } => Ok(true),
AppCommandView::Other(Op::ApproveGuardianDeniedAction { event }) => {
AppCommandView::ApproveGuardianDeniedAction { event }
| AppCommandView::Other(Op::ApproveGuardianDeniedAction { event }) => {
app_server
.thread_approve_guardian_denied_action(thread_id, event)
.await?;
Expand Down
28 changes: 28 additions & 0 deletions codex-rs/tui/src/app_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::PathBuf;

use codex_config::types::ApprovalsReviewer;
use codex_protocol::approvals::ElicitationAction;
use codex_protocol::approvals::GuardianAssessmentEvent;
use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::Personality;
use codex_protocol::config_types::ReasoningSummary as ReasoningSummaryConfig;
Expand Down Expand Up @@ -104,6 +105,9 @@ pub(crate) enum AppCommand {
Review {
review_request: ReviewRequest,
},
ApproveGuardianDeniedAction {
event: GuardianAssessmentEvent,
},
Other(Op),
}

Expand Down Expand Up @@ -186,6 +190,9 @@ pub(crate) enum AppCommandView<'a> {
Review {
review_request: &'a ReviewRequest,
},
ApproveGuardianDeniedAction {
event: &'a GuardianAssessmentEvent,
},
Other(&'a Op),
}

Expand Down Expand Up @@ -450,6 +457,9 @@ impl AppCommand {
Self::Shutdown => Op::Shutdown,
Self::ThreadRollback { num_turns } => Op::ThreadRollback { num_turns },
Self::Review { review_request } => Op::Review { review_request },
Self::ApproveGuardianDeniedAction { event } => {
Op::ApproveGuardianDeniedAction { event }
}
Self::Other(op) => op,
}
}
Expand Down Expand Up @@ -568,6 +578,9 @@ impl AppCommand {
num_turns: *num_turns,
},
Self::Review { review_request } => AppCommandView::Review { review_request },
Self::ApproveGuardianDeniedAction { event } => {
AppCommandView::ApproveGuardianDeniedAction { event }
}
Self::Other(op) => AppCommandView::Other(op),
}
}
Expand Down Expand Up @@ -716,11 +729,26 @@ impl From<Op> for AppCommand {
Op::Shutdown => Self::Shutdown,
Op::ThreadRollback { num_turns } => Self::ThreadRollback { num_turns },
Op::Review { review_request } => Self::Review { review_request },
Op::ApproveGuardianDeniedAction { event } => {
Self::ApproveGuardianDeniedAction { event }
Comment thread
etraut-openai marked this conversation as resolved.
}
op => Self::Other(op),
}
}
}

impl PartialEq<Op> for AppCommand {
fn eq(&self, other: &Op) -> bool {
self.clone().into_core() == *other
}
}

impl PartialEq<AppCommand> for Op {
fn eq(&self, other: &AppCommand) -> bool {
*self == other.clone().into_core()
}
}

impl From<&Op> for AppCommand {
fn from(value: &Op) -> Self {
Self::from(value.clone())
Expand Down
6 changes: 3 additions & 3 deletions codex-rs/tui/src/app_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ use codex_file_search::FileMatch;
use codex_protocol::ThreadId;
use codex_protocol::openai_models::ModelPreset;
use codex_protocol::protocol::GetHistoryEntryResponseEvent;
use codex_protocol::protocol::Op;
use codex_protocol::protocol::RateLimitSnapshot;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_approval_presets::ApprovalPreset;

use crate::app_command::AppCommand;
use crate::bottom_pane::ApprovalRequest;
use crate::bottom_pane::StatusLineItem;
use crate::bottom_pane::TerminalTitleItem;
Expand Down Expand Up @@ -132,7 +132,7 @@ pub(crate) enum AppEvent {
/// Submit an op to the specified thread, regardless of current focus.
SubmitThreadOp {
thread_id: ThreadId,
op: Op,
op: AppCommand,
},

/// Deliver a synthetic history lookup response to a specific thread channel.
Expand Down Expand Up @@ -182,7 +182,7 @@ pub(crate) enum AppEvent {

/// Forward an `Op` to the Agent. Using an `AppEvent` for this avoids
/// bubbling channels through layers of widgets.
CodexOp(Op),
CodexOp(AppCommand),

/// Approve one retry of a recent auto-review denial selected in the TUI.
ApproveRecentAutoReviewDenial {
Expand Down
40 changes: 18 additions & 22 deletions codex-rs/tui/src/app_event_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,48 +38,45 @@ impl AppEventSender {
}

pub(crate) fn interrupt(&self) {
self.send(AppEvent::CodexOp(AppCommand::interrupt().into_core()));
self.send(AppEvent::CodexOp(AppCommand::interrupt()));
}

pub(crate) fn compact(&self) {
self.send(AppEvent::CodexOp(AppCommand::compact().into_core()));
self.send(AppEvent::CodexOp(AppCommand::compact()));
}

pub(crate) fn set_thread_name(&self, name: String) {
self.send(AppEvent::CodexOp(
AppCommand::set_thread_name(name).into_core(),
));
self.send(AppEvent::CodexOp(AppCommand::set_thread_name(name)));
}

pub(crate) fn review(&self, review_request: ReviewRequest) {
self.send(AppEvent::CodexOp(
AppCommand::review(review_request).into_core(),
));
self.send(AppEvent::CodexOp(AppCommand::review(review_request)));
}

pub(crate) fn list_skills(&self, cwds: Vec<PathBuf>, force_reload: bool) {
self.send(AppEvent::CodexOp(
AppCommand::list_skills(cwds, force_reload).into_core(),
));
self.send(AppEvent::CodexOp(AppCommand::list_skills(
cwds,
force_reload,
)));
}

#[cfg_attr(target_os = "linux", allow(dead_code))]
pub(crate) fn realtime_conversation_audio(&self, params: ConversationAudioParams) {
self.send(AppEvent::CodexOp(
AppCommand::realtime_conversation_audio(params).into_core(),
));
self.send(AppEvent::CodexOp(AppCommand::realtime_conversation_audio(
params,
)));
}

pub(crate) fn user_input_answer(&self, id: String, response: RequestUserInputResponse) {
self.send(AppEvent::CodexOp(
AppCommand::user_input_answer(id, response).into_core(),
));
self.send(AppEvent::CodexOp(AppCommand::user_input_answer(
id, response,
)));
}

pub(crate) fn exec_approval(&self, thread_id: ThreadId, id: String, decision: ReviewDecision) {
self.send(AppEvent::SubmitThreadOp {
thread_id,
op: AppCommand::exec_approval(id, /*turn_id*/ None, decision).into_core(),
op: AppCommand::exec_approval(id, /*turn_id*/ None, decision),
});
}

Expand All @@ -91,14 +88,14 @@ impl AppEventSender {
) {
self.send(AppEvent::SubmitThreadOp {
thread_id,
op: AppCommand::request_permissions_response(id, response).into_core(),
op: AppCommand::request_permissions_response(id, response),
});
}

pub(crate) fn patch_approval(&self, thread_id: ThreadId, id: String, decision: ReviewDecision) {
self.send(AppEvent::SubmitThreadOp {
thread_id,
op: AppCommand::patch_approval(id, decision).into_core(),
op: AppCommand::patch_approval(id, decision),
});
}

Expand All @@ -113,8 +110,7 @@ impl AppEventSender {
) {
self.send(AppEvent::SubmitThreadOp {
thread_id,
op: AppCommand::resolve_elicitation(server_name, request_id, decision, content, meta)
.into_core(),
op: AppCommand::resolve_elicitation(server_name, request_id, decision, content, meta),
});
}
}
Loading
Loading