mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Simplify
This commit is contained in:
@@ -80,7 +80,6 @@ use crate::parse_command::parse_command;
|
||||
use crate::plan_tool::handle_update_plan;
|
||||
use crate::project_doc::get_user_instructions;
|
||||
use crate::protocol::AgentMessageDeltaEvent;
|
||||
use crate::protocol::AgentMessageEvent;
|
||||
use crate::protocol::AgentReasoningDeltaEvent;
|
||||
use crate::protocol::AgentReasoningRawContentDeltaEvent;
|
||||
use crate::protocol::AgentReasoningSectionBreakEvent;
|
||||
@@ -1461,39 +1460,6 @@ async fn submission_loop(
|
||||
};
|
||||
sess.send_event(event).await;
|
||||
}
|
||||
Op::CompactApproval { id: _, decision } => {
|
||||
// If approved, reuse the same logic as Op::Compact: try to
|
||||
// inject the compact trigger into the current task; if there is
|
||||
// no running task, spawn a compact task.
|
||||
if matches!(
|
||||
decision,
|
||||
ReviewDecision::Approved | ReviewDecision::ApprovedForSession
|
||||
) {
|
||||
// Visual indicator so the user sees compaction start.
|
||||
let start_msg = Event {
|
||||
id: sub.id.clone(),
|
||||
msg: EventMsg::AgentMessage(AgentMessageEvent {
|
||||
message: "Compacting conversation…".to_string(),
|
||||
}),
|
||||
};
|
||||
sess.send_event(start_msg).await;
|
||||
|
||||
if let Err(items) = sess
|
||||
.inject_input(vec![InputItem::Text {
|
||||
text: compact::COMPACT_TRIGGER_TEXT.to_string(),
|
||||
}])
|
||||
.await
|
||||
{
|
||||
compact::spawn_compact_task(
|
||||
sess.clone(),
|
||||
Arc::clone(&turn_context),
|
||||
sub.id,
|
||||
items,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
Op::Compact => {
|
||||
// Attempt to inject input into current task
|
||||
if let Err(items) = sess
|
||||
|
||||
@@ -920,8 +920,9 @@ async fn compact_trims_history_on_context_limit_error() {
|
||||
.as_array()
|
||||
.map(Vec::len)
|
||||
.unwrap_or(0);
|
||||
assert!(
|
||||
len2 + 1 == len1,
|
||||
assert_eq!(
|
||||
len1,
|
||||
len2 + 1,
|
||||
"second compact attempt should trim exactly one item: {len1} -> {len2}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -562,9 +562,7 @@ impl EventProcessor for EventProcessorWithHumanOutput {
|
||||
ts_println!(self, "task aborted: review ended");
|
||||
}
|
||||
},
|
||||
EventMsg::CompactApprovalRequest(_) => {
|
||||
// No-op for exec human output; frontends handle approvals.
|
||||
}
|
||||
EventMsg::CompactApprovalRequest(_) => {}
|
||||
EventMsg::ShutdownComplete => return CodexStatus::Shutdown,
|
||||
EventMsg::ConversationPath(_) => {}
|
||||
EventMsg::UserMessage(_) => {}
|
||||
|
||||
@@ -140,15 +140,6 @@ pub enum Op {
|
||||
decision: ReviewDecision,
|
||||
},
|
||||
|
||||
/// Approve or deny running a compact operation recommended by the agent.
|
||||
CompactApproval {
|
||||
/// The id of the submission we are responding to (the event that
|
||||
/// requested approval).
|
||||
id: String,
|
||||
/// The user's decision.
|
||||
decision: ReviewDecision,
|
||||
},
|
||||
|
||||
/// Append an entry to the persistent cross-session message history.
|
||||
///
|
||||
/// Note the entry is not guaranteed to be logged if the user has
|
||||
@@ -555,7 +546,6 @@ pub struct TaskStartedEvent {
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, TS)]
|
||||
pub struct CompactApprovalRequestEvent {
|
||||
/// Human‑readable reason to show in the UI.
|
||||
pub reason: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -428,11 +428,8 @@ impl ChatWidget {
|
||||
);
|
||||
}
|
||||
|
||||
fn on_compact_approval_request(&mut self, id: String, ev: CompactApprovalRequestEvent) {
|
||||
let request = ApprovalRequest::Compact {
|
||||
id,
|
||||
reason: ev.reason,
|
||||
};
|
||||
fn on_compact_approval_request(&mut self, ev: CompactApprovalRequestEvent) {
|
||||
let request = ApprovalRequest::Compact { reason: ev.reason };
|
||||
self.bottom_pane.push_approval_request(request);
|
||||
self.request_redraw();
|
||||
}
|
||||
@@ -1212,9 +1209,7 @@ impl ChatWidget {
|
||||
EventMsg::ApplyPatchApprovalRequest(ev) => {
|
||||
self.on_apply_patch_approval_request(id.unwrap_or_default(), ev)
|
||||
}
|
||||
EventMsg::CompactApprovalRequest(ev) => {
|
||||
self.on_compact_approval_request(id.unwrap_or_default(), ev)
|
||||
}
|
||||
EventMsg::CompactApprovalRequest(ev) => self.on_compact_approval_request(ev),
|
||||
EventMsg::ExecCommandBegin(ev) => self.on_exec_command_begin(ev),
|
||||
EventMsg::ExecCommandOutputDelta(delta) => self.on_exec_command_output_delta(delta),
|
||||
EventMsg::PatchApplyBegin(ev) => self.on_patch_apply_begin(ev),
|
||||
|
||||
@@ -44,12 +44,7 @@ pub(crate) enum ApprovalRequest {
|
||||
reason: Option<String>,
|
||||
grant_root: Option<PathBuf>,
|
||||
},
|
||||
/// Ask the user to confirm running a compact operation to shrink the
|
||||
/// conversation history when the model refuses input due to context limits.
|
||||
Compact {
|
||||
/// The id of the server event requesting approval.
|
||||
id: String,
|
||||
/// A short human‑readable reason to display above the buttons.
|
||||
reason: String,
|
||||
},
|
||||
}
|
||||
@@ -326,7 +321,7 @@ impl UserApprovalWidget {
|
||||
// No history line for patch approval decisions.
|
||||
}
|
||||
ApprovalRequest::Compact { .. } => {
|
||||
// No history line for patch approval decisions. That's handled by compact task itself.
|
||||
// No history line for compact approval decisions. That's handled by compact task itself.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,10 +334,7 @@ impl UserApprovalWidget {
|
||||
id: id.clone(),
|
||||
decision,
|
||||
},
|
||||
ApprovalRequest::Compact { id, .. } => Op::CompactApproval {
|
||||
id: id.clone(),
|
||||
decision,
|
||||
},
|
||||
ApprovalRequest::Compact { .. } => Op::Compact,
|
||||
};
|
||||
|
||||
self.app_event_tx.send(AppEvent::CodexOp(op));
|
||||
|
||||
Reference in New Issue
Block a user