Fix TUI app-server permission profile conversions (#16284)

Addresses #16283

Problem: TUI app-server permission approvals could drop filesystem
grants because request and response payloads were round-tripped through
mismatched camelCase and snake_case JSON shapes.
Solution: Replace the lossy JSON round-trips with typed app-server/core
permission conversions so requested and granted permission profiles,
including filesystem paths and scope, are preserved end to end.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-04-01 22:00:27 -06:00
1 parent d1068e057a
commit cb9ef06ecc
15 files changed
+602 -60

No files matched your search

+4 -16
View File
@@ -43,6 +43,7 @@ use url::Url;
use self::realtime::PendingSteerCompareKey;
use crate::app_command::AppCommand;
use crate::app_event::RealtimeAudioDeviceKind;
use crate::app_server_approval_conversions::network_approval_context_to_core;
use crate::app_server_session::ThreadSessionState;
#[cfg(not(target_os = "linux"))]
use crate::audio_device::list_realtime_audio_device_names;
@@ -1283,16 +1284,6 @@ fn thread_session_state_to_legacy_event(
}
}
fn convert_via_json<T, U>(value: T) -> Option<U>
where
T: serde::Serialize,
U: serde::de::DeserializeOwned,
{
serde_json::to_value(value)
.ok()
.and_then(|value| serde_json::from_value(value).ok())
}
fn hook_output_entry_from_notification(
entry: codex_app_server_protocol::HookOutputEntry,
) -> codex_protocol::protocol::HookOutputEntry {
@@ -1371,8 +1362,8 @@ fn exec_approval_request_from_params(
reason: params.reason,
network_approval_context: params
.network_approval_context
.and_then(convert_via_json),
additional_permissions: params.additional_permissions.and_then(convert_via_json),
.map(network_approval_context_to_core),
additional_permissions: params.additional_permissions.map(Into::into),
turn_id: params.turn_id,
approval_id: params.approval_id,
proposed_execpolicy_amendment: params
@@ -1559,10 +1550,7 @@ fn request_permissions_from_params(
turn_id: params.turn_id,
call_id: params.item_id,
reason: params.reason,
permissions: serde_json::from_value(
serde_json::to_value(params.permissions).unwrap_or(serde_json::Value::Null),
)
.unwrap_or_default(),
permissions: params.permissions.into(),
}
}