Skip to content

Commit cdbc852

Browse files
claude[bot]claude
andauthored
docs(plugin-tree): compile the README's snippet against the authorable surface (#8251)
The page's only collected fence was a bare `object-view` literal carrying `views: [{ type: 'tree', tree: { ... } }]`. It never parsed (TS1005 x2 + TS1109), so the ledger row was the whole of what this gate knew about the page, and a genuine type error in that literal left the row byte-identical. Two facts made the obvious repair wrong. `ObjectViewSchema` declares no `views` member at all, so annotating the literal with it compiles green while checking nothing that matters -- measured: `views: 'not-even-an-array'` is accepted, only `objectName` turns red. And `tree` is a host-composition view type, not an authorable one: objectui#5321 ruled it recorded rather than declared, and ObjectView.tsx states verbatim that its config surface is "not authoring surface to teach in the docs". The example taught, as authored metadata, the one shape that ruling forbids teaching. So the example now writes the `object-tree` node an author can actually select, bound through the exported `ObjectQLComponentSchema` union, which narrows on `type` and checks all five declared members. The host-only `tree` alias keeps its paragraph, as prose rather than as a copyable example. The four documented defaults were each checked against ObjectTree.tsx and were already correct; they are unchanged. Part of #5174 (batch 33) Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3404893 commit cdbc852

2 files changed

Lines changed: 32 additions & 19 deletions

File tree

‎packages/plugin-tree/README.md‎

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,26 @@ handles *fixed-depth* hierarchies; a tree handles arbitrary depth.)
99

1010
It registers two component types via the `ComponentRegistry`:
1111

12-
- `object-tree` — the object-bound renderer
13-
- `tree` — the view-type alias used by `ObjectView` / `ViewSwitcher`
12+
- `object-tree` — the object-bound renderer, and the one an author selects
13+
- `tree` — a view-type alias reached only by host composition (see below)
1414

1515
## Usage
1616

17+
Author an `object-tree` node. Its config keys sit **flat on the node**, and
18+
`ObjectQLComponentSchema` narrows on `type`, so each one is checked against
19+
`ObjectTreeSchema`:
20+
1721
```ts
18-
// As a view inside an ObjectView
19-
{
20-
type: 'object-view',
22+
import type { ObjectQLComponentSchema } from '@object-ui/types';
23+
24+
const schema: ObjectQLComponentSchema = {
25+
type: 'object-tree',
2126
objectName: 'business_unit',
22-
views: [
23-
{
24-
type: 'tree',
25-
tree: {
26-
parentField: 'parent', // single-parent pointer (auto-detected if omitted)
27-
labelField: 'name', // indented first column
28-
fields: ['name', 'manager'], // additional flat columns
29-
defaultExpandedDepth: 1, // 0 = roots only; omit = expand all
30-
},
31-
},
32-
],
33-
}
27+
parentField: 'parent', // single-parent pointer (auto-detected if omitted)
28+
labelField: 'name', // indented first column
29+
fields: ['name', 'manager'], // additional flat columns
30+
defaultExpandedDepth: 1, // 0 = roots only; omit = expand all
31+
};
3432
```
3533

3634
### Config
@@ -45,6 +43,23 @@ It registers two component types via the `ComponentRegistry`:
4543
Records whose parent is missing (or points outside the result set) are kept as
4644
roots, so nothing is silently dropped.
4745

46+
### The `tree` view type is host composition, not authoring
47+
48+
`tree` is **not** an authorable view type. Neither `ObjectViewSchema.defaultViewType`
49+
nor `NamedListView.type` admits it — both are the same seven-value union that stops
50+
at `map` — so no authored document selects a tree view, and `ObjectViewSchema`
51+
declares no `views` member at all. The `tree` branch runs only when a **host**
52+
composes `ObjectView` with a `views` prop, whose entries carry `id` and `label`
53+
and are typed `ViewType`. That was ruled deliberate on objectui#5321
54+
(2026-08-20): `tree` and `chart` are recorded as host-composition-only surfaces
55+
rather than added to the authored unions. The per-view `tree` config block that
56+
path reads is host config, so it is not documented here as authoring surface.
57+
58+
The live consumer is the console: it passes stored view records to `ObjectView`
59+
as `views`, and its create-view dialog offers `tree` among the types a console
60+
user can create. To render a tree from authored metadata, write the
61+
`object-tree` node above.
62+
4863
## License
4964

5065
MIT — see [LICENSE](./LICENSE).

‎scripts/check-doc-snippet-types.mjs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,6 @@ const UNGATED_DOCS = {
781781
'1 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies; 1 undefined-name diagnostic(s) — blocks continue an earlier block, or use ambient names the page never defines; plus TS2322x1 — candidate real defects, un-triaged',
782782
'packages/plugin-markdown/README.md':
783783
'2 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies',
784-
'packages/plugin-tree/README.md':
785-
'3 parse diagnostic(s) — blocks fenced `ts` that are bare object literals or elided bodies',
786784
};
787785

788786
// ── Fence scanning ───────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)