Skip to content

Commit f86087e

Browse files
authored
Revert "only use preambles for realtime" (#12830)
Reverts #12806
1 parent c1851be commit f86087e

File tree

1 file changed

+41
-74
lines changed

1 file changed

+41
-74
lines changed

codex-rs/core/src/codex.rs

Lines changed: 41 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ use crate::protocol::ModelRerouteEvent;
197197
use crate::protocol::ModelRerouteReason;
198198
use crate::protocol::NetworkApprovalContext;
199199
use crate::protocol::Op;
200+
use crate::protocol::PatchApplyStatus;
200201
use crate::protocol::PlanDeltaEvent;
201202
use crate::protocol::RateLimitSnapshot;
202203
use crate::protocol::ReasoningContentDeltaEvent;
@@ -5808,80 +5809,46 @@ fn realtime_text_for_event(msg: &EventMsg) -> Option<String> {
58085809
TurnItem::AgentMessage(item) => Some(agent_message_text(item)),
58095810
_ => None,
58105811
},
5811-
EventMsg::Error(_)
5812-
| EventMsg::Warning(_)
5813-
| EventMsg::RealtimeConversationStarted(_)
5814-
| EventMsg::RealtimeConversationRealtime(_)
5815-
| EventMsg::RealtimeConversationClosed(_)
5816-
| EventMsg::ModelReroute(_)
5817-
| EventMsg::ContextCompacted(_)
5818-
| EventMsg::ThreadRolledBack(_)
5819-
| EventMsg::TurnStarted(_)
5820-
| EventMsg::TurnComplete(_)
5821-
| EventMsg::TokenCount(_)
5822-
| EventMsg::UserMessage(_)
5823-
| EventMsg::AgentMessageDelta(_)
5824-
| EventMsg::AgentReasoning(_)
5825-
| EventMsg::AgentReasoningDelta(_)
5826-
| EventMsg::AgentReasoningRawContent(_)
5827-
| EventMsg::AgentReasoningRawContentDelta(_)
5828-
| EventMsg::AgentReasoningSectionBreak(_)
5829-
| EventMsg::SessionConfigured(_)
5830-
| EventMsg::ThreadNameUpdated(_)
5831-
| EventMsg::McpStartupUpdate(_)
5832-
| EventMsg::McpStartupComplete(_)
5833-
| EventMsg::McpToolCallBegin(_)
5834-
| EventMsg::McpToolCallEnd(_)
5835-
| EventMsg::WebSearchBegin(_)
5836-
| EventMsg::WebSearchEnd(_)
5837-
| EventMsg::ExecCommandBegin(_)
5838-
| EventMsg::ExecCommandOutputDelta(_)
5839-
| EventMsg::TerminalInteraction(_)
5840-
| EventMsg::ExecCommandEnd(_)
5841-
| EventMsg::PatchApplyBegin(_)
5842-
| EventMsg::PatchApplyEnd(_)
5843-
| EventMsg::ViewImageToolCall(_)
5844-
| EventMsg::ExecApprovalRequest(_)
5845-
| EventMsg::RequestUserInput(_)
5846-
| EventMsg::DynamicToolCallRequest(_)
5847-
| EventMsg::DynamicToolCallResponse(_)
5848-
| EventMsg::SkillRequestApproval(_)
5849-
| EventMsg::ElicitationRequest(_)
5850-
| EventMsg::ApplyPatchApprovalRequest(_)
5851-
| EventMsg::DeprecationNotice(_)
5852-
| EventMsg::BackgroundEvent(_)
5853-
| EventMsg::UndoStarted(_)
5854-
| EventMsg::UndoCompleted(_)
5855-
| EventMsg::StreamError(_)
5856-
| EventMsg::TurnDiff(_)
5857-
| EventMsg::GetHistoryEntryResponse(_)
5858-
| EventMsg::McpListToolsResponse(_)
5859-
| EventMsg::ListCustomPromptsResponse(_)
5860-
| EventMsg::ListSkillsResponse(_)
5861-
| EventMsg::ListRemoteSkillsResponse(_)
5862-
| EventMsg::RemoteSkillDownloaded(_)
5863-
| EventMsg::SkillsUpdateAvailable
5864-
| EventMsg::PlanUpdate(_)
5865-
| EventMsg::TurnAborted(_)
5866-
| EventMsg::ShutdownComplete
5867-
| EventMsg::EnteredReviewMode(_)
5868-
| EventMsg::ExitedReviewMode(_)
5869-
| EventMsg::RawResponseItem(_)
5870-
| EventMsg::ItemStarted(_)
5871-
| EventMsg::AgentMessageContentDelta(_)
5872-
| EventMsg::PlanDelta(_)
5873-
| EventMsg::ReasoningContentDelta(_)
5874-
| EventMsg::ReasoningRawContentDelta(_)
5875-
| EventMsg::CollabAgentSpawnBegin(_)
5876-
| EventMsg::CollabAgentSpawnEnd(_)
5877-
| EventMsg::CollabAgentInteractionBegin(_)
5878-
| EventMsg::CollabAgentInteractionEnd(_)
5879-
| EventMsg::CollabWaitingBegin(_)
5880-
| EventMsg::CollabWaitingEnd(_)
5881-
| EventMsg::CollabCloseBegin(_)
5882-
| EventMsg::CollabCloseEnd(_)
5883-
| EventMsg::CollabResumeBegin(_)
5884-
| EventMsg::CollabResumeEnd(_) => None,
5812+
EventMsg::ExecCommandBegin(event) => {
5813+
let command = event.command.join(" ");
5814+
Some(format!(
5815+
"Exec command started: {command}\nWorking directory: {}",
5816+
event.cwd.display()
5817+
))
5818+
}
5819+
EventMsg::PatchApplyBegin(event) => {
5820+
let mut files: Vec<String> = event
5821+
.changes
5822+
.keys()
5823+
.map(|path| path.display().to_string())
5824+
.collect();
5825+
files.sort();
5826+
let file_list = if files.is_empty() {
5827+
"none".to_string()
5828+
} else {
5829+
files.join(", ")
5830+
};
5831+
Some(format!(
5832+
"apply_patch started ({count} file change(s))\nFiles: {file_list}",
5833+
count = files.len()
5834+
))
5835+
}
5836+
EventMsg::PatchApplyEnd(event) => {
5837+
let status = match event.status {
5838+
PatchApplyStatus::Completed => "completed",
5839+
PatchApplyStatus::Failed => "failed",
5840+
PatchApplyStatus::Declined => "declined",
5841+
};
5842+
let mut text = format!("apply_patch {status}");
5843+
if !event.stdout.is_empty() {
5844+
text.push_str(&format!("\nstdout:\n{}", event.stdout));
5845+
}
5846+
if !event.stderr.is_empty() {
5847+
text.push_str(&format!("\nstderr:\n{}", event.stderr));
5848+
}
5849+
Some(text)
5850+
}
5851+
_ => None,
58855852
}
58865853
}
58875854

0 commit comments

Comments
 (0)