From 779e5a03c745a4518a5030a4563262a224ffc121 Mon Sep 17 00:00:00 2001 From: Guinness Chen Date: Wed, 25 Mar 2026 12:37:47 -0700 Subject: [PATCH] Remove schema whitespace workaround --- .../schema/typescript/v2/Thread.ts | 2 +- .../v2/ThreadMetadataUpdateParams.ts | 2 +- codex-rs/app-server-protocol/src/export.rs | 32 ------------------- .../src/schema_fixtures.rs | 5 ++- 4 files changed, 4 insertions(+), 37 deletions(-) diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts b/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts index 0d91e1ba4e..c1fe04fc46 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/Thread.ts @@ -66,7 +66,7 @@ name: string | null, /** * Arbitrary client-defined metadata. */ -metadata: { [key in string]?: string }, +metadata: { [key in string]?: string }, /** * Only populated on `thread/resume`, `thread/rollback`, `thread/fork`, and `thread/read` * (when `includeTurns` is true) responses. diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadMetadataUpdateParams.ts b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadMetadataUpdateParams.ts index b5f99f9e27..acfed5cee5 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/ThreadMetadataUpdateParams.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/ThreadMetadataUpdateParams.ts @@ -7,7 +7,7 @@ export type ThreadMetadataUpdateParams = { threadId: string, /** * Replace the stored client-defined metadata for this thread. */ -metadata?: { [key in string]?: string } | null, +metadata?: { [key in string]?: string } | null, /** * Patch the stored Git metadata for this thread. * Omit a field to leave it unchanged, set it to `null` to clear it, or diff --git a/codex-rs/app-server-protocol/src/export.rs b/codex-rs/app-server-protocol/src/export.rs index 8821477fd8..b89f23c666 100644 --- a/codex-rs/app-server-protocol/src/export.rs +++ b/codex-rs/app-server-protocol/src/export.rs @@ -179,12 +179,6 @@ pub fn generate_ts_with_options( } } - if !ts_files.is_empty() { - for file in &ts_files { - normalize_typescript_whitespace_in_file(file)?; - } - } - Ok(()) } @@ -1913,32 +1907,6 @@ fn prepend_header_if_missing(path: &Path) -> Result<()> { Ok(()) } -fn normalize_typescript_whitespace_in_file(path: &Path) -> Result<()> { - let content = - fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display()))?; - let normalized = normalize_typescript_whitespace(&content); - if normalized == content { - return Ok(()); - } - - fs::write(path, normalized).with_context(|| format!("Failed to write {}", path.display()))?; - Ok(()) -} - -pub(crate) fn normalize_typescript_whitespace(content: &str) -> String { - let mut normalized = String::with_capacity(content.len()); - for line in content.lines() { - normalized.push_str(line.trim_end()); - normalized.push('\n'); - } - - if !content.ends_with('\n') { - normalized.pop(); - } - - normalized -} - fn ts_files_in(dir: &Path) -> Result> { let mut files = Vec::new(); for entry in diff --git a/codex-rs/app-server-protocol/src/schema_fixtures.rs b/codex-rs/app-server-protocol/src/schema_fixtures.rs index 7319a0b414..56dcf33a4d 100644 --- a/codex-rs/app-server-protocol/src/schema_fixtures.rs +++ b/codex-rs/app-server-protocol/src/schema_fixtures.rs @@ -5,7 +5,6 @@ use crate::ServerRequest; use crate::export::GENERATED_TS_HEADER; use crate::export::filter_experimental_ts_tree; use crate::export::generate_index_ts_tree; -use crate::export::normalize_typescript_whitespace; use crate::protocol::common::visit_client_response_types; use crate::protocol::common::visit_server_response_types; use anyhow::Context; @@ -141,7 +140,7 @@ fn read_file_bytes(path: &Path) -> Result> { .strip_prefix(GENERATED_TS_HEADER) .unwrap_or(&text) .to_string(); - return Ok(normalize_typescript_whitespace(&text).into_bytes()); + return Ok(text.into_bytes()); } Ok(bytes) } @@ -279,7 +278,7 @@ fn collect_typescript_fixture_file( let output_path = normalize_relative_fixture_path(&output_path); files.insert( output_path, - normalize_typescript_whitespace(&contents.replace("\r\n", "\n").replace('\r', "\n")), + contents.replace("\r\n", "\n").replace('\r', "\n"), ); let mut visitor = TypeScriptFixtureCollector {