Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli/account-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async function fetchOAuthRows(
needsReauth: a.needsReauth,
// Forward the server's answer verbatim, including `null`. Collapsing null to "absent" here
// would destroy the one distinction this field exists to make.
plan: a.plan ?? null,
...(Object.hasOwn(a, "plan") ? { plan: a.plan } : {}),
...(a.quota !== undefined ? { quota: a.quota } : {}),
...(a.quotaUnavailable !== undefined ? { quotaUnavailable: a.quotaUnavailable } : {}),
}));
Expand Down
16 changes: 16 additions & 0 deletions tests/cli/cli-account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,22 @@ describe("ocx account CLI (issue #180 matrix)", () => {
expect(new Set(parsed.accounts.map(row => row.type))).toEqual(new Set(["codex", "oauth", "api-key"]));
});

test("OAuth JSON preserves the plan presence signal from older proxies", async () => {
oauthAccounts = [
{ id: "legacy" },
{ id: "unknown", plan: null },
{ id: "known", plan: "max" },
];

const result = await run(["list", "anthropic", "--json"]);
const parsed = JSON.parse(result.stdout) as { accounts: Array<Record<string, unknown>> };

expect(result.code).toBe(0);
expect(parsed.accounts[0]).not.toHaveProperty("plan");
expect(parsed.accounts[1]).toHaveProperty("plan", null);
expect(parsed.accounts[2]).toHaveProperty("plan", "max");
});

test("3: empty providers are skipped by default and shown with --all", async () => {
const normal = await run(["list"]);
const withAll = await run(["list", "--all"]);
Expand Down
Loading