Repository navigation
fix(console): the Studio object-reference picker offers objects by label, not machine name - #33533
Conversation
…hine names The All-metadata form's ref:object select (e.g. Page -> Object) listed bare object names. The page's one object-list read now keeps each entry's label, handed to the widget as WidgetContext.objectLabels, and the option draws the label with the name as secondary monospace text, the face ObjectPicker draws. A label-less object shows its name once; the value written stays the name. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pknWTXgjDm8g4ayZD
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pknWTXgjDm8g4ayZD
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pknWTXgjDm8g4ayZD
…ion in the ref:object pin Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pknWTXgjDm8g4ayZD
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5pknWTXgjDm8g4ayZD
|
domain:ui#2 · os-project-manager · session_01FEkQ5oF8GgTHN2jBZoDwz8 席位核对Verdict: ACCEPT · head
|
Requested by Leehom · project thread
domain:ui#2 · os-project-manager · session_01FEkQ5pknWTXgjDm8g4ayZD
Fixes #33104
Clause-②: no
Metadata-protocol: none
维护者速读
r5lbl_item),和流程触发器、Lookup 关联对象选择器的样子一致;没有标签的对象只显示一次名字。widgets.tsx的RefObjectWidget选项渲染;ResourceEditPage.tsx的objectsState加载器与widgetContext里新增的objectLabels一行;新测试RefObjectWidget.labels-33104.test.tsx。pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/RefObjectWidget.labels-33104.test.tsx,预期 3 条全绿。What changes
MetadataResourceEditPage'sobjectsStateloader already readclient.list('object')but mapped each entry to its name and dropped the label. It now keeps{ name, label? }(a label is kept only when it is a non-blank string), sorted by name exactly as before. The widget context derives both members from that one state:objectNamesthroughmapLoaded(unchanged shape, soobject-selectorand every other reader see what they saw), and a newobjectLabels(ReadonlyMapname → label) while the list is loaded. No second list request.RefObjectWidgetdraws the label first.WidgetContextgainsobjectLabels, an optional read-onlyMapfrom object name to label (app-shell is private; the type is not published). Each option of theref:objectselect shows the label, then the machine name as secondary text in the classes the StudioObjectPickeruses for its option name (font-mono text-[11px] text-muted-foreground), with an explicit space so the accessible name is two words. It stays on one line because Radix renders the selected item's text into the one-line trigger too. An object with no label is drawn as its name, once. TheSelectItemvalue is the name, so the value written is unchanged..changeset/33104-ref-object-picker-labels.md:@object-ui/consolepatch (app-shell is private and ships inside the console build).Tests
ui/packages/app-shell/src/views/metadata-admin/RefObjectWidget.labels-33104.test.tsx(new), driven through the opened Radix select (ArrowDownon the trigger, as the sibling suites do):SchemaFormwith the page type's realcreateSchema(Page → Object): the labelled object's option shows "R5 Label Item" first andr5lbl_itemin the monospace muted name line; clicking it emitsobject: 'r5lbl_item'(the value written is the name).showcase_note) is offered by its name only, with no name line, so the name is not shown twice.MetadataResourceEditPagein Page create mode, withclient.list('object')answering one labelled and one label-less entry: the picker shows the label the list answered, andlist('object')was called exactly once.Measured on main first (sources
widgets.tsxandResourceEditPage.tsxrestored tof068cde8, test file as committed):Base: 2 failed | 1 passed (3), the option text is the bare name
The control (label-less object, name once) passes on base, as a control should. The base option in
RefObjectWidgetis aSelectItemwhose value and whose text are both the bare namen, fed by the loader'slist.map((x) => x?.name).Ablation of the label rendering only (
scripts/ablation-replace.mjsonwidgets.tsx, anchorconst label = context?.objectLabels?.get(n);replaced by a branch that always yieldsundefinedwith markerABL33104; anchor 1 → 0, replacement 0 → 1, blob14bfddb9e5ec→bbcc0295e5bc, run at77376716, before the one doc-comment commit; ui vitest resolves@object-ui/*tosrc/, no dist in the path):Ablated: 2 failed | 1 passed (3); restored: blob == HEAD, 3 passed
Acceptance notes
item.textValue.toLowerCase().startsWith(...)in@radix-ui/react-select), and that text now starts with the label. So typing a label's first letters jumps to the object, and typing a machine-name prefix reaches a labelled object only when its label starts the same way. Matching both label and name would need a searchable control instead of the Radix select; this PR does not swap the control. Declared, not pinned.object-selector(ObjectSelectorWidget, same file) still lists bare names. It reads the sameobjectNamesand could readobjectLabelsthe same way, but no form spec in this repository mountswidget: 'object-selector'(only its registry rows), so there is no measured reach. Noted, not filed.eslint --no-inline-configonResourceEditPage.tsxreports 3react-hooks"Cannot create components during render" errors; the same 3 are on basef068cde8(line-shifted), none in the lines this PR touches.Verification
Head
7409ee45. Local, in a fresh worktree after building the engine closures (@objectstack/spec|formula|client|lint|sdui-parser...) and@object-ui/app-shell^...:pnpm --filter @object-ui/app-shell run type-check(src +tsconfig.test.json): exit 0.pnpm --dir ui exec vitest run --maxWorkers=2on the 110 metadata-admin test files namedSchemaForm*,ResourceEditPage*,WidgetContext*,*Widget*,selector-placeholder*,anchors*(the readers ofwidgets.tsx's context and of the edit page): 110 files / 823 tests passed (run at113a93ac; the later commits touch only the new test's imports and one doc comment inwidgets.tsx).node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, 37 families) run on head7409ee45: all 37 exit 0, and--ranreconciles "37 derived, 37 run, 0 NOT-MEASURED, 0 UNRUN".check:type-check-debtran alone under the verify lock (VERDICT command-exit 0).Derived gate families, exit codes
check:test-source-aliaswas red on the first round for the new test (it reaches lazyimport('@objectstack/lint')andimport('@object-ui/plugin-detail')during collection); fixed with module-top side-effect imports, the convention the siblingResourceEditPage.*suites use.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5pknWTXgjDm8g4ayZD