Repository navigation
Commit 8436f67
fix(console): show the platform-managed state on hosted storage and AI provider settings (#34327)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99tocKWwN1LMoWm6vP4y3d6)_
Fixes #34149
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:托管环境里直接打开 Setup →「文件存储」时,控制台显示「此项由平台托管」,不再是通用报错;「AI
与向量化」页顶部多一行「AI 提供商、模型与凭据由平台托管」,对话标题与可观测性设置照常可改。
- **为什么改**:#33891 让服务端在托管环境拒绝存储设置、裁掉 AI
提供商键,控制台还不认这个拒绝,书签或手输网址会看到报错或缺了提供商的表单。
- **风险与回滚**:只改控制台设置页的读法与三条文案;自托管环境不受影响(对照用例钉住)。回滚即还原本 PR。
- **先看**:`ui/apps/console/src/pages/settings/platformManaged.ts`(拒绝与 AI
投影的判定)、`SettingsView.tsx` 的 `error?.managed` 分支与 `aiProviderManaged`
行、`api.ts` 的 `runSettingsAction` 新增一行。
- **两分钟验证**:在 `ui/` 下跑 `pnpm exec vitest run
apps/console/src/pages/settings/__tests__/SettingsView.platformManaged-34149.test.tsx`,预期
9 例全绿。
- **需要你做的**:无,席位落地。
## What changes
The console half of #33891 (server contract landed in #34254).
- **Storage page, hosted.** `GET /api/settings/storage` answers `409
RESOURCE_CONFLICT` with `error.details.managedBy: 'platform'` on a
cloud-managed environment. `SettingsView` now reads that refusal by its
declared shape (status, code and `details.managedBy`, never the message,
via `isPlatformManagedRefusal` in the new `platformManaged.ts`) and
draws a "Managed by the platform" card: no form, no save bar, no retry.
A `409` without `managedBy: 'platform'` keeps today's error card.
- **AI page, hosted (Ask 2).** The page is served projected, so nothing
errors. The console draws one line, "The AI provider, its model and
credentials are managed by the platform.", only when two served facts
agree: the auth config's `features.cloudManaged === true` (plugin-auth
answers it from the same `isCloudManaged()` the settings projection
reads, and `FirstRunChecklist` already reads it through `getAuthConfig`,
which asks no new request) and the served `ai` manifest carries no
`provider` key (the projection actually ran). No served field was added.
- **Stale page refusals.** `runSettingsAction` now throws the managed
refusal like a failed read (status + raw body on `payload`) instead of
folding it into `{ ok: false, message }`; `onAction` and `onSave` toast
"Managed by the platform" for that shape. Read from the code before this
change: such a refusal fell to the last branch of `runSettingsAction`
and a stale `ai.test` click toasted the server's English sentence.
- **i18n.** Three keys under `console.settingsView` in every pack
(`platformManagedTitle`, `platformManagedBody`, `aiProviderManaged`);
`zh-Hant` regenerated with `node scripts/gen-zh-hant.mjs`.
- `SettingsHub.tsx` is untouched: it reads the list (`GET
/api/settings`), which already leaves `storage` out on a hosted
environment.
## Tests
New: `__tests__/SettingsView.platformManaged-34149.test.tsx` (9 cases)
and `platformManaged.test.ts` (5 cases).
- hosted `GET storage` 409 + `managedBy: 'platform'` → managed card, no
input, no retry, one read;
- CONTROL: 409 `RESOURCE_CONFLICT` without `managedBy` → today's error
card with the server's sentence;
- CONTROL: self-hosted storage → form renders;
- hosted AI (flag on, provider withheld) → one line, served keys still
render;
- CONTROLs: flag off with a projected manifest → no line; flag off with
the full manifest → no line; flag on but provider served → no line;
- stale action and stale save refused as platform-managed → the managed
toast;
- `runSettingsAction`: the managed 409 throws with status and raw body;
another 409 stays `{ ok: false, message }`.
No existing test was edited.
<details><summary>Ablations (each landed on disk through
scripts/ablation-replace.mjs, restored to the HEAD blob)</summary>
- A1 `isPlatformManagedRefusal` returns false → 5 red (storage managed
state, stale action, stale save, the helper, the api throw).
- A2 the `features.cloudManaged` check dropped → red: the helper case
and the view CONTROL "a page served without a provider on a self-hosted
environment draws no line".
- A3 the `runSettingsAction` throw line deleted → red: "throws the
refusal with its status and raw body".
Each run: `ok mutation landed` then `ok restored: blob == HEAD and git
diff HEAD is empty`.
</details>
## Acceptance notes
- The console names the `ai` namespace and its `provider` key as
constants (`platformManaged.ts`); the server's table is
`CLOUD_MANAGED_HIDDEN_SETTINGS`. If a later server stops withholding the
provider, the line disappears by itself (the manifest check); if it
starts projecting another namespace partially, that page draws no line
until the console learns it. A served marker on the projected manifest
would remove the console constant, but it is a served field (Clause-②,
server), so it was not added here.
- `onClearSaved` (clear a value beneath an env pin) on a stale page
still toasts the server's sentence for a managed refusal; on a hosted
environment the managed keys are not served, so the row is not reachable
without a stale page.
## Verification
All on head `febd90e8`, run after the last commit.
- `pnpm --filter @object-ui/console type-check`: exit 0.
- `cd ui && pnpm exec vitest run packages/i18n/
apps/console/src/pages/settings/`: 145 files, 2313 passed, 13 skipped,
exit 0 (includes the zh-Hant generated-pack pin and the settings-page
bare-literal pin).
- Derived gate set (`node scripts/pm/dispatch-gates.mjs --commands`): 40
commands, all exit 0; `--ran` reconciliation: 40 derived, 40 run, 0
NOT-MEASURED, 0 UNRUN.
- `pnpm check:new-line-citations` (ui): 0 new citations.
- eslint on the five changed console files: 0 errors.
- Narrowing, declared: the console run covers
`apps/console/src/pages/settings/` and `packages/i18n/`, the modules
that import the changed files; CI's Test UI shards run the whole tree.
No dogfood battery: no `!` in the title and no `(narrowing)` arm.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSWkWcHBfKEZ8RmTrv)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c934631 commit 8436f67
17 files changed
Lines changed: 549 additions & 10 deletions
File tree
- .changeset
- ui
- apps/console/src/pages/settings
- __tests__
- packages/i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
374 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
375 | 382 | | |
376 | 383 | | |
377 | 384 | | |
| |||
448 | 455 | | |
449 | 456 | | |
450 | 457 | | |
451 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
452 | 463 | | |
453 | 464 | | |
454 | 465 | | |
455 | 466 | | |
456 | 467 | | |
457 | 468 | | |
458 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
459 | 499 | | |
460 | 500 | | |
461 | 501 | | |
| |||
529 | 569 | | |
530 | 570 | | |
531 | 571 | | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
532 | 590 | | |
533 | 591 | | |
534 | 592 | | |
| |||
550 | 608 | | |
551 | 609 | | |
552 | 610 | | |
| 611 | + | |
553 | 612 | | |
554 | 613 | | |
555 | 614 | | |
| |||
650 | 709 | | |
651 | 710 | | |
652 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
653 | 716 | | |
654 | 717 | | |
655 | 718 | | |
| |||
731 | 794 | | |
732 | 795 | | |
733 | 796 | | |
734 | | - | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
735 | 802 | | |
736 | 803 | | |
737 | 804 | | |
| |||
790 | 857 | | |
791 | 858 | | |
792 | 859 | | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
793 | 871 | | |
794 | 872 | | |
795 | 873 | | |
| |||
0 commit comments