mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
This PR addresses a current hole in the TypeScript code generation for
the API server protocol. Fields that are marked as "Optional<>" in the
Rust code are serialized such that the value is omitted when it is
deserialized — appearing as `undefined`, but the TS type indicates
(incorrectly) that it is always defined but possibly `null`. This can
lead to subtle errors that the TypeScript compiler doesn't catch. The
fix is to include the `#[ts(optional_fields = nullable)]` macro for all
protocol structs that contain one or more `Optional<>` fields.
This PR also includes a new test that validates that all TS protocol
code containing "| null" in its type is marked optional ("?") to catch
cases where `#[ts(optional_fields = nullable)]` is omitted.
22 lines
669 B
Rust
22 lines
669 B
Rust
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use std::path::PathBuf;
|
|
use ts_rs::TS;
|
|
|
|
/// Base namespace for custom prompt slash commands (without trailing colon).
|
|
/// Example usage forms constructed in code:
|
|
/// - Command token after '/': `"{PROMPTS_CMD_PREFIX}:name"`
|
|
/// - Full slash prefix: `"/{PROMPTS_CMD_PREFIX}:"`
|
|
pub const PROMPTS_CMD_PREFIX: &str = "prompts";
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema, TS)]
|
|
#[ts(optional_fields = nullable)]
|
|
pub struct CustomPrompt {
|
|
pub name: String,
|
|
pub path: PathBuf,
|
|
pub content: String,
|
|
pub description: Option<String>,
|
|
pub argument_hint: Option<String>,
|
|
}
|