codex: address PR review feedback (#26754)

This commit is contained in:
Eric Traut
2026-06-06 18:03:01 -07:00
parent 7d03470539
commit 5cb56085d4
2 changed files with 25 additions and 7 deletions
+1 -2
View File
@@ -608,8 +608,7 @@ impl App {
let request_handle = app_server.request_handle();
let app_event_tx = self.app_event_tx.clone();
tokio::spawn(async move {
let result =
super::side_server::unsubscribe_side_thread(request_handle, thread_id).await;
let result = super::side_server::cleanup_side_thread(request_handle, thread_id).await;
app_event_tx.send(AppEvent::SideThreadCleanupFinished(thread_id, result));
});
}
+24 -5
View File
@@ -6,6 +6,8 @@ use codex_app_server_protocol::ThreadInjectItemsParams;
use codex_app_server_protocol::ThreadInjectItemsResponse;
use codex_app_server_protocol::ThreadUnsubscribeParams;
use codex_app_server_protocol::ThreadUnsubscribeResponse;
use codex_app_server_protocol::TurnInterruptParams;
use codex_app_server_protocol::TurnInterruptResponse;
pub(super) async fn prepare_side_thread(
request_handle: AppServerRequestHandle,
@@ -56,18 +58,35 @@ pub(super) async fn prepare_side_thread(
Ok(started)
}
pub(super) async fn unsubscribe_side_thread(
pub(super) async fn cleanup_side_thread(
request_handle: AppServerRequestHandle,
thread_id: ThreadId,
) -> std::result::Result<(), String> {
request_handle
let interrupt_result = request_handle
.request_typed::<TurnInterruptResponse>(ClientRequest::TurnInterrupt {
request_id: RequestId::String(format!("side-thread-interrupt-{}", Uuid::new_v4())),
params: TurnInterruptParams {
thread_id: thread_id.to_string(),
turn_id: String::new(),
},
})
.await;
let unsubscribe_result = request_handle
.request_typed::<ThreadUnsubscribeResponse>(ClientRequest::ThreadUnsubscribe {
request_id: RequestId::String(format!("side-thread-unsubscribe-{}", Uuid::new_v4())),
params: ThreadUnsubscribeParams {
thread_id: thread_id.to_string(),
},
})
.await
.map(|_| ())
.map_err(|err| format!("thread/unsubscribe failed in TUI: {err}"))
.await;
match (interrupt_result, unsubscribe_result) {
(Ok(_), Ok(_)) => Ok(()),
(Err(interrupt_err), Ok(_)) => Err(format!("turn/interrupt failed: {interrupt_err}")),
(Ok(_), Err(unsubscribe_err)) => {
Err(format!("thread/unsubscribe failed: {unsubscribe_err}"))
}
(Err(interrupt_err), Err(unsubscribe_err)) => Err(format!(
"turn/interrupt failed: {interrupt_err}; thread/unsubscribe failed: {unsubscribe_err}"
)),
}
}