You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "hqhq1025 (via GitHub)" <gi...@apache.org> on 2026/08/21 01:02:02 UTC
Re: [PR] fix: give "what can this connection run" one authority [maka]
hqhq1025 commented on code in PR #3330:
URL: https://github.com/apache/maka/pull/3330#discussion_r3826510530
##########
packages/core/src/llm-connections.ts:
##########
@@ -174,6 +174,86 @@ export function connectionEnabledModelIds(connection: {
return [...seen];
}
+/**
+ * What `connection.models` IS, which is not the same question as where it was
+ * written from.
+ *
+ * `modelSource` records provenance: `'fallback'` for the array a connection was
+ * seeded with, `'fetched'` once a discovery run replaced it. For a provider
+ * whose `modelDiscovery.kind` is `'fallback'` that run replays the array this
+ * build shipped, so `'fetched'` is accurate and still describes a snapshot. The
+ * predicate for "a provider enumerated this account" is therefore a
+ * conjunction, and this is the only place it lives:
+ *
+ * - `live` — a provider with a model-list endpoint enumerated this account.
+ * Evidence, and an allowlist. An empty one is still evidence: it says the
+ * credential reaches nothing, which is a fact about the account.
+ * - `snapshot` — the array this build shipped, either as the seed a
+ * connection was created with or replayed by a `kind: 'fallback'`
+ * provider's discovery run. It describes the provider at release, not the
+ * account, so it cannot rule on what a plan serves (#1584).
+ * - `absent` — no catalog at all, and none asked for. A connection can be
+ * created and used before its first discovery run (#2896).
+ *
+ * The split is by authority, not by how full the array is: "the provider
+ * listed nothing" and "nobody has asked yet" are opposite facts, and an empty
+ * array alone cannot tell them apart. `modelSource` can — the codec keeps it
+ * present exactly when a run has written this row.
+ */
+export type ConnectionModelInventory = 'absent' | 'live' | 'snapshot';
+
+/** The `LlmConnection` fields that decide what a connection may run. */
+export interface ConnectionModelAuthorityInput {
+ readonly providerType: ProviderType;
+ readonly enabledModelIds?: readonly string[];
+ readonly defaultModel?: string;
+ readonly models?: readonly ModelInfo[];
+ readonly modelSource?: ModelDiscoverySource;
+}
+
+export function classifyConnectionModelInventory(
+ connection: ConnectionModelAuthorityInput,
+): ConnectionModelInventory {
+ if (connection.models === undefined || connection.modelSource === undefined) return 'absent';
+ if (!providerSupportsModelDiscovery(connection.providerType)) return 'snapshot';
Review Comment:
[P1] Preserve provider-returned models that are absent from the fallback snapshot
This classifies every `modelDiscovery.kind !== "fallback"` result with `modelSource: "fetched"` as an account-authoritative allowlist, but ZenMux, NVIDIA, DeepInfra, Groq, OpenRouter, and Alibaba still run successful provider responses through `filter: "fallback-models"`. On a normal OpenRouter `/models` response containing one bundled ID and one new compatible ID, discovery persisted only the bundled ID; this authority then rejected the returned, user-enabled model as `not_in_live_list`. These providers expose refresh instead of manual addition, so the first desired outcome in #1584 remains unreachable. Remove snapshot-membership filtering for successful live discovery, or persist an explicit partial/non-authoritative inventory classification before using absence as a veto.
##########
apps/desktop/src/renderer/settings/use-connection-detail.ts:
##########
@@ -478,6 +479,66 @@ export function useConnectionDetail(props: ConnectionDetailProps) {
}
}
+ /**
+ * Introduce a model the provider's catalog does not list.
+ *
+ * Only offered where refresh cannot help: a provider with no model-list
+ * endpoint replays the array this build shipped, so a model the user's plan
+ * serves but Maka has never heard of has no other way in (#1584).
+ *
+ * The id enters `enabledModelIds` — the same user-selection authority a
+ * catalogued model uses, so nothing here pretends the provider advertised
+ * it — and the context window enters `relayModelProfiles`, which is where a
+ * user states a fact no other source knows. Both go in ONE write: the store
+ * requires every declaration to key an enabled model, so a table written
+ * ahead of its id would be rejected.
+ *
+ * The saved table is the base, not the unsaved draft: adding a model must
+ * not silently commit edits the user has open in the capability section.
+ * The draft is then caught up by hand, because a dirty draft deliberately
+ * does not reseed from props — see `relayProfileDraftReseedPlan`.
+ */
+ async function addDeclaredModel(id: string, contextWindow: number) {
+ const modelId = id.trim();
+ if (!modelId || enabledModelIds.includes(modelId)) return;
+ if (connectionDetailActionGuard.has('save-enabled-models') || detailActionBusy) return;
+ const next = [...enabledModelIds, modelId];
+ const previous = enabledModelIds;
+ const lifecycle = connectionDetailLifecycleRef.current;
+ const releaseSaveModels = connectionDetailActionGuard.begin('save-enabled-models');
+ if (!releaseSaveModels) return;
+ setSavingEnabledModels(true);
+ setEnabledModelIds(next);
+ let saved = false;
+ try {
+ await props.bridge.update(connection.slug, {
+ enabledModelIds: next,
+ relayModelProfiles: { ...(savedRelayProfiles ?? {}), [modelId]: { contextWindow } },
Review Comment:
[P1] Keep manually added models across snapshot refresh
This write establishes the user-selected ID and its context-window declaration, but `ConnectionCatalogDocumentOwner.writeModelFetchResult` still reconciles every `source: "fetched"` result as an allowlist. A fallback provider such as `volcengine-agent-plan` labels its replayed shipped snapshot `fetched`; refreshing after adding `deepseek-v4-pro-beta` removed that ID from `enabledModelIds` and pruned its persisted profile, so the model became unusable after restart. This violates #1584’s explicit survival-across-refresh contract. Use the provider-aware inventory classification at the storage boundary: only a genuinely live inventory should rewrite selection/default/profile state; a snapshot refresh should update observed metadata while preserving user authority.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org