Skip to content

Conversation

@bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Oct 27, 2025

Revert #5642 because this generates:

// GENERATED CODE! DO NOT MODIFY BY HAND!

// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type GetAccountResponse = Account | null;

But Account is unknown.

The unique use of #[ts(export)] on GetAccountResponse is also suspicious as are the changes to codex-rs/app-server-protocol/src/export.rs since the existing system has worked fine for quite some time.

Though a pure backout of #5642 puts things in a state where, as the PR noted, the following does not work:

cargo run -p codex-app-server-protocol --bin export -- --out DIR

So in addition to the backout, this PR adds:

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
pub struct GetAccountResponse {
    pub account: Account,
}

and changes GetAccount.response as follows:

-        response: Option<Account>,
+        response: GetAccountResponse,

making it consistent with other types.

With this change, I verified that both of the following work:

just codex generate-ts --out /tmp/somewhere
cargo run -p codex-app-server-protocol --bin export -- --out /tmp/somewhere-else

The generated TypeScript is as follows:

// GetAccountResponse.ts
import type { Account } from "./Account";

export type GetAccountResponse = { account: Account, };

and

// Account.ts
import type { PlanType } from "./PlanType";

export type Account = { "type": "ApiKey", api_key: string, } | { "type": "chatgpt", email: string | null, plan_type: PlanType, };

Though while the inconsistency between "type": "ApiKey" and "type": "chatgpt" is quite concerning, I'm not sure if that format is ever written to disk in any case, but @owenlin0, I would recommend looking into that.

Also, it appears that the types in codex-rs/protocol/src/account.rs are used exclusively by the app-server-protocol crate, so perhaps they should just be moved there?

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 128 to 132
#[ts(rename = "account/read")]
GetAccount {
params: #[ts(type = "undefined")] #[serde(skip_serializing_if = "Option::is_none")] Option<()>,
response: GetAccountResponse,
response: Option<Account>,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore export failure for account/read response

Changing GetAccount back to response: Option<Account> means export_client_responses will again call Option<Account>::export_all_to(...). ts_rs cannot export Option<T> as a standalone type, so the export binary will fail with CannotBeExported before any TypeScript files are generated. The reverted GetAccountResponse wrapper existed solely to represent Account | null while being exportable. With this change, running cargo run -p codex-app-server-protocol --bin export -- --out … will error out, making schema generation unusable.

Useful? React with 👍 / 👎.

@bolinfest
Copy link
Collaborator Author

@codex review please

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bolinfest bolinfest changed the title Back out "[app-server] fix account/read response annotation (#5642)" Oct 27, 2025
@bolinfest bolinfest merged commit a55b0c4 into main Oct 27, 2025
40 checks passed
@bolinfest bolinfest deleted the pr5796 branch October 27, 2025 01:57
@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants