GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(codex): add account picker visibility setting · lidge-jun/opencodex@a44af1f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • codex
      • account-namespaces.ts
    • config.ts
    • types.ts
  • tests
    • codex-account-namespaces.test.ts
    • config.test.ts
    • router.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/codex/account-namespaces.ts‎

Copy file name to clipboardExpand all lines: src/codex/account-namespaces.ts
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,14 @@ export function codexAccountNamespaceEntries(
147147
return Object.entries(config.codexAccountNamespaces ?? {})
148148
.map(([namespace, accountId]) => [namespace, normalizeCodexAccountNamespaceTarget(accountId)]);
149149
}
150+
151+
/**
152+
* Whether generated account-qualified rows are enabled for catalog discovery.
153+
* A non-empty hand-written map predating the explicit override remains enabled.
154+
*/
155+
export function codexAccountPickerEnabled(
156+
config: Pick<OcxConfig, "codexAccountNamespaces" | "codexAccountPickerEnabled">,
157+
): boolean {
158+
return (config.codexAccountPickerEnabled === undefined || config.codexAccountPickerEnabled === true)
159+
&& Object.keys(config.codexAccountNamespaces ?? {}).length > 0;
160+
}
Collapse file

‎src/config.ts‎

Copy file name to clipboardExpand all lines: src/config.ts
+38-1Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,9 @@ const configSchema = z.object({
10241024
codexShimAutoRestore: z.boolean().optional(),
10251025
pausedCodexAccountIds: z.array(z.string().regex(/^[a-zA-Z0-9._-]{1,64}$/)).optional(),
10261026
codexAccountNamespaces: codexAccountNamespacesSchema.optional(),
1027+
// A malformed hand edit must degrade to false without discarding providers, accounts,
1028+
// or the exact selector map. Live writes remain strict.
1029+
codexAccountPickerEnabled: z.boolean().optional().catch(false),
10271030
// Model ids excluded from the Grok Build managed block (dashboard switches).
10281031
grokExcludedModels: z.array(z.string()).optional(),
10291032
// Invalid values degrade to undefined ("auto") instead of failing the whole
@@ -1650,6 +1653,18 @@ function malformedNativeSubagentFieldWarning(field: NativeSubagentPersistedField
16501653
return `${field} ignored: expected ${expected}`;
16511654
}
16521655

1656+
function malformedCodexAccountPickerWarning(rawParsed: unknown): string | null {
1657+
const raw = rawConfigRecord(rawParsed);
1658+
if (!raw || !Object.hasOwn(raw, "codexAccountPickerEnabled")) return null;
1659+
if (typeof raw.codexAccountPickerEnabled === "boolean") return null;
1660+
return "codexAccountPickerEnabled ignored: expected a boolean";
1661+
}
1662+
1663+
function warnDegradedCodexAccountPicker(rawParsed: unknown): void {
1664+
const warning = malformedCodexAccountPickerWarning(rawParsed);
1665+
if (warning) console.warn(`⚠️ config.json ${warning}. Other settings were preserved.`);
1666+
}
1667+
16531668
function nativeSubagentSyncDisabledReason(config: OcxConfig, rawParsed?: unknown): string | null {
16541669
if (config.syncCodexSubagentDefaults !== true) return null;
16551670
const malformed = malformedNativeSubagentFields(rawParsed);
@@ -1700,6 +1715,7 @@ export function loadConfig(): OcxConfig {
17001715
warnDegradedApiKeys(parsed, config);
17011716
warnDegradedClaudeSubagentEffort(parsed);
17021717
warnDegradedNativeSubagentConfig(parsed, config);
1718+
warnDegradedCodexAccountPicker(parsed);
17031719
return normalizeClaudeSubagentEffort(normalizeNativeSubagentSync(config, parsed), parsed);
17041720
}
17051721
// Schema validation failed — merge defaults into the raw object instead of
@@ -1719,6 +1735,7 @@ export function loadConfig(): OcxConfig {
17191735
warnDegradedApiKeys(parsed, config);
17201736
warnDegradedClaudeSubagentEffort(parsed);
17211737
warnDegradedNativeSubagentConfig(parsed, config);
1738+
warnDegradedCodexAccountPicker(parsed);
17221739
return normalizeClaudeSubagentEffort(normalizeNativeSubagentSync(config, parsed), parsed);
17231740
}
17241741
// Merge couldn't fix it — truly broken config
@@ -1767,6 +1784,8 @@ function validFileConfigDiagnostics(config: OcxConfig, rawParsed: unknown): Conf
17671784
warnings.push(`claudeCode.subagentEffort ignored: expected one of ${CLAUDE_SUBAGENT_EFFORTS.join(", ")}`);
17681785
}
17691786
warnings.push(...malformedNativeSubagentFields(rawParsed).map(malformedNativeSubagentFieldWarning));
1787+
const pickerWarning = malformedCodexAccountPickerWarning(rawParsed);
1788+
if (pickerWarning) warnings.push(pickerWarning);
17701789
if (syncDisabledReason) {
17711790
warnings.push(`syncCodexSubagentDefaults ignored: ${syncDisabledReason}`);
17721791
}
@@ -1844,12 +1863,30 @@ function googleAntigravityStaticCatalogVersionError(value: unknown): string | nu
18441863
return "schema_invalid: googleAntigravityStaticCatalogVersion: must be 1 or omitted";
18451864
}
18461865

1866+
function codexAccountPickerEnabledError(value: unknown): string | null {
1867+
const raw = rawConfigRecord(value);
1868+
if (!raw) return null;
1869+
const descriptor = Object.getOwnPropertyDescriptor(raw, "codexAccountPickerEnabled");
1870+
if (!descriptor) {
1871+
return "codexAccountPickerEnabled" in raw
1872+
? "schema_invalid: codexAccountPickerEnabled: must be an own boolean data property or omitted"
1873+
: null;
1874+
}
1875+
if (!("value" in descriptor)) {
1876+
return "schema_invalid: codexAccountPickerEnabled: must be an own boolean data property or omitted";
1877+
}
1878+
const enabled = descriptor.value;
1879+
if (enabled === undefined || typeof enabled === "boolean") return null;
1880+
return "schema_invalid: codexAccountPickerEnabled: must be a boolean or omitted";
1881+
}
1882+
18471883
/** Validate an in-memory config candidate without touching disk. Used by headless CLI import/set. */
18481884
export function validateConfigCandidate(value: unknown): { ok: true; config: OcxConfig } | { ok: false; error: string } {
18491885
const boundaryError = blankHostnameError(value)
18501886
?? claudeSubagentEffortError(value)
18511887
?? appOwnedMemoryBudgetError(value)
1852-
?? googleAntigravityStaticCatalogVersionError(value);
1888+
?? googleAntigravityStaticCatalogVersionError(value)
1889+
?? codexAccountPickerEnabledError(value);
18531890
if (boundaryError) return { ok: false, error: boundaryError };
18541891
const result = configSchema.safeParse(value);
18551892
if (result.success) return { ok: true, config: normalizeApiKeyIds(result.data as OcxConfig) };
Collapse file

‎src/types.ts‎

Copy file name to clipboardExpand all lines: src/types.ts
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,11 @@ export interface OcxConfig {
768768
* are intentionally separate from these selectors.
769769
*/
770770
codexAccountNamespaces?: Record<string, string>;
771+
/**
772+
* Picker visibility override for account-qualified native models. When omitted, a non-empty
773+
* selector map remains visible for compatibility with hand-written configurations.
774+
*/
775+
codexAccountPickerEnabled?: boolean;
771776
/** Active pool account id for next session. undefined = main (passthrough as-is). */
772777
activeCodexAccountId?: string;
773778
/** Auto-switch threshold (0-100). Default 80. 0 = disabled. */
Collapse file

‎tests/codex-account-namespaces.test.ts‎

Copy file name to clipboardExpand all lines: tests/codex-account-namespaces.test.ts
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "../src/codex/account-namespace-match";
1313
import {
1414
appendDefaultCodexAccountNamespace,
15+
codexAccountPickerEnabled,
1516
codexAccountNamespaceEntries,
1617
defaultCodexAccountNamespaces,
1718
isMainCodexAccountTarget,
@@ -306,6 +307,29 @@ describe("Codex account namespace foundations", () => {
306307
})).toEqual({ "main-2": "@main", p454545: "main" });
307308
});
308309

310+
test("keeps existing selector maps enabled unless the visibility override is false", () => {
311+
expect(codexAccountPickerEnabled({ codexAccountNamespaces: { desktop: "@main" } })).toBe(true);
312+
expect(codexAccountPickerEnabled({
313+
codexAccountNamespaces: { desktop: "@main" },
314+
codexAccountPickerEnabled: true,
315+
})).toBe(true);
316+
expect(codexAccountPickerEnabled({
317+
codexAccountNamespaces: { desktop: "@main" },
318+
codexAccountPickerEnabled: false,
319+
})).toBe(false);
320+
expect(codexAccountPickerEnabled({
321+
codexAccountNamespaces: {},
322+
codexAccountPickerEnabled: true,
323+
})).toBe(false);
324+
expect(codexAccountPickerEnabled({})).toBe(false);
325+
for (const malformed of [null, "false", 0, {}, []]) {
326+
expect(codexAccountPickerEnabled({
327+
codexAccountNamespaces: { desktop: "@main" },
328+
codexAccountPickerEnabled: malformed as never,
329+
})).toBe(false);
330+
}
331+
});
332+
309333
test("matches route and account namespaces exactly but provider namespaces case-insensitively", () => {
310334
const inherited = Object.create({ inherited: "account-id" }) as Record<string, string>;
311335
inherited.side = "side-account-id";
Collapse file

‎tests/config.test.ts‎

Copy file name to clipboardExpand all lines: tests/config.test.ts
+89-1Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ describe("opencodex config defaults", () => {
14771477
expect(isValidProviderName("constructor")).toBe(false);
14781478
});
14791479

1480-
test("persists an explicit Codex account selector map without enabling it by default", () => {
1480+
test("persists an explicit Codex account selector map without adding one to defaults", () => {
14811481
const selectors = {
14821482
desktop: "@main",
14831483
work: "work-account",
@@ -1492,6 +1492,94 @@ describe("opencodex config defaults", () => {
14921492
expect(Object.hasOwn(getDefaultConfig(), "codexAccountNamespaces")).toBe(false);
14931493
});
14941494

1495+
test("persists the optional picker override without adding it to defaults", () => {
1496+
for (const enabled of [true, false]) {
1497+
writeAccountNamespaceConfig({ desktop: "@main" }, { codexAccountPickerEnabled: enabled });
1498+
1499+
const diagnostics = readConfigDiagnostics();
1500+
expect(diagnostics.error).toBeNull();
1501+
expect(diagnostics.config.codexAccountPickerEnabled).toBe(enabled);
1502+
}
1503+
1504+
expect(Object.hasOwn(getDefaultConfig(), "codexAccountPickerEnabled")).toBe(false);
1505+
});
1506+
1507+
test("malformed persisted picker visibility fails closed without discarding accounts or providers", () => {
1508+
writeAccountNamespaceConfig({ desktop: "@main", side: "stored-account" }, {
1509+
codexAccountPickerEnabled: "yes",
1510+
codexAccounts: [
1511+
{ id: "main", email: "[email protected]", isMain: true },
1512+
{ id: "stored-account", email: "[email protected]", isMain: false },
1513+
],
1514+
});
1515+
1516+
const diagnostics = readConfigDiagnostics();
1517+
expect(diagnostics).toMatchObject({
1518+
source: "file",
1519+
error: null,
1520+
config: {
1521+
defaultProvider: "openai",
1522+
providers: { openai: { baseUrl: "https://chatgpt.com/backend-api/codex" } },
1523+
codexAccounts: [
1524+
{ id: "main", email: "[email protected]", isMain: true },
1525+
{ id: "stored-account", email: "[email protected]", isMain: false },
1526+
],
1527+
codexAccountNamespaces: { desktop: "@main", side: "stored-account" },
1528+
codexAccountPickerEnabled: false,
1529+
},
1530+
});
1531+
expect(diagnostics.warnings).toContain(
1532+
"codexAccountPickerEnabled ignored: expected a boolean",
1533+
);
1534+
expect(backupNames()).toEqual([]);
1535+
1536+
const warnSpy = spyOn(console, "warn").mockImplementation(() => {});
1537+
try {
1538+
expect(loadConfig()).toMatchObject({
1539+
codexAccountPickerEnabled: false,
1540+
codexAccountNamespaces: { desktop: "@main", side: "stored-account" },
1541+
providers: { openai: { baseUrl: "https://chatgpt.com/backend-api/codex" } },
1542+
});
1543+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("codexAccountPickerEnabled ignored"));
1544+
} finally {
1545+
warnSpy.mockRestore();
1546+
}
1547+
1548+
for (const invalid of [null, "false", 1]) {
1549+
expect(validateConfigCandidate({
1550+
...getDefaultConfig(),
1551+
codexAccountPickerEnabled: invalid,
1552+
})).toMatchObject({
1553+
ok: false,
1554+
error: expect.stringContaining("codexAccountPickerEnabled"),
1555+
});
1556+
}
1557+
1558+
const inherited = Object.assign(
1559+
Object.create({ codexAccountPickerEnabled: true }) as Record<string, unknown>,
1560+
getDefaultConfig(),
1561+
);
1562+
expect(validateConfigCandidate(inherited)).toMatchObject({
1563+
ok: false,
1564+
error: expect.stringContaining("own boolean data property"),
1565+
});
1566+
1567+
let getterCalls = 0;
1568+
const accessor = { ...getDefaultConfig() } as Record<string, unknown>;
1569+
Object.defineProperty(accessor, "codexAccountPickerEnabled", {
1570+
enumerable: true,
1571+
get() {
1572+
getterCalls += 1;
1573+
return true;
1574+
},
1575+
});
1576+
expect(validateConfigCandidate(accessor)).toMatchObject({
1577+
ok: false,
1578+
error: expect.stringContaining("own boolean data property"),
1579+
});
1580+
expect(getterCalls).toBe(0);
1581+
});
1582+
14951583
test("validates Claude Desktop profiles and Codex account selectors independently", () => {
14961584
const desktopProfile = {
14971585
version: 1,
Collapse file

‎tests/router.test.ts‎

Copy file name to clipboardExpand all lines: tests/router.test.ts
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ describe("routeModel registry effort defaults", () => {
130130
});
131131
expect(() => routeModel(config, "side/claude-opus-4-6"))
132132
.toThrow("only supports native OpenAI model ids");
133+
134+
config.codexAccountPickerEnabled = false;
135+
expect(routeModel(config, "side/gpt-5.5")).toMatchObject({
136+
providerName: "openai",
137+
modelId: "gpt-5.5",
138+
codexAccountMode: "pool",
139+
codexAccountId: "side-account-id",
140+
codexAccountNamespace: "side",
141+
provider: { authMode: "forward" },
142+
});
133143
});
134144

135145
test("requires an enabled canonical OpenAI forward provider before exact credential injection", () => {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.