mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
feat(tui): add subagent inbox foundation
Preserve the subagent inbox foundation behavior on the current origin/main base and collapse the branch back to a single commit for easier future restacks.
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui_app_server/src/chatwidget/tests.rs
|
||||
expression: rendered
|
||||
---
|
||||
• Agent message: Please review the latest diff from 019cbff7-558b-77d3-8653-8238ab5361ec
|
||||
@@ -106,7 +106,10 @@ use codex_protocol::items::AgentMessageItem;
|
||||
use codex_protocol::items::PlanItem;
|
||||
use codex_protocol::items::TurnItem;
|
||||
use codex_protocol::items::UserMessageItem;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
use codex_protocol::models::MessagePhase;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::openai_models::ModelPreset;
|
||||
use codex_protocol::openai_models::ReasoningEffortPreset;
|
||||
use codex_protocol::openai_models::default_input_modalities;
|
||||
@@ -114,6 +117,8 @@ use codex_protocol::parse_command::ParsedCommand;
|
||||
use codex_protocol::plan_tool::PlanItemArg;
|
||||
use codex_protocol::plan_tool::StepStatus;
|
||||
use codex_protocol::plan_tool::UpdatePlanArgs;
|
||||
use codex_protocol::protocol::AGENT_INBOX_MESSAGE_PREFIX;
|
||||
use codex_protocol::protocol::AgentInboxPayload;
|
||||
use codex_protocol::protocol::AgentMessageDeltaEvent;
|
||||
use codex_protocol::protocol::AgentMessageEvent;
|
||||
use codex_protocol::protocol::AgentReasoningDeltaEvent;
|
||||
@@ -149,6 +154,7 @@ use codex_protocol::protocol::PatchApplyBeginEvent;
|
||||
use codex_protocol::protocol::PatchApplyEndEvent;
|
||||
use codex_protocol::protocol::PatchApplyStatus as CorePatchApplyStatus;
|
||||
use codex_protocol::protocol::RateLimitWindow;
|
||||
use codex_protocol::protocol::RawResponseItemEvent;
|
||||
use codex_protocol::protocol::ReadOnlyAccess;
|
||||
use codex_protocol::protocol::RealtimeConversationClosedEvent;
|
||||
use codex_protocol::protocol::RealtimeConversationRealtimeEvent;
|
||||
@@ -292,6 +298,27 @@ fn snapshot(percent: f64) -> RateLimitSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
fn agent_inbox_function_call_output(sender: ThreadId, message: &str) -> ResponseItem {
|
||||
let payload = serde_json::to_string(&AgentInboxPayload::new(sender, message.to_string()))
|
||||
.expect("agent inbox payload should serialize");
|
||||
ResponseItem::FunctionCallOutput {
|
||||
call_id: "call-agent-inbox".to_string(),
|
||||
output: FunctionCallOutputPayload::from_text(payload),
|
||||
}
|
||||
}
|
||||
|
||||
fn agent_inbox_message(sender: ThreadId, message: &str) -> ResponseItem {
|
||||
ResponseItem::Message {
|
||||
id: None,
|
||||
role: "assistant".to_string(),
|
||||
content: vec![ContentItem::OutputText {
|
||||
text: format!("{AGENT_INBOX_MESSAGE_PREFIX}{sender}] {message}"),
|
||||
}],
|
||||
end_turn: None,
|
||||
phase: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn resumed_initial_messages_render_history() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
@@ -397,6 +424,44 @@ async fn thread_snapshot_replay_does_not_duplicate_agent_message_history() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_snapshot_replay_deduplicates_agent_inbox_compatibility_items() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(None).await;
|
||||
|
||||
let sender =
|
||||
ThreadId::from_string("019cbff7-558b-77d3-8653-8238ab5361ec").expect("valid thread id");
|
||||
let message = "Please review the latest diff";
|
||||
|
||||
chat.handle_codex_event_replay(Event {
|
||||
id: "evt-agent-output".into(),
|
||||
msg: EventMsg::RawResponseItem(RawResponseItemEvent {
|
||||
item: agent_inbox_function_call_output(sender, message),
|
||||
}),
|
||||
});
|
||||
chat.handle_codex_event_replay(Event {
|
||||
id: "evt-agent-message".into(),
|
||||
msg: EventMsg::RawResponseItem(RawResponseItemEvent {
|
||||
item: agent_inbox_message(sender, message),
|
||||
}),
|
||||
});
|
||||
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
assert_eq!(
|
||||
cells.len(),
|
||||
1,
|
||||
"expected replayed agent inbox compatibility items to render one history row"
|
||||
);
|
||||
let rendered = cells
|
||||
.iter()
|
||||
.map(|lines| lines_to_single_string(lines))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert_snapshot!(
|
||||
"thread_snapshot_replay_agent_inbox_dedupes_compatibility_items",
|
||||
rendered
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn replayed_user_message_preserves_text_elements_and_local_images() {
|
||||
let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
@@ -2192,6 +2257,7 @@ async fn make_chatwidget_manual(
|
||||
status_line_branch_lookup_complete: false,
|
||||
external_editor_state: ExternalEditorState::Closed,
|
||||
realtime_conversation: RealtimeConversationUiState::default(),
|
||||
last_replayed_agent_inbox_message: None,
|
||||
last_rendered_user_message_event: None,
|
||||
last_non_retry_error: None,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user