You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/09/01 03:18:36 UTC
(maka) 02/03: fix(core): drop unservable Codex ids from the stored selection too
This is an automated email from the ASF dual-hosted git repository.
Astro-Han pushed a commit to branch refactor/model-catalog-host-authority
in repository https://gitbox.apache.org/repos/asf/maka.git
commit 696149b28fcab025dc9c642bb142220ef8a459fe
Author: AstroHan <le...@outlook.com>
AuthorDate: Tue Sep 1 11:17:11 2026 +0800
fix(core): drop unservable Codex ids from the stored selection too
`normalizeOpenAiCodexConnection` filtered the model inventory but left
`enabledModelIds` alone. A model this subscription cannot serve was
picker-visible once, so a connection saved back then still lists it
there — and the catalog lists an enabled id back even when no inventory
describes it. The id came out the other side selectable, and failed at
the provider once a scheduled run finally sent to it.
Filter the stored selection by the same rule as the inventory, and keep
the identity return when nothing changed so callers still see an
untouched connection.
Generated-by: Claude Code
---
.../main/__tests__/model-catalog-choices.test.ts | 30 ++++++++++++++++++++++
packages/core/src/model-catalog.ts | 28 ++++++++++++++++----
2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/apps/desktop/src/main/__tests__/model-catalog-choices.test.ts b/apps/desktop/src/main/__tests__/model-catalog-choices.test.ts
index fc213a486a..fae34ca0bf 100644
--- a/apps/desktop/src/main/__tests__/model-catalog-choices.test.ts
+++ b/apps/desktop/src/main/__tests__/model-catalog-choices.test.ts
@@ -26,6 +26,7 @@ import type {
import { resolveConnectionModelCatalog } from '@maka/core/model-catalog';
import { buildChatModelChoices } from '@maka/core/chat-model-choice';
import { pickNewChatModel } from '../../renderer/shell-chat-model-selection.js';
+import { buildCatalogDailyReviewModelOptions } from '../../renderer/model-catalog-choices.js';
function connection(
overrides: Partial<IdentifiedLlmConnection> &
@@ -117,4 +118,33 @@ describe('model catalog picker helpers', () => {
assert.ok(choices.every((choice) => !(choice.connectionName ?? '').includes('@')));
});
+ it('does not offer Daily Review a Codex model the subscription cannot serve', () => {
+ // A connection saved while `gpt-5-codex` was still picker-visible keeps it
+ // in `enabledModelIds`. The inventory filter alone left it there, and the
+ // catalog listed it back as a model no inventory describes — selectable,
+ // and failing at the provider once a scheduled run sent to it.
+ const options = buildCatalogDailyReviewModelOptions(
+ [
+ connection({
+ slug: 'codex',
+ providerType: 'openai-codex',
+ defaultModel: 'gpt-5.5',
+ enabledModelIds: ['gpt-5.5', 'gpt-5-codex'],
+ models: [{ id: 'gpt-5.5' }],
+ modelSource: 'fetched',
+ }),
+ ],
+ '',
+ );
+ const keys = options.map(([key]) => key);
+ assert.ok(
+ keys.includes('codex::gpt-5.5'),
+ `expected the servable model to be offered, got ${JSON.stringify(keys)}`,
+ );
+ assert.equal(
+ keys.includes('codex::gpt-5-codex'),
+ false,
+ `unsupported Codex model was offered: ${JSON.stringify(keys)}`,
+ );
+ });
});
diff --git a/packages/core/src/model-catalog.ts b/packages/core/src/model-catalog.ts
index c7223ac931..52bda9f4dc 100644
--- a/packages/core/src/model-catalog.ts
+++ b/packages/core/src/model-catalog.ts
@@ -350,7 +350,7 @@ export function buildConnectionModelCatalogEntries(
* and the session compatibility projection share one normalization.
*/
export function normalizeOpenAiCodexConnection<
- T extends Pick<LlmConnection, 'providerType' | 'models' | 'defaultModel'>,
+ T extends Pick<LlmConnection, 'providerType' | 'models' | 'defaultModel' | 'enabledModelIds'>,
>(connection: T): T {
if (connection.providerType !== 'openai-codex') return connection;
const fallbackModels = PROVIDER_REGISTRY['openai-codex'].fallbackModels;
@@ -358,15 +358,33 @@ export function normalizeOpenAiCodexConnection<
(entry) => entry.id && !CODEX_SUBSCRIPTION_UNSUPPORTED_CHATGPT_MODELS.has(entry.id),
);
const models = safeModels.length ? safeModels : fallbackModels.map((id) => ({ id }));
- const enabledModelIds = new Set(models.map((entry) => entry.id));
+ // The stored selection is filtered by the same rule as the inventory. An id
+ // this subscription cannot serve was picker-visible once, so it is still in
+ // `enabledModelIds` on a connection saved back then; leaving it there put it
+ // back into the catalog as a model no inventory lists — selectable, and
+ // failing at the provider when a scheduled run finally sent to it.
+ const servableEnabledModelIds = connection.enabledModelIds?.filter(
+ (id) => !CODEX_SUBSCRIPTION_UNSUPPORTED_CHATGPT_MODELS.has(id),
+ );
+ const enabledModelIds =
+ servableEnabledModelIds?.length === connection.enabledModelIds?.length
+ ? connection.enabledModelIds
+ : servableEnabledModelIds;
+ const listedModelIds = new Set(models.map((entry) => entry.id));
const defaultModel =
connection.defaultModel &&
!CODEX_SUBSCRIPTION_UNSUPPORTED_CHATGPT_MODELS.has(connection.defaultModel) &&
- enabledModelIds.has(connection.defaultModel)
+ listedModelIds.has(connection.defaultModel)
? connection.defaultModel
: (models[0]?.id ?? fallbackModels[0] ?? connection.defaultModel);
- if (models === connection.models && defaultModel === connection.defaultModel) return connection;
- return { ...connection, defaultModel, models };
+ if (
+ models === connection.models &&
+ defaultModel === connection.defaultModel &&
+ enabledModelIds === connection.enabledModelIds
+ ) {
+ return connection;
+ }
+ return { ...connection, defaultModel, models, enabledModelIds };
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org