Skip to content

Commit 4bdbdac

Browse files
feat(console): the Studio landing lists every change this environment made to its installed apps in one panel (#34825)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBSqEJfSXXrgRvGw4hppNUc2)_ Fixes #34714 repo:objectstack#3 · os-support-ai · session_01WGufzivEnnozveqZfr4fDx Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:Studio 首页在「已安装的应用」下面加了「本环境的定制」面板,把所有已安装应用上的改动列在一处:每行写条目名、类型、所属应用和改动方式(改了原有的 / 新增的 / 已停用),点一下打开这个条目;可按页签(全部 / 新增字段 / 表单与视图 / 流程 / 已停用)筛选、搜索、按应用分组,默认显示前 6 行。 - 为什么改:原来想知道「这个环境改了哪些东西」,要一个应用一个应用点进去看。 - 风险与回滚:只改首页,不改服务端接口和存储;卡片和面板共用每个应用的一次读取,面板总数天然等于卡片上「已定制 + 已停用」之和;其他包带来的内容不算定制、不进清单;某个应用读不到时写明「这个应用的定制读不到」,不当成 0。回滚即还原本 PR。 - 先看:`ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts`(每行怎么来、标签怎么读);`LandingCustomizationsPanel.tsx`;`BuilderLanding.tsx` 里改成读完整清单的那段 effect。 - 两分钟验证:中文界面在 Studio 里给某个已安装应用的对象加一个字段并发布,回到 `/_console/studio`,「本环境的定制」里应出现一行「新增的 · 字段 · 应用名」,数字与该应用卡片上的「已定制」一致。 - 需要你做的:无,席位落地。 ## What changes The Studio landing gains a **Customizations in this environment** panel, under the installed apps (the place #34715 left for it). - **One row per change** this deployment made to an installed app, from each app's customization read (`GET /api/v1/packages/:id/customizations`, ADR-0146 D3): a served `overrides` entry reads **Changed**, an `extensions` member (field, validation rule, index) reads **Added**, a `switchedOff` entry reads **Switched off**. `contributions` (what other packages bring to the app) make no row. Nothing is folded or deduped (`customizationRowsOf`, `landingCustomizations-io.ts`). - **One read per app serves the card and the panel.** The landing now calls `fetchPackageCustomizations` and draws the card's numbers off the same answer through a new pure `customizationCountsOf` in `packageCustomizations-io.ts` (which `fetchPackageCustomizationCounts` now uses too). The served counts are each list's length (`GetPackageCustomizationsResponseSchema.counts`), so the panel's total equals the cards' "customized" + "switched off" by construction, with no second request. - **Labels.** The served answer carries names, not labels. `loadCustomizationLabels` reads the app's own published list once per type that has rows (`client.list(type, { packageId })`), and the app's objects for an added field's label; a failed list leaves the rows on their names. No row, no request. - **Each row opens its item**: `/studio/<app>/metadata/<type>/<name>`, which the area forwards to the item's pillar for a pillar type (a flow opens the Automations pillar on it); an added member opens its object. - **Tabs** All / New fields / Forms and views / Flows / Switched off (each with its count), a **search** over label, name, kind, app and mode, and **Group by app**. The first 6 rows show; the rest are behind "Show all N". - **With no change anywhere** the panel is one line. **An app whose read fails** (a 403 included) is named, "<app>: this app's customizations could not be read.", and never counted as 0; its card shows the existing failed line. - 29 new keys under `engine.studio.landing.envCustomizations.*` in the studio namespace (en, zh). No eager `locales/en.ts` edit. No server change. Scope notes (ADR-0146 D6, as the card says): no diff against the app, no "based on" version, no clone lineage, no per-organization split. ## Tests <details><summary>New and updated tests (12 landing files, 73 tests pass)</summary> - New `BuilderLanding.envCustomizations-34714.test.tsx` (10), real landing, real panel, real customization reader over a stubbed wire: - two apps with one change each and one switched-off flow ⇒ 3 rows with app and mode (`Changed · View · HotCRM`, `Switched off · Flow · HotCRM`, `Added · Field · Service Desk`); a served contribution makes no row; the label read's answer replaces the name; - each row's href (item on the app's area; an added field on its object), and a click lands on the item route; - the panel total equals the cards' sum, and exactly one customization request per app is sent; - empty state: one line, no total, no toolbar; - a 403 app: unreadable line naming it, the other app's row still listed, total 1, the card `data-state="failed"`; - tabs, search, group by app; the first 6 rows and "Show all 9"; - zh-CN: 本环境的定制, 改了原有的 / 新增的 / 已停用, 新增字段, 表单与视图; - `customizationRowsOf` excludes contributions; `loadCustomizationLabels` reads one list per type with rows (zh label resolved, a field's label from its object, a failed list keeps names, no row ⇒ no request). - `taskOrder-34715`, `recentPackages-11863`: the heading order now includes the panel. `accessibleNames-12510`, `orgScope-11553`, `setupExit-12513`: their pending customization double now stands in for `fetchPackageCustomizations`. </details> ## Acceptance notes Premise measured on `origin/main` f6f5b50 before coding (claim 6944526029): `fetchPackageCustomizations` at `packageCustomizations-io.ts:59`, the counts reader at :86, the landing reading only counts (`BuilderLanding.tsx:161`); the served lists and `counts.*` = each list's length; the answer carries no label. `StudioRailCustomizations` holds the rail's marks and filter, not a cross-app list, so the panel reuses its pair fold (already on the landing) and not its components. Live readings, en and zh, console from this branch's source over real backends. Scripts, readings and screenshots: `/mnt/project-files/objectstack-seat3/34714-live/` (project share). 1. **Showcase** (`examples/app-showcase`, fresh): before any change the panel reads "No installed app has been changed in this environment yet." / 「本环境还没有改过任何已安装的应用。」. After an added field on `showcase_task` (ensure-customization 201, object_extension draft 200, pair publish 200) and `showcase_urgent_task_alert` switched off (toggle 200): 2 rows, `Region | Added · Field` and `Alert on Urgent Task (created or escalated) | Switched off · Flow` (labels read from the app's lists); total 2 = card "1 customized, 1 switched off"; the flow row opens `/studio/com.example.showcase/automations?surface=flow:showcase_urgent_task_alert`, the field row `/studio/com.example.showcase/data?surface=object:showcase_task`. 2. **Two installed apps** (`examples/app-multi-package`, core + orders): one added field each ⇒ 2 rows (`Tier · Multi-Package Core`, `Channel · Multi-Package Orders`), total 2 = cards 1 + 1. The core read also serves a nav contribution from orders: no row for it. 3. **403**: a response stand-in answers 403 `PERMISSION_DENIED` for the orders read only: "Multi-Package Orders: this app's customizations could not be read." / 「Multi-Package Orders:这个应用的定制读不到。」, total 1, the core row still listed, the orders card reads its failed line. 4. 375 px: no horizontal scroll; tabs, search and the group button are 44 px tall. Acceptance 1 combines two apps and a switched-off flow in one environment; live, those are read in two environments (no example ships two installed apps with a packaged flow); the exact combination is the first component case. On the multi-package example, ensure-customization on the orders module answers the core pair (shared namespace `crm`, ADR-0130 D4); orders' extension was written there and the orders read lists it. ## Verification <details><summary>Gates on head 9f42374 (main 3bbda33 merged in)</summary> - `pnpm --dir ui exec vitest run packages/app-shell/src/views/studio-design/BuilderLanding`: 12 files, 73 tests pass on the merged-forward tree. - studio-design directory (before the merge forward, same panel code): 336 files, 2587 tests pass. - Derived gates (`dispatch-gates --commands`, 38): all exit 0 (`vitest run scripts/` in ui at `--maxWorkers=2`). - `pnpm --filter @object-ui/app-shell run type-check` exit 0 (after rebuilding the stale local `@object-ui/core` dist that main's #34647 needs); `@object-ui/i18n` type-check exit 0; ESLint on every changed `ui/` file exit 0. - `pnpm console:build` exit 0; `pnpm check:eager-closure` exit 0. **i18n-locale-en: 60.2 KB of the 60.5 KB ceiling** (unchanged; this PR does not touch `locales/en.ts`, its keys are in the lazy studio namespace). Aggregate 1895.8 KB / 2431.6 KB. - `pnpm check:changeset-fixed` exit 0; `check:test-source-alias` exit 0. - `scripts/pm/overlap-check.mjs --branch=HEAD`: VERDICT clean (#34677 and #34799 share the studio en/zh files and merge cleanly). </details> Deviations: the branch is this thread's pinned branch `claude/project-thread-eqwj27`, restarted from `main` after #34747 merged. File surface beyond the claim's "new panel component": `landingCustomizations-io.ts` beside it (rows and the label read, split out so a test can double the label read). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; ESLint passes on every changed file. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzivEnnozveqZfr4fDx --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b1bca7a commit 4bdbdac

13 files changed

Lines changed: 985 additions & 17 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/i18n': patch
3+
---
4+
5+
feat(console): the Studio landing lists every change this environment made to its installed apps in one panel
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
The Studio landing gains a **Customizations in this environment** panel under the installed apps, so "what did we change here" no longer means opening each app.
11+
12+
- One row per change, read from each installed app's customization read (`GET /api/v1/packages/:id/customizations`, the read its card already makes): items the app's customization package overrides read **Changed**, fields, validation rules and indexes it adds read **Added**, the app's items switched off in this environment read **Switched off**. What other packages contribute is not this environment's change and makes no row.
13+
- Each row names the item (its label where the app's list gives one, else its name), its kind and its app, and opens it in Studio.
14+
- Tabs narrow the list (All, New fields, Forms and views, Flows, Switched off), a search narrows it by text, and the rows can be grouped by app. The first six rows show; the rest are behind "Show all".
15+
- The panel's total equals the cards' "customized" plus "switched off": one read per app now serves both the card and the panel.
16+
- With no change anywhere the panel is one line. An app whose read fails (a 403 included) is named as unreadable, never counted as 0.
17+
18+
New keys under `engine.studio.landing.envCustomizations.*` in the studio namespace (en, zh). No server change.

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ vi.mock('./packages-io', async (importOriginal) => {
3737
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
3838
// A read-only base's customization read (ADR-0146 D3) is not under test here:
3939
// it stays pending, so no request leaves the file.
40-
vi.mock('./packageCustomizations-io', () => ({
41-
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
40+
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
41+
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
42+
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
4243
}));
4344
// One flow belongs to no package, so the landing draws that entry (objectstack#34715).
4445
vi.mock('./packageSurfaces', async (importOriginal) => {

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx‎

Lines changed: 362 additions & 0 deletions
Large diffs are not rendered by default.

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.orgScope-11553.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ vi.mock('./packages-io', async (importOriginal) => {
3939
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
4040
// A read-only base's customization read (ADR-0146 D3) is not under test here:
4141
// it stays pending, so no request leaves the file.
42-
vi.mock('./packageCustomizations-io', () => ({
43-
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
42+
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
43+
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
44+
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
4445
}));
4546

4647
vi.mock('./packageSurfaces', async (importOriginal) => {

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ vi.mock('./packages-io', async (importOriginal) => {
5858
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
5959
// A read-only base's customization read (ADR-0146 D3) is not under test here:
6060
// it stays pending, so no request leaves the file.
61-
vi.mock('./packageCustomizations-io', () => ({
62-
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
61+
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
62+
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
63+
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
6364
}));
6465

6566
// The package-less flow count the landing draws (objectstack#34715) is not under
@@ -127,6 +128,7 @@ describe('Studio landing → recent packages (objectui#11863)', () => {
127128
await screen.findByText('Recently viewed');
128129
expect(screen.getAllByRole('heading', { level: 2 }).map((h) => h.textContent)).toEqual([
129130
'Installed apps',
131+
'Customizations in this environment',
130132
'Your own apps',
131133
'Recently viewed',
132134
'Outside any app',

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.setupExit-12513.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ vi.mock('./packages-io', async (importOriginal) => {
3535
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
3636
// A read-only base's customization read (ADR-0146 D3) is not under test here:
3737
// it stays pending, so no request leaves the file.
38-
vi.mock('./packageCustomizations-io', () => ({
39-
fetchPackageCustomizationCounts: vi.fn(() => new Promise<never>(() => {})),
38+
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
39+
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
40+
fetchPackageCustomizations: vi.fn(() => new Promise<never>(() => {})),
4041
}));
4142

4243
// The package-less flow count the landing draws (objectstack#34715) is not under

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.taskOrder-34715.test.tsx‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,25 @@ vi.mock('./packages-io', async (importOriginal) => {
4040
};
4141
});
4242
vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null }));
43-
vi.mock('./packageCustomizations-io', () => ({
44-
fetchPackageCustomizationCounts: vi.fn(async (id: string) => counts.byId[id] ?? { customized: 0, switchedOff: 0 }),
43+
vi.mock('./packageCustomizations-io', async (importOriginal) => ({
44+
...(await importOriginal<typeof import('./packageCustomizations-io')>()),
45+
// A served answer whose lists are as long as the counts asked for: `customized` view overrides, `switchedOff` flows.
46+
fetchPackageCustomizations: vi.fn(async (id: string) => {
47+
const { customized, switchedOff } = counts.byId[id] ?? { customized: 0, switchedOff: 0 };
48+
return {
49+
packageId: id,
50+
overrides: Array.from({ length: customized }, (_, i) => ({ type: 'view', name: `view_${i}` })),
51+
extensions: [],
52+
switchedOff: Array.from({ length: switchedOff }, (_, i) => ({ type: 'flow', name: `flow_${i}` })),
53+
contributions: [],
54+
counts: { overrides: customized, extensions: 0, switchedOff, contributions: 0 },
55+
};
56+
}),
57+
}));
58+
// The panel's label read (objectstack#34714) is not under test here: rows keep their names.
59+
vi.mock('./landingCustomizations-io', async (importOriginal) => ({
60+
...(await importOriginal<typeof import('./landingCustomizations-io')>()),
61+
loadCustomizationLabels: vi.fn(async () => ({})),
4562
}));
4663
vi.mock('./packageSurfaces', async (importOriginal) => {
4764
const mod = await importOriginal<typeof import('./packageSurfaces')>();
@@ -102,7 +119,7 @@ describe('Studio landing: ordered by what the author came to do (objectstack#347
102119
renderLanding();
103120

104121
await screen.findByText('HotCRM');
105-
expect(headings()).toEqual(['Installed apps', 'Your own apps', 'Outside any app']);
122+
expect(headings()).toEqual(['Installed apps', 'Customizations in this environment', 'Your own apps', 'Outside any app']);
106123
const installed = screen.getByTestId('studio-landing-installed');
107124
// DOM order: each installed card precedes the author's own card.
108125
const own = screen.getByTestId('studio-landing-own');

‎ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx‎

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ import { t, tFormat, useMetadataLocale } from '../metadata-admin/i18n.js';
3434
import { PackageFormDialog } from '../metadata-admin/PackageFormDialog.js';
3535
import { isMarketplaceEnabled } from '../../runtime-config.js';
3636
import { fetchPackages, fetchListedPackageIds, duplicatePackage, isSpecPackageId, type PkgEntry } from './packages-io.js';
37-
import { fetchPackageCustomizationCounts, type PackageCustomizationCounts } from './packageCustomizations-io.js';
37+
import {
38+
customizationCountsOf,
39+
fetchPackageCustomizations,
40+
type PackageCustomizationCounts,
41+
type PackageCustomizations,
42+
} from './packageCustomizations-io.js';
43+
import { LandingCustomizationsPanel, type AppCustomizationRead } from './LandingCustomizationsPanel.js';
3844
import { customizationPackageId, isCustomizationPackage } from '@objectstack/spec/kernel';
3945
import { PackageIdInput } from './PackageIdInput.js';
4046
import { studioOrgScopePath } from './studioScope.js';
@@ -61,7 +67,7 @@ const RECENT_PACKAGES_SHOWN = 3;
6167
* read. No entry means the read has not answered: the line shows no number.
6268
*/
6369
type CustomizationLine =
64-
| { kind: 'read'; counts: PackageCustomizationCounts }
70+
| { kind: 'read'; counts: PackageCustomizationCounts; read: PackageCustomizations }
6571
| { kind: 'failed'; message: string };
6672

6773
/** A package's Studio address on one pillar, the way `open` below spells it. */
@@ -170,9 +176,14 @@ export function BuilderLanding(): React.ReactElement {
170176
if (!customizationTargetKey) return;
171177
let cancelled = false;
172178
for (const id of customizationTargetKey.split('\n')) {
173-
fetchPackageCustomizationCounts(id).then(
174-
(counts) => {
175-
if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', counts } }));
179+
// objectstack#34714 — the whole answer is kept: the card draws its two
180+
// numbers off it and the "Customizations in this environment" panel its
181+
// rows, so one read serves both and the panel's total is the cards' sum.
182+
fetchPackageCustomizations(id).then(
183+
(read) => {
184+
if (!cancelled) {
185+
setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', counts: customizationCountsOf(read), read } }));
186+
}
176187
},
177188
(e: unknown) => {
178189
const message = e instanceof Error ? e.message : String(e);
@@ -184,6 +195,21 @@ export function BuilderLanding(): React.ReactElement {
184195
cancelled = true;
185196
};
186197
}, [customizationTargetKey]);
198+
// objectstack#34714 — the panel's apps are the cards' bases, in card order;
199+
// its reads are the same answers the cards draw.
200+
const customizationApps = React.useMemo(
201+
() => readonly.filter((p) => !isCustomizationPackage(p.id)).map((p) => ({ id: p.id, name: p.name })),
202+
// eslint-disable-next-line react-hooks/exhaustive-deps
203+
[customizationTargetKey, pkgs],
204+
);
205+
const customizationReads = React.useMemo(() => {
206+
const out: Record<string, AppCustomizationRead> = {};
207+
for (const [id, line] of Object.entries(customizationLines)) {
208+
out[id] = line.kind === 'read' ? { kind: 'read', read: line.read } : line;
209+
}
210+
return out;
211+
}, [customizationLines]);
212+
187213
// objectui#11553 — how many flows belong to no package: the same published
188214
// and draft union the package-less scope lists (`loadPackageLessSurfaces`).
189215
// The entry is drawn once the read says there is at least one; a failed read
@@ -416,6 +442,15 @@ export function BuilderLanding(): React.ReactElement {
416442
</section>
417443
)}
418444

445+
{/* objectstack#34714 — every change this deployment made to its
446+
* installed apps, in one list, under the apps themselves. */}
447+
<LandingCustomizationsPanel
448+
apps={customizationApps}
449+
reads={customizationReads}
450+
locale={locale}
451+
headingClass={headingClass}
452+
/>
453+
419454
<h2 className={headingClass}>{t('engine.studio.landing.ownHeading', locale)}</h2>
420455
<div data-testid="studio-landing-own" className="mb-6 grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3">
421456
{writable.map((p) => (

0 commit comments

Comments
 (0)