Skip to content

Commit fbc0ae5

Browse files
ericjutacodex
andcommitted
fix: reconcile upstream picks with local APIs
Adapts selected upstream changes to this branch's existing tool, TUI, and exec-server APIs after scoped lint validation. Co-authored-by: Codex <noreply@openai.com>
1 parent 183ebad commit fbc0ae5

6 files changed

Lines changed: 22 additions & 137 deletions

File tree

codex-rs/core/src/tools/handlers/apply_patch_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use codex_protocol::protocol::SandboxPolicy;
99
use core_test_support::PathBufExt;
1010
use core_test_support::PathExt;
1111
use pretty_assertions::assert_eq;
12+
use serde_json::json;
1213
use std::sync::Arc;
1314
use tempfile::TempDir;
1415
use tokio::sync::Mutex;

codex-rs/core/src/tools/handlers/unified_exec_tests.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,18 +424,19 @@ async fn write_stdin_post_tool_use_payload_keeps_parallel_session_metadata_separ
424424
hook_command: Some("sleep 1; echo beta".to_string()),
425425
};
426426

427-
let (session, turn) = make_session_and_context().await;
427+
let (session_b, turn_b) = make_session_and_context().await;
428428
let invocation_b = ToolInvocation {
429-
session: session.clone().into(),
430-
turn: turn.clone().into(),
429+
session: session_b.into(),
430+
turn: turn_b.into(),
431431
tracker: Arc::new(Mutex::new(TurnDiffTracker::new())),
432432
call_id: "write-call-b".to_string(),
433433
tool_name: codex_tools::ToolName::plain("exec_command"),
434434
payload: payload.clone(),
435435
};
436+
let (session_a, turn_a) = make_session_and_context().await;
436437
let invocation_a = ToolInvocation {
437-
session: session.into(),
438-
turn: turn.into(),
438+
session: session_a.into(),
439+
turn: turn_a.into(),
439440
tracker: Arc::new(Mutex::new(TurnDiffTracker::new())),
440441
call_id: "write-call-a".to_string(),
441442
tool_name: codex_tools::ToolName::plain("exec_command"),

codex-rs/core/src/tools/registry.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,10 @@ where
239239
Box::pin(async move {
240240
let call_id = invocation.call_id.clone();
241241
let payload = invocation.payload.clone();
242+
let post_tool_invocation = invocation.clone();
242243
let output = self.handle(invocation).await?;
243244
let post_tool_use_payload =
244-
ToolHandler::post_tool_use_payload(self, &call_id, &payload, &output);
245+
ToolHandler::post_tool_use_payload(self, &post_tool_invocation, &output);
245246
Ok(AnyToolResult {
246247
call_id,
247248
payload,

codex-rs/exec-server/src/local_process.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ fn notification_sender(inner: &Inner) -> Option<RpcNotificationSender> {
704704
mod tests {
705705
use super::*;
706706
use codex_config::types::ShellEnvironmentPolicyInherit;
707-
use codex_utils_pty::ProcessDriver;
708707
use pretty_assertions::assert_eq;
709708
use tokio::sync::oneshot;
710709
use tokio::time::timeout;
@@ -875,7 +874,7 @@ mod tests {
875874
let previous = processes.insert(
876875
process_id.clone(),
877876
ProcessEntry::Running(Box::new(RunningProcess {
878-
session: dummy_session(),
877+
session: dummy_session().await,
879878
tty: false,
880879
pipe_stdin: false,
881880
output: VecDeque::new(),
@@ -921,21 +920,16 @@ mod tests {
921920
}
922921
}
923922

924-
fn dummy_session() -> ExecCommandSession {
925-
let (writer_tx, _writer_rx) = mpsc::channel(1);
926-
let (_stdout_tx, stdout_rx) = tokio::sync::broadcast::channel(1);
927-
let (_stderr_tx, stderr_rx) = tokio::sync::broadcast::channel(1);
928-
let (_exit_tx, exit_rx) = oneshot::channel();
929-
930-
codex_utils_pty::spawn_from_driver(ProcessDriver {
931-
writer_tx,
932-
stdout_rx,
933-
stderr_rx: Some(stderr_rx),
934-
exit_rx,
935-
terminator: None,
936-
writer_handle: None,
937-
resizer: None,
938-
})
923+
async fn dummy_session() -> ExecCommandSession {
924+
codex_utils_pty::spawn_pipe_process_no_stdin(
925+
"true",
926+
&[],
927+
std::path::Path::new("/tmp"),
928+
&HashMap::new(),
929+
&None,
930+
)
931+
.await
932+
.expect("spawn dummy process")
939933
.session
940934
}
941935

codex-rs/tools/src/tool_config_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ fn memory_tool_defaults_to_native_backend_and_feature_flag() {
225225
model_info: &model_info,
226226
available_models: &available_models,
227227
features: &features,
228+
image_generation_tool_auth_allowed: true,
228229
web_search_mode: Some(WebSearchMode::Cached),
229230
session_source: SessionSource::Cli,
230231
sandbox_policy: &SandboxPolicy::DangerFullAccess,
@@ -244,6 +245,7 @@ fn memory_backend_override_is_retained() {
244245
model_info: &model_info,
245246
available_models: &available_models,
246247
features: &features,
248+
image_generation_tool_auth_allowed: true,
247249
web_search_mode: Some(WebSearchMode::Cached),
248250
session_source: SessionSource::Cli,
249251
sandbox_policy: &SandboxPolicy::DangerFullAccess,

codex-rs/tui/src/app/thread_session_state.rs

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -50,117 +50,3 @@ impl App {
5050
session
5151
}
5252
}
53-
#[cfg(test)]
54-
mod tests {
55-
use super::*;
56-
use crate::app::side::SideThreadState;
57-
use crate::app::test_support::make_test_app;
58-
use crate::app::thread_events::ThreadEventChannel;
59-
use crate::test_support::PathBufExt;
60-
use crate::test_support::test_path_buf;
61-
use codex_config::types::ApprovalsReviewer;
62-
use codex_protocol::protocol::AskForApproval;
63-
use codex_protocol::protocol::SandboxPolicy;
64-
use pretty_assertions::assert_eq;
65-
use std::path::PathBuf;
66-
67-
fn test_thread_session(thread_id: ThreadId, cwd: PathBuf) -> ThreadSessionState {
68-
ThreadSessionState {
69-
thread_id,
70-
forked_from_id: None,
71-
fork_parent_title: None,
72-
thread_name: None,
73-
model: "gpt-test".to_string(),
74-
model_provider_id: "test-provider".to_string(),
75-
service_tier: None,
76-
approval_policy: AskForApproval::Never,
77-
approvals_reviewer: ApprovalsReviewer::User,
78-
sandbox_policy: SandboxPolicy::new_read_only_policy(),
79-
cwd: cwd.abs(),
80-
instruction_source_paths: Vec::new(),
81-
reasoning_effort: None,
82-
history_log_id: 0,
83-
history_entry_count: 0,
84-
network_proxy: None,
85-
rollout_path: Some(PathBuf::new()),
86-
}
87-
}
88-
89-
#[tokio::test]
90-
async fn permission_settings_sync_updates_active_snapshot_without_rewriting_side_thread() {
91-
let mut app = make_test_app().await;
92-
let main_thread_id =
93-
ThreadId::from_string("00000000-0000-0000-0000-000000000401").expect("valid thread");
94-
let side_thread_id =
95-
ThreadId::from_string("00000000-0000-0000-0000-000000000402").expect("valid thread");
96-
let main_session = test_thread_session(main_thread_id, test_path_buf("/tmp/main"));
97-
let side_session = ThreadSessionState {
98-
approval_policy: AskForApproval::OnRequest,
99-
sandbox_policy: SandboxPolicy::new_workspace_write_policy(),
100-
..test_thread_session(side_thread_id, test_path_buf("/tmp/side"))
101-
};
102-
103-
app.primary_thread_id = Some(main_thread_id);
104-
app.active_thread_id = Some(main_thread_id);
105-
app.primary_session_configured = Some(main_session.clone());
106-
app.thread_event_channels.insert(
107-
main_thread_id,
108-
ThreadEventChannel::new_with_session(
109-
/*capacity*/ 4,
110-
main_session.clone(),
111-
Vec::new(),
112-
),
113-
);
114-
app.thread_event_channels.insert(
115-
side_thread_id,
116-
ThreadEventChannel::new_with_session(
117-
/*capacity*/ 4,
118-
side_session.clone(),
119-
Vec::new(),
120-
),
121-
);
122-
app.side_threads
123-
.insert(side_thread_id, SideThreadState::new(main_thread_id));
124-
app.config.permissions.approval_policy =
125-
codex_config::Constrained::allow_any(AskForApproval::OnRequest);
126-
app.config.approvals_reviewer = ApprovalsReviewer::GuardianSubagent;
127-
app.config.permissions.sandbox_policy =
128-
codex_config::Constrained::allow_any(SandboxPolicy::new_workspace_write_policy());
129-
130-
app.sync_active_thread_permission_settings_to_cached_session()
131-
.await;
132-
133-
let expected_main_session = ThreadSessionState {
134-
approval_policy: AskForApproval::OnRequest,
135-
approvals_reviewer: ApprovalsReviewer::GuardianSubagent,
136-
sandbox_policy: SandboxPolicy::new_workspace_write_policy(),
137-
..main_session
138-
};
139-
assert_eq!(
140-
app.primary_session_configured,
141-
Some(expected_main_session.clone())
142-
);
143-
144-
let main_store_session = app
145-
.thread_event_channels
146-
.get(&main_thread_id)
147-
.expect("main thread channel")
148-
.store
149-
.lock()
150-
.await
151-
.session
152-
.clone();
153-
assert_eq!(main_store_session, Some(expected_main_session));
154-
155-
let side_store_session = app
156-
.thread_event_channels
157-
.get(&side_thread_id)
158-
.expect("side thread channel")
159-
.store
160-
.lock()
161-
.await
162-
.session
163-
.clone();
164-
assert_eq!(side_store_session, Some(side_session));
165-
}
166-
}

0 commit comments

Comments
 (0)