mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Show file destinations in TUI change approvals (#39285)
## What changed - Show a description and the destination paths affected by each file-change approval. - Include both source and target paths for moves, format cross-platform paths for display, and show `unavailable` when change details are missing. - Recover file changes from buffered events and thread snapshots so live and replayed approvals retain their destination details. ## Testing - Add coverage for active and replayed approvals, moved and cross-platform paths, and the missing-destination fallback. GitOrigin-RevId: 24f90b313fd8643f90cbead1504c788b140d7fed
This commit is contained in:
1 parent
ba37d0c45b
commit
e7f9fa9cd9
14 files changed
+411
-73
No files matched your search
@@ -0,0 +1,68 @@
|
||||
//! Recover file-change details for live and replayed approval requests.
|
||||
|
||||
use super::*;
|
||||
|
||||
impl App {
|
||||
pub(super) async fn thread_file_change_changes(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
turn_id: &str,
|
||||
item_id: &str,
|
||||
) -> Option<Vec<codex_app_server_protocol::FileUpdateChange>> {
|
||||
let channel = self.thread_event_channels.get(&thread_id)?;
|
||||
let store = channel.store.lock().await;
|
||||
store.file_change_changes(turn_id, item_id)
|
||||
}
|
||||
|
||||
pub(super) async fn handle_thread_event_now_recovering_file_changes(
|
||||
&mut self,
|
||||
event: ThreadBufferedEvent,
|
||||
) {
|
||||
let changes = match (&event, self.active_thread_id) {
|
||||
(ThreadBufferedEvent::Request(request), Some(thread_id)) => match request.as_ref() {
|
||||
ServerRequest::FileChangeRequestApproval { params, .. } => {
|
||||
self.thread_file_change_changes(thread_id, ¶ms.turn_id, ¶ms.item_id)
|
||||
.await
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
match (changes, event) {
|
||||
(Some(changes), ThreadBufferedEvent::Request(request)) => {
|
||||
if self
|
||||
.pending_app_server_requests
|
||||
.contains_server_request(request.as_ref())
|
||||
{
|
||||
self.handle_file_change_request(*request, changes);
|
||||
}
|
||||
}
|
||||
(_, event) => self.handle_thread_event_now(event),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn handle_file_change_request(
|
||||
&mut self,
|
||||
request: ServerRequest,
|
||||
changes: Vec<codex_app_server_protocol::FileUpdateChange>,
|
||||
) {
|
||||
let ServerRequest::FileChangeRequestApproval { params, .. } = request else {
|
||||
return;
|
||||
};
|
||||
self.chat_widget.on_apply_patch_approval_request(
|
||||
params.item_id.clone(),
|
||||
crate::approval_events::ApplyPatchApprovalRequestEvent {
|
||||
call_id: params.item_id,
|
||||
turn_id: params.turn_id,
|
||||
changes: crate::app_server_approval_conversions::file_update_changes_to_display(
|
||||
changes,
|
||||
),
|
||||
reason: params.reason,
|
||||
grant_root: params.grant_root,
|
||||
},
|
||||
);
|
||||
if self.startup_protected_input_boundary && !self.chat_widget.has_active_view() {
|
||||
self.startup_pending_protected_request = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user