Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 7cbc724

Browse files
Sam Altmanclaude
andauthored
fix(types): retire icon from the record:highlights fields[] entry arm (#9347)
`@objectstack/spec` `RecordHighlightsProps.fields[]`'s object arm declares exactly `name`/`label`/`type`/`readonly` behind a `never` catchall — it is `$strict`, so an unlisted key is REFUSED, not stripped, and the refusal takes the whole document with it. This repo declared a fifth key, `icon`, on three layers: the published type, the renderer's entry normalizer, and the registry manifest's `fields` input description. All three were already broken rather than working. No author could get an `icon` past the contract, so the normalizer's read was unreachable and the manifest's promise was impossible to honour. `HeaderHighlight` renders no `.icon` on the far side either. Retiring makes the three layers agree with the one layer that has authority; widening the contract instead is an upstream decision on its own card. Re-measured against the installed pin (17.4.0) with three controls: a declared key parses green, an arbitrary key is refused with the SAME `invalid_union` code as `icon`, and the bare-string arm is unaffected. `sections[].icon` on `RecordDetailsComponentProps` is a different key on a different face — the contract declares it and `DetailSection` draws it — and is deliberately untouched. Claude-Session: https://claude.ai/code/session_01L5xpA5q533BgTTNADibEFt Co-authored-by: Claude <noreply@anthropic.com>
1 parent edea22a commit 7cbc724

6 files changed

Lines changed: 408 additions & 5 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
'@object-ui/types': minor
3+
'@object-ui/plugin-detail': minor
4+
---
5+
6+
Retire `icon` from the `record:highlights` `fields[]` entry, across all three layers that
7+
carried it (objectui#9280).
8+
9+
**Breaking, deliberately.** `{ name: 'amount', icon: 'dollar-sign' }` on a
10+
`record:highlights` entry no longer type-checks. Nothing that worked stops working: the key
11+
was never authorable in the first place, and this change is what makes `tsc` say so.
12+
13+
`@objectstack/spec` `RecordHighlightsProps.fields[]`'s object arm declares exactly
14+
`name`/`label`/`type`/`readonly` behind a `never` catchall — it is `$strict`, so an unlisted
15+
key is REFUSED, not stripped, and the refusal takes the WHOLE document with it. Re-measured
16+
on this branch against the installed pin (17.4.0) rather than inherited from the card, with
17+
three controls in the same pass so the instrument is not blind:
18+
19+
```
20+
fields[] object-arm keys : ["label","name","readonly","type"] catchall: never ($strict)
21+
{ fields: [{ name:'x', label:'L' }] } GREEN <- CONTROL
22+
{ fields: [{ name:'x', icon:'star' }] } RED invalid_union at fields.0
23+
{ fields: [{ name:'x', zzzNonsense:1 }] } RED invalid_union at fields.0 <- CONTROL
24+
{ fields: ['x'] } GREEN <- CONTROL
25+
```
26+
27+
A declared key parses green, so the arm is not refusing everything; an arbitrary key is
28+
refused with the SAME code as `icon`, so `icon` was not special-cased; the bare-string arm is
29+
untouched, so only the object arm moved.
30+
31+
FROM → TO, per layer:
32+
33+
- `packages/types/src/record-components.ts` — `RecordHighlightsComponentProps.fields[]`'s
34+
object arm: `{ name; label?; icon?; type?; readonly? }` → **`{ name; label?; type?; readonly? }`**.
35+
The key is **removed, not tombstoned**: the contract's arm is `$strict`, so the refusal an
36+
author needs already exists upstream and arrives named (`invalid_union` at the entry). A
37+
`?: never` tombstone buys nothing here — it is the remedy for a non-strict mirror that
38+
would otherwise strip in silence, which is not this arm.
39+
- `packages/plugin-detail/src/renderers/record-highlights.tsx` — the entry normalizer stops
40+
copying `icon: f?.icon` into the normalized entry. That read was **unreachable**, not
41+
merely unused: no author could feed it past the `$strict` arm, and `HeaderHighlight`
42+
renders no `.icon` on the far side either, so the copy had no consumer in either
43+
direction.
44+
- `packages/plugin-detail/src/index.tsx` — the registry manifest's `fields` input description
45+
sketched the entry as `{name,label?,icon?,type?,readonly?}` → **`{name,label?,type?,readonly?}`**.
46+
The `inputs` ARE the published contract (`gen-manifest.ts` serializes them into
47+
`sdui.manifest.json` and `sdui-intrinsics.d.ts`), so leaving the sketch standing would have
48+
gone on teaching AI and human authors a key that gets the whole document refused at publish.
49+
50+
**Migration.** Nothing in this repository has to change. An in-repo census over every
51+
`record:highlights` region (109 regions, all tracked files) scores an entry-level `icon`
52+
**0**, against `readonly` **23** in the same pass over the same regions — the instrument was
53+
not blind. If you author `icon` on a highlight entry in your own metadata, delete it: it was
54+
already causing the publish to refuse the document whole. Whether a highlight chip *should*
55+
be able to carry an icon is a separate question this change does not answer — the route for
56+
that is an upstream `@objectstack/spec` widening, on its own card, ⛔ never a redeclaration
57+
here.
58+
59+
⚠️ `sections[].icon` on `RecordDetailsComponentProps` is a **different key on a different
60+
face** and is **unaffected**: the contract declares it and `DetailSection` genuinely draws
61+
it. Two keys sharing a word in one file are not the same key.
62+
63+
Pinned in `packages/types/src/__tests__/record-highlights-fields-icon-9280.test.ts` across
64+
three instruments that do not see the same thing — a `tsc` `@ts-expect-error` leg with a
65+
`{name,label}` control that stays green, `safeParse` legs against the installed spec
66+
artifact, and a source-text read whose lit control is that very `sections[].icon` member, so
67+
an empty result on the highlights arm is a reading rather than a matcher that cannot match.
68+
`packages/plugin-detail/src/__tests__/recordHighlightsInputs.spec-parity.test.ts` gains the
69+
REVERSE direction it was missing: it already failed when a spec entry key went undocumented,
70+
and now also fails when the description advertises an entry key the spec refuses.

‎packages/plugin-detail/src/__tests__/recordHighlightsInputs.spec-parity.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,34 @@ describe('record:highlights — registry inputs vs @objectstack/spec', () => {
147147
expect(description).toContain('readonly');
148148
});
149149

150+
it('the `fields` entry-shape sketch advertises no key the spec refuses', () => {
151+
// The REVERSE direction of the check above, and the one objectui#9280 was
152+
// filed for: the description sketched the entry as
153+
// `{name,label?,icon?,type?,readonly?}` while the spec's object arm is
154+
// `$strict` over four keys, so the manifest was teaching authors a key that
155+
// gets the WHOLE document refused at publish. Under-documenting a key is a
156+
// discoverability bug; over-advertising one is an impossible promise.
157+
const description = fieldsInput()?.description ?? '';
158+
const sketch = /\{([a-zA-Z?,\s]+)\}/.exec(description)?.[1];
159+
expect(sketch, 'the description must keep an entry-shape sketch to check').toBeDefined();
160+
161+
const advertised = (sketch ?? '')
162+
.split(',')
163+
.map((k) => k.trim().replace(/\?$/, ''))
164+
.filter(Boolean)
165+
.sort();
166+
167+
// Derived from the spec at runtime, so a spec that WIDENS the arm fails
168+
// here instead of leaving the sketch quietly short.
169+
expect(advertised).toEqual(specEntryKeys().sort());
170+
171+
// ⭐ LIT CONTROL for this matcher: it really does read keys out of the
172+
// sketch rather than returning an empty list that trivially compares
173+
// equal. `name` is the one key the arm cannot lose.
174+
expect(advertised).toContain('name');
175+
expect(advertised).not.toContain('icon');
176+
});
177+
150178
it('declares no top-level input the spec does not accept', () => {
151179
const allowed = new Set(specTopLevelKeys());
152180
const offSpec = inputs().map((i) => i.name).filter((name) => !allowed.has(name));

‎packages/plugin-detail/src/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ ComponentRegistry.register('highlights', RecordHighlightsRenderer, {
637637
// un-gated (pinned as `MULTI_KIND_MEMBER_CONTRACTS` in the repo-wide parity
638638
// gate). objectui#3407 / objectstack#5176.
639639
inputs: [
640-
{ name: 'fields', type: 'array', required: true, description: 'Key fields to highlight (1-7), bare names or {name,label?,icon?,type?,readonly?}. Set readonly: true on an entry to render that chip read-only — it suppresses the inline-edit affordance and the HeaderHighlight editability gate enforces it. Use it for hook/automation-maintained columns that must not be hand-edited from the record header; marking the OBJECT field readonly instead would also strip the hook\'s own write-back.' },
640+
{ name: 'fields', type: 'array', required: true, description: 'Key fields to highlight (1-7), bare names or {name,label?,type?,readonly?}. Set readonly: true on an entry to render that chip read-only — it suppresses the inline-edit affordance and the HeaderHighlight editability gate enforces it. Use it for hook/automation-maintained columns that must not be hand-edited from the record header; marking the OBJECT field readonly instead would also strip the hook\'s own write-back.' },
641641
{ name: 'layout', type: 'enum', enum: ['horizontal', 'vertical'], description: 'Layout orientation for highlight fields' },
642642
],
643643
});

‎packages/plugin-detail/src/renderers/record-highlights.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export const RecordHighlightsRenderer: React.FC<RecordHighlightsRendererProps> =
5050
required.every((p) => perms.can(objectName, p as any));
5151

5252
const rawFields: any[] = Array.isArray(schema.fields) ? schema.fields : [];
53-
// Normalize: accepts either bare strings or { name, label?, icon?, type?, readonly? }.
53+
// Normalize: accepts either bare strings or { name, label?, type?, readonly? }
54+
// — the four keys the contract's object arm declares, and no fifth.
5455
//
5556
// `readonly` is copied through deliberately: HeaderHighlight's editability
5657
// gate has always consulted `field.readonly`, but this map used to rebuild
@@ -59,13 +60,21 @@ export const RecordHighlightsRenderer: React.FC<RecordHighlightsRendererProps> =
5960
// never fire from authored metadata (objectstack#5077). Rebuilding key-by-key
6061
// rather than spreading keeps the entry shape closed — an undeclared key is
6162
// still not silently forwarded to the strip.
63+
//
64+
// `icon` was copied through here until objectui#9280 and that read was
65+
// UNREACHABLE, not merely unused: `@objectstack/spec`
66+
// `RecordHighlightsProps.fields[]`'s object arm is `$strict` (a `never`
67+
// catchall over `name`/`label`/`type`/`readonly`), so a document carrying
68+
// `icon` is refused WHOLE at publish and no author could ever feed this
69+
// branch. `HeaderHighlight` renders no `.icon` either, so the copy also had
70+
// no consumer on the far side. Retired in both directions rather than left
71+
// standing as a read for a key nothing can author.
6272
const normalized = rawFields.map((f) =>
6373
typeof f === 'string'
6474
? { name: f }
6575
: {
6676
name: f?.name,
6777
label: f?.label,
68-
icon: f?.icon,
6978
type: f?.type,
7079
readonly: f?.readonly === true,
7180
},

0 commit comments

Comments
 (0)