Centralize app-server turn error conversion (#62096)

## What changed

Add a shared `From<ErrorEvent>` implementation for `TurnError` and reuse it in thread history, rollout projection, and live event handling. Preserve the existing field mappings and keep `additional_details` unset.

Parameterize the compaction replay test by error code and recoverability, retaining the existing `server_error` case, and document retry expectations for WebSocket closes.

GitOrigin-RevId: 3afcc23e9fdc314477febe6b4a4aeb680efafd5a
This commit is contained in:
adi-oai
2026-11-17 18:56:05 +00:00
committed by copyberry
parent cb64621bf3
commit 0122b120cd
6 changed files with 47 additions and 65 deletions
@@ -451,6 +451,18 @@ pub struct TurnError {
pub misalignment: Option<MisalignmentErrorDetails>,
}
impl From<codex_protocol::protocol::ErrorEvent> for TurnError {
fn from(error: codex_protocol::protocol::ErrorEvent) -> Self {
let additional_details = None;
Self {
message: error.message,
codex_error_info: error.codex_error_info.map(Into::into),
additional_details,
misalignment: error.misalignment.map(Into::into),
}
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]