Skip to content

Commit b6bd304

Browse files
committed
docs: clarify legacy discovery migration
1 parent db2cd7e commit b6bd304

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/oauth/index.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,10 @@ export function buildModelsRequest(prov: OcxProviderConfig, apiKey: string | und
542542
* the primary source; this keeps the static fallback (and models-not-in-/models) current.
543543
*
544544
* Only touches providers that are registry-managed AND still `authMode: "oauth"`. Preset fields
545-
* are refreshed, while the registry's `liveModels` default is filled only when the user has no
546-
* explicit toggle. Persists + returns true when anything changed.
545+
* are refreshed, while the registry's `liveModels` default is normally filled only when no value
546+
* is stored. Antigravity has one versioned exception below because its old GUI-generated `true`
547+
* cannot be distinguished from a hand-written pre-migration `true`. Persists + returns true when
548+
* anything changed.
547549
*/
548550
function cloneProviderField(value: unknown): unknown {
549551
if (Array.isArray(value)) return [...value];
@@ -580,9 +582,11 @@ export function reconcileOAuthProviders(config: OcxConfig): boolean {
580582
config.googleAntigravityStaticCatalogVersion !== GOOGLE_ANTIGRAVITY_STATIC_CATALOG_VERSION;
581583
for (const [name, prov] of Object.entries(config.providers)) {
582584
const def = OAUTH_PROVIDERS[name];
583-
// Normalize the canonical row before the OAuth-only reconciliation guard. Legacy GUI
584-
// saves can carry an omitted or non-OAuth authMode, and stamping the migration marker
585-
// while skipping such a row would make its materialized `true` look user-authored later.
585+
// Normalize the canonical row before the OAuth-only reconciliation guard. The old GUI and a
586+
// manual edit both persist the same bare `true`, with no source metadata, so every ambiguous
587+
// pre-marker value is reset once. A deliberate live-discovery choice can be re-enabled after
588+
// the marker and is then preserved. Do this before the guard so omitted/non-OAuth authMode
589+
// rows do not get stamped without actually receiving the new static default.
586590
if (name === GOOGLE_ANTIGRAVITY_PROVIDER && migrateAntigravityStaticCatalog && prov.liveModels !== false) {
587591
prov.liveModels = false;
588592
changed = true;
@@ -598,9 +602,9 @@ export function reconcileOAuthProviders(config: OcxConfig): boolean {
598602
}
599603
changed = true;
600604
}
601-
// Before this marker existed, the GUI materialized an omitted `liveModels` as `true`
602-
// on any settings save. The pre-guard normalization above resets that legacy state
603-
// once; choices made after this migration are preserved by the version boundary.
605+
// Before this marker existed, the GUI materialized an omitted `liveModels` as `true` on any
606+
// settings save. Since persisted values have no provenance, the pre-guard normalization above
607+
// intentionally resets all pre-marker `true` values once. Later choices are version-bounded.
604608
if (prov.liveModels === undefined && preset.liveModels !== undefined) {
605609
prov.liveModels = preset.liveModels;
606610
changed = true;
@@ -676,9 +680,9 @@ export function upsertOAuthProvider(config: OcxConfig, provider: string): void {
676680
const existing = config.providers[provider];
677681
const next: OcxProviderConfig = { ...def.providerConfig };
678682
// `liveModels` is a user-facing provider toggle. A registry default seeds new rows, but an
679-
// explicit post-migration choice must survive re-login and the latest-config upsert. A
680-
// pre-marker Antigravity `true` may have been materialized by the old GUI, so it is reset
681-
// once instead of being misclassified as user provenance.
683+
// explicit post-migration choice must survive re-login and the latest-config upsert. Old GUI
684+
// saves and manual edits left identical pre-marker `true` values, so that ambiguous state is
685+
// reset once; users who deliberately forced discovery can re-enable it after migration.
682686
const preserveExistingLiveModels = provider !== GOOGLE_ANTIGRAVITY_PROVIDER
683687
|| config.googleAntigravityStaticCatalogVersion === GOOGLE_ANTIGRAVITY_STATIC_CATALOG_VERSION;
684688
if (preserveExistingLiveModels && typeof existing?.liveModels === "boolean") {

tests/oauth-provider-reconcile.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ describe("OAuth provider reconciliation", () => {
4141
modelContextWindows: { "gemini-3.5-flash-low": 1_048_576 },
4242
project: "config-project-sentinel",
4343
note: "user-owned-note",
44-
// Older Provider Settings saves materialized this effective default.
44+
// This is deliberately ambiguous: old Provider Settings saves and manual edits
45+
// persisted the same value, so the versioned migration normalizes both once.
4546
liveModels: true,
4647
},
4748
},
@@ -101,7 +102,7 @@ describe("OAuth provider reconciliation", () => {
101102
expect(config.providers["google-antigravity"].models).toHaveLength(6);
102103
});
103104

104-
test("normalizes pre-marker Antigravity rows even when authMode is omitted or non-OAuth", () => {
105+
test("normalizes ambiguous pre-marker Antigravity rows even when authMode is omitted or non-OAuth", () => {
105106
const home = mkdtempSync(join(tmpdir(), "ocx-antigravity-authmode-reconcile-"));
106107
homes.push(home);
107108
process.env.OPENCODEX_HOME = home;
@@ -125,7 +126,7 @@ describe("OAuth provider reconciliation", () => {
125126
}
126127
});
127128

128-
test("seeds the static catalog during pre-marker re-login, then preserves later overrides", () => {
129+
test("normalizes ambiguous pre-marker true during re-login, then preserves later overrides", () => {
129130
const config = {
130131
port: 10100,
131132
defaultProvider: "google-antigravity",

0 commit comments

Comments
 (0)