Skip to content

Commit 220eba7

Browse files
committed
Back out "[app-server] fix account/read response annotation (#5642)"
Original commit changeset: 190e7eb
1 parent 7aab45e commit 220eba7

File tree

2 files changed

+13
-31
lines changed

2 files changed

+13
-31
lines changed

codex-rs/app-server-protocol/src/export.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use std::io::Write;
2323
use std::path::Path;
2424
use std::path::PathBuf;
2525
use std::process::Command;
26-
use ts_rs::ExportError;
2726
use ts_rs::TS;
2827

2928
const HEADER: &str = "// GENERATED CODE! DO NOT MODIFY BY HAND!\n\n";
@@ -105,19 +104,6 @@ macro_rules! for_each_schema_type {
105104
};
106105
}
107106

108-
fn export_ts_with_context<F>(label: &str, export: F) -> Result<()>
109-
where
110-
F: FnOnce() -> std::result::Result<(), ExportError>,
111-
{
112-
match export() {
113-
Ok(()) => Ok(()),
114-
Err(ExportError::CannotBeExported(ty)) => Err(anyhow!(
115-
"failed to export {label}: dependency {ty} cannot be exported"
116-
)),
117-
Err(err) => Err(err.into()),
118-
}
119-
}
120-
121107
pub fn generate_types(out_dir: &Path, prettier: Option<&Path>) -> Result<()> {
122108
generate_ts(out_dir, prettier)?;
123109
generate_json(out_dir)?;
@@ -127,17 +113,13 @@ pub fn generate_types(out_dir: &Path, prettier: Option<&Path>) -> Result<()> {
127113
pub fn generate_ts(out_dir: &Path, prettier: Option<&Path>) -> Result<()> {
128114
ensure_dir(out_dir)?;
129115

130-
export_ts_with_context("ClientRequest", || ClientRequest::export_all_to(out_dir))?;
131-
export_ts_with_context("client responses", || export_client_responses(out_dir))?;
132-
export_ts_with_context("ClientNotification", || {
133-
ClientNotification::export_all_to(out_dir)
134-
})?;
135-
136-
export_ts_with_context("ServerRequest", || ServerRequest::export_all_to(out_dir))?;
137-
export_ts_with_context("server responses", || export_server_responses(out_dir))?;
138-
export_ts_with_context("ServerNotification", || {
139-
ServerNotification::export_all_to(out_dir)
140-
})?;
116+
ClientRequest::export_all_to(out_dir)?;
117+
export_client_responses(out_dir)?;
118+
ClientNotification::export_all_to(out_dir)?;
119+
120+
ServerRequest::export_all_to(out_dir)?;
121+
export_server_responses(out_dir)?;
122+
ServerNotification::export_all_to(out_dir)?;
141123

142124
generate_index_ts(out_dir)?;
143125

codex-rs/app-server-protocol/src/protocol.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ client_request_definitions! {
225225
},
226226
}
227227

228+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
229+
#[serde(rename_all = "camelCase")]
230+
pub struct GetAccountResponse {
231+
pub account: Account,
232+
}
233+
228234
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema, TS)]
229235
#[serde(rename_all = "camelCase")]
230236
pub struct InitializeParams {
@@ -535,12 +541,6 @@ pub struct GetAccountRateLimitsResponse {
535541
pub rate_limits: RateLimitSnapshot,
536542
}
537543

538-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
539-
#[serde(transparent)]
540-
#[ts(export)]
541-
#[ts(type = "Account | null")]
542-
pub struct GetAccountResponse(#[ts(type = "Account | null")] pub Option<Account>);
543-
544544
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
545545
#[serde(rename_all = "camelCase")]
546546
pub struct GetAuthStatusResponse {

0 commit comments

Comments
 (0)