Add TUI request bookkeeping for user verification (#43708)

## What changed

- Track verification parameters and attempt IDs with cancellation tokens so callers can reject stale results after cancellation, server resolution, or reconnect.
- Add `ResolveUserVerification` to send acceptance proofs or cancellation through MCP elicitation responses, omit proofs from session recordings, and remove resolved prompts from thread replay.
- Add typed verification error messages with safe fallbacks that omit raw provider diagnostics.

## Testing

Add unit coverage for attempt invalidation, duplicate attempt prevention, proof serialization, resolved prompt replay, and safe error messages.

GitOrigin-RevId: 3466c9a83fe5f512a861fec062bef10dcd3025c8
This commit is contained in:
riley-oai authored and copyberry committed 2026-09-08 05:12:10 +00:00
1 parent ef6c058202
commit 95327467c3
8 files changed
+503 -17

No files matched your search

+32
View File
@@ -9,6 +9,7 @@ use codex_app_server_protocol::RequestId as AppServerRequestId;
use codex_app_server_protocol::ReviewTarget;
use codex_app_server_protocol::ToolRequestUserInputResponse;
use codex_app_server_protocol::UserInput;
use codex_app_server_protocol::UserVerificationProof;
use codex_config::types::ApprovalsReviewer;
use codex_protocol::ThreadId;
use codex_protocol::approvals::GuardianAssessmentEvent;
@@ -161,6 +162,12 @@ pub(crate) enum AppCommand {
content: Option<Value>,
meta: Option<Value>,
},
#[allow(dead_code)] // Connected by the following verification UI integration.
ResolveUserVerification {
server_name: String,
request_id: AppServerRequestId,
response: UserVerificationResponse,
},
UserInputAnswer {
id: String,
response: ToolRequestUserInputResponse,
@@ -186,6 +193,18 @@ pub(crate) enum AppCommand {
},
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[allow(dead_code)] // Connected by the following verification UI integration.
pub(crate) enum UserVerificationResponse {
Accept {
// AppCommand serialization is used by session recording, not the RPC wire response.
// The controller serializes the assertion only into McpServerElicitationRequestResponse.
#[serde(skip_serializing)]
proof: UserVerificationProof,
},
Cancel,
}
impl AppCommand {
pub(crate) fn interrupt() -> Self {
Self::Interrupt
@@ -294,6 +313,19 @@ impl AppCommand {
}
}
#[allow(dead_code)] // Connected by the following verification UI integration.
pub(crate) fn resolve_user_verification(
server_name: String,
request_id: AppServerRequestId,
response: UserVerificationResponse,
) -> Self {
Self::ResolveUserVerification {
server_name,
request_id,
response,
}
}
pub(crate) fn user_input_answer(id: String, response: ToolRequestUserInputResponse) -> Self {
Self::UserInputAnswer { id, response }
}