Skip to content

Commit e08aad7

Browse files
fix(console): name permission sets, master objects, audited records and condition subjects by label (#34088)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Gz6rLAtQusAQi5SbZGeg9y)_ Part of #33864 — items 1, 2, 3 and 5 land here. Item 4 (Setup palette record hits) stays open on the card: its title is the server search's, not the Console's (see Acceptance notes). Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - **改了什么**:控制台四处界面改为显示标签:Studio 访问权限页的建议授权横幅、其提示与状态行用权限集标签;记录共享「由父级控制」显示父对象标签;设置 → 审计日志的「记录」列显示记录名称;流程入口条件的字段下拉显示字段标签,路径作为次要文字。 - **为什么改**:这些界面违反「给人看的地方用标签,机器名至多作次要文字」的约定(QA 扫描发现)。 - **风险与回滚**:只改显示层,不改写入或契约。审计日志每页按对象多发一次批量读取(每个对象一次 `find`,与列表网格的指针列同一读取器)。回滚即还原本 PR。 - **先看**:`AuditLogPage.tsx`(记录列改用 `RecordPointerCell`)、`StudioDesignSurface.tsx`(`suggestedSetLabel`)、`PackageOwdOverviewPanel.tsx`(`masterLabelOf`)。 - **两分钟验证**:在 showcase 以管理员打开 设置 → 审计日志,「记录」列应显示记录名称,鼠标悬停显示记录 id;记录已删除的行显示「对象 · record unavailable」。 - **需要你做的**:无,席位落地。 ## What changes Anything shown to a person names the thing by its label; the machine name appears at most as secondary text (`ux-conventions.labels-over-machine-names`). 1. **Studio → Access, suggested-binding strip** (`StudioDesignSurface.tsx`, `AccessPillar`). A suggestion row carries only `permission_set_name`. The strip lists this package's suggestions, and those are this package's own sets, which the pillar's rail already reads with their labels. `suggestedSetLabel` names the set by that label in the banner, every toast (Grant, Dismiss, Revoke, Reconsider, the not-in-force warning) and the state line a resolved row keeps. A set the rail holds no label for is named by its machine name. No server change: the suggestion payload is unchanged. 2. **Studio → Access → Record sharing, "By parent →"** (`PackageOwdOverviewPanel.tsx`). `masterLabelOf` names the master object by this package's own object as the table reads it (pending draft included), else the served object's label, else its machine name. A master outside the package is read by name (`readObjectsByName`, the hook the inbox's object rows use), so the table asks for the few masters it names, never the whole object registry; the objects-reader census (`openPathObjectReaders-12811.test.ts`) gains its row as `byName`. 3. **Setup → Audit Log, Record column** (`ui/apps/console/src/pages/system/AuditLogPage.tsx`). `sys_audit_log.record_id` is the id half of a `referenceVia` pair typed by `object_name`. The column now draws it through `RecordPointerCell`, the batched resolver a list grid's `referenceVia` column already uses (one `find` per object per tick, the ADR-0079 name ladder, the raw id as the tooltip). A row with no object or record keeps the dash. `@object-ui/plugin-grid` exports `RecordPointerCell` (and its two types) for this; the README's export list names them. No second resolver is written. 4. **Setup ⌘K palette record hits — not in this PR.** See Acceptance notes. 5. **Studio flow editor → Entry condition** (`FlowNodeConfigField.tsx`). The mount passes `labelSubjects`, the existing `ConditionBuilder` option the Validations panel already uses: a field subject reads by its label with its CEL spelling beside it, and `previous.FIELD` reads as "FIELD LABEL (before the change)". The whole-record `previous` has no label and reads as its spelling. No new i18n keys: every string here already existed. ## Tests One pin per item, each in the component's existing harness file as a top-level `describe`: - Item 1, `StudioDesignSurface.accessSuggestionsReadOnly-33158.test.tsx`: the banner, the Grant toast and accepted line, the Dismiss toast and dismissed line name "CRM user"; CONTROL: a set with an empty rail label reads `crm_user`. - Item 2, `PackageOwdOverviewPanel.test.tsx`: a served master outside the package reads "Customer Account"; CONTROL: an unlabelled master reads its name. - Item 3, `AuditLogPage.objectLabels-28968.test.tsx`: a readable record reads "Acme Corp" with `acc_1` as the tooltip; CONTROL: an unread record reads `nightly_widget · record unavailable`, a row with no record the dash. - Item 5, `FlowNodeConfigField.entryCondition.test.tsx`: `Status` / `status`, `Contract term (months)` / `contract_term_months`, the `previous.status` label; CONTROL: `previous` keeps its spelling. Forced test edits (the option text now carries label + spelling, or the master now reads by label): - `PackageOwdOverviewPanel.test.tsx` › 'shows the master link': asserted `/crm_account/`, now the label "Account". - `FlowNodeConfigField.entryCondition.test.tsx`: `subjectOptions` reads each option's spelling (the hint), and two clicks pick an option by spelling instead of by accessible name. - `FlowNodeInspector.entryCondition.test.tsx` › 'its subject dropdown offers the FLATTENED vocabulary…': reads the spelling (the hint) of each option. - `AuditLogPage.objectLabels-28968.test.tsx`: the hoisted adapter double now answers `crm_account`'s definition and record (the other cases in the file are unchanged and green). - `useObjectFields.draftOverlay-11895.test.tsx` (both cases): the wait finds the option by the label-first accessible name the builder now renders (`Issue summary issue_summary`, `Industry industry`), and the assertions read each option's spelling (the hint) with exact `toContain`, so `previous.*` cannot satisfy them. It also gains the module-top `import '@objectstack/lint'` that `check:test-source-alias` asks of an edited suite reaching the flow inspectors. - `openPathObjectReaders-12811.test.ts`: one new census row, `PackageOwdOverviewPanel.tsx` → `byName`; no other row changed. <details><summary>Ablations — one per item, each red, each restored to HEAD (on c034387's tree, via <code>scripts/ablation-replace.mjs</code>; ui vitest resolves <code>@object-ui/*</code> to <code>src/</code>, so no build leg)</summary> | Item | Mutation (anchor → replacement) | Pin file | Result | |---|---|---|---| | 1 | `suggestedSetLabel` body → `s.permission_set_name` | `StudioDesignSurface.accessSuggestionsReadOnly-33158.test.tsx` | 3 failed / 5 passed (the CONTROL stays green) | | 2 | `{ master: masterLabelOf(row.master) }` → `{ master: row.master }` | `PackageOwdOverviewPanel.test.tsx` | 2 failed / 9 passed | | 3 | Record cell guard → `(false as boolean) &&` (the raw id cell) | `AuditLogPage.objectLabels-28968.test.tsx` | 2 failed / 5 passed | | 5 | `labelSubjects` → `labelSubjects={false}` | `FlowNodeConfigField.entryCondition.test.tsx` | 2 failed / 39 passed (the CONTROL stays green) | Each leg: anchor hit x1 → x0, blob changed, then restored with blob == HEAD and an empty `git diff HEAD`. </details> ## Acceptance notes - **Item 4 left out, as the dispatch order says for a fix outside this lane's files.** The palette titles a record hit with the server's `searchAll` hit title when there is one (`useRecordSearch`), and the server titles a hit with the row's `nameField` value as stored (`renderTitle` in `packages/metadata-protocol/src/protocol-record-reads.ts`). `sys_record_share` declares `nameField: 'recipient_id'`, so a Record Share hit is titled with the raw principal id. Naming it needs a server or object-metadata change under `packages/**` (resolve a reference name field to the referenced record's name, or declare a different title), not `CommandPalette.tsx` and not this card's file surface. The Notification Event (`sys_notification`, `nameField: 'topic'`) hit was NOT MEASURED here: the declared title is `topic`, so why the QA run saw the id needs a live repro. Both go back to the seat to split. - **Item 1 has a second host.** The marketplace package page (`MarketplacePackagePage.tsx`) mounts the same `SuggestedBindingsPanel` and still names the set by machine name in its prompt and toasts. It is not on the card. Its fix needs a label source that page does not read today (the package's permission sets, or a label on the suggestion payload, which is a server change). Same defect class, reported to the seat, not fixed here. - **Item 3 unreadable rows.** The delta asked for the id as the fallback. The shared resolver draws "OBJECT · record unavailable" with the id as the tooltip, its one rendering for deleted and not-visible records. I kept the shared face rather than fork it for one page. The id is still in the tooltip and in the drawer's "Target record" line. If the seat wants the bare id on this page, it is a one-prop change to `RecordPointerCell`. - **Item 5, other mounts.** `ConditionBuilder` keeps `labelSubjects` off by default, so the hook, action visible/disabled, page-block and widget mounts still list spellings. They are not on the card. - Revoke's missing toast stays with #33865, queued behind this card on the same banner. This PR only renames the set in the toasts that already exist. ## Verification The details below are on `c0343878`, in this card's container. `319ae3fc` only changes the changeset's `Clause-②:` line to `yes (widening)` (`@object-ui/plugin-grid` is published, and its entry now exports `RecordPointerCell` and two types); `pnpm check:changeset-fixed` re-ran on it, exit 0. On the head `5f4c47f5` (the CI round: the census row with the by-name read, and the draft-overlay pin): `os-verify-lock.sh -c 'cd ui && pnpm exec vitest run --maxWorkers=3 packages/app-shell/src/views/metadata-admin packages/app-shell/src/console/__tests__ packages/app-shell/src/views/studio-design'`: `Test Files 1153 passed (1153)`, `Tests 11138 passed | 1 skipped (11139)`, `VERDICT command-exit 0`. `pnpm check:test-source-alias` exit 0; `tsc --noEmit` on app-shell exit 0; `eslint` on the two touched sources 0 errors. <details><summary>Tests — 85 files around the four surfaces: 865 passed</summary> `os-verify-lock.sh -c 'cd ui && pnpm exec vitest run --maxWorkers=2 FILES'` over every `StudioDesignSurface.access*`, `PackageOwdOverviewPanel*`, `FlowNode*`, `ConditionBuilder*`, `FlowCanvas*`, `flowSingleBrace-12329`, `flow-node-producers.label`, `SuggestedBindingsPanel`, `AuditLogPage*` test file and plugin-grid's pointer and `referenceVia` suites: `Test Files 85 passed (85)`, `Tests 865 passed (865)`, `VERDICT command-exit 0`. The whole app-shell suite is CI's (Test UI); this narrowing is declared. </details> <details><summary>Type-check — app-shell, plugin-grid, console: exit 0</summary> `pnpm --filter @object-ui/app-shell type-check`, `@object-ui/plugin-grid`, `@object-ui/console`, each under the lock after `turbo run build --filter='@object-ui/console^...'` (74/74 tasks): `VERDICT command-exit 0` three times. `pnpm check:type-check-debt`: exit 0, no entry above its number. </details> <details><summary>Derived gates — 37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN</summary> `node scripts/pm/dispatch-gates.mjs --commands` (no paths) derived 37 families; every one exited 0, including `pnpm --dir ui exec vitest run scripts/` (171 files passed, 2 skipped) and `pnpm check:test-source-alias` (its first round flagged the two edited flow entry-condition suites; both now load `@objectstack/lint` at module top). `--ran` reconciliation: `37 derived famil(ies) accounted for — 37 run, 0 NOT-MEASURED`. Run beyond the derivation, both exit 0: `pnpm check:published-readme-exports` (the README's export list names the new export), `pnpm check:changeset-fixed`. Also: `pnpm check:new-line-citations` 0 new; `eslint` on the touched files 0 errors. Repo-wide lint and the rest of the farm are CI's. </details> Dogfood battery: not owed (no `!` in the title, no narrowing arm). --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSBi2p2cTsYqd7ScSZ)_ <!-- signed: domain:ui#1 · os-steve · session_01ADHkmSBi2p2cTsYqd7ScSZ --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 499266d commit e08aad7

14 files changed

Lines changed: 346 additions & 26 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/plugin-grid': patch
5+
---
6+
7+
fix(console): four Console surfaces name things by their label, not their machine name
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
Anything shown to a person uses the label; the machine name appears at most as secondary text.
13+
14+
- Studio → Access: the suggested-binding banner, its Grant and Dismiss toasts and the state line a resolved suggestion keeps name the permission set by the label the rail shows for it, not by its machine name. A set with no label is still named by its machine name.
15+
- Studio → Access → Record sharing: a "Controlled by parent" row reads `By parent → ` and the master object's label: this package's own object as the table reads it, else the served object's label, else its machine name.
16+
- Setup → Audit Log: the Record column names the audited record by its display name, through the same batched resolver a list grid's `referenceVia` pointer column uses. The raw id is the tooltip; a record no read answers reads as `OBJECT · record unavailable` (its object's label). `@object-ui/plugin-grid` now exports that resolver's face, `RecordPointerCell`.
17+
- Studio flow editor → Entry condition: the subject list offers each field by its label, with its path (`status`, `previous.status`) beside it.

‎ui/apps/console/src/pages/system/AuditLogPage.objectLabels-28968.test.tsx‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ const { ADAPTER, METADATA, SERVED_OBJECTS } = vi.hoisted(() => {
4545
{ name: 'sys_audit_log', label: '审计日志' },
4646
]) as readonly unknown[];
4747
return {
48+
// objectstack#33864 — `crm_account` is readable through the adapter, so
49+
// its record can be named; every other object answers no definition and
50+
// no rows (the actor lookup's `sys_user` included).
4851
ADAPTER: {
49-
find: async () => ({ data: [], total: 0 }),
52+
find: async (objectName: string) =>
53+
objectName === 'crm_account'
54+
? { data: [{ id: 'acc_1', name: 'Acme Corp' }], total: 1 }
55+
: { data: [], total: 0 },
5056
findOne: async () => null,
51-
getObjectSchema: async () => undefined,
57+
getObjectSchema: async (objectName: string) =>
58+
objectName === 'crm_account'
59+
? { name: 'crm_account', label: '客户', nameField: 'name', fields: { name: { type: 'text', label: 'Name' } } }
60+
: undefined,
5261
},
5362
SERVED_OBJECTS,
5463
// Mutable per test: the served objects.
@@ -167,3 +176,32 @@ describe('AuditLogPage — the Object column and drawer show the served object l
167176
expect(options).toContain('crm_blank');
168177
});
169178
});
179+
180+
/** The Record cell's text, by row. */
181+
function recordCells(): string[] {
182+
return bodyRows().map((row) => row.querySelectorAll('td')[3]?.textContent ?? '');
183+
}
184+
185+
/**
186+
* objectstack#33864 — the Record column names the audited record by its
187+
* display name (`ux-conventions.labels-over-machine-names`), read through the
188+
* grid's batched `referenceVia` pointer resolver (`record_id` is the id half
189+
* of the pair `object_name` types). The raw id stays the cell's tooltip.
190+
*/
191+
describe('AuditLogPage — the Record column names the audited record (objectstack#33864)', () => {
192+
it("shows a readable record's display name, the raw id as its tooltip", async () => {
193+
renderPage();
194+
await waitFor(() => expect(recordCells()[0]).toBe('Acme Corp'));
195+
const cell = bodyRows()[0]!.querySelectorAll('td')[3]!;
196+
expect(cell.querySelector('[data-record-pointer="readable"]')).toHaveAttribute('title', 'acc_1');
197+
expect(recordCells()[0]).not.toContain('acc_1');
198+
});
199+
200+
it('CONTROL: a record no read answers reads as unavailable, never as a bare id; a row with no record shows the dash', async () => {
201+
renderPage();
202+
await waitFor(() => expect(recordCells()[1]).toBe('nightly_widget · record unavailable'));
203+
const cell = bodyRows()[1]!.querySelectorAll('td')[3]!;
204+
expect(cell.querySelector('[data-record-pointer="unreadable"]')).toHaveAttribute('title', 'wid_1');
205+
expect(recordCells()[3]).toBe('—');
206+
});
207+
});

‎ui/apps/console/src/pages/system/AuditLogPage.tsx‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import {
7575
type ComboboxOption,
7676
} from '@object-ui/components';
7777
import { LookupField, getLazyFieldWidget, objectRefOptionLabel } from '@object-ui/fields';
78+
import { RecordPointerCell } from '@object-ui/plugin-grid';
7879
import { ConsolePageHeader, useAdapter, useMetadata } from '@object-ui/app-shell';
7980
import { Search, X, AlertCircle, ScrollText, ExternalLink } from 'lucide-react';
8081
import { actionBadgeVariant, actionFilterOptionsOf, actionLabelOf } from './auditLogActions';
@@ -719,7 +720,20 @@ export function AuditLogPage() {
719720
<TableCell className="font-mono text-xs">{formatDate(r.created_at, displayLocale)}</TableCell>
720721
<TableCell><Badge variant={variant}>{actionLabelOf(actionOptions, r.action) ?? '—'}</Badge></TableCell>
721722
<TableCell>{objectLabelOf(objects, r.object_name) ?? '—'}</TableCell>
722-
<TableCell className="font-mono text-xs">{truncate(r.record_id, 18)}</TableCell>
723+
<TableCell className="max-w-[16rem] text-xs">
724+
{/* The record by its display name, through the batched
725+
pointer resolver the grid's `referenceVia` columns
726+
use (`sys_audit_log.record_id` is the id half of the
727+
pair `object_name` types). */}
728+
{r.object_name && r.record_id ? (
729+
<RecordPointerCell
730+
pointer={{ objectName: r.object_name, recordId: r.record_id }}
731+
dataSource={adapter}
732+
/>
733+
) : (
734+
<span className="font-mono">{truncate(r.record_id, 18)}</span>
735+
)}
736+
</TableCell>
723737
<TableCell><ActorCell face={actorOf(r)} /></TableCell>
724738
<TableCell className="font-mono text-xs">{r.ip_address || '—'}</TableCell>
725739
</TableRow>

‎ui/packages/app-shell/src/console/__tests__/openPathObjectReaders-12811.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ const OBJECTS_READERS: Record<string, { kind: Kind; why: string }> = {
131131
kind: 'off',
132132
why: "Studio: the Data pillar's Form tab asks selectRecordFormView which form view the app opens, over the served objects (objectstack#30057)",
133133
},
134+
'packages/app-shell/src/views/studio-design/PackageOwdOverviewPanel.tsx': {
135+
kind: 'byName',
136+
why: "Studio's record-sharing table: a controlled-by-parent row's master outside the package, its label by name (objectstack#33864)",
137+
},
134138
'packages/app-shell/src/views/studio-design/relatedListVocabulary.ts': {
135139
kind: 'off',
136140
why: "Studio: an object's inbound relationships, read while its Settings relatedLists editor or a field group's related-table picker is mounted",

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.entryCondition.test.tsx‎

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ import * as React from 'react';
4444
import { describe, it, expect, afterEach, beforeAll, vi } from 'vitest';
4545
import { render, cleanup, screen, fireEvent } from '@testing-library/react';
4646
import userEvent from '@testing-library/user-event';
47+
// The source under test reaches a dynamic `import('@objectstack/lint')`; pay
48+
// that load during collection, never inside a case's clocked window.
49+
import '@objectstack/lint';
4750

4851
/**
4952
* The trigger object's field catalog. Stubbed at the hook rather than at the
@@ -76,6 +79,7 @@ const FIELD_NAMES_IN_SCOPE = FIELDS.filter((f) => !f.hidden).map((f) => f.name);
7679
import { FlowNodeConfigField } from './FlowNodeConfigField';
7780
import { fieldsForNodeType, type FlowConfigField } from './flow-node-config';
7881
import { resolveFlowScope, type TriggerScope } from './flow-scope';
82+
import { tFormat } from '../i18n';
7983

8084
afterEach(cleanup);
8185

@@ -277,12 +281,29 @@ describe('#6226 probe instrument — positive controls', () => {
277281

278282
/* ── the subject vocabulary AT THIS SITE ─────────────────────────────────── */
279283

280-
/** Open the row's SUBJECT dropdown and read back every subject offered. */
284+
/**
285+
* An option's CEL spelling. A field subject reads by its label with the
286+
* spelling beside it (objectstack#33864), so the spelling is that hint; an
287+
* unlabelled subject (`previous`) reads as its spelling alone.
288+
*/
289+
function spellingOf(option: HTMLElement): string {
290+
const hint = option.querySelector('.font-mono');
291+
return (hint ?? option).textContent ?? '';
292+
}
293+
294+
/** Open the row's SUBJECT dropdown and read back the spelling of every subject offered. */
281295
async function subjectOptions(container: HTMLElement): Promise<string[]> {
282296
const trigger = container.querySelectorAll('[role="combobox"]')[0] as HTMLElement;
283297
await userEvent.click(trigger);
284298
const opts = await screen.findAllByRole('option');
285-
return opts.map((o) => o.textContent ?? '');
299+
return opts.map(spellingOf);
300+
}
301+
302+
/** The open dropdown's option that offers `spelling`. */
303+
function optionBySpelling(spelling: string): HTMLElement {
304+
const option = screen.getAllByRole('option').find((o) => spellingOf(o) === spelling);
305+
if (!option) throw new Error(`no option offers ${spelling}`);
306+
return option;
286307
}
287308

288309
/** The field holding exactly one row, ready to have its subject read. The
@@ -348,14 +369,14 @@ describe('#6226 the flow entry field offers the FLATTENED trigger vocabulary', (
348369
const { container, onCommit } = mountOneRow();
349370
const opts = await subjectOptions(container);
350371
expect(opts).toContain('amount');
351-
await userEvent.click(screen.getByRole('option', { name: 'amount' }));
372+
await userEvent.click(optionBySpelling('amount'));
352373
expect(onCommit).toHaveBeenCalledWith("amount == 'x'");
353374
});
354375

355376
it('authors the create-path idiom `previous == null` end to end', async () => {
356377
const { container, onCommit } = mountOneRow();
357378
await userEvent.click(container.querySelectorAll('[role="combobox"]')[0] as HTMLElement);
358-
await userEvent.click(screen.getByRole('option', { name: 'previous' }));
379+
await userEvent.click(optionBySpelling('previous'));
359380
const valueBox = container.querySelector('input') as HTMLInputElement;
360381
fireEvent.change(valueBox, { target: { value: 'null' } });
361382
expect(onCommit).toHaveBeenLastCalledWith('previous == null');
@@ -372,6 +393,42 @@ describe('#6226 the flow entry field offers the FLATTENED trigger vocabulary', (
372393

373394
/* ── the escape hatch ────────────────────────────────────────────────────── */
374395

396+
/**
397+
* objectstack#33864 — the subject list names a field by its label, its CEL
398+
* spelling beside it as secondary text (`ux-conventions.labels-over-machine-names`).
399+
*/
400+
describe('objectstack#33864 the flow entry field names each subject by its field label', () => {
401+
/** Open the dropdown; each option as [its main text, its secondary spelling or null]. */
402+
async function labelledOptions(container: HTMLElement): Promise<Array<[string, string | null]>> {
403+
await userEvent.click(container.querySelectorAll('[role="combobox"]')[0] as HTMLElement);
404+
const opts = await screen.findAllByRole('option');
405+
return opts.map((o) => {
406+
const hint = o.querySelector('.font-mono')?.textContent ?? null;
407+
const text = o.textContent ?? '';
408+
return [hint === null ? text : text.slice(0, text.length - hint.length), hint];
409+
});
410+
}
411+
412+
it('a field reads by its label, with its spelling as the hint', async () => {
413+
const opts = await labelledOptions(mountOneRow().container);
414+
expect(opts).toContainEqual(['Status', 'status']);
415+
expect(opts).toContainEqual(['Contract term (months)', 'contract_term_months']);
416+
});
417+
418+
it("a `previous.FIELD` reads by the field's label, before the change", async () => {
419+
const opts = await labelledOptions(mountOneRow().container);
420+
expect(opts).toContainEqual([
421+
tFormat('engine.inspector.condition.previousField', 'en', { field: 'Status' }),
422+
'previous.status',
423+
]);
424+
});
425+
426+
it('CONTROL: the whole-record `previous` has no label, so it reads as its spelling', async () => {
427+
const opts = await labelledOptions(mountOneRow().container);
428+
expect(opts).toContainEqual(['previous', null]);
429+
});
430+
});
431+
375432
describe('#6226 raw CEL remains reachable — the ruling\'s escape hatch', () => {
376433
it('a row-mode field can be switched to the raw expression editor', async () => {
377434
const container = mountField({ value: 'status == "done"' });

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,9 @@ export function FlowNodeConfigField({ field, value, onCommit, disabled, locale,
730730
// objectui#11789 — one verdict: the scope note this field renders
731731
// below replaces the raw editor's "Valid CEL", never sits under it.
732732
scopeIssue={unknownRefs.length > 0}
733+
// A subject reads by its field label, its CEL spelling beside it
734+
// (`ux-conventions.labels-over-machine-names`).
735+
labelSubjects
733736
/>
734737
);
735738
}

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeInspector.entryCondition.test.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import { describe, it, expect, vi, afterEach, beforeAll } from 'vitest';
2626
import { render, screen, cleanup } from '@testing-library/react';
2727
import userEvent from '@testing-library/user-event';
28+
// The source under test reaches a dynamic `import('@objectstack/lint')`; pay
29+
// that load during collection, never inside a case's clocked window.
30+
import '@objectstack/lint';
2831

2932
// The engine config-schema hook is stubbed empty so the inspector uses its
3033
// hardcoded field groups (fieldsForNodeType); the trigger field catalog is
@@ -120,7 +123,11 @@ describe('#6226 the flow inspector hands the entry condition its trigger vocabul
120123
.parentElement!;
121124
const subject = row.querySelector('[role="combobox"]') as HTMLElement;
122125
await userEvent.click(subject);
123-
const opts = (await screen.findAllByRole('option')).map((o) => o.textContent ?? '');
126+
// A field subject reads by its label with its spelling beside it
127+
// (objectstack#33864): read the spelling, the hint where there is one.
128+
const opts = (await screen.findAllByRole('option')).map(
129+
(o) => (o.querySelector('.font-mono') ?? o).textContent ?? '',
130+
);
124131
expect(opts).toContain('status');
125132
expect(opts).toContain('previous.status');
126133
// One subject per value: the bare spelling, never `record.FIELD` beside it

‎ui/packages/app-shell/src/views/metadata-admin/previews/useObjectFields.draftOverlay-11895.test.tsx‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ vi.mock('../useMetadata', async (importOriginal) => ({
6666
useMetadataClient: () => h.client,
6767
}));
6868

69+
// The source under test reaches a dynamic `import('@objectstack/lint')`; pay
70+
// that load during collection, never inside a case's clocked window.
71+
import '@objectstack/lint';
6972
import { useObjectFields } from './useObjectFields';
7073
import { t, useMetadataLocale } from '../i18n';
7174
import { FlowNodeConfigField } from '../inspectors/FlowNodeConfigField';
@@ -190,8 +193,18 @@ function startNodeScope(objectName: string): TriggerScope | undefined {
190193
return resolveFlowScope(draft, 'start').trigger;
191194
}
192195

193-
/** Open the entry condition's SUBJECT dropdown and read every subject it offers. */
194-
async function entrySubjects(objectName: string, expectField: string): Promise<string[]> {
196+
/**
197+
* The CEL spelling an option offers. The entry-condition builder names a field
198+
* subject by its label with its spelling beside it (`labelSubjects`,
199+
* objectstack#33864); a subject with no label (`previous`) is its spelling.
200+
*/
201+
function spellingOf(option: HTMLElement): string {
202+
const hint = option.querySelector('.font-mono');
203+
return (hint ?? option).textContent ?? '';
204+
}
205+
206+
/** Open the entry condition's SUBJECT dropdown and read the spelling of every subject it offers. */
207+
async function entrySubjects(objectName: string, expectOption: string): Promise<string[]> {
195208
const { container } = render(
196209
<FlowNodeConfigField
197210
field={ENTRY_CONDITION}
@@ -203,22 +216,22 @@ async function entrySubjects(objectName: string, expectField: string): Promise<s
203216
const trigger = container.querySelectorAll('[role="combobox"]')[0] as HTMLElement;
204217
await userEvent.click(trigger);
205218
// Waits for the catalog: the options follow the field read when it lands.
206-
await screen.findByRole('option', { name: expectField });
207-
return screen.getAllByRole('option').map((o) => o.textContent ?? '');
219+
await screen.findByRole('option', { name: expectOption });
220+
return screen.getAllByRole('option').map(spellingOf);
208221
}
209222

210223
describe('the flow entry-condition builder offers a draft-only object\'s fields (objectui#11895)', () => {
211224
it('offers the draft object\'s fields, not only `previous`', async () => {
212225
installServer(WORLD);
213-
const opts = await entrySubjects('repair_ticket', 'issue_summary');
226+
const opts = await entrySubjects('repair_ticket', 'Issue summary issue_summary');
214227
expect(opts).toContain('issue_summary');
215228
expect(opts).toContain('severity');
216229
expect(opts).toContain('previous.issue_summary');
217230
});
218231

219232
it('CONTROL — a published object\'s fields are offered as before', async () => {
220233
installServer(WORLD);
221-
const opts = await entrySubjects('account', 'industry');
234+
const opts = await entrySubjects('account', 'Industry industry');
222235
expect(opts).toContain('name');
223236
expect(opts).toContain('industry');
224237
});

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

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import React from 'react';
1919

2020
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
2121

22-
import { t } from '../metadata-admin/i18n';
22+
import { MetadataCtx, type MetadataContextValue } from '@object-ui/react';
23+
import { t, tFormat } from '../metadata-admin/i18n';
2324
import { PackageOwdOverviewPanel } from './PackageOwdOverviewPanel';
2425

2526
const en = (key: string) => t(key, 'en-US');
@@ -156,7 +157,56 @@ describe('PackageOwdOverviewPanel — controlled_by_parent', () => {
156157
renderPanel(freshServer());
157158
await screen.findByTestId('owd-row-crm_case');
158159
const master = screen.getByTestId('owd-master-crm_case');
159-
expect(master.textContent).toMatch(/crm_account/);
160+
// objectstack#33864 — the master is named by its label, not its name.
161+
expect(master.textContent).toBe(tFormat('engine.studio.owd.byParent', 'en-US', { master: 'Account' }));
162+
});
163+
});
164+
165+
/**
166+
* objectstack#33864 — "By parent → …" names the master object by its label
167+
* (`ux-conventions.labels-over-machine-names`): this package's own object as
168+
* the table reads it, else the served object's label, else the machine name.
169+
*/
170+
describe('PackageOwdOverviewPanel — the master is named by its label (objectstack#33864)', () => {
171+
function servedObjects(objects: unknown[]): MetadataContextValue {
172+
return {
173+
apps: [],
174+
objects,
175+
dashboards: [],
176+
reports: [],
177+
pages: [],
178+
loading: false,
179+
error: null,
180+
refresh: async () => {},
181+
invalidate: () => {},
182+
ensureType: async () => [],
183+
getItem: async () => null,
184+
getItemsByType: () => [],
185+
getTypeStatus: () => 'ready',
186+
};
187+
}
188+
const byParent = (master: string) => tFormat('engine.studio.owd.byParent', 'en-US', { master });
189+
190+
/** A package that holds only the detail: its master lives in another package. */
191+
function detailOnly(): Server {
192+
const server = freshServer();
193+
delete server.objects.crm_account;
194+
return server;
195+
}
196+
197+
// This package's own master is pinned by 'shows the master link' above.
198+
it("a master outside this package reads as the served object's label", async () => {
199+
render(
200+
<MetadataCtx.Provider value={servedObjects([{ name: 'crm_account', label: 'Customer Account' }])}>
201+
<PackageOwdOverviewPanel client={makeClient(detailOnly())} packageId="com.example.showcase" locale="en-US" />
202+
</MetadataCtx.Provider>,
203+
);
204+
expect(await screen.findByTestId('owd-master-crm_case')).toHaveTextContent(byParent('Customer Account'));
205+
});
206+
207+
it('CONTROL: a master no read can label is named by its machine name', async () => {
208+
renderPanel(detailOnly());
209+
expect(await screen.findByTestId('owd-master-crm_case')).toHaveTextContent(byParent('crm_account'));
160210
});
161211
});
162212

0 commit comments

Comments
 (0)