Repository navigation
Commit 9462d8a
refactor(ui-types): one source for the filter-builder field-type list; close the three K4 review should-fixes (#27400)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao93rRemsb94HTBb9ZVJHChk)_
Fixes #27369
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:filter-builder 的 14 种字段类型现在只在 `@object-ui/types` 的
`filter-field-types.ts` 声明一次,校验 schema、TS 接口、渲染器三处都从这里取;顺带处理 K4
评审的三条建议改项。
- 为什么改:以前三处手抄列表互相漂移(objectui#6939、#7562、#8774 修的都是这个),K4 之后还多了一份冻结列表。
- 风险与回滚:可接受的类型集合不变(仍 14 个,`type` 可选,缺省 `text`);渲染行为不变。回滚即 revert 本 PR。
-
先看:`ui/packages/types/src/filter-field-types.ts`、`ui/packages/components/src/custom/filter-builder.tsx`
的分组导入、`ui/scripts/check-doc-links.mjs` 新增的 skills 扫描行。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/types/src/__tests__/filter-builder-mirror-6939.test.ts
examples/schema-catalog/test/filter-builder-mirror-6939.test.tsx`,预期全绿。
- 需要你做的:本 PR 触及 `.github/workflows/ci.yml`(Tier H),待分诊合约复审后由你合并。
## What changes
**One source for the field-type list (card items 1–2).**
- New `ui/packages/types/src/filter-field-types.ts` declares the
renderer's four behaviour buckets (`FILTER_NUMBER_LIKE_TYPES`,
`FILTER_DATE_LIKE_TYPES`, `FILTER_SELECT_LIKE_TYPES`,
`FILTER_LOOKUP_LIKE_TYPES`) and `FILTER_FIELD_TYPES` (`text`, the
buckets, `boolean`, in the order the retired doc used), plus the member
type `FilterFieldType`. All are exported from `@object-ui/types`.
- `FilterFieldSchema.type` is `z.enum(FILTER_FIELD_TYPES).optional()`.
Its `.describe()` no longer cites "the published doc", and its docblock
says where the authority lives now.
- `FilterField['type']` is `FilterFieldType`, not a restated union.
- `filter-builder.tsx` imports the four buckets and declares no list of
its own. They are rebound as `readonly string[]` locals so the existing
`.includes(authoredType)` call sites compile unchanged.
- The validator half of `filter-builder-mirror-6939` drops
`LAST_PUBLISHED_TYPES` and its doc-reader leftovers. It now pins: the
enum equals `FILTER_FIELD_TYPES` member for member; every member is a
spec `FieldType` (`packages/spec/src/data/field.zod.ts`) except
`SPEC_FIELD_TYPE_EXEMPTIONS`, which names `status` with its one-line
reason; every exemption is still live (in the list, still outside the
spec); and the seven bucketed members are each carried by their shared
bucket, which the renderer imports. The header's objectstack#27145
section is rewritten to say the authority is `FILTER_FIELD_TYPES`.
- The render half
(`examples/schema-catalog/test/filter-builder-mirror-6939.test.tsx`)
replaces the stale hand-kept seven ("…and the mirror refuses it") with
one case per member of `FILTER_FIELD_TYPES` except `text`. Each case
uses the existing `oneRow` measurement and asserts that the member draws
a control signature (inputs plus trigger count) different from a
nonsense spelling. `text` is the fallthrough target by construction; its
by-name branch stays pinned in the validator half.
**K4 should-fix (1): the skill doc URLs are now gated.** This took both
halves. `check-skills-paths.mjs` judges only backtick paths, and it
resolves `content/` against `ui/`, so it could not reach a site URL. I
chose `check-doc-links.mjs` instead:
- `SCAN_ROOTS` gains `{ path: '../skills/objectui', rule: 'disk',
diskRoot: '../skills/objectui' }`. The bundle is read on GitHub and by
agents, so its relative hrefs are disk paths. It ships to customer
projects as one directory, so the new per-row `diskRoot` makes the
bundle itself the boundary a relative href must stay inside. The default
boundary, this tree's root, sits below the bundle and would have
rejected all 34 intra-bundle links.
- The two prose URLs (`app-composition.md:62`, `styling.md:318`) become
markdown links. The gate already judges `objectstack.ai` links as site
routes against `apps/docs`.
- The new row also surfaced one gate gap: `guides/schema-expressions.md`
has a heading inside a blockquote (`> ### …`). Both renderers anchor
that heading, but the gate's ATX scan did not see it, and the corpus
test went red. The heading scan now strips blockquote markers first. A
unit pin covers this, and the setext-count test counts blockquoted ATX
headings.
- `check-skills-token-ratchet`: the Theming link cost `styling.md` 2
tokens. I paid them by deleting text in the same line ("the token list"
became "tokens"). `app-composition.md` is 1 token lighter.
**K4 should-fix (2).** `.github/workflows/ci.yml`: the ui paths-filter
comment said "four roots outside ui/" above a list of five globs. It now
says "five paths outside ui/". This is a comment-only change.
**K4 should-fix (3).** `ui/AGENTS.md` rule #2 pointed at the retired
`content/docs/guide/*.md`. It now names the matching page under
`content/docs/frontend/`.
**Changeset:** `.changeset/27369-filter-builder-field-types.md`,
`@object-ui/types` patch and `@object-ui/components` patch, with both
declaration lines.
### Skill bundle readings (`skills/**` touched)
| | before | after |
|:---|---:|---:|
| `skills/objectui/guides/app-composition.md` | 63 lines · 1079 tokens |
63 lines · 1078 tokens |
| `skills/objectui/rules/styling.md` | 320 lines · 2699 tokens | 320
lines · 2699 tokens |
| all `SKILL.md` in `skills/` | 4614 lines | 4614 lines |
| `skills/objectui/**/*.md` | 4825 lines | 4825 lines |
## Tests
All runs are on head `796bf3a3` or on its parent `7dc5d3f6`, which
differs only in `styling.md`.
- Card acceptance: `pnpm --dir ui exec vitest run packages/types
examples/schema-catalog` passed, with Test Files 429/429 and Tests
12850/12850.
- `pnpm --dir ui exec vitest run
scripts/__tests__/check-doc-links.test.ts`: 123/123. The whole
`scripts/` suite also ran as part of the derived gates (exit 0).
- Type-check UI: `@object-ui/types` `type-check` (src, examples and
tests programs), `@object-ui/components` `type-check` and
`@object-ui/example-schema-catalog` `type-check` all exit 0, built
against a fresh build of their dependency closure.
- The four `components-complex-filter-builder/*` catalog entries and the
nested `search-interface` builder still validate (`the catalog entries
the mirror refused` describe, green).
- `git grep -n "LAST_PUBLISHED_TYPES\|published doc's fourteen"` prints
nothing.
<details><summary>One-time ablations (each restored from HEAD; git
status clean after each)</summary>
ui vitest resolves `@object-ui/types` to `src` through its alias, so
these needed no dist rebuild.
1. **A fifteenth member with no renderer branch.** I added `'email'` to
`FILTER_FIELD_TYPES` only. The render half went red on `` `email` draws
a branch of its own, not the fallthrough `` (1 failed, 99 passed). The
spec check stayed green, as it should, because `email` is a spec
`FieldType`.
2. **A fifteenth member outside the spec.** I added `'zz_not_spec'` to
`FILTER_SELECT_LIKE_TYPES`. The validator half went red on `every member
is a spec FieldType, or a named exemption` (1 failed, 48 passed).
3. **Removing a member from a bucket narrows all three faces together.**
I dropped `rating` from `FILTER_NUMBER_LIKE_TYPES`:
- **Schema:** `accepts rating, and the renderer draws it from the shared
bucket FILTER_NUMBER_LIKE_TYPES` went red.
- **Interface:** a scratch `const f: FilterField = { …, type: 'rating'
}` failed `tsc -p tsconfig.test.json` with TS2322. The control, run
before the mutation, showed 0 errors.
- **Renderer:** with `rating` forced into the render probe, `` `rating`
draws a branch of its own `` went red. A `rating` column now draws the
fallthrough.
</details>
## Acceptance notes
- `status` is the one member that is not a spec `FieldType`. It is
exempted by name, not dropped, so the accepted set does not narrow.
- `check-doc-links` gained a row field (`diskRoot`) and a heading-scan
fix. Both are inside the claim's "only if item 3 needs them" surface:
the row is what gates the URLs, and the heading fix is what the row
needed to land green.
## Verification
<details><summary>Derived gates: 88 derived, 87 run, 1 NOT
MEASURED</summary>
`node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--commands` derived 88 commands. I ran all of them on `7dc5d3f6` and
reran the one red family after the fix:
- `node scripts/check-skills-token-ratchet.mjs`: exit 1 on `7dc5d3f6`
(`styling.md` 2701/2699), then exit 0 on `796bf3a3`.
- `pnpm --filter @objectstack/spec run check:skill-examples`: exit 3
until `client-react` was built, then exit 0 (270 prose examples
type-check).
- `pnpm check:dual-build-cjs-loads`: exit 3, PREREQUISITE NOT MET
because it needs every published package's dist. **NOT MEASURED**
locally. The diff touches no package it loads, and CI runs it.
- The other 85 exited 0.
Reconciliation: `dispatch-gates --ran` printed `88 derived famil(ies)
accounted for — 87 run, 1 NOT-MEASURED`. Lint UI: `pnpm --dir ui run
lint:root` reported 0 errors, and `turbo run lint` over the three
touched ui packages reported 0 errors. Neither reported a warning on a
changed line.
</details>
Tier H by path (`.github/workflows/ci.yml`). It stays a draft until
green, then the triage seat writes the contract review and the
maintainer merges.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxvBS38kVpxSqdV8T4)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ebed73b commit 9462d8a
14 files changed
Lines changed: 368 additions & 249 deletions
File tree
- .changeset
- .github/workflows
- skills/objectui
- guides
- rules
- ui
- examples/schema-catalog/test
- packages
- components/src/custom
- types/src
- __tests__
- zod
- scripts
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
| 318 | + | |
319 | 319 | | |
320 | 320 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
403 | 404 | | |
404 | 405 | | |
405 | 406 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
415 | 433 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
1203 | 1207 | | |
1204 | 1208 | | |
1205 | 1209 | | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1224 | 1222 | | |
1225 | 1223 | | |
1226 | 1224 | | |
| |||
0 commit comments