mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Remove core protocol dependency [2/2] (#20325)
## Why With the local model layer and app-server routing in place from PR1, this PR moves the active TUI runtime onto app-server notifications. The affected pieces share the same event flow, so the command surface, session state, bottom-pane prompts, chat rendering, history/status views, and tests move together to keep the stacked branch buildable. This PR also removes the obsolete compatibility surface that is no longer used after the migration. The proposed protocol-boundary verifier layer was dropped from the stack; enforcing that final boundary will be simpler once `codex-tui` no longer needs any `codex_protocol` references. This PR is part 2 of a 2-PR stack: 1. Add TUI-owned replacement models and extract app-server event routing. 2. Move the active TUI flow to app-server notifications and delete obsolete adapter code. ## What changed - Rewired app command and session handling to use app-server request and notification shapes. - Moved approval overlays, request-user-input flows, MCP elicitation, realtime events, and review commands onto the app-server-facing model surface. - Updated chat rendering, history cells, status views, multi-agent UI, replay state, and TUI tests to use app-server notifications plus the local models introduced in PR1. - Deleted `codex-rs/tui/src/app/app_server_adapter.rs` and the superseded `chatwidget/tests/background_events.rs` fixture path. ## Verification - `cargo check -p codex-tui --tests` - Top of stack: `cargo test -p codex-tui`
This commit is contained in:
1 parent
5cc5f12efc
commit
f2bc2f26a9
76 files changed
+5078
-9951
No files matched your search
@@ -14,10 +14,8 @@
|
||||
//! `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;
|
||||
|
||||
@@ -63,15 +61,12 @@ pub(crate) fn find_loaded_subagent_threads_for_primary(
|
||||
continue;
|
||||
}
|
||||
|
||||
let SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id: source_parent_thread_id,
|
||||
..
|
||||
}) = &thread.source
|
||||
let Some(source_parent_thread_id) = thread_spawn_parent_thread_id(&thread.source)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if *source_parent_thread_id != parent_thread_id {
|
||||
if source_parent_thread_id != parent_thread_id {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -96,6 +91,18 @@ 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()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::LoadedSubagentThread;
|
||||
@@ -104,7 +111,6 @@ mod tests {
|
||||
use codex_app_server_protocol::Thread;
|
||||
use codex_app_server_protocol::ThreadStatus;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::protocol::SubAgentSource;
|
||||
use codex_utils_absolute_path::test_support::PathBufExt;
|
||||
use codex_utils_absolute_path::test_support::test_path_buf;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -131,6 +137,25 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn thread_spawn_source(
|
||||
parent_thread_id: ThreadId,
|
||||
depth: i32,
|
||||
agent_nickname: &str,
|
||||
agent_role: &str,
|
||||
) -> SessionSource {
|
||||
serde_json::from_value(serde_json::json!({
|
||||
"subAgent": {
|
||||
"thread_spawn": {
|
||||
"parent_thread_id": parent_thread_id.to_string(),
|
||||
"depth": depth,
|
||||
"agent_nickname": agent_nickname,
|
||||
"agent_role": agent_role,
|
||||
}
|
||||
}
|
||||
}))
|
||||
.expect("valid subagent source")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_loaded_subagent_tree_for_primary_thread() {
|
||||
let primary_thread_id =
|
||||
@@ -146,39 +171,21 @@ mod tests {
|
||||
|
||||
let mut child = test_thread(
|
||||
child_thread_id,
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id: primary_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: Some("Scout".to_string()),
|
||||
agent_role: Some("explorer".to_string()),
|
||||
}),
|
||||
thread_spawn_source(primary_thread_id, /*depth*/ 1, "Scout", "explorer"),
|
||||
);
|
||||
child.agent_nickname = Some("Scout".to_string());
|
||||
child.agent_role = Some("explorer".to_string());
|
||||
|
||||
let mut grandchild = test_thread(
|
||||
grandchild_thread_id,
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id: child_thread_id,
|
||||
depth: 2,
|
||||
agent_path: None,
|
||||
agent_nickname: Some("Atlas".to_string()),
|
||||
agent_role: Some("worker".to_string()),
|
||||
}),
|
||||
thread_spawn_source(child_thread_id, /*depth*/ 2, "Atlas", "worker"),
|
||||
);
|
||||
grandchild.agent_nickname = Some("Atlas".to_string());
|
||||
grandchild.agent_role = Some("worker".to_string());
|
||||
|
||||
let unrelated_child = test_thread(
|
||||
unrelated_child_id,
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id: unrelated_parent_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: Some("Other".to_string()),
|
||||
agent_role: Some("researcher".to_string()),
|
||||
}),
|
||||
thread_spawn_source(unrelated_parent_id, /*depth*/ 1, "Other", "researcher"),
|
||||
);
|
||||
|
||||
let loaded = find_loaded_subagent_threads_for_primary(
|
||||
|
||||
Reference in new issue
Block a user