Skip to content

Commit 4265176

Browse files
feat(console): the shared-record page shows authored field labels, picklist labels and currency from the resolve answer's fields (#27199)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ82jnVCgB5yzt8bWfLcSkizx)_ Fixes #27121 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:分享链接页 `/s/:token` 读取 resolve 应答新增的 `fields` 投影,每行显示字段的作者标签;选项字段显示选项标签和颜色,货币字段按 `currencyConfig` 经 `resolveFieldCurrency` 格式化,查找字段显示存储的记录 id。 - 为什么改:#26991 已让服务端返回字段显示投影,但页面仍用字段名转写的标签和按 JSON 形状格式化的值,匿名访客看不到作者标签、选项标签和货币。 - 风险与回滚:只改 console 一页的展示层;不多发任何请求,不改 resolve 请求、密码流程和脱敏。旧服务端不返回 `fields` 时页面与之前完全一样。回滚即 revert 本 PR。 - 先看:`ui/apps/console/src/pages/SharedRecordFields.tsx`(`NO_FETCH_CELL_RENDERERS` 按渲染器身份放行)、`shared-record-shape.ts`(`fields` 折叠)、`SharedRecordPage-27121.test.tsx`。 - 两分钟验证:`pnpm --dir ui exec vitest run apps/console/src/pages/SharedRecordPage-27121.test.tsx apps/console/src/pages/shared-record-shape.test.ts`,预期 2 个文件、19 个用例全部通过。 - 需要你做的:无,席位落地。 ## What changes - `shared-record-shape.ts`: `WireResolvedShare` and `ResolvedShare` gain `fields`, and `normalizeResolvedShare` folds it through on both the enveloped and the bare body. An answer without `fields` (a server older than #26991) leaves it `undefined`. - **How the console types it: mirrored, not imported.** `@object-ui/console` does not depend on `@objectstack/types`, so `SharedFieldDisplay` mirrors only the members of `ShareLinkFieldDisplay` this page reads (`label`, `type`, `options`, `multiple`, `currencyConfig`, `reference`, `displayField`). No workspace dependency was added. - `SharedRecordFields.tsx` takes `fields`: - **Label:** the field's authored `label`; a key with no `fields` entry keeps `humanizeLabel(key)`. - **Value:** through the record detail view's own read-only cell renderer for the field's type (`getCellRenderer`, the call the detail view makes), but only when that renderer is one of `NO_FETCH_CELL_RENDERERS`: `SelectCellRenderer` (authored option label and colour, one badge per value for `multiple`) and `CurrencyCellRenderer` (the code from `resolveFieldCurrency` with the field's `currencyConfig` and the localization context's tenant default, which this route does not mount). The set is matched by renderer identity, the way the detail view matches its own boolean and text faces, so a host-registered face for a type is never picked up. - **Everything else**, a lookup included, keeps the JSON-shape formatting from #26767. A lookup's value is the stored id, so the row reads the authored label and the id. - `SharedRecordPage.tsx` passes `data.fields` through. - Changeset: `@object-ui/console` patch. ## Tests - `SharedRecordPage-27121.test.tsx` (7 cases): authored labels; picklist option label and declared colour, both labels for a multi-select; currency equals `formatCurrency(n, resolveFieldCurrency(field), 'en')` for a fixed EUR config (and contains the euro sign) and a plain amount for a dynamic config; a lookup shows its id and the page requests nothing but resolve; a lookup never calls `find`, `findOne` or `getObjectSchema` on a data source a host provides; control: a key with no `fields` entry keeps its humanized label; an answer without `fields` renders exactly as before. - `shared-record-shape.test.ts` (+2 cases): `fields` survives both envelopes; it stays absent when the server omits it. - Ablation 1 (run before the host-data-source case existed), `fields: wire.fields` deleted through `scripts/ablation-replace.mjs`: 5 of 18 red (the shape carry test and the label, picklist, currency and lookup tests); the control and the no-`fields` test stay green; restore proven by blob equal to HEAD and an empty `git diff HEAD`. - Ablation 2, the `NO_FETCH_CELL_RENDERERS` check replaced by the bare registry answer: the host-data-source lookup test goes red (1 of 7); restored the same way. A first attempt was a no-op refused by the tool (its replacement text occurred elsewhere), so it was rerun with a unique replacement; and before the host-data-source test existed this ablation stayed green, which is why that test was added. ## Acceptance notes - **Lookup display is the stored id.** Nothing serves the target record's name to an anonymous visitor (the meta and data doors refuse one), and the projection carries the target object's api name, not a label. Showing a name would need a server-side change; it is reported to the seat, not built here. - **Number, percent, date and date-time values keep the JSON-shape formatting.** Those paths already use the console's one number and date faces; the detail view's number and percent cells additionally read `scale`, which the projection does not carry, so routing them through the cells would not add fidelity. - **#27119 is untouched.** No new currency fallback: a dynamic or unconfigured currency field shows whatever `resolveFieldCurrency` answers today, which on this route (no tenant default mounted) is a plain amount. - The pending changeset from #26767 says authored labels, picklist labels and currency "do not show yet"; this PR's changeset says they now do. Both are unreleased, so the release that compiles them will carry both entries. ## Verification Run on head `de0b485b` (after merging `origin/main` at `38490dbd`): <details><summary>Build, tests and type-check</summary> - `pnpm --workspace-concurrency=2 --filter '@object-ui/console^...' build` under the verify lock: exit 0. - `pnpm --dir ui exec vitest run --maxWorkers=2 apps/console/src/pages/`: Test Files 126 passed (126), Tests 904 passed (904). - `pnpm --filter @object-ui/console run type-check`: exit 0 (run before the merge; the merge touched no file this diff touches). - `pnpm --dir ui run check:new-line-citations`: 0 new citations. </details> <details><summary>Derived gates (33, all exit 0)</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 33 families on this diff; each was run and exited 0; `--ran` reconciliation: 33 derived, 33 run, 0 NOT-MEASURED, 0 UNRUN. `--tier`: no path-derived mandate (TIER_DEFAULT). Changed lines: 396, under the 3,000 threshold. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbaGXxC3vCjA46AStCM)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9fa70b4 commit 4265176

6 files changed

Lines changed: 374 additions & 22 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
feat(console): a shared record shows its authored field labels, picklist labels and currency
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Before.** The share-link page `/s/:token` labelled each row of a non-chat record with the field key humanized ("Annual Revenue") and formatted each value by its JSON shape only, so a picklist showed its stored code and a currency amount showed a plain number.
11+
- **Now.** The page reads the resolve answer's `fields` projection. Each row carries the field's authored label. A picklist value shows its authored option label and colour, one badge per value for a multi-select. A currency amount is formatted in the currency the field declares (`currencyConfig`), through the same resolution the record detail view uses; a field with no fixed currency and no tenant default still shows a plain amount.
12+
- **Lookups.** A lookup row shows its authored label and the stored record id. The page never reads the referenced record: an anonymous visitor cannot, so the target's name is not shown.
13+
- **Unchanged.** A key the projection does not describe, and an answer from a server that does not send `fields`, keep the humanized label and the JSON-shape value. Redacted fields stay absent. The page makes no request beyond the resolve call.

‎ui/apps/console/src/pages/SharedRecordFields.tsx‎

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,43 @@
88
* own keys, after the server stripped the link's redacted fields. ⛔ It never
99
* adds a key the record does not carry, and never fetches anything to widen it.
1010
*
11-
* Why no field labels or field types. The resolve answer is `{ record, link,
12-
* redactFields }` on both producers — no object schema. The one door to that
13-
* schema, `GET /meta/object/:name`, refuses an anonymous caller, and this page's
14-
* visitor is anonymous by design (its requests carry no bearer token). So the
15-
* label is the record key humanized, and the value is formatted by its JSON
16-
* shape: an ISO date or date-time string through the console's one date-display
17-
* path, a number through its one number-display path, a boolean as Yes / No,
18-
* and an array or object as short text — never raw JSON.
11+
* Labels and types come from the resolve answer's `fields` projection
12+
* (objectstack#27121), and from nowhere else. The one door to the object
13+
* schema, `GET /meta/object/:name`, refuses an anonymous caller, and this
14+
* page's visitor is anonymous by design (its requests carry no bearer token),
15+
* so the server projects the display facts of exactly the fields `record`
16+
* carries — a redacted field is absent from both. ⛔ Nothing here fetches.
17+
*
18+
* - The label is the field's authored `label`; a key with no `fields` entry
19+
* (or an answer from a server that predates the projection) keeps the record
20+
* key humanized.
21+
* - The value goes through the record detail view's own read-only cell
22+
* renderer for its type, but only a renderer measured to draw from the value
23+
* and the projected field alone: see {@link NO_FETCH_CELL_RENDERERS}.
24+
* - Every other value is formatted by its JSON shape: an ISO date or date-time
25+
* string through the console's one date-display path, a number through its
26+
* one number-display path, a boolean as Yes / No (the detail view's
27+
* read-only word), and an array or object as short text — never raw JSON.
28+
* That includes a lookup: its value is the stored id, and the target's name
29+
* is not served to an anonymous visitor, so the id is what shows.
1930
*
2031
* System fields are shown, not hidden: the record detail view's notion of a
2132
* framework-managed column (`isSystemManagedField`, `@object-ui/types`) only
2233
* orders them after the business fields, the way the detail view keeps
2334
* provenance out of the leading rows.
2435
*/
2536

37+
import type * as React from 'react';
2638
import { formatDate, formatDateTime, formatDisplayNumber, humanizeLabel } from '@object-ui/core';
39+
import {
40+
CurrencyCellRenderer,
41+
getCellRenderer,
42+
SelectCellRenderer,
43+
type CellRendererProps,
44+
} from '@object-ui/fields';
2745
import { useDisplayLocale, useObjectTranslation } from '@object-ui/i18n';
28-
import { isSystemManagedField } from '@object-ui/types';
46+
import { isSystemManagedField, type FieldMetadata } from '@object-ui/types';
47+
import type { SharedFieldDisplay } from './shared-record-shape';
2948

3049
/** An empty value's face — the date-display path's own placeholder. */
3150
const EMPTY = '—';
@@ -73,12 +92,40 @@ function formatValue(value: unknown, locale: string, t: Translate, depth = 0): s
7392
return String(value);
7493
}
7594

95+
/**
96+
* The detail view's read-only cell renderers this page may draw with — matched
97+
* by renderer IDENTITY, the way the detail view matches its own boolean and
98+
* text faces, so a host that registered its own face for a type (one that may
99+
* read records) is never picked up here.
100+
*
101+
* Each was read for what it touches: `SelectCellRenderer` draws the option's
102+
* authored label and colour from `field.options`; `CurrencyCellRenderer`
103+
* resolves its code with `resolveFieldCurrency` from the field's
104+
* `currencyConfig` and the tenant default the localization context holds
105+
* (none on this page). Neither fetches. ⛔ Never add `LookupCellRenderer` or
106+
* `UserCellRenderer`: both read the referenced record through the data source,
107+
* which an anonymous visitor cannot.
108+
*/
109+
const NO_FETCH_CELL_RENDERERS: ReadonlySet<React.FC<CellRendererProps>> = new Set([
110+
SelectCellRenderer,
111+
CurrencyCellRenderer,
112+
]);
113+
114+
/** The detail view's renderer for `field`'s type, when it is one this page may use. */
115+
function noFetchRendererOf(field: SharedFieldDisplay | undefined): React.FC<CellRendererProps> | undefined {
116+
if (!field?.type) return undefined;
117+
const renderer = getCellRenderer(field.type);
118+
return NO_FETCH_CELL_RENDERERS.has(renderer) ? renderer : undefined;
119+
}
120+
76121
export interface SharedRecordFieldsProps {
77122
/** The record as the resolve answer carried it, redacted fields already stripped. */
78123
record: Record<string, unknown>;
124+
/** The resolve answer's display projection, keyed by field name; absent from an older server. */
125+
fields?: Record<string, SharedFieldDisplay>;
79126
}
80127

81-
export function SharedRecordFields({ record }: SharedRecordFieldsProps) {
128+
export function SharedRecordFields({ record, fields }: SharedRecordFieldsProps) {
82129
const { t } = useObjectTranslation();
83130
const locale = useDisplayLocale();
84131
const keys = Object.keys(record);
@@ -91,14 +138,22 @@ export function SharedRecordFields({ record }: SharedRecordFieldsProps) {
91138
const system = keys.filter((key) => isSystemManagedField(key));
92139

93140
const rows = (group: string[]) =>
94-
group.map((key) => (
95-
<div key={key} className="grid grid-cols-1 gap-1 py-2 sm:grid-cols-[minmax(8rem,1fr)_2fr] sm:gap-4">
96-
<dt className="text-xs font-medium text-muted-foreground">{humanizeLabel(key)}</dt>
97-
<dd className="min-w-0 whitespace-pre-wrap break-words text-sm text-foreground">
98-
{formatValue(record[key], locale, t)}
99-
</dd>
100-
</div>
101-
));
141+
group.map((key) => {
142+
const field = fields?.[key];
143+
const Renderer = noFetchRendererOf(field);
144+
return (
145+
<div key={key} className="grid grid-cols-1 gap-1 py-2 sm:grid-cols-[minmax(8rem,1fr)_2fr] sm:gap-4">
146+
<dt className="text-xs font-medium text-muted-foreground">{field?.label || humanizeLabel(key)}</dt>
147+
<dd className="min-w-0 whitespace-pre-wrap break-words text-sm text-foreground">
148+
{Renderer ? (
149+
<Renderer value={record[key]} field={{ name: key, ...field } as unknown as FieldMetadata} />
150+
) : (
151+
formatValue(record[key], locale, t)
152+
)}
153+
</dd>
154+
</div>
155+
);
156+
});
102157

103158
return (
104159
<div className="rounded-md border bg-card px-4">
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#27121 — the shared-record page reads the resolve answer's
5+
* `fields` projection (objectstack#26991): each row carries the field's
6+
* authored label, a picklist value its authored option label, a currency
7+
* value its currency through `resolveFieldCurrency`, and a lookup its stored
8+
* id. A key with no `fields` entry, and an answer from a server that predates
9+
* the projection, keep the humanized label and the JSON-shape value.
10+
*
11+
* The stub answers `/share-links/:token/resolve` the way both producers do:
12+
* enveloped, with the redacted fields already stripped from `record` and
13+
* `fields` covering exactly the keys `record` carries. Every visitor is
14+
* anonymous, and every request the page makes is recorded, so a renderer that
15+
* fetched the lookup target (or `/meta`) would show up here.
16+
*/
17+
18+
import '@testing-library/jest-dom/vitest';
19+
import { afterEach, describe, expect, it, vi } from 'vitest';
20+
import { cleanup, render, screen, within } from '@testing-library/react';
21+
import { MemoryRouter, Route, Routes } from 'react-router-dom';
22+
import { formatCurrency } from '@object-ui/fields';
23+
import { resolveFieldCurrency } from '@object-ui/i18n';
24+
import { SchemaRendererProvider } from '@object-ui/react';
25+
import SharedRecordPage from './SharedRecordPage';
26+
27+
const TOKEN = 'tok_27121';
28+
const RESOLVE_PATH = `/api/v1/share-links/${TOKEN}/resolve`;
29+
30+
/** An `account`-like record as resolve hands it over, `ssn` already redacted. */
31+
const ACCOUNT = {
32+
id: 'acc_1',
33+
name: 'Acme Corporation',
34+
account_type: 'customer',
35+
regions: ['emea', 'apac'],
36+
annual_revenue: 1250000,
37+
pipeline_value: 480000,
38+
parent_id: 'acc_parent_9',
39+
founded_on: '2026-03-15',
40+
};
41+
42+
const FIXED_EUR = { currencyMode: 'fixed', defaultCurrency: 'EUR' } as const;
43+
const DYNAMIC = { currencyMode: 'dynamic', defaultCurrency: 'CNY' } as const;
44+
45+
/** The projection the server builds for ACCOUNT — `founded_on` deliberately left out. */
46+
const FIELDS = {
47+
id: { label: 'Record ID', type: 'text' },
48+
name: { label: 'Account Name', type: 'text' },
49+
account_type: {
50+
label: 'Relationship',
51+
type: 'select',
52+
options: [
53+
{ value: 'prospect', label: 'Prospect' },
54+
{ value: 'customer', label: 'Paying customer', color: 'green' },
55+
],
56+
},
57+
regions: {
58+
label: 'Sales Regions',
59+
type: 'multiselect',
60+
multiple: true,
61+
options: [
62+
{ value: 'emea', label: 'Europe & Africa' },
63+
{ value: 'apac', label: 'Asia Pacific' },
64+
],
65+
},
66+
annual_revenue: { label: 'Yearly Revenue', type: 'currency', currencyConfig: FIXED_EUR },
67+
pipeline_value: { label: 'Open Pipeline', type: 'currency', currencyConfig: DYNAMIC },
68+
parent_id: { label: 'Parent Account', type: 'lookup', reference: 'account', displayField: 'name' },
69+
};
70+
71+
const json = (status: number, body: unknown) =>
72+
new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });
73+
74+
/** Stub the resolve route; answer `fields` only when given. Returns every requested path. */
75+
function shareServer(record: Record<string, unknown>, fields?: Record<string, unknown>): string[] {
76+
const requested: string[] = [];
77+
vi.stubGlobal(
78+
'fetch',
79+
vi.fn(async (input: string | URL | Request) => {
80+
const raw = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
81+
const { pathname } = new URL(raw, 'http://localhost');
82+
requested.push(pathname);
83+
if (pathname === RESOLVE_PATH) {
84+
return json(200, {
85+
success: true,
86+
data: {
87+
record,
88+
link: {
89+
id: 'sl_1',
90+
token: TOKEN,
91+
object_name: 'account',
92+
record_id: String(record.id),
93+
permission: 'view',
94+
audience: 'anyone',
95+
},
96+
redactFields: ['ssn'],
97+
...(fields ? { fields } : {}),
98+
},
99+
});
100+
}
101+
return new Response(null, { status: 404 });
102+
}),
103+
);
104+
return requested;
105+
}
106+
107+
function renderLink(dataSource?: Record<string, unknown>) {
108+
const routed = (
109+
<MemoryRouter initialEntries={[`/s/${TOKEN}`]}>
110+
<Routes>
111+
<Route path="/s/:token" element={<SharedRecordPage />} />
112+
</Routes>
113+
</MemoryRouter>
114+
);
115+
return render(
116+
dataSource ? <SchemaRendererProvider dataSource={dataSource as never}>{routed}</SchemaRendererProvider> : routed,
117+
);
118+
}
119+
120+
/** The value cell beside the row whose label reads `label`. */
121+
function cellOf(label: string): HTMLElement {
122+
const term = screen.getByText(label, { selector: 'dt' });
123+
const value = term.parentElement?.querySelector('dd');
124+
expect(value).not.toBeNull();
125+
return value as HTMLElement;
126+
}
127+
128+
afterEach(() => {
129+
cleanup();
130+
vi.unstubAllGlobals();
131+
});
132+
133+
describe('SharedRecordPage — rows read the resolve answer’s fields projection (objectstack#27121)', () => {
134+
it('labels each row with the field’s authored label', async () => {
135+
shareServer(ACCOUNT, FIELDS);
136+
renderLink();
137+
138+
await screen.findByText('Shared account');
139+
expect(cellOf('Account Name')).toHaveTextContent('Acme Corporation');
140+
expect(cellOf('Yearly Revenue')).toBeInTheDocument();
141+
expect(cellOf('Record ID')).toHaveTextContent('acc_1');
142+
// The humanized key is gone wherever an authored label exists.
143+
expect(screen.queryByText('Name', { selector: 'dt' })).toBeNull();
144+
expect(screen.queryByText('Annual Revenue', { selector: 'dt' })).toBeNull();
145+
});
146+
147+
it('a picklist value shows its authored option label and colour, one per value when multiple', async () => {
148+
shareServer(ACCOUNT, FIELDS);
149+
renderLink();
150+
151+
await screen.findByText('Shared account');
152+
const relationship = cellOf('Relationship');
153+
const badge = within(relationship).getByText('Paying customer');
154+
// The option label, not the stored code.
155+
expect(relationship.textContent).toBe('Paying customer');
156+
// The option's declared colour reaches the badge the detail view draws.
157+
expect(badge.closest('[class*="green"]')).not.toBeNull();
158+
159+
const regions = cellOf('Sales Regions');
160+
expect(within(regions).getByText('Europe & Africa')).toBeInTheDocument();
161+
expect(within(regions).getByText('Asia Pacific')).toBeInTheDocument();
162+
});
163+
164+
it('a currency value is formatted in the currency resolveFieldCurrency answers for its currencyConfig', async () => {
165+
shareServer(ACCOUNT, FIELDS);
166+
renderLink();
167+
168+
await screen.findByText('Shared account');
169+
// Fixed mode: the declared code.
170+
const eur = resolveFieldCurrency({ currencyConfig: FIXED_EUR });
171+
expect(eur).toBe('EUR');
172+
expect(cellOf('Yearly Revenue')).toHaveTextContent(formatCurrency(1250000, eur, 'en'));
173+
expect(cellOf('Yearly Revenue').textContent).toContain('€');
174+
175+
// Dynamic mode with no tenant default on this page: whatever the shared
176+
// resolution answers today (no code), so a plain amount and never CNY.
177+
const dynamic = resolveFieldCurrency({ currencyConfig: DYNAMIC });
178+
expect(dynamic).toBeUndefined();
179+
expect(cellOf('Open Pipeline')).toHaveTextContent(formatCurrency(480000, dynamic, 'en'));
180+
expect(cellOf('Open Pipeline').textContent).not.toMatch(/CN¥|¥|CNY/);
181+
});
182+
183+
it('a lookup shows its stored id under its authored label, and nothing but resolve is fetched', async () => {
184+
const requested = shareServer(ACCOUNT, FIELDS);
185+
renderLink();
186+
187+
await screen.findByText('Shared account');
188+
expect(cellOf('Parent Account').textContent).toBe('acc_parent_9');
189+
// One request, to resolve: no lookup-name read, no /meta, no /data.
190+
expect(requested).toEqual([RESOLVE_PATH]);
191+
});
192+
193+
it('a lookup never reads its target, even under a host that holds a data source', async () => {
194+
// The `/s/:token` route mounts no data source today; this pins the page's
195+
// own guard, so hoisting one above the route cannot turn an anonymous
196+
// visit into a read of the referenced record.
197+
const dataSource = {
198+
find: vi.fn(async () => ({ data: [{ id: 'acc_parent_9', name: 'Globex' }] })),
199+
findOne: vi.fn(async () => ({ id: 'acc_parent_9', name: 'Globex' })),
200+
getObjectSchema: vi.fn(async () => ({ name: 'account', fields: {} })),
201+
};
202+
const requested = shareServer(ACCOUNT, FIELDS);
203+
renderLink(dataSource);
204+
205+
await screen.findByText('Shared account');
206+
// Let any effect a renderer scheduled settle before reading the spies.
207+
await new Promise((resolve) => setTimeout(resolve, 50));
208+
expect(cellOf('Parent Account').textContent).toBe('acc_parent_9');
209+
expect(dataSource.find).not.toHaveBeenCalled();
210+
expect(dataSource.findOne).not.toHaveBeenCalled();
211+
expect(dataSource.getObjectSchema).not.toHaveBeenCalled();
212+
expect(requested).toEqual([RESOLVE_PATH]);
213+
});
214+
215+
it('a key with no fields entry keeps the humanized label and the JSON-shape value (control)', async () => {
216+
shareServer(ACCOUNT, FIELDS);
217+
renderLink();
218+
219+
await screen.findByText('Shared account');
220+
const founded = cellOf('Founded On');
221+
expect(founded.textContent).not.toBe('2026-03-15');
222+
expect(founded.textContent).not.toBe('');
223+
});
224+
225+
it('an answer without fields (an older server) renders exactly as before the projection', async () => {
226+
const requested = shareServer(ACCOUNT);
227+
const { container } = renderLink();
228+
229+
await screen.findByText('Shared account');
230+
expect(cellOf('Name').textContent).toBe('Acme Corporation');
231+
expect(cellOf('Account Type').textContent).toBe('customer');
232+
expect(cellOf('Annual Revenue').textContent).toBe('1,250,000');
233+
expect(cellOf('Parent Id').textContent).toBe('acc_parent_9');
234+
expect(screen.queryByText('Account Name', { selector: 'dt' })).toBeNull();
235+
expect(container.querySelectorAll('dt')).toHaveLength(Object.keys(ACCOUNT).length);
236+
expect(requested).toEqual([RESOLVE_PATH]);
237+
});
238+
});

‎ui/apps/console/src/pages/SharedRecordPage.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* as proper proposed-plan / draft cards instead of a raw tool-result JSON
1616
* dump. Every other object renders its fields read-only through
1717
* `SharedRecordFields`: the record's own keys, labelled and formatted, and
18-
* never the raw JSON (objectstack#26767).
18+
* never the raw JSON (objectstack#26767) — labelled with the authored labels
19+
* the resolve answer's `fields` projection carries (objectstack#27121).
1920
*
2021
* A link's password travels in the `X-Share-Password` request header, never in
2122
* the request URL (objectui#11649) — see `SHARE_PASSWORD_HEADER`. A `401` is
@@ -345,7 +346,7 @@ export default function SharedRecordPage() {
345346
</h1>
346347
</header>
347348
<main className="flex-1 overflow-y-auto p-4">
348-
<SharedRecordFields record={data.record} />
349+
<SharedRecordFields record={data.record} fields={data.fields} />
349350
{data.redactedFields && data.redactedFields.length > 0 && (
350351
<p className="mt-2 text-[11px] text-muted-foreground">
351352
{t('sharedRecord.redactedFields', {

0 commit comments

Comments
 (0)