mirror of
https://github.com/openai/codex.git
synced 2026-11-22 07:13:50 +00:00
multi-agent: add path-based v2 activity tracking (#27007)
## Why Multi-agent v2 identifies agents by canonical paths, but its tool handlers still emitted the larger legacy collaboration begin/end events built around nickname and role metadata. App-server, rollout-trace, analytics, and TUI consumers therefore lacked one compact path-based completion signal that behaved consistently across live events and replay. The TUI also needs a bounded `/agent` status surface for v2 agents. It should use recent local activity for previews, refresh liveness without loading full histories, and keep the legacy picker available when no path-backed v2 agent is known. ## What changed - Replace the v2 `spawn_agent`, `send_message`, `followup_task`, and `interrupt_agent` legacy lifecycle emissions with a success-only `SubAgentActivity` event. The event records the tool call ID, occurrence time, affected thread, canonical agent path, and `started`, `interacted`, or `interrupted` kind. - Expose the activity as a completion-only app-server v2 `subAgentActivity` thread item in live notifications and reconstructed history, regenerate the protocol schemas, and count it in sub-agent tool analytics. - Track canonical paths from live activity and loaded-thread metadata in the TUI, and render the activity in live and replayed transcripts. - Make `/agent` list running path-backed agents with summaries from bounded local event buffers. Each summary is capped at 240 graphemes, the scan is capped at six recent items, only the last three wrapped lines are shown, and command output is omitted. Liveness falls back to metadata-only `thread/read` when local turn state is unavailable. - Persist the activity as a terminal rollout-trace runtime payload and reduce it to the corresponding spawn, send, follow-up, or close interaction edge. `interrupt_agent` is classified as a close-edge operation. - Preserve the legacy picker when no path-backed v2 agent is known. ## Compatibility App-server v2 clients that consumed `collabAgentToolCall` begin/end pairs for these tools must handle the new completion-only `subAgentActivity` item. Legacy v1 collaboration behavior is unchanged. ## Screenshot <img width="684" height="288" alt="Screenshot 2026-06-08 at 15 40 47" src="https://github.com/user-attachments/assets/194b3cd0-619d-45fb-b587-cf3e2b1b8a1d" /> ## Testing - `just test -p codex-app-server-protocol` - `just test -p codex-rollout-trace` - Added focused coverage for activity analytics, terminal trace serialization, spawn-edge reduction, `interrupt_agent` classification, TUI status rendering without aggregated command output, and clearing stale running state after a completed turn.
This commit is contained in:
57 files changed
+2070
-176
No files matched your search
@@ -62,6 +62,7 @@ use crate::multi_agents::agent_picker_status_dot_spans;
|
||||
use crate::multi_agents::format_agent_picker_item_name;
|
||||
use crate::multi_agents::next_agent_shortcut_matches;
|
||||
use crate::multi_agents::previous_agent_shortcut_matches;
|
||||
use crate::multi_agents::sub_agent_activity_display;
|
||||
use crate::pager_overlay::Overlay;
|
||||
use crate::render::highlight::highlight_bash_to_lines;
|
||||
use crate::render::renderable::Renderable;
|
||||
@@ -198,6 +199,7 @@ use toml::Value as TomlValue;
|
||||
use uuid::Uuid;
|
||||
mod agent_message_consolidation;
|
||||
mod agent_navigation;
|
||||
mod agent_status_feed;
|
||||
mod app_server_event_targets;
|
||||
mod app_server_events;
|
||||
pub(crate) mod app_server_requests;
|
||||
@@ -267,6 +269,20 @@ fn collab_receiver_thread_ids(notification: &ServerNotification) -> Option<&[Str
|
||||
}
|
||||
}
|
||||
|
||||
fn sub_agent_activity_item(notification: &ServerNotification) -> Option<&ThreadItem> {
|
||||
match notification {
|
||||
ServerNotification::ItemStarted(notification) => match ¬ification.item {
|
||||
ThreadItem::SubAgentActivity { .. } => Some(¬ification.item),
|
||||
_ => None,
|
||||
},
|
||||
ServerNotification::ItemCompleted(notification) => match ¬ification.item {
|
||||
ThreadItem::SubAgentActivity { .. } => Some(¬ification.item),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn collab_receiver_is_not_found(
|
||||
notification: &ServerNotification,
|
||||
receiver_thread_id: &str,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
//! updated or marked closed.
|
||||
|
||||
use crate::multi_agents::AgentPickerThreadEntry;
|
||||
use crate::multi_agents::SubAgentActivityDisplay;
|
||||
use crate::multi_agents::format_agent_picker_item_name;
|
||||
use crate::multi_agents::next_agent_shortcut;
|
||||
use crate::multi_agents::previous_agent_shortcut;
|
||||
@@ -86,16 +87,56 @@ impl AgentNavigationState {
|
||||
if !self.threads.contains_key(&thread_id) {
|
||||
self.order.push(thread_id);
|
||||
}
|
||||
let (previous_agent_path, previous_is_running) = self
|
||||
.threads
|
||||
.get(&thread_id)
|
||||
.map(|entry| (entry.agent_path.clone(), entry.is_running))
|
||||
.unwrap_or((None, false));
|
||||
self.threads.insert(
|
||||
thread_id,
|
||||
AgentPickerThreadEntry {
|
||||
agent_nickname,
|
||||
agent_role,
|
||||
agent_path: previous_agent_path,
|
||||
is_running: previous_is_running && !is_closed,
|
||||
is_closed,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn record_sub_agent_activity(&mut self, activity: SubAgentActivityDisplay) {
|
||||
if !self.threads.contains_key(&activity.thread_id) {
|
||||
self.order.push(activity.thread_id);
|
||||
}
|
||||
let entry =
|
||||
self.threads
|
||||
.entry(activity.thread_id)
|
||||
.or_insert_with(|| AgentPickerThreadEntry {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: false,
|
||||
});
|
||||
entry.agent_path = Some(activity.agent_path);
|
||||
entry.is_running = activity.is_running_hint;
|
||||
entry.is_closed = false;
|
||||
}
|
||||
|
||||
pub(crate) fn set_running(&mut self, thread_id: ThreadId, is_running: bool) {
|
||||
if let Some(entry) = self.threads.get_mut(&thread_id) {
|
||||
entry.is_running = is_running;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn set_agent_path(&mut self, thread_id: ThreadId, agent_path: Option<String>) {
|
||||
if let Some(agent_path) = agent_path
|
||||
&& let Some(entry) = self.threads.get_mut(&thread_id)
|
||||
{
|
||||
entry.agent_path = Some(agent_path);
|
||||
}
|
||||
}
|
||||
|
||||
/// Marks a thread as closed without removing it from the traversal cache.
|
||||
///
|
||||
/// Closed threads stay in the picker and in spawn order so users can still review them and so
|
||||
@@ -105,6 +146,7 @@ impl AgentNavigationState {
|
||||
pub(crate) fn mark_closed(&mut self, thread_id: ThreadId) {
|
||||
if let Some(entry) = self.threads.get_mut(&thread_id) {
|
||||
entry.is_closed = true;
|
||||
entry.is_running = false;
|
||||
} else {
|
||||
self.upsert(
|
||||
thread_id, /*agent_nickname*/ None, /*agent_role*/ None,
|
||||
@@ -155,6 +197,22 @@ impl AgentNavigationState {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn ordered_path_backed_subagent_threads(
|
||||
&self,
|
||||
primary_thread_id: Option<ThreadId>,
|
||||
) -> Vec<(ThreadId, &AgentPickerThreadEntry)> {
|
||||
self.ordered_threads()
|
||||
.into_iter()
|
||||
.filter(|(thread_id, entry)| {
|
||||
Some(*thread_id) != primary_thread_id
|
||||
&& entry
|
||||
.agent_path
|
||||
.as_deref()
|
||||
.is_some_and(|agent_path| !agent_path.trim().is_empty())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns tracked thread ids in the same stable order used by the picker.
|
||||
pub(crate) fn tracked_thread_ids(&self) -> Vec<ThreadId> {
|
||||
self.ordered_threads()
|
||||
@@ -217,6 +275,14 @@ impl AgentNavigationState {
|
||||
self.threads
|
||||
.get(&thread_id)
|
||||
.map(|entry| {
|
||||
if !is_primary
|
||||
&& let Some(agent_path) = entry
|
||||
.agent_path
|
||||
.as_deref()
|
||||
.filter(|agent_path| !agent_path.trim().is_empty())
|
||||
{
|
||||
return format!("`{agent_path}`");
|
||||
}
|
||||
format_agent_picker_item_name(
|
||||
entry.agent_nickname.as_deref(),
|
||||
entry.agent_role.as_deref(),
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
//! Bounded, best-effort previews for the v2 `/agent` status output.
|
||||
|
||||
use super::ThreadBufferedEvent;
|
||||
use super::ThreadEventStore;
|
||||
use crate::history_cell::HistoryCell;
|
||||
use crate::history_cell::plain_lines;
|
||||
use crate::text_formatting::truncate_text;
|
||||
use codex_app_server_protocol::CollabAgentTool;
|
||||
use codex_app_server_protocol::ServerNotification;
|
||||
use codex_app_server_protocol::SubAgentActivityKind;
|
||||
use codex_app_server_protocol::ThreadItem;
|
||||
use ratatui::style::Stylize;
|
||||
use ratatui::text::Line;
|
||||
use std::collections::HashSet;
|
||||
|
||||
const AGENT_STATUS_PREVIEW_LINES: usize = 3;
|
||||
const AGENT_STATUS_PREVIEW_ITEMS: usize = 6;
|
||||
const AGENT_STATUS_PREVIEW_GRAPHEMES: usize = 240;
|
||||
const AGENT_STATUS_PREVIEW_INDENT: u16 = 4;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct AgentStatusHistoryCell {
|
||||
entries: Vec<AgentStatusThreadPreview>,
|
||||
}
|
||||
|
||||
impl AgentStatusHistoryCell {
|
||||
pub(super) fn new(entries: Vec<AgentStatusThreadPreview>) -> Self {
|
||||
Self { entries }
|
||||
}
|
||||
}
|
||||
|
||||
impl HistoryCell for AgentStatusHistoryCell {
|
||||
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
|
||||
let mut lines: Vec<Line<'static>> = vec![
|
||||
"/agent".magenta().into(),
|
||||
"Sub-agents running".bold().into(),
|
||||
"".into(),
|
||||
];
|
||||
|
||||
if self.entries.is_empty() {
|
||||
lines.push(" • No sub-agents running.".italic().into());
|
||||
return lines;
|
||||
}
|
||||
|
||||
for entry in &self.entries {
|
||||
lines.push(entry.title_line());
|
||||
let preview_width = width.saturating_sub(AGENT_STATUS_PREVIEW_INDENT).max(1);
|
||||
let preview_lines = entry.preview_lines(preview_width);
|
||||
if preview_lines.is_empty() {
|
||||
lines.push(vec![" ".into(), "No recent activity yet.".dim().italic()].into());
|
||||
} else {
|
||||
lines.extend(preview_lines.into_iter().map(indent_preview_line));
|
||||
}
|
||||
lines.push("".into());
|
||||
}
|
||||
let _ = lines.pop();
|
||||
lines
|
||||
}
|
||||
|
||||
fn raw_lines(&self) -> Vec<Line<'static>> {
|
||||
plain_lines(self.display_lines(u16::MAX))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct AgentStatusThreadPreview {
|
||||
agent_path: String,
|
||||
activity: Vec<String>,
|
||||
}
|
||||
|
||||
impl AgentStatusThreadPreview {
|
||||
pub(super) fn from_store(agent_path: String, store: &ThreadEventStore) -> Self {
|
||||
Self::from_events(agent_path, store.buffer.iter().rev())
|
||||
}
|
||||
|
||||
pub(super) fn empty(agent_path: String) -> Self {
|
||||
Self::from_events(agent_path, std::iter::empty())
|
||||
}
|
||||
|
||||
fn from_events<'a>(
|
||||
agent_path: String,
|
||||
events: impl Iterator<Item = &'a ThreadBufferedEvent>,
|
||||
) -> Self {
|
||||
let mut seen_item_ids = HashSet::new();
|
||||
let mut activity = Vec::new();
|
||||
for event in events {
|
||||
let item = match event {
|
||||
ThreadBufferedEvent::Notification(ServerNotification::ItemCompleted(event)) => {
|
||||
&event.item
|
||||
}
|
||||
ThreadBufferedEvent::Notification(ServerNotification::ItemStarted(event)) => {
|
||||
&event.item
|
||||
}
|
||||
ThreadBufferedEvent::Notification(_)
|
||||
| ThreadBufferedEvent::Request(_)
|
||||
| ThreadBufferedEvent::HistoryEntryResponse(_)
|
||||
| ThreadBufferedEvent::FeedbackSubmission(_) => continue,
|
||||
};
|
||||
if !seen_item_ids.insert(item.id().to_string()) {
|
||||
continue;
|
||||
}
|
||||
if let Some(summary) = activity_summary(item) {
|
||||
activity.push(summary);
|
||||
if activity.len() == AGENT_STATUS_PREVIEW_ITEMS {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
activity.reverse();
|
||||
Self {
|
||||
agent_path,
|
||||
activity,
|
||||
}
|
||||
}
|
||||
|
||||
fn title_line(&self) -> Line<'static> {
|
||||
vec![" • ".dim(), format!("`{}`", self.agent_path).cyan()].into()
|
||||
}
|
||||
|
||||
fn preview_lines(&self, width: u16) -> Vec<Line<'static>> {
|
||||
let mut lines = self
|
||||
.activity
|
||||
.iter()
|
||||
.flat_map(|activity| textwrap::wrap(activity, width as usize))
|
||||
.filter(|line| !line.trim().is_empty())
|
||||
.map(|line| line.into_owned().dim().into())
|
||||
.collect::<Vec<_>>();
|
||||
if lines.len() > AGENT_STATUS_PREVIEW_LINES {
|
||||
lines.drain(..lines.len() - AGENT_STATUS_PREVIEW_LINES);
|
||||
}
|
||||
lines
|
||||
}
|
||||
}
|
||||
|
||||
fn activity_summary(item: &ThreadItem) -> Option<String> {
|
||||
let summary = match item {
|
||||
ThreadItem::AgentMessage { text, .. } | ThreadItem::Plan { text, .. } => text,
|
||||
ThreadItem::Reasoning { summary, .. } => summary.last()?,
|
||||
ThreadItem::CommandExecution { command, .. } => {
|
||||
let command = truncate_text(
|
||||
command,
|
||||
AGENT_STATUS_PREVIEW_GRAPHEMES.saturating_sub("$ ".len()),
|
||||
);
|
||||
return bounded_summary(&format!("$ {command}"));
|
||||
}
|
||||
ThreadItem::FileChange { changes, .. } => {
|
||||
return bounded_summary(&format!("Updated {} file(s)", changes.len()));
|
||||
}
|
||||
ThreadItem::McpToolCall { server, tool, .. } => {
|
||||
return bounded_summary(&format!("MCP {server}/{tool}"));
|
||||
}
|
||||
ThreadItem::DynamicToolCall {
|
||||
namespace, tool, ..
|
||||
} => {
|
||||
let tool = namespace
|
||||
.as_ref()
|
||||
.map(|namespace| format!("{namespace}/{tool}"))
|
||||
.unwrap_or_else(|| tool.clone());
|
||||
return bounded_summary(&format!("Tool {tool}"));
|
||||
}
|
||||
ThreadItem::CollabAgentToolCall { tool, .. } => {
|
||||
let action = match tool {
|
||||
CollabAgentTool::SpawnAgent => "Spawned an agent",
|
||||
CollabAgentTool::SendInput => "Sent input to an agent",
|
||||
CollabAgentTool::ResumeAgent => "Resumed an agent",
|
||||
CollabAgentTool::Wait => "Waited for an agent",
|
||||
CollabAgentTool::CloseAgent => "Closed an agent",
|
||||
};
|
||||
return Some(action.to_string());
|
||||
}
|
||||
ThreadItem::SubAgentActivity {
|
||||
kind, agent_path, ..
|
||||
} => {
|
||||
let action = match kind {
|
||||
SubAgentActivityKind::Started => "Started",
|
||||
SubAgentActivityKind::Interacted => "Contacted",
|
||||
SubAgentActivityKind::Interrupted => "Interrupted",
|
||||
};
|
||||
return bounded_summary(&format!("{action} {agent_path}"));
|
||||
}
|
||||
ThreadItem::WebSearch { query, .. } => {
|
||||
return bounded_summary(&format!("Web search: {query}"));
|
||||
}
|
||||
ThreadItem::ImageView { path, .. } => {
|
||||
return bounded_summary(&format!("Viewed {}", path.display()));
|
||||
}
|
||||
ThreadItem::ImageGeneration { .. } => return Some("Generated an image".to_string()),
|
||||
ThreadItem::EnteredReviewMode { .. } => return Some("Entered review mode".to_string()),
|
||||
ThreadItem::ExitedReviewMode { .. } => return Some("Exited review mode".to_string()),
|
||||
ThreadItem::ContextCompaction { .. } => return Some("Compacted context".to_string()),
|
||||
ThreadItem::UserMessage { .. } | ThreadItem::HookPrompt { .. } => return None,
|
||||
};
|
||||
bounded_summary(summary)
|
||||
}
|
||||
|
||||
fn bounded_summary(summary: &str) -> Option<String> {
|
||||
let summary = truncate_text(summary, AGENT_STATUS_PREVIEW_GRAPHEMES);
|
||||
let summary = summary.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
(!summary.is_empty()).then_some(summary)
|
||||
}
|
||||
|
||||
fn indent_preview_line(mut line: Line<'static>) -> Line<'static> {
|
||||
line.spans.insert(0, " ".into());
|
||||
line
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "agent_status_feed_tests.rs"]
|
||||
mod tests;
|
||||
@@ -0,0 +1,109 @@
|
||||
use super::*;
|
||||
use codex_app_server_protocol::CommandExecutionSource;
|
||||
use codex_app_server_protocol::CommandExecutionStatus;
|
||||
use codex_app_server_protocol::ItemCompletedNotification;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
|
||||
#[test]
|
||||
fn agent_status_uses_bounded_buffered_activity() {
|
||||
let mut store = ThreadEventStore::new(/*capacity*/ 8);
|
||||
store.push_notification(ServerNotification::ItemCompleted(
|
||||
ItemCompletedNotification {
|
||||
item: ThreadItem::CommandExecution {
|
||||
id: "command-1".to_string(),
|
||||
command: "cargo test -p codex-tui".to_string(),
|
||||
cwd: AbsolutePathBuf::try_from("/workspace").expect("absolute path"),
|
||||
process_id: None,
|
||||
source: CommandExecutionSource::Agent,
|
||||
status: CommandExecutionStatus::Completed,
|
||||
command_actions: Vec::new(),
|
||||
aggregated_output: Some("unbounded output\n".repeat(10_000)),
|
||||
exit_code: Some(0),
|
||||
duration_ms: Some(42),
|
||||
},
|
||||
thread_id: "thread-child".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
completed_at_ms: 1,
|
||||
},
|
||||
));
|
||||
store.push_notification(ServerNotification::ItemCompleted(
|
||||
ItemCompletedNotification {
|
||||
item: ThreadItem::AgentMessage {
|
||||
id: "message-1".to_string(),
|
||||
text: "Finished checking the focused TUI tests.".to_string(),
|
||||
phase: None,
|
||||
memory_citation: None,
|
||||
},
|
||||
thread_id: "thread-child".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
completed_at_ms: 2,
|
||||
},
|
||||
));
|
||||
|
||||
let preview = AgentStatusThreadPreview::from_store("/root/reviewer".to_string(), &store);
|
||||
let cell = AgentStatusHistoryCell::new(vec![preview]);
|
||||
let rendered = cell
|
||||
.display_lines(/*width*/ 80)
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
insta::assert_snapshot!(rendered, @r###"
|
||||
/agent
|
||||
Sub-agents running
|
||||
|
||||
• `/root/reviewer`
|
||||
$ cargo test -p codex-tui
|
||||
Finished checking the focused TUI tests.
|
||||
"###);
|
||||
assert!(!rendered.contains("unbounded output"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn agent_status_uses_reasoning_summaries_only() {
|
||||
let mut store = ThreadEventStore::new(/*capacity*/ 8);
|
||||
store.push_notification(ServerNotification::ItemCompleted(
|
||||
ItemCompletedNotification {
|
||||
item: ThreadItem::Reasoning {
|
||||
id: "reasoning-with-summary".to_string(),
|
||||
summary: vec!["safe summary".to_string()],
|
||||
content: vec!["hidden raw reasoning".to_string()],
|
||||
},
|
||||
thread_id: "thread-child".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
completed_at_ms: 1,
|
||||
},
|
||||
));
|
||||
store.push_notification(ServerNotification::ItemCompleted(
|
||||
ItemCompletedNotification {
|
||||
item: ThreadItem::Reasoning {
|
||||
id: "reasoning-without-summary".to_string(),
|
||||
summary: Vec::new(),
|
||||
content: vec!["raw-only reasoning".to_string()],
|
||||
},
|
||||
thread_id: "thread-child".to_string(),
|
||||
turn_id: "turn-1".to_string(),
|
||||
completed_at_ms: 2,
|
||||
},
|
||||
));
|
||||
|
||||
let preview = AgentStatusThreadPreview::from_store("/root/reviewer".to_string(), &store);
|
||||
let cell = AgentStatusHistoryCell::new(vec![preview]);
|
||||
let rendered = cell
|
||||
.display_lines(/*width*/ 80)
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
|
||||
insta::assert_snapshot!(rendered, @r###"
|
||||
/agent
|
||||
Sub-agents running
|
||||
|
||||
• `/root/reviewer`
|
||||
safe summary
|
||||
"###);
|
||||
assert!(!rendered.contains("hidden raw reasoning"));
|
||||
assert!(!rendered.contains("raw-only reasoning"));
|
||||
}
|
||||
@@ -14,8 +14,10 @@
|
||||
//! `SessionSource::SubAgent(ThreadSpawn { parent_thread_id, .. })` edges until no new children are
|
||||
//! found. The primary thread itself is never included in the output.
|
||||
|
||||
use codex_app_server_protocol::SessionSource;
|
||||
use codex_app_server_protocol::Thread;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::SubAgentSource;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
|
||||
@@ -26,6 +28,7 @@ pub(crate) struct LoadedSubagentThread {
|
||||
pub(crate) thread_id: ThreadId,
|
||||
pub(crate) agent_nickname: Option<String>,
|
||||
pub(crate) agent_role: Option<String>,
|
||||
pub(crate) agent_path: Option<String>,
|
||||
}
|
||||
|
||||
/// Walks the spawn tree rooted at `primary_thread_id` and returns every descendant subagent.
|
||||
@@ -84,6 +87,7 @@ pub(crate) fn find_loaded_subagent_threads_for_primary(
|
||||
thread_id,
|
||||
agent_nickname: thread.agent_nickname,
|
||||
agent_role: thread.agent_role,
|
||||
agent_path: thread_spawn_agent_path(&thread.source),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -91,16 +95,22 @@ pub(crate) fn find_loaded_subagent_threads_for_primary(
|
||||
loaded_threads
|
||||
}
|
||||
|
||||
fn thread_spawn_parent_thread_id(
|
||||
source: &codex_app_server_protocol::SessionSource,
|
||||
) -> Option<ThreadId> {
|
||||
let value = serde_json::to_value(source).ok()?;
|
||||
let parent_thread_id = value
|
||||
.get("subAgent")?
|
||||
.get("thread_spawn")?
|
||||
.get("parent_thread_id")?
|
||||
.as_str()?;
|
||||
ThreadId::from_string(parent_thread_id).ok()
|
||||
fn thread_spawn_agent_path(source: &SessionSource) -> Option<String> {
|
||||
match source {
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn { agent_path, .. }) => {
|
||||
agent_path.clone().map(String::from)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn thread_spawn_parent_thread_id(source: &SessionSource) -> Option<ThreadId> {
|
||||
match source {
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id, ..
|
||||
}) => Some(*parent_thread_id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -208,11 +218,13 @@ mod tests {
|
||||
thread_id: child_thread_id,
|
||||
agent_nickname: Some("Scout".to_string()),
|
||||
agent_role: Some("explorer".to_string()),
|
||||
agent_path: None,
|
||||
},
|
||||
LoadedSubagentThread {
|
||||
thread_id: grandchild_thread_id,
|
||||
agent_nickname: Some("Atlas".to_string()),
|
||||
agent_role: Some("worker".to_string()),
|
||||
agent_path: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
@@ -8,6 +8,60 @@ use super::*;
|
||||
|
||||
impl App {
|
||||
pub(super) async fn open_agent_picker(&mut self, app_server: &mut AppServerSession) {
|
||||
self.backfill_loaded_subagent_threads(app_server).await;
|
||||
// V2 subagents are identified by canonical paths observed from activity events or loaded
|
||||
// thread metadata. Prefer local buffered turn state for liveness, and fall back to
|
||||
// thread/read only when no local event channel exists.
|
||||
let path_backed_thread_ids: Vec<_> = self
|
||||
.agent_navigation
|
||||
.ordered_path_backed_subagent_threads(self.primary_thread_id)
|
||||
.into_iter()
|
||||
.map(|(thread_id, _)| thread_id)
|
||||
.collect();
|
||||
for thread_id in path_backed_thread_ids {
|
||||
if let Some(channel) = self.thread_event_channels.get(&thread_id)
|
||||
&& channel.attachment() == ThreadEventAttachment::Live
|
||||
{
|
||||
let is_running = channel.store.lock().await.active_turn_id().is_some();
|
||||
self.agent_navigation.set_running(thread_id, is_running);
|
||||
} else {
|
||||
self.refresh_agent_picker_thread_liveness(app_server, thread_id)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
let path_backed_threads = self
|
||||
.agent_navigation
|
||||
.ordered_path_backed_subagent_threads(self.primary_thread_id);
|
||||
if !path_backed_threads.is_empty() {
|
||||
let running_threads: Vec<_> = path_backed_threads
|
||||
.into_iter()
|
||||
.filter_map(|(thread_id, entry)| {
|
||||
if !entry.is_running || entry.is_closed {
|
||||
return None;
|
||||
}
|
||||
Some((thread_id, entry.agent_path.as_deref()?.trim().to_string()))
|
||||
})
|
||||
.collect();
|
||||
let mut entries = Vec::new();
|
||||
for (thread_id, agent_path) in running_threads {
|
||||
let preview = if let Some(channel) = self.thread_event_channels.get(&thread_id) {
|
||||
let store = channel.store.lock().await;
|
||||
super::agent_status_feed::AgentStatusThreadPreview::from_store(
|
||||
agent_path, &store,
|
||||
)
|
||||
} else {
|
||||
super::agent_status_feed::AgentStatusThreadPreview::empty(agent_path)
|
||||
};
|
||||
entries.push(preview);
|
||||
}
|
||||
|
||||
self.chat_widget
|
||||
.add_to_history(super::agent_status_feed::AgentStatusHistoryCell::new(
|
||||
entries,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
let mut thread_ids = self.agent_navigation.tracked_thread_ids();
|
||||
for thread_id in self.thread_event_channels.keys().copied() {
|
||||
if !thread_ids.contains(&thread_id) {
|
||||
@@ -44,14 +98,14 @@ impl App {
|
||||
let items: Vec<SelectionItem> = self
|
||||
.agent_navigation
|
||||
.ordered_threads()
|
||||
.iter()
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(idx, (thread_id, entry))| {
|
||||
if self.active_thread_id == Some(*thread_id) {
|
||||
if self.active_thread_id == Some(thread_id) {
|
||||
initial_selected_idx = Some(idx);
|
||||
}
|
||||
let id = *thread_id;
|
||||
let is_primary = self.primary_thread_id == Some(*thread_id);
|
||||
let id = thread_id;
|
||||
let is_primary = self.primary_thread_id == Some(thread_id);
|
||||
let name = format_agent_picker_item_name(
|
||||
entry.agent_nickname.as_deref(),
|
||||
entry.agent_role.as_deref(),
|
||||
@@ -62,7 +116,7 @@ impl App {
|
||||
name: name.clone(),
|
||||
name_prefix_spans: agent_picker_status_dot_spans(entry.is_closed),
|
||||
description: Some(uuid.clone()),
|
||||
is_current: self.active_thread_id == Some(*thread_id),
|
||||
is_current: self.active_thread_id == Some(thread_id),
|
||||
actions: vec![Box::new(move |tx| {
|
||||
tx.send(AppEvent::SelectAgentThread(id));
|
||||
})],
|
||||
@@ -145,6 +199,14 @@ impl App {
|
||||
.await
|
||||
{
|
||||
Ok(thread) => {
|
||||
let is_running = matches!(
|
||||
thread.status,
|
||||
codex_app_server_protocol::ThreadStatus::Active { .. }
|
||||
);
|
||||
let is_closed = matches!(
|
||||
thread.status,
|
||||
codex_app_server_protocol::ThreadStatus::NotLoaded
|
||||
);
|
||||
self.upsert_agent_picker_thread(
|
||||
thread_id,
|
||||
thread.agent_nickname.or_else(|| {
|
||||
@@ -157,11 +219,9 @@ impl App {
|
||||
.as_ref()
|
||||
.and_then(|entry| entry.agent_role.clone())
|
||||
}),
|
||||
matches!(
|
||||
thread.status,
|
||||
codex_app_server_protocol::ThreadStatus::NotLoaded
|
||||
),
|
||||
is_closed,
|
||||
);
|
||||
self.agent_navigation.set_running(thread_id, is_running);
|
||||
true
|
||||
}
|
||||
Err(err) => {
|
||||
@@ -186,6 +246,8 @@ impl App {
|
||||
is_closed,
|
||||
);
|
||||
}
|
||||
self.agent_navigation
|
||||
.set_running(thread_id, /*is_running*/ false);
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -248,6 +310,9 @@ impl App {
|
||||
}
|
||||
};
|
||||
let channel = self.ensure_thread_channel(thread_id);
|
||||
if !live_attached {
|
||||
channel.mark_replay_only();
|
||||
}
|
||||
let mut store = channel.store.lock().await;
|
||||
store.set_session(session, turns);
|
||||
Ok(live_attached)
|
||||
@@ -610,13 +675,17 @@ impl App {
|
||||
}
|
||||
|
||||
for thread in find_loaded_subagent_threads_for_primary(threads, primary_thread_id) {
|
||||
let agent_path = thread.agent_path;
|
||||
self.upsert_agent_picker_thread(
|
||||
thread.thread_id,
|
||||
thread.agent_nickname,
|
||||
thread.agent_role,
|
||||
/*is_closed*/ false,
|
||||
);
|
||||
self.agent_navigation
|
||||
.set_agent_path(thread.thread_id, agent_path);
|
||||
}
|
||||
self.sync_active_agent_label();
|
||||
|
||||
!had_read_error
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use crate::history_cell::PlainHistoryCell;
|
||||
use crate::history_cell::UserHistoryCell;
|
||||
use crate::history_cell::new_session_info;
|
||||
use crate::multi_agents::AgentPickerThreadEntry;
|
||||
use crate::multi_agents::SubAgentActivityDisplay;
|
||||
use assert_matches::assert_matches;
|
||||
|
||||
use crate::app_command::AppCommand as Op;
|
||||
@@ -1164,6 +1165,8 @@ async fn collab_receiver_notification_caches_thread_without_app_server_read() {
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: false,
|
||||
})
|
||||
);
|
||||
@@ -1223,6 +1226,8 @@ async fn open_agent_picker_keeps_missing_threads_for_replay() -> Result<()> {
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: true,
|
||||
})
|
||||
);
|
||||
@@ -1256,6 +1261,88 @@ async fn open_agent_picker_preserves_cached_metadata_for_replay_threads() -> Res
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: Some("Robie".to_string()),
|
||||
agent_role: Some("explorer".to_string()),
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: true,
|
||||
})
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn open_agent_picker_clears_completed_path_backed_agent_running_state() -> Result<()> {
|
||||
let mut app = Box::pin(make_test_app()).await;
|
||||
let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(
|
||||
app.chat_widget.config_ref(),
|
||||
))
|
||||
.await
|
||||
.expect("embedded app server");
|
||||
let thread_id = ThreadId::new();
|
||||
let channel = ThreadEventChannel::new(/*capacity*/ 4);
|
||||
{
|
||||
let mut store = channel.store.lock().await;
|
||||
store.push_notification(turn_started_notification(thread_id, "turn-1"));
|
||||
store.push_notification(turn_completed_notification(
|
||||
thread_id,
|
||||
"turn-1",
|
||||
TurnStatus::Completed,
|
||||
));
|
||||
}
|
||||
app.thread_event_channels.insert(thread_id, channel);
|
||||
app.agent_navigation
|
||||
.record_sub_agent_activity(SubAgentActivityDisplay {
|
||||
thread_id,
|
||||
agent_path: "/root/child".to_string(),
|
||||
is_running_hint: true,
|
||||
});
|
||||
|
||||
Box::pin(app.open_agent_picker(&mut app_server)).await;
|
||||
|
||||
assert_eq!(
|
||||
app.agent_navigation.get(&thread_id),
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: Some("/root/child".to_string()),
|
||||
is_running: false,
|
||||
is_closed: false,
|
||||
})
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn open_agent_picker_refreshes_replay_only_path_backed_liveness() -> Result<()> {
|
||||
let mut app = Box::pin(make_test_app()).await;
|
||||
let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(
|
||||
app.chat_widget.config_ref(),
|
||||
))
|
||||
.await
|
||||
.expect("embedded app server");
|
||||
let thread_id = ThreadId::new();
|
||||
let mut channel = ThreadEventChannel::new(/*capacity*/ 4);
|
||||
channel.mark_replay_only();
|
||||
{
|
||||
let mut store = channel.store.lock().await;
|
||||
store.push_notification(turn_started_notification(thread_id, "turn-1"));
|
||||
}
|
||||
app.thread_event_channels.insert(thread_id, channel);
|
||||
app.agent_navigation
|
||||
.record_sub_agent_activity(SubAgentActivityDisplay {
|
||||
thread_id,
|
||||
agent_path: "/root/child".to_string(),
|
||||
is_running_hint: true,
|
||||
});
|
||||
|
||||
Box::pin(app.open_agent_picker(&mut app_server)).await;
|
||||
|
||||
assert_eq!(
|
||||
app.agent_navigation.get(&thread_id),
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: Some("/root/child".to_string()),
|
||||
is_running: false,
|
||||
is_closed: true,
|
||||
})
|
||||
);
|
||||
@@ -1310,6 +1397,8 @@ async fn open_agent_picker_marks_terminal_read_errors_closed() -> Result<()> {
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: Some("Robie".to_string()),
|
||||
agent_role: Some("explorer".to_string()),
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: true,
|
||||
})
|
||||
);
|
||||
@@ -1348,6 +1437,8 @@ fn open_agent_picker_marks_loaded_threads_open() -> Result<()> {
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: false,
|
||||
})
|
||||
);
|
||||
@@ -2819,6 +2910,8 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
|
||||
Some(&AgentPickerThreadEntry {
|
||||
agent_nickname: Some("Robie".to_string()),
|
||||
agent_role: Some("explorer".to_string()),
|
||||
agent_path: None,
|
||||
is_running: false,
|
||||
is_closed: false,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -31,6 +31,12 @@ pub(super) struct FeedbackThreadEvent {
|
||||
pub(super) result: Result<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(super) enum ThreadEventAttachment {
|
||||
Live,
|
||||
ReplayOnly,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct ThreadEventStore {
|
||||
pub(super) session: Option<ThreadSessionState>,
|
||||
@@ -285,6 +291,7 @@ pub(super) struct ThreadEventChannel {
|
||||
pub(super) sender: mpsc::Sender<ThreadBufferedEvent>,
|
||||
pub(super) receiver: Option<mpsc::Receiver<ThreadBufferedEvent>>,
|
||||
pub(super) store: Arc<Mutex<ThreadEventStore>>,
|
||||
attachment: ThreadEventAttachment,
|
||||
}
|
||||
|
||||
impl ThreadEventChannel {
|
||||
@@ -294,9 +301,18 @@ impl ThreadEventChannel {
|
||||
sender,
|
||||
receiver: Some(receiver),
|
||||
store: Arc::new(Mutex::new(ThreadEventStore::new(capacity))),
|
||||
attachment: ThreadEventAttachment::Live,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn mark_replay_only(&mut self) {
|
||||
self.attachment = ThreadEventAttachment::ReplayOnly;
|
||||
}
|
||||
|
||||
pub(super) fn attachment(&self) -> ThreadEventAttachment {
|
||||
self.attachment
|
||||
}
|
||||
|
||||
#[cfg_attr(not(test), allow(dead_code))]
|
||||
pub(super) fn new_with_session(
|
||||
capacity: usize,
|
||||
@@ -310,6 +326,7 @@ impl ThreadEventChannel {
|
||||
store: Arc::new(Mutex::new(ThreadEventStore::new_with_session(
|
||||
capacity, session, turns,
|
||||
))),
|
||||
attachment: ThreadEventAttachment::Live,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -896,6 +896,14 @@ impl App {
|
||||
&mut self,
|
||||
notification: &ServerNotification,
|
||||
) {
|
||||
if let Some(activity) =
|
||||
sub_agent_activity_item(notification).and_then(sub_agent_activity_display)
|
||||
{
|
||||
self.agent_navigation.record_sub_agent_activity(activity);
|
||||
self.sync_active_agent_label();
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(receiver_thread_ids) = collab_receiver_thread_ids(notification) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -327,6 +327,7 @@ impl ChatWidget {
|
||||
reasoning_effort,
|
||||
agents_states,
|
||||
}),
|
||||
item @ ThreadItem::SubAgentActivity { .. } => self.on_sub_agent_activity(item),
|
||||
ThreadItem::EnteredReviewMode { review, .. } if !from_replay => {
|
||||
self.enter_review_mode_with_hint(review, /*from_replay*/ false);
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ impl ChatWidget {
|
||||
reasoning_effort,
|
||||
agents_states,
|
||||
}),
|
||||
item @ ThreadItem::SubAgentActivity { .. } => self.on_sub_agent_activity(item),
|
||||
ThreadItem::DynamicToolCall { .. } => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,13 @@ impl ChatWidget {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn on_sub_agent_activity(&mut self, item: ThreadItem) {
|
||||
self.record_visible_turn_activity();
|
||||
if let Some(cell) = multi_agents::sub_agent_activity_history_cell(&item) {
|
||||
self.on_collab_event(cell);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn handle_file_change_completed_now(&mut self, item: ThreadItem) {
|
||||
let ThreadItem::FileChange { status, .. } = item else {
|
||||
return;
|
||||
|
||||
@@ -192,6 +192,7 @@ mod terminal_title;
|
||||
mod terminal_visualization_instructions;
|
||||
mod text_formatting;
|
||||
mod theme_picker;
|
||||
mod thread_transcript;
|
||||
mod token_usage;
|
||||
mod tooltips;
|
||||
mod transcript_reflow;
|
||||
|
||||
@@ -11,6 +11,7 @@ use codex_app_server_protocol::CollabAgentState;
|
||||
use codex_app_server_protocol::CollabAgentStatus;
|
||||
use codex_app_server_protocol::CollabAgentTool;
|
||||
use codex_app_server_protocol::CollabAgentToolCallStatus;
|
||||
use codex_app_server_protocol::SubAgentActivityKind;
|
||||
use codex_app_server_protocol::ThreadItem;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::openai_models::ReasoningEffort as ReasoningEffortConfig;
|
||||
@@ -35,10 +36,21 @@ pub(crate) struct AgentPickerThreadEntry {
|
||||
pub(crate) agent_nickname: Option<String>,
|
||||
/// Agent type shown in brackets when present, for example `worker`.
|
||||
pub(crate) agent_role: Option<String>,
|
||||
/// Canonical v2 agent path, when the thread was observed through v2 activity.
|
||||
pub(crate) agent_path: Option<String>,
|
||||
/// Whether the latest liveness refresh says the agent thread is actively working.
|
||||
pub(crate) is_running: bool,
|
||||
/// Whether the thread has emitted a close event and should render dimmed.
|
||||
pub(crate) is_closed: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub(crate) struct SubAgentActivityDisplay {
|
||||
pub(crate) thread_id: ThreadId,
|
||||
pub(crate) agent_path: String,
|
||||
pub(crate) is_running_hint: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub(crate) struct AgentMetadata {
|
||||
/// Human-friendly nickname shown in rendered tool-call rows.
|
||||
@@ -266,6 +278,56 @@ pub(crate) fn tool_call_history_cell(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn sub_agent_activity_display(item: &ThreadItem) -> Option<SubAgentActivityDisplay> {
|
||||
let ThreadItem::SubAgentActivity {
|
||||
kind,
|
||||
agent_thread_id,
|
||||
agent_path,
|
||||
..
|
||||
} = item
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
Some(SubAgentActivityDisplay {
|
||||
thread_id: parse_thread_id(agent_thread_id)?,
|
||||
agent_path: agent_path.clone(),
|
||||
is_running_hint: !matches!(kind, SubAgentActivityKind::Interrupted),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn sub_agent_activity_history_cell(item: &ThreadItem) -> Option<PlainHistoryCell> {
|
||||
let ThreadItem::SubAgentActivity {
|
||||
kind, agent_path, ..
|
||||
} = item
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
Some(collab_event(
|
||||
sub_agent_activity_title(*kind, agent_path),
|
||||
Vec::new(),
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn sub_agent_activity_summary(kind: SubAgentActivityKind, agent_path: &str) -> String {
|
||||
match kind {
|
||||
SubAgentActivityKind::Started => format!("Started `{agent_path}`"),
|
||||
SubAgentActivityKind::Interacted => format!("Interacted with `{agent_path}`"),
|
||||
SubAgentActivityKind::Interrupted => format!("Interrupted `{agent_path}`"),
|
||||
}
|
||||
}
|
||||
|
||||
fn sub_agent_activity_title(kind: SubAgentActivityKind, agent_path: &str) -> Line<'static> {
|
||||
let (prefix, path) = match kind {
|
||||
SubAgentActivityKind::Started => ("Started ", agent_path),
|
||||
SubAgentActivityKind::Interacted => ("Interacted with ", agent_path),
|
||||
SubAgentActivityKind::Interrupted => ("Interrupted ", agent_path),
|
||||
};
|
||||
title_spans_line(vec![
|
||||
Span::from(prefix).bold(),
|
||||
Span::from(format!("`{path}`")).cyan(),
|
||||
])
|
||||
}
|
||||
|
||||
fn spawn_end(
|
||||
new_thread_id: Option<ThreadId>,
|
||||
prompt: &str,
|
||||
|
||||
@@ -4,8 +4,6 @@ use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod transcript;
|
||||
|
||||
use crate::app_server_session::AppServerSession;
|
||||
use crate::clipboard_paste::normalize_pasted_search_query;
|
||||
use crate::color::blend;
|
||||
@@ -25,6 +23,9 @@ use crate::status::format_directory_display;
|
||||
use crate::terminal_palette::best_color;
|
||||
use crate::terminal_palette::default_bg;
|
||||
use crate::text_formatting::truncate_text;
|
||||
use crate::thread_transcript::RawReasoningVisibility;
|
||||
use crate::thread_transcript::TranscriptCells;
|
||||
use crate::thread_transcript::load_session_transcript;
|
||||
use crate::tui::FrameRequester;
|
||||
use crate::tui::Tui;
|
||||
use crate::tui::TuiEvent;
|
||||
@@ -60,9 +61,6 @@ use tokio::sync::mpsc;
|
||||
use tokio_stream::StreamExt;
|
||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||
use tracing::warn;
|
||||
use transcript::RawReasoningVisibility;
|
||||
use transcript::TranscriptCells;
|
||||
use transcript::load_session_transcript;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
const PAGE_SIZE: usize = 25;
|
||||
@@ -5751,7 +5749,7 @@ session_picker_view = "dense"
|
||||
|
||||
#[test]
|
||||
fn thread_to_transcript_cells_renders_core_message_types() {
|
||||
use transcript::thread_to_transcript_cells;
|
||||
use crate::thread_transcript::thread_to_transcript_cells;
|
||||
|
||||
let thread_id = ThreadId::new();
|
||||
let thread = Thread {
|
||||
@@ -5820,7 +5818,7 @@ session_picker_view = "dense"
|
||||
|
||||
#[test]
|
||||
fn thread_to_transcript_cells_hides_raw_reasoning_when_not_enabled() {
|
||||
use transcript::thread_to_transcript_cells;
|
||||
use crate::thread_transcript::thread_to_transcript_cells;
|
||||
|
||||
let thread_id = ThreadId::new();
|
||||
let thread = Thread {
|
||||
@@ -5878,7 +5876,7 @@ session_picker_view = "dense"
|
||||
|
||||
#[test]
|
||||
fn thread_to_transcript_cells_shows_raw_reasoning_over_summary_when_enabled() {
|
||||
use transcript::thread_to_transcript_cells;
|
||||
use crate::thread_transcript::thread_to_transcript_cells;
|
||||
|
||||
let thread_id = ThreadId::new();
|
||||
let thread = Thread {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Render persisted thread turns into history-cell building blocks.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::app_server_session::AppServerSession;
|
||||
@@ -7,6 +9,7 @@ use crate::history_cell::HistoryCell;
|
||||
use crate::history_cell::PlainHistoryCell;
|
||||
use crate::history_cell::ReasoningSummaryCell;
|
||||
use crate::history_cell::UserHistoryCell;
|
||||
use crate::multi_agents::sub_agent_activity_summary;
|
||||
use codex_app_server_protocol::Thread;
|
||||
use codex_app_server_protocol::ThreadItem;
|
||||
use codex_protocol::ThreadId;
|
||||
@@ -191,6 +194,11 @@ fn fallback_transcript_cell(item: &ThreadItem) -> Option<PlainHistoryCell> {
|
||||
ThreadItem::CollabAgentToolCall { tool, status, .. } => {
|
||||
vec![format!("agent tool: {tool:?} · {status:?}").dim().into()]
|
||||
}
|
||||
ThreadItem::SubAgentActivity {
|
||||
kind, agent_path, ..
|
||||
} => {
|
||||
vec![sub_agent_activity_summary(*kind, agent_path).dim().into()]
|
||||
}
|
||||
ThreadItem::WebSearch { query, .. } => {
|
||||
vec![vec!["web search: ".dim(), query.clone().into()].into()]
|
||||
}
|
||||
Reference in new issue
Block a user