Skip to content

Commit e8e5915

Browse files
committed
fix(models): make switches reflect final visibility
1 parent 3b766d9 commit e8e5915

11 files changed

Lines changed: 500 additions & 65 deletions

File tree

‎docs-site/src/content/docs/guides/web-dashboard.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Cost values in **Logs** and **Usage** are API list-price equivalents calculated
4545
They are not billing receipts or evidence of an actual charge; subscription usage or provider credits
4646
may apply instead.
4747

48+
## Model visibility
49+
50+
The **Models** switches show final Codex visibility: a routed model is on only when its provider allowlist includes it (or no allowlist is set) and it is not disabled. Turning a model on reconciles both filters atomically; **All on** clears the provider allowlist so newly discovered models are also on.
51+
4852
## Delegation picker vs spawn routing
4953

5054
The Dashboard's **Sub-agent delegation** picker stores `injectionModel` and, optionally,
@@ -98,6 +102,7 @@ The GUI is a thin client over the proxy's JSON management API. Useful endpoints
98102
| `GET` / `PUT /api/v2` | Read or set the surface mode, Codex feature flag, and v2 thread limit. |
99103
| `GET /api/providers` · `POST /api/providers` · `PATCH /api/providers?name=...` · `DELETE /api/providers?name=...` | List, add/replace, enable/disable, or remove providers. |
100104
| `GET /api/models` · `PUT /api/disabled-models` | List native/routed model rows and update the shared disabled-model set. |
105+
| `GET /api/selected-models` · `PUT /api/model-visibility` | Read provider allowlists and atomically change the final visibility of one model or provider group. |
101106
| `GET /api/key-providers` · `GET /api/oauth/providers` | Read the API-key and OAuth provider catalogs. |
102107
| `POST /api/oauth/login` · `GET /api/oauth/status` | Start a provider OAuth flow and poll for completion. |
103108
| `GET /api/codex-auth/accounts?refresh=1` | List main and pool accounts, force quota refresh, and report main-account `hasCredential` / terminal `needsReauth` state. |

‎docs-site/src/content/docs/ja/guides/web-dashboard.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ bun run dev:gui
4444
**ログ**と**使用量**のコスト値は報告されたトークンで計算した API 定価換算値です。請求明細や
4545
実際の請求証拠ではなく、サブスクリプション使用量またはプロバイダークレジットが代わりに適用される場合があります。
4646

47+
## モデルの表示
48+
49+
**モデル** スイッチは Codex での最終的な表示状態を示します。ルーティングモデルはプロバイダーの allowlist に含まれる(または allowlist がない)うえで、無効化されていない場合だけオンになります。オン操作は両方のフィルターを原子的に調整し、**すべてオン** は allowlist を解除して新しいモデルも含めます。
50+
4751
## 委任セレクターとスポーンルーティングの違い
4852

4953
ダッシュボードの **サブエージェント委任** セレクターは `injectionModel` とオプションの `injectionEffort` を
@@ -92,6 +96,7 @@ GUI はプロキシの JSON 管理 API を使うシンクライアントです
9296
| `GET` / `PUT /api/v2` | サーフェスモード、Codex 機能フラグ、v2 スレッド上限を読むか変えます。 |
9397
| `GET /api/providers` · `POST /api/providers` · `PATCH /api/providers?name=...` · `DELETE /api/providers?name=...` | プロバイダー一覧の参照、追加/差替、有効化/無効化、削除。 |
9498
| `GET /api/models` · `PUT /api/disabled-models` | ネイティブ/ルーティングモデル行を参照し共有 disabled model 一覧を更新します。 |
99+
| `GET /api/selected-models` · `PUT /api/model-visibility` | プロバイダー allowlist を読み取り、モデルまたはプロバイダーグループの最終表示状態を原子的に変更します。 |
95100
| `GET /api/key-providers` · `GET /api/oauth/providers` | API キーおよび OAuth プロバイダーカタログを読みます。 |
96101
| `POST /api/oauth/login` · `GET /api/oauth/status` | プロバイダー OAuth ログインを開始し完了可否を確認します。 |
97102
| `GET /api/codex-auth/accounts?refresh=1` | メインおよびプールアカウントを参照しクォータを強制更新し、メインの `hasCredential` / terminal `needsReauth` 状態を返します。 |

‎docs-site/src/content/docs/ko/guides/web-dashboard.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ bun run dev:gui
4444
**Logs**와 **Usage**의 비용 값은 보고된 토큰으로 계산한 API 정가 환산치입니다. 결제 영수증이나
4545
실제 청구 증거가 아니며, 구독 사용량 또는 프로바이더 크레딧이 대신 적용될 수 있습니다.
4646

47+
## 모델 노출
48+
49+
**Models** 스위치는 Codex의 최종 노출 상태를 나타냅니다. 라우팅 모델은 프로바이더 allowlist에 포함되거나 allowlist가 없고, 동시에 비활성화되지 않았을 때만 켜집니다. 모델을 켜면 두 필터를 원자적으로 조정하며, **모두 활성화**는 allowlist를 해제해 새로 발견되는 모델도 켭니다.
50+
4751
## 위임 선택기와 스폰 라우팅의 차이
4852

4953
Dashboard의 **Sub-agent delegation** 선택기는 `injectionModel`과 선택적인 `injectionEffort`를
@@ -94,6 +98,7 @@ GUI는 프록시의 JSON 관리 API를 사용하는 얇은 클라이언트입니
9498
| `GET` / `PUT /api/v2` | 서피스 모드, Codex 기능 플래그, v2 thread 상한을 읽거나 바꿉니다. |
9599
| `GET /api/providers` · `POST /api/providers` · `PATCH /api/providers?name=...` · `DELETE /api/providers?name=...` | 프로바이더 목록 조회, 추가/교체, 활성화/비활성화, 제거. |
96100
| `GET /api/models` · `PUT /api/disabled-models` | 네이티브/라우팅 모델 행을 조회하고 공용 disabled model 목록을 갱신합니다. |
101+
| `GET /api/selected-models` · `PUT /api/model-visibility` | 프로바이더 allowlist를 읽고 개별 모델 또는 프로바이더 그룹의 최종 노출 상태를 원자적으로 변경합니다. |
97102
| `GET /api/key-providers` · `GET /api/oauth/providers` | API key 및 OAuth 프로바이더 카탈로그를 읽습니다. |
98103
| `POST /api/oauth/login` · `GET /api/oauth/status` | 프로바이더 OAuth 로그인을 시작하고 완료 여부를 확인합니다. |
99104
| `GET /api/codex-auth/accounts?refresh=1` | main 및 pool 계정을 조회하고 할당량을 강제로 갱신하며 main 계정의 `hasCredential` / terminal `needsReauth` 상태를 표시합니다. |

‎docs-site/src/content/docs/ru/guides/web-dashboard.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ bun run dev:gui
4545
рассчитанные на основе сообщённых токенов. Они не являются счётом и не подтверждают фактическое
4646
списание; расходы могут покрываться подпиской или кредитами провайдера.
4747

48+
## Видимость моделей
49+
50+
Переключатели **Models** показывают итоговую видимость в Codex. Маршрутизируемая модель включена, только если она входит в allowlist провайдера (или allowlist отсутствует) и не отключена. Включение атомарно согласует оба фильтра, а **Включить все** удаляет allowlist и включает новые модели.
51+
4852
## Селектор делегирования и маршрутизация порождений
4953

5054
Селектор **Sub-agent delegation** в дашборде сохраняет `injectionModel` и, при желании,
@@ -97,6 +101,7 @@ GUI — это тонкий клиент поверх JSON-API управлен
97101
| `GET` / `PUT /api/v2` | Чтение или настройка режима поверхности, фиче-флага Codex и лимита потоков v2. |
98102
| `GET /api/providers` · `POST /api/providers` · `PATCH /api/providers?name=...` · `DELETE /api/providers?name=...` | Список, добавление/замена, включение/отключение или удаление провайдеров. |
99103
| `GET /api/models` · `PUT /api/disabled-models` | Список строк нативных/маршрутизируемых моделей и обновление общего набора отключённых моделей. |
104+
| `GET /api/selected-models` · `PUT /api/model-visibility` | Чтение allowlist провайдера и атомарное изменение итоговой видимости модели или группы провайдера. |
100105
| `GET /api/key-providers` · `GET /api/oauth/providers` | Чтение каталогов провайдеров с API-ключом и OAuth. |
101106
| `POST /api/oauth/login` · `GET /api/oauth/status` | Запуск OAuth-процесса провайдера и опрос его завершения. |
102107
| `GET /api/codex-auth/accounts?refresh=1` | Список основного и пуловых аккаунтов с принудительным обновлением квот и состояниями `hasCredential` / terminal `needsReauth` основного аккаунта. |

‎docs-site/src/content/docs/zh-cn/guides/web-dashboard.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ bun run dev:gui
4343
**Logs** 和 **Usage** 中的费用是根据已报告 token 计算的 API 标价折算值,不是账单,也不能证明
4444
实际发生了扣费;实际可能计入订阅用量或消耗服务商额度。
4545

46+
## 模型可见性
47+
48+
**Models** 开关表示 Codex 中的最终可见状态。路由模型只有在 provider allowlist 中(或未设置 allowlist)且未被禁用时才会开启。开启模型会原子地协调两个过滤条件;**全部开启** 会清除 allowlist,因此以后新发现的模型也会开启。
49+
4650
## 委派选择器与生成路由的区别
4751

4852
Dashboard 的 **Sub-agent delegation** 选择器会保存 `injectionModel`,以及可选的
@@ -89,6 +93,7 @@ GUI 是代理 JSON 管理 API 之上的轻量客户端。常用 endpoint 包括
8993
| `GET` / `PUT /api/v2` | 读取或设置界面模式、Codex feature flag 和 v2 thread 上限。 |
9094
| `GET /api/providers` · `POST /api/providers` · `PATCH /api/providers?name=...` · `DELETE /api/providers?name=...` | 列出、添加/替换、启用/禁用或删除 provider。 |
9195
| `GET /api/models` · `PUT /api/disabled-models` | 列出原生/路由模型,并更新共享的 disabled-model 集合。 |
96+
| `GET /api/selected-models` · `PUT /api/model-visibility` | 读取 provider allowlist,并原子地更改单个模型或 provider 分组的最终可见状态。 |
9297
| `GET /api/key-providers` · `GET /api/oauth/providers` | 读取 API key 和 OAuth provider 目录。 |
9398
| `POST /api/oauth/login` · `GET /api/oauth/status` | 启动 provider OAuth 流程并轮询完成状态。 |
9499
| `GET /api/codex-auth/accounts?refresh=1` | 列出主账号与池账号、强制刷新配额,并返回主账号的 `hasCredential` / terminal `needsReauth` 状态。 |

‎gui/src/model-visibility.ts‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
export type ProviderModelMap = Record<string, string[]>;
2+
3+
export interface ModelVisibilityTarget { id: string; native?: boolean; }
4+
5+
export type ModelVisibilityScope = "models" | "provider";
6+
7+
function isRecord(value: unknown): value is Record<string, unknown> {
8+
return typeof value === "object" && value !== null && !Array.isArray(value);
9+
}
10+
11+
function uniqueStrings(value: unknown): string[] {
12+
if (!Array.isArray(value) || value.some(item => typeof item !== "string")) {
13+
throw new Error("invalid model list");
14+
}
15+
return [...new Set(value)];
16+
}
17+
18+
export function parseSelectedModels(value: unknown): ProviderModelMap {
19+
if (!isRecord(value)) throw new Error("invalid selected models response");
20+
const selected = value.selected;
21+
if (!isRecord(selected)) throw new Error("invalid selected models response");
22+
return Object.fromEntries(
23+
Object.entries(selected).map(([provider, ids]) => [provider, uniqueStrings(ids)]),
24+
);
25+
}
26+
27+
export async function fetchSelectedModels(
28+
apiBase: string,
29+
fetchImpl: typeof fetch = fetch,
30+
): Promise<ProviderModelMap> {
31+
const response = await fetchImpl(`${apiBase}/api/selected-models`);
32+
if (!response.ok) throw new Error(`selected models HTTP ${response.status}`);
33+
return parseSelectedModels(await response.json());
34+
}
35+
36+
export function modelIncluded(
37+
selected: ProviderModelMap,
38+
provider: string,
39+
modelId: string,
40+
native = false,
41+
): boolean {
42+
if (native) return true;
43+
const allowlist = selected[provider];
44+
return !allowlist || allowlist.length === 0 || allowlist.includes(modelId);
45+
}
46+
47+
export function modelVisible(
48+
selected: ProviderModelMap,
49+
provider: string,
50+
modelId: string,
51+
native: boolean,
52+
blocked: boolean,
53+
): boolean {
54+
return modelIncluded(selected, provider, modelId, native) && !blocked;
55+
}
56+
57+
export async function putModelVisibility(
58+
apiBase: string,
59+
scope: ModelVisibilityScope,
60+
provider: string,
61+
targets: ModelVisibilityTarget[],
62+
enabled: boolean,
63+
fetchImpl: typeof fetch = fetch,
64+
): Promise<Response> {
65+
return fetchImpl(`${apiBase}/api/model-visibility`, {
66+
method: "PUT",
67+
headers: { "Content-Type": "application/json" },
68+
body: JSON.stringify({ scope, provider, targets, enabled }),
69+
});
70+
}
71+
72+
export function shouldApplyLoadGeneration(request: number, current: number): boolean {
73+
return request === current;
74+
}

0 commit comments

Comments
 (0)