fix: align playground default model id with org namespace

Opening an org-scoped deployment in the Playground pre-selected the bare
model name (e.g. `qwen3-0.6b`), which never matched the org-namespaced
option the `/v1/models` dropdown actually lists (`org1/qwen3-0.6b`), so
the selection showed an unmatched value.

Resolve the owning org from the route row's `owner_principal_id` (falling
back to the org the caller is currently acting under for the admin "All"
view) and reconstruct the same `{org}/{name}` id the server reports. The
platform org carries no prefix, matching the server's behaviour.

- user.ts: add `getOrgById`/`getCurrentOrg` that scan both org caches
  (`organizationList` + admin-only `allOrganizations`) with string-
  normalised id comparison; `getOrgNameById` is now a thin wrapper.
  Helpers accept `undefined` so optional row fields type-check.
- use-open-playground: build the prefix from the resolved org record,
  keying the skip-prefix decision off `is_platform`.
- RouteItem: declare the `owner_principal_id` the list API returns.
- RouteTargetFormItem: drop the duplicate `overridden_model_name`
  declaration that TS flagged as a duplicate identifier.
This commit is contained in:
gitlawr
2026-06-03 10:59:43 +08:00
committed by jialin
parent fadbcc3e44
commit 72e794c281
3 changed files with 51 additions and 26 deletions
+3 -1
View File
@@ -4,7 +4,6 @@ export interface RouteTargetFormItem {
weight?: number | null;
model_id?: number;
provider_id?: number;
overridden_model_name?: string;
fallback_status_codes?: string[];
parentId?: string | number;
}
@@ -32,6 +31,9 @@ export interface RouteItem {
targets: number;
ready_targets: number;
access_policy: string;
// Org principal that owns this route. Drives the ``{org}/{name}`` model-id
// prefix when opening the route in the Playground.
owner_principal_id?: number;
}
export interface RouteTarget extends RouteTargetFormItem {