You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a8396da
Browse filesBrowse the repository at this point in the historyBrowse files
fix(app-shell): Lookup and roll-up target pickers take objects only (#37905)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao5S6gNFvmKHxrqpXWgottKg)_Fixes#36747
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 搭建者在 Studio 字段面板里设置关联字段的目标对象、汇总字段的子对象时,以前随手打的文字也会保存,现在只能从列表里选对象。
- 属于 Studio 搭建体验评审中“元数据写错要当场拒收”这一组,替搭建者挡住打错字就存下一个指向不存在对象的字段。
- 打了不存在的对象名,面板会提示没有选中对象,原来已选的目标保留不动;只存在于草稿里的对象照样能选;可以直接撤回本次改动。
- 无。
## What changes
- `ObjectFieldInspector.tsx`: the Lookup *Related object* door and the
roll-up *Child object* door now pass `objectsOnly` to `ObjectPicker`.
Neither door accepts an expression. Flow references keep free text (the
prop stays off by default).
- `ObjectPicker.tsx` (rework round 1): with `objectsOnly`, typed text
that names no pickable object is a refusal. The input goes back to the
stored value, the "not chosen" line shows, and nothing is committed, so
a typo no longer erases a target the field already has. Clearing the
input on purpose still commits no object (an empty name), which the
doors turn into removal. While the catalog is unread or its read failed,
typed text is committed as before. The trigger-object picker in the
new-automation dialog, the only other `objectsOnly` caller, starts empty
and behaves as before; if it already holds an object, a refused typo now
keeps it.
**Premise verified (draft-only objects stay pickable).** The picker's
catalog is `useObjectCatalog`, which reads `GET
/meta/object?preview=draft` (`withPreviewDrafts(true).list('object')`).
Server-side, `packages/rest/src/meta-draft-read-builder-gate.test.ts`
("every builder reads the draft overlay ... the draft-only app is
listed") pins that the type-generic preview list carries draft-only
items for builders. In the picker, a draft entry is an ordinary enabled
option (only out-of-closure entries are disabled). The new pin asserts
the draft-only object is absent from the published list and is still
chosen at both doors.
## Tests
New top-level `describe` in the existing harness
`ObjectFieldInspector.objectPicker-11783.test.tsx` (ruling record
6583487846), six cases, three per door:
- a field that already has a target (`sys_user`): a refused typo leaves
it in place, no patch is written, and the refusal is shown;
- typed text naming no listed object on an empty field: no target saved,
refusal shown;
- a listed object that exists only as a draft: chosen and saved.
`ObjectPicker.test.tsx`: the objectsOnly pin from objectstack#30038 that
asserted a typo clears a chosen object now asserts the object is kept,
on Enter and on blur. A new pin asserts that an input cleared on purpose
still commits an empty name.
Both test files gain a module-top `import '@objectstack/lint'`, as
`check:test-source-alias` prescribes for a test file whose source loads
it lazily.
<details><summary>Readings (head 0009f82)</summary>
- `vitest run` (ui root) over ObjectFieldInspector*, ObjectPicker* and
the trigger-object dialog's pins (StudioDesignSurface createTaken-26917,
flowPresets-11861, newFlowTrigger-11788): Test Files 40 passed (40),
Tests 439 passed (439) on d6491f4; final head 0009f82:
ObjectPicker.test.tsx + the harness file 25/25 passed.
- `@object-ui/app-shell` `type-check` (both `tsconfig.json` and
`tsconfig.test.json`): exit 0.
- Ablation, round 0: with both `objectsOnly` lines deleted on disk, the
two refusal cases go red (2 failed / 5 passed) and the draft-only cases
stay green, as they should.
- Ablation, round 1: with the old clear-on-refusal branch put back in
`commitTyped` on disk, 3 failed / 22 passed: the picker's keep-on-typo
pin and both doors' existing-target pins. Restored from HEAD.
- `dispatch-gates.mjs --commands`: 38 derived families run, all exit 0
(`check:test-source-alias` went red once per edited test file and was
fixed each time by the lint import; the rerun exited 0 on 0009f82).
`--ran`: 38 derived, 38 run, 0 UNRUN.
</details>
## Acceptance notes
- The save door itself does not check that a Lookup or roll-up target
exists at authoring time; this PR closes the Studio picker path only.
## Verification
Read first: `ObjectPicker.tsx` `commitTyped` (the refusal branch, the
riskiest hunk), then `ObjectFieldInspector.tsx` (the two `objectsOnly`
lines), then the new `describe` at the end of the harness file.
Two-minute check: `cd ui && pnpm exec vitest run
packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.objectPicker-11783.test.tsx`
— expect 9 passed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibzpqH1nQTsbGckLspg)_
<!-- signed: repo:objectstack#3 · os-tesla ·
session_01L9qibzpqH1nQTsbGckLspg -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(app-shell): the Lookup's Related object and the roll-up's Child object take objects only
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
In Studio's field inspector, the Lookup's *Related object* and the roll-up summary's *Child object* pickers committed whatever text was typed, so a typo saved a field pointing at an object that does not exist. Neither door accepts an expression, so once the picker's object list has loaded, both commit only an object it lists: typed text that names no listed object is refused, the picker says no object is chosen, and the target the field already had stays (clearing the input on purpose still removes it). While the list is not yet read, or its read failed, the typed text is still committed as before. The trigger object in the new-automation dialog, the one other picker that takes objects only, now also keeps its chosen object on a refused typo. Objects that exist only as a pending draft stay choosable, because the picker lists the draft-overlaid catalog. Flow references keep their free text.
Copy file name to clipboardExpand all lines: ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.objectPicker-11783.test.tsx
0 commit comments