dsh-model-switch 0.4.61 → 0.4.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## v0.4.62
|
|
2
|
+
|
|
3
|
+
修复设置页「模型目录偶发加载失败后整个页面卡死」的问题:两个会话在不同供应商上并行、后台任务(如记忆蒸馏)恰在加载瞬间占用 Host 时,`session/modelCatalog` 的一次瞬时失败会把设置页永久留在空目录状态——供应商配置组下拉里所有供应商都带 ⚠、模型下拉没有选项、依赖目录的开关全部禁用,只能重开设置页恢复。
|
|
4
|
+
|
|
5
|
+
- **根因**:`useSettingsCatalog` 只在挂载与供应商排序变化时各加载一次,`.catch()` 只设置错误文案、`groups` 保持 `[]`,没有任何重试或刷新入口。空目录时 `groupProviderChoices` 把每个已配置供应商追加为 `unavailable ⚠`,且宿主目录响应里的 `failures`(哪些供应商只是暂时加载失败)被客户端整个丢弃,"暂时不可用"被渲染成"已删除"。
|
|
6
|
+
- **修复(`src/client/main-row-controller.ts`)**:目录加载改为状态机 `loading / ready / failed`——失败后按 400ms / 1200ms 退避重试(共 3 次尝试),重试成功即自愈;**失败时保留最近一次成功的 groups**(不再把可用目录清空);只有最新一次加载可以落地(取消的加载被丢弃)。新增 `withCatalogFailures()` 把宿主 `failures` 合并为无模型的供应商条目:这些供应商保持可选(不再显示 ⚠),但不发明模型行(种子逻辑因 `models[0]` 为空自动跳过)。`src/client/index.tsx` 的 `loadCatalog` 现在把 `failures` 与 `groups` 一起返回。
|
|
7
|
+
- **UI(`src/client/ModelSwitchSettings.tsx`)**:目录失败时显示明确提示与「重试」按钮;从未加载成功时显示原始失败文案,还留着上一次成功目录时显示"目录暂时不可用(已保存的组仍可编辑)";初始加载期显示"正在加载模型目录…"。供应商配置组的「删除该组」与已选组编辑在目录失败期间保持可用;依赖模型种子的能力开关语义不变(目录为空仍禁用,防误点)。
|
|
8
|
+
- **测试**:`tests/client-controller.spec.ts` 新增 8 条(failures 合并去重、空名回退 id、失败供应商在组编辑器可选、重试助手的首试即成/退避重试/预算用尽抛最后错误/取消即停);`tests/settings-ui.client.spec.tsx` 新增 4 条(加载提示、失败重试按钮触发 reload、残留组可编辑可删除、宿主报失败的供应商不带 ⚠ 且可删除)。`pnpm run check` 全绿(tsc + tsdown + 656 测试 + pack 闸门)。
|
|
9
|
+
|
|
1
10
|
## v0.4.61
|
|
2
11
|
|
|
3
12
|
修复 DSH 0.2.1 上**子代理与团队通道全部不可用**的 P0:`spawn_teammate` / `subagent` 一律失败,报 `cannot get property "workingDirectory" without inject`。
|
package/lib/client.js
CHANGED
|
@@ -1141,8 +1141,10 @@ window.__ModuleLoader__.load({
|
|
|
1141
1141
|
* catalog-only list makes that group unreachable: the row stays stored, no
|
|
1142
1142
|
* selection can open it, and nothing can delete it. Union in every configured
|
|
1143
1143
|
* group's provider and mark the missing ones unavailable so the editor can still
|
|
1144
|
-
* open and remove them.
|
|
1145
|
-
*
|
|
1144
|
+
* open and remove them. Feed this the merged list from `withCatalogFailures` so
|
|
1145
|
+
* a provider that merely failed to load stays selectable instead of looking
|
|
1146
|
+
* deleted.
|
|
1147
|
+
* @param groups - the live model catalog merged with the host's load failures.
|
|
1146
1148
|
* @param configured - provider ids that still have a stored group.
|
|
1147
1149
|
* @param current - the group being edited, kept listed even when it is unknown.
|
|
1148
1150
|
* @returns catalog choices first (original order), then the missing providers.
|
|
@@ -1161,38 +1163,110 @@ window.__ModuleLoader__.load({
|
|
|
1161
1163
|
}
|
|
1162
1164
|
return choices;
|
|
1163
1165
|
}
|
|
1164
|
-
/**
|
|
1166
|
+
/** Backoff between catalog retries: a busy Host clears within seconds, not minutes. */
|
|
1167
|
+
const CATALOG_RETRY_DELAYS_MS = [400, 1200];
|
|
1168
|
+
/**
|
|
1169
|
+
* Load the model catalog with bounded backoff.
|
|
1170
|
+
*
|
|
1171
|
+
* The catalog RPC is one read against a live Host; a transient failure (a busy
|
|
1172
|
+
* Host, a reconnecting remote, a background task saturating the provider
|
|
1173
|
+
* lookups) must recover on its own instead of leaving the settings page stuck
|
|
1174
|
+
* on an empty catalog. Each attempt re-runs `load`; a cancelled load rethrows
|
|
1175
|
+
* the last error without further attempts.
|
|
1176
|
+
*/
|
|
1177
|
+
async function loadCatalogWithRetry(load, options = {}) {
|
|
1178
|
+
const attempts = options.attempts ?? 3;
|
|
1179
|
+
const delaysMs = options.delaysMs ?? CATALOG_RETRY_DELAYS_MS;
|
|
1180
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => {
|
|
1181
|
+
setTimeout(resolve, ms);
|
|
1182
|
+
}));
|
|
1183
|
+
let lastError;
|
|
1184
|
+
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
1185
|
+
if (attempt > 0) await sleep(delaysMs[Math.min(attempt - 1, delaysMs.length - 1)] ?? 0);
|
|
1186
|
+
if (options.cancelled?.() === true) break;
|
|
1187
|
+
try {
|
|
1188
|
+
return await load();
|
|
1189
|
+
} catch (error) {
|
|
1190
|
+
lastError = error;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
throw lastError instanceof Error ? lastError : /* @__PURE__ */ new Error("catalog load failed");
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Merge the host's load failures into the catalog as model-less groups.
|
|
1197
|
+
*
|
|
1198
|
+
* A failed provider is KNOWN (the Host listed it) but temporarily unavailable.
|
|
1199
|
+
* Rendering it as absent would mark every stored route for it "unavailable ⚠"
|
|
1200
|
+
* and lock the provider-group editor while a background task hiccups. A
|
|
1201
|
+
* model-less group keeps the provider selectable without inventing model rows;
|
|
1202
|
+
* seeding logic skips it because `models[0]` is undefined.
|
|
1203
|
+
*/
|
|
1204
|
+
function withCatalogFailures(groups, failures) {
|
|
1205
|
+
const known = new Set(groups.map((group) => group.id));
|
|
1206
|
+
const extra = failures.filter((failure) => failure.id.trim() !== "" && !known.has(failure.id)).map((failure) => ({
|
|
1207
|
+
id: failure.id,
|
|
1208
|
+
name: failure.name.trim() === "" ? failure.id : failure.name,
|
|
1209
|
+
models: []
|
|
1210
|
+
}));
|
|
1211
|
+
return [...groups, ...extra];
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Load the model catalog backing every route editor, with bounded retries.
|
|
1215
|
+
*
|
|
1216
|
+
* A failed load keeps the last successful groups (the editor stays usable and
|
|
1217
|
+
* honest via the error hint) instead of collapsing to an empty catalog; a
|
|
1218
|
+
* provider-order change or `reload()` starts a fresh attempt, and only the
|
|
1219
|
+
* newest attempt may land.
|
|
1220
|
+
*/
|
|
1165
1221
|
function useSettingsCatalog(input) {
|
|
1166
|
-
const [
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1222
|
+
const [state, setState] = (0, react.useState)({
|
|
1223
|
+
status: "loading",
|
|
1224
|
+
groups: [],
|
|
1225
|
+
failures: [],
|
|
1226
|
+
error: void 0
|
|
1227
|
+
});
|
|
1228
|
+
const latest = (0, react.useRef)(input);
|
|
1229
|
+
latest.current = input;
|
|
1230
|
+
const runRef = (0, react.useRef)(0);
|
|
1231
|
+
const run = (0, react.useCallback)(() => {
|
|
1232
|
+
const runId = runRef.current + 1;
|
|
1233
|
+
runRef.current = runId;
|
|
1234
|
+
setState((previous) => ({
|
|
1235
|
+
...previous,
|
|
1236
|
+
status: "loading"
|
|
1237
|
+
}));
|
|
1238
|
+
loadCatalogWithRetry(() => latest.current.loadCatalog(), { cancelled: () => runId !== runRef.current }).then((payload) => {
|
|
1239
|
+
if (runId !== runRef.current) return;
|
|
1240
|
+
setState({
|
|
1241
|
+
status: "ready",
|
|
1242
|
+
groups: withCatalogFailures(payload.groups, payload.failures),
|
|
1243
|
+
failures: payload.failures,
|
|
1244
|
+
error: void 0
|
|
1178
1245
|
});
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1246
|
+
}).catch(() => {
|
|
1247
|
+
if (runId !== runRef.current) return;
|
|
1248
|
+
setState((previous) => ({
|
|
1249
|
+
...previous,
|
|
1250
|
+
status: "failed",
|
|
1251
|
+
error: latest.current.t("catalogFailed")
|
|
1252
|
+
}));
|
|
1253
|
+
});
|
|
1254
|
+
}, []);
|
|
1255
|
+
const subscribeRef = (0, react.useRef)(input.subscribeProviderOrder);
|
|
1256
|
+
subscribeRef.current = input.subscribeProviderOrder;
|
|
1257
|
+
(0, react.useEffect)(() => {
|
|
1258
|
+
run();
|
|
1259
|
+
const stop = subscribeRef.current?.(() => {
|
|
1260
|
+
run();
|
|
1183
1261
|
});
|
|
1184
1262
|
return () => {
|
|
1185
|
-
|
|
1263
|
+
runRef.current += 1;
|
|
1186
1264
|
stop?.();
|
|
1187
1265
|
};
|
|
1188
|
-
}, [
|
|
1189
|
-
input.loadCatalog,
|
|
1190
|
-
input.subscribeProviderOrder,
|
|
1191
|
-
input.t
|
|
1192
|
-
]);
|
|
1266
|
+
}, [run]);
|
|
1193
1267
|
return {
|
|
1194
|
-
|
|
1195
|
-
|
|
1268
|
+
...state,
|
|
1269
|
+
reload: run
|
|
1196
1270
|
};
|
|
1197
1271
|
}
|
|
1198
1272
|
//#endregion
|
|
@@ -1650,7 +1724,7 @@ window.__ModuleLoader__.load({
|
|
|
1650
1724
|
return choices;
|
|
1651
1725
|
}
|
|
1652
1726
|
function ModelSwitchSettings(props) {
|
|
1653
|
-
const { groups, catalogError } = useSettingsCatalog(props);
|
|
1727
|
+
const { groups, status: catalogStatus, error: catalogError, reload: reloadCatalog } = useSettingsCatalog(props);
|
|
1654
1728
|
const subagent = props.useSubagentSettings((value) => value);
|
|
1655
1729
|
const search = props.useSearchSettings((value) => value);
|
|
1656
1730
|
const image = props.useImageSettings((value) => value);
|
|
@@ -2289,9 +2363,21 @@ window.__ModuleLoader__.load({
|
|
|
2289
2363
|
className: ModelSwitchSettings_module_css_default.saved,
|
|
2290
2364
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { className: ModelSwitchSettings_module_css_default.savedDot }), synced ? props.t("settingsSynced") : props.t("loading")]
|
|
2291
2365
|
}),
|
|
2292
|
-
catalogError === void 0 ?
|
|
2366
|
+
catalogError === void 0 ? catalogStatus === "loading" && groups.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2367
|
+
className: ModelSwitchSettings_module_css_default.hint,
|
|
2368
|
+
children: props.t("catalogLoading")
|
|
2369
|
+
}) : null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
2293
2370
|
className: cx(ModelSwitchSettings_module_css_default.hint, ModelSwitchSettings_module_css_default.message),
|
|
2294
|
-
children:
|
|
2371
|
+
children: [
|
|
2372
|
+
groups.length === 0 ? catalogError : props.t("catalogUnavailableHint"),
|
|
2373
|
+
" ",
|
|
2374
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2375
|
+
type: "button",
|
|
2376
|
+
className: cx(ModelSwitchSettings_module_css_default.button, ModelSwitchSettings_module_css_default.secondaryButton),
|
|
2377
|
+
onClick: reloadCatalog,
|
|
2378
|
+
children: props.t("catalogRetry")
|
|
2379
|
+
})
|
|
2380
|
+
]
|
|
2295
2381
|
}),
|
|
2296
2382
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2297
2383
|
className: ModelSwitchSettings_module_css_default.group,
|
|
@@ -3397,6 +3483,9 @@ window.__ModuleLoader__.load({
|
|
|
3397
3483
|
loading: "正在加载设置…",
|
|
3398
3484
|
requestFailed: "保存失败",
|
|
3399
3485
|
catalogFailed: "无法加载模型目录。",
|
|
3486
|
+
catalogLoading: "正在加载模型目录…",
|
|
3487
|
+
catalogRetry: "重试",
|
|
3488
|
+
catalogUnavailableHint: "模型目录暂时不可用(后台任务繁忙或 Host 忙碌时会偶发);已显示的供应商与已保存的组仍可编辑,也可点击重试。",
|
|
3400
3489
|
autoReview: "自动审查模型",
|
|
3401
3490
|
autoReviewFollow: "跟随会话模型",
|
|
3402
3491
|
autoReviewHelp: "为官方 auto-review(Auto 权限预设的逐调用审查)指定审查模型;需启用官方 auto-review 能力包。关闭时审查跟随当前会话模型。本插件启用时,官方「自动审查」组件由本插件接管。",
|
|
@@ -3494,6 +3583,9 @@ window.__ModuleLoader__.load({
|
|
|
3494
3583
|
loading: "Loading settings…",
|
|
3495
3584
|
requestFailed: "Save failed",
|
|
3496
3585
|
catalogFailed: "Could not load the model catalog.",
|
|
3586
|
+
catalogLoading: "Loading the model catalog…",
|
|
3587
|
+
catalogRetry: "Retry",
|
|
3588
|
+
catalogUnavailableHint: "The model catalog is temporarily unavailable (it can hiccup while a background task or the Host is busy); the providers shown and saved groups stay editable, or retry now.",
|
|
3497
3589
|
autoReview: "Auto review model",
|
|
3498
3590
|
autoReviewFollow: "Follows the session model",
|
|
3499
3591
|
autoReviewHelp: "Pin the reviewer model for the official auto-review gate (per-call review under the Auto permission preset). Requires the official auto-review bundle. When off, reviews follow the session model. With this plugin enabled the official auto-review component is taken over.",
|
|
@@ -6259,7 +6351,10 @@ window.__ModuleLoader__.load({
|
|
|
6259
6351
|
if (!response.ok || response.value === void 0) throw new Error(t("catalogFailed"));
|
|
6260
6352
|
const enabled = await fetchAntigravityCatalogGroups(connectionRpc);
|
|
6261
6353
|
const order = orderStore.getSnapshot();
|
|
6262
|
-
return
|
|
6354
|
+
return {
|
|
6355
|
+
groups: sortCatalogGroupsWithRoutes(withAntigravityCatalog(response.value.groups, enabled), order, readCatalogRoutes(directory)),
|
|
6356
|
+
failures: response.value.failures
|
|
6357
|
+
};
|
|
6263
6358
|
},
|
|
6264
6359
|
...connectionRpc === void 0 ? {} : { loadCapabilities: async (revision, signal) => {
|
|
6265
6360
|
const rpc = connectionRpc;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { ModelProviderGroup } from '@deepseek-ai/dsh-api-session-controller/types';
|
|
3
2
|
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
4
3
|
import type { InjectFace, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
5
4
|
import { type CapabilityRouteView, type ModelSwitchSettingsView, type ReviewStatusView, type SubagentSettingsView, type ToolCatalogRow } from '../client-contract.js';
|
|
@@ -7,6 +6,7 @@ import { type ProviderGroupConfig } from '../provider-group.js';
|
|
|
7
6
|
import type { RuntimeCapabilities } from '../runtime-capabilities.js';
|
|
8
7
|
import { type CapabilitiesSnapshot } from './search-capabilities.js';
|
|
9
8
|
import type { ModelSwitchLocaleKey } from './locales.js';
|
|
9
|
+
import { type SettingsCatalogPayload } from './main-row-controller.js';
|
|
10
10
|
import type { ConfigViewForm, ConfigViewOp } from './derived-config-form.js';
|
|
11
11
|
export interface ModelSwitchSettingsFace {
|
|
12
12
|
t: (key: ModelSwitchLocaleKey) => string;
|
|
@@ -41,7 +41,7 @@ export interface ModelSwitchSettingsFace {
|
|
|
41
41
|
}>;
|
|
42
42
|
/** Replace or remove (undefined) one provider's saved capability group. */
|
|
43
43
|
saveProviderGroup: (provider: string, group: ProviderGroupConfig | undefined) => Promise<void>;
|
|
44
|
-
loadCatalog: () => Promise<
|
|
44
|
+
loadCatalog: () => Promise<SettingsCatalogPayload>;
|
|
45
45
|
/** Host capabilities long-poll; absent in legacy faces, which keep the static-capabilities path. */
|
|
46
46
|
loadCapabilities?: (revision?: number, signal?: AbortSignal) => Promise<CapabilitiesSnapshot>;
|
|
47
47
|
subscribeProviderOrder?: (listener: () => void) => () => void;
|
|
@@ -28,6 +28,9 @@ export declare const zh: {
|
|
|
28
28
|
readonly loading: "正在加载设置…";
|
|
29
29
|
readonly requestFailed: "保存失败";
|
|
30
30
|
readonly catalogFailed: "无法加载模型目录。";
|
|
31
|
+
readonly catalogLoading: "正在加载模型目录…";
|
|
32
|
+
readonly catalogRetry: "重试";
|
|
33
|
+
readonly catalogUnavailableHint: "模型目录暂时不可用(后台任务繁忙或 Host 忙碌时会偶发);已显示的供应商与已保存的组仍可编辑,也可点击重试。";
|
|
31
34
|
readonly autoReview: "自动审查模型";
|
|
32
35
|
readonly autoReviewFollow: "跟随会话模型";
|
|
33
36
|
readonly autoReviewHelp: "为官方 auto-review(Auto 权限预设的逐调用审查)指定审查模型;需启用官方 auto-review 能力包。关闭时审查跟随当前会话模型。本插件启用时,官方「自动审查」组件由本插件接管。";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelProviderGroup } from '@deepseek-ai/dsh-api-session-controller/types';
|
|
1
|
+
import type { ModelCatalogFailure, ModelProviderGroup } from '@deepseek-ai/dsh-api-session-controller/types';
|
|
2
2
|
import type { CapabilityRouteView } from '../client-contract.js';
|
|
3
3
|
import type { ModelSwitchLocaleKey } from './locales.js';
|
|
4
4
|
export interface Choice {
|
|
@@ -25,20 +25,74 @@ export declare function deriveRouteChoices(groups: readonly ModelProviderGroup[]
|
|
|
25
25
|
* catalog-only list makes that group unreachable: the row stays stored, no
|
|
26
26
|
* selection can open it, and nothing can delete it. Union in every configured
|
|
27
27
|
* group's provider and mark the missing ones unavailable so the editor can still
|
|
28
|
-
* open and remove them.
|
|
29
|
-
*
|
|
28
|
+
* open and remove them. Feed this the merged list from `withCatalogFailures` so
|
|
29
|
+
* a provider that merely failed to load stays selectable instead of looking
|
|
30
|
+
* deleted.
|
|
31
|
+
* @param groups - the live model catalog merged with the host's load failures.
|
|
30
32
|
* @param configured - provider ids that still have a stored group.
|
|
31
33
|
* @param current - the group being edited, kept listed even when it is unknown.
|
|
32
34
|
* @returns catalog choices first (original order), then the missing providers.
|
|
33
35
|
*/
|
|
34
36
|
export declare function groupProviderChoices(groups: readonly ModelProviderGroup[], configured: readonly string[], current: string | undefined): Choice[];
|
|
37
|
+
/** One provider whose model catalog lookup failed on the Host (`ModelCatalogFailure`). */
|
|
38
|
+
export type CatalogFailure = ModelCatalogFailure;
|
|
39
|
+
/** What one catalog load resolves with: successful groups plus the host's isolated failures. */
|
|
40
|
+
export interface SettingsCatalogPayload {
|
|
41
|
+
readonly groups: readonly ModelProviderGroup[];
|
|
42
|
+
readonly failures: readonly CatalogFailure[];
|
|
43
|
+
}
|
|
44
|
+
/** How many attempts one catalog load makes before the settings page gives up. */
|
|
45
|
+
export declare const CATALOG_LOAD_ATTEMPTS = 3;
|
|
46
|
+
/** Backoff between catalog retries: a busy Host clears within seconds, not minutes. */
|
|
47
|
+
export declare const CATALOG_RETRY_DELAYS_MS: readonly number[];
|
|
48
|
+
export interface CatalogRetryOptions {
|
|
49
|
+
attempts?: number;
|
|
50
|
+
delaysMs?: readonly number[];
|
|
51
|
+
sleep?: (ms: number) => Promise<void>;
|
|
52
|
+
cancelled?: () => boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Load the model catalog with bounded backoff.
|
|
56
|
+
*
|
|
57
|
+
* The catalog RPC is one read against a live Host; a transient failure (a busy
|
|
58
|
+
* Host, a reconnecting remote, a background task saturating the provider
|
|
59
|
+
* lookups) must recover on its own instead of leaving the settings page stuck
|
|
60
|
+
* on an empty catalog. Each attempt re-runs `load`; a cancelled load rethrows
|
|
61
|
+
* the last error without further attempts.
|
|
62
|
+
*/
|
|
63
|
+
export declare function loadCatalogWithRetry(load: () => Promise<SettingsCatalogPayload>, options?: CatalogRetryOptions): Promise<SettingsCatalogPayload>;
|
|
64
|
+
/**
|
|
65
|
+
* Merge the host's load failures into the catalog as model-less groups.
|
|
66
|
+
*
|
|
67
|
+
* A failed provider is KNOWN (the Host listed it) but temporarily unavailable.
|
|
68
|
+
* Rendering it as absent would mark every stored route for it "unavailable ⚠"
|
|
69
|
+
* and lock the provider-group editor while a background task hiccups. A
|
|
70
|
+
* model-less group keeps the provider selectable without inventing model rows;
|
|
71
|
+
* seeding logic skips it because `models[0]` is undefined.
|
|
72
|
+
*/
|
|
73
|
+
export declare function withCatalogFailures(groups: readonly ModelProviderGroup[], failures: readonly CatalogFailure[]): ModelProviderGroup[];
|
|
74
|
+
export type SettingsCatalogStatus = 'loading' | 'ready' | 'failed';
|
|
75
|
+
export interface SettingsCatalogState {
|
|
76
|
+
status: SettingsCatalogStatus;
|
|
77
|
+
/** Live groups merged with the host's load failures; the last good list survives a later failure. */
|
|
78
|
+
groups: readonly ModelProviderGroup[];
|
|
79
|
+
failures: readonly CatalogFailure[];
|
|
80
|
+
/** Localized failure message; undefined while loading or ready. */
|
|
81
|
+
error: string | undefined;
|
|
82
|
+
/** Reload now (used by the retry button and provider-order changes). */
|
|
83
|
+
reload(): void;
|
|
84
|
+
}
|
|
35
85
|
export interface SettingsCatalogInputs {
|
|
36
|
-
loadCatalog(): Promise<
|
|
86
|
+
loadCatalog(): Promise<SettingsCatalogPayload>;
|
|
37
87
|
subscribeProviderOrder?: (listener: () => void) => () => void;
|
|
38
88
|
t(key: ModelSwitchLocaleKey): string;
|
|
39
89
|
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Load the model catalog backing every route editor, with bounded retries.
|
|
92
|
+
*
|
|
93
|
+
* A failed load keeps the last successful groups (the editor stays usable and
|
|
94
|
+
* honest via the error hint) instead of collapsing to an empty catalog; a
|
|
95
|
+
* provider-order change or `reload()` starts a fresh attempt, and only the
|
|
96
|
+
* newest attempt may land.
|
|
97
|
+
*/
|
|
98
|
+
export declare function useSettingsCatalog(input: SettingsCatalogInputs): SettingsCatalogState;
|