mirror of
https://github.com/openai/codex.git
synced 2026-11-01 00:15:56 +00:00
## Why `codex-rs/app-server-protocol/src/protocol/v2.rs` had grown into a single ~12k-line definition file for the entire app-server v2 API. This is purely a mechanical refactor to break up the monolithic `v2.rs` file that contains all app-server API v2 types into more modular files, grouped by resource (e.g. account, thread, turn, etc.). `just write-app-server-schema` shows no real changes, so we can be sure that this is purely an internal organizational change. ## What changed - Replaced the monolithic `protocol/v2.rs` with a `protocol/v2/` module tree and a small `mod.rs` that only declares and reexports modules. - Grouped v2 API definitions by conceptual owner, including `account`, `apps`, `collaboration_mode`, `command_exec`, `config`, `device_key`, `experimental_feature`, `feedback`, `fs`, `hook`, `item`, `mcp`, `model`, `notification`, `permissions`, `plugin`, `process`, `realtime`, `review`, `thread`, `thread_data`, `turn`, and `windows_sandbox`. - Moved v2 tests into `protocol/v2/tests.rs` so `mod.rs` stays small. - Kept shared protocol helpers in `protocol/v2/shared.rs`, including the enum mirroring macro and common cross-resource types. - Co-located resource-specific notifications and server-request payloads with the modules that own those resources. - Regenerated app-server protocol schema fixtures. The schema diffs are non-semantic newline-only changes after the refactor. ## Verification - `cargo check -p codex-app-server-protocol` - `cargo test -p codex-app-server-protocol` - `just write-app-server-schema`
66 lines
2.0 KiB
Rust
66 lines
2.0 KiB
Rust
use super::Turn;
|
|
use super::shared::v2_enum_from_core;
|
|
use schemars::JsonSchema;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use ts_rs::TS;
|
|
|
|
v2_enum_from_core!(
|
|
pub enum ReviewDelivery from codex_protocol::protocol::ReviewDelivery {
|
|
Inline, Detached
|
|
}
|
|
);
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ReviewStartParams {
|
|
pub thread_id: String,
|
|
pub target: ReviewTarget,
|
|
|
|
/// Where to run the review: inline (default) on the current thread or
|
|
/// detached on a new thread (returned in `reviewThreadId`).
|
|
#[serde(default)]
|
|
#[ts(optional = nullable)]
|
|
pub delivery: Option<ReviewDelivery>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export_to = "v2/")]
|
|
pub struct ReviewStartResponse {
|
|
pub turn: Turn,
|
|
/// Identifies the thread where the review runs.
|
|
///
|
|
/// For inline reviews, this is the original thread id.
|
|
/// For detached reviews, this is the id of the new review thread.
|
|
pub review_thread_id: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
|
#[serde(tag = "type", rename_all = "camelCase")]
|
|
#[ts(tag = "type", export_to = "v2/")]
|
|
pub enum ReviewTarget {
|
|
/// Review the working tree: staged, unstaged, and untracked files.
|
|
UncommittedChanges,
|
|
|
|
/// Review changes between the current branch and the given base branch.
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(rename_all = "camelCase")]
|
|
BaseBranch { branch: String },
|
|
|
|
/// Review the changes introduced by a specific commit.
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(rename_all = "camelCase")]
|
|
Commit {
|
|
sha: String,
|
|
/// Optional human-readable label (e.g., commit subject) for UIs.
|
|
title: Option<String>,
|
|
},
|
|
|
|
/// Arbitrary instructions, equivalent to the old free-form prompt.
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(rename_all = "camelCase")]
|
|
Custom { instructions: String },
|
|
}
|