Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/39003-app-shell-studio-leftovers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@object-ui/app-shell': patch
'@object-ui/layout': patch
'@object-ui/i18n': patch
'@objectstack/spec': patch
---

fix(console): clean up the Studio view editor's form-view leftovers, the retired package-less scope's references, and the sidebar's icon and colour resolvers

Clause-②: no
Metadata-protocol: none

- The Studio view editor and the runtime view-config panel edit list views only, as a `view` holds since protocol 19 (ADR-0159 D7). The view inspector's form branch (the form-layout type picker, the form-variant schema and the required-field-in-a-gated-section Save gate, which only a form held in a view could reach) is removed, with `toInlineFormType` and the unused studio string `engine.viewPreview.formFailed` and the `engine.inspector.view.gatedRequired.*` strings. A form is edited as a `form` item.
- A record create or edit's chrome (`resolveRecordFormChrome`) no longer goes through the named-form-view reader that nothing called with a form; it gives the host's own buttons, labels and layout as before.
- The metadata list drops the `emptyListHint` host member that nothing set since the package-less Studio scope retired; two changes-panel comments that described that scope now say who narrows the list today.
- The sidebar's icon and colour resolvers (`useNavTargetIcon`, `useNavTargetColor`) answer as of the render that made them, as the label resolver does: an object's tile drawn before its read lands takes the object's colour once it lands, instead of staying gray. `NavTargetLabelResolver`, `NavTargetIconResolver` and `NavTargetColorResolver` (`@object-ui/layout`) now state that a resolver's answers are fixed for its identity and that it may keep them for its own lifetime only.
- `@objectstack/spec`: the protocol-19 semantic entry `internal-record-forms-not-loaded` no longer names the lint rule retired in that protocol in its acceptance text, and the `form` liveness note for `buttons` names the console form page's `readFormButton` as the reader, no longer the removed named-form chrome reader.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ older `required` field; for those fields this amendment changes nothing on creat
**Not in scope.** Only the object field's own `visibleWhen`. A field group's
`visibleWhen`, a form view's field or section predicate, a hidden tab and static
`hidden` are not read: the validator does not consume view metadata (ruled on
#13252; Studio's gated-section fence covers the section case at authoring).
#13252; Studio fences no section case at authoring, so a required field in a gated
section is answered by this contract at the record save).

**Which server answer is canonical.** Three server sites answer "required, but
hidden". For the **record write contract** this rule is canonical; it is the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ So a form reaches the platform in **three shapes**: the container's `form`, a `f

### No record form reads a form view

Since #36425 the console's create dialog, full-page create, action-opened create and edit lay out by the object's `fieldGroups` and the rules on its fields. The docblock of `ui/packages/app-shell/src/utils/recordFormNavigation.ts#FormViewDefinition` says it in these words: "No record create or edit reads one". `addRecord.formView` is a tombstone in `packages/spec/src/ui/view.zod.ts`. The lint rule `form-view-internal-not-loaded` (`packages/lint/src/validate-internal-form-views.ts`) reports an internal create or edit form as steering nothing. No per-role or per-position form assignment exists.
Since #36425 the console's create dialog, full-page create, action-opened create and edit lay out by the object's `fieldGroups` and the rules on its fields. The docblock of `ui/packages/app-shell/src/utils/recordFormNavigation.ts#RecordFormModalLayout` says it in these words: "An internal form view steers nothing". `addRecord.formView` is a tombstone in `packages/spec/src/ui/view.zod.ts`. The lint rule `form-view-internal-not-loaded` (`packages/lint/src/validate-internal-form-views.ts`) reports an internal create or edit form as steering nothing. No per-role or per-position form assignment exists.

### Named forms have three consumers

Expand Down
2 changes: 1 addition & 1 deletion packages/spec/liveness/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
},
"buttons": {
"status": "live",
"note": "Inherited verdict (2026-11-26, ADR-0159 card ②): a `form` item's body keys ARE `FormViewSchema`'s shape, taken by reference (packages/spec/src/ui/view.zod.ts#FormSchema), and the anonymous doors serve the item's body to the public form renderer an old-shape form reached until protocol 19 (packages/rest/src/form-routes.ts#resolveFormBySlug), so this row was seeded with view.json `form.<key>`'s verdict; that row left view.json with the container's tombstone (2026-12-01, ADR-0159 D7), and this row is the one classification of the key. Until card ③ (#37087) the console opens no `form` item from an action; re-verify this row with that card. objectui: ObjectForm.tsx foldFormButtons() reads schema.buttons and folds submit/cancel {show,label} onto the flat showSubmit/submitText/showCancel/cancelText props (framework#1894 / #2998); ObjectView forwards it, and every console form entry point resolves submit/cancel through resolveFormViewChrome / readFormButton (#26843). Flat keys kept as deprecated back-compat (explicit flat key wins). SUB-KEY buttons.reset REMOVED 2026-10-28 (#27153, ADR-0049 enforce-or-remove, ruled retire): measured at origin/main fbe344b3, six button bars (components form.tsx, console FormPage, ModalForm, DrawerForm, WizardForm, MasterDetailForm) drew submit/cancel and none drew reset; reset.label had no reader; the one fold of reset.show landed on ObjectForm showReset, which means clear-after-save (resetOnSubmit), not a button. Tombstoned inside the buttons block (retiredKey carries the prescription) and stripped from stored rows and sources by the protocol-18 form-view-buttons-reset-removed conversion; the fold was removed in the same change. Sub-keys cannot be drilled (one level only), so the removal is recorded here; submit and cancel keep this row live."
"note": "Inherited verdict (2026-11-26, ADR-0159 card ②): a `form` item's body keys ARE `FormViewSchema`'s shape, taken by reference (packages/spec/src/ui/view.zod.ts#FormSchema), and the anonymous doors serve the item's body to the public form renderer an old-shape form reached until protocol 19 (packages/rest/src/form-routes.ts#resolveFormBySlug), so this row was seeded with view.json `form.<key>`'s verdict; that row left view.json with the container's tombstone (2026-12-01, ADR-0159 D7), and this row is the one classification of the key. Until card ③ (#37087) the console opens no `form` item from an action; re-verify this row with that card. objectui: ObjectForm.tsx foldFormButtons() reads schema.buttons and folds submit/cancel {show,label} onto the flat showSubmit/submitText/showCancel/cancelText props (framework#1894 / #2998); ObjectView forwards it, and the console form page that opens a named form (FormPage) resolves submit/cancel through readFormButton (#26843). Flat keys kept as deprecated back-compat (explicit flat key wins). SUB-KEY buttons.reset REMOVED 2026-10-28 (#27153, ADR-0049 enforce-or-remove, ruled retire): measured at origin/main fbe344b3, six button bars (components form.tsx, console FormPage, ModalForm, DrawerForm, WizardForm, MasterDetailForm) drew submit/cancel and none drew reset; reset.label had no reader; the one fold of reset.show landed on ObjectForm showReset, which means clear-after-save (resetOnSubmit), not a button. Tombstoned inside the buttons block (retiredKey carries the prescription) and stripped from stored rows and sources by the protocol-18 form-view-buttons-reset-removed conversion; the fold was removed in the same change. Sub-keys cannot be drilled (one level only), so the removal is recorded here; submit and cancel keep this row live."
},
"defaults": {
"status": "live",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { SemanticMigration } from '../../types.js';
// objectstack-ai/objectstack#36425 — the Console's record create and edit
// surfaces stop loading an object's internal form view. No key is retired and
// no stored row is rewritten: an internal form still parses and installs, and
// steers nothing. The lint rule `form-view-internal-not-loaded` names each one.
// steers nothing.
export const entry: SemanticMigration = {
id: 'internal-record-forms-not-loaded',
surface:
Expand All @@ -24,8 +24,7 @@ export const entry: SemanticMigration = {
+ '`required` written on a form field entry is no longer asked for. Nothing converts it, because the '
+ 'right field groups and field rules are a judgment about the object, not a rewrite of the form.',
acceptanceCriteria:
'`os validate` reports no `form-view-internal-not-loaded` warning, or each one is a form you keep on '
+ 'purpose as inert. Opening New and Edit on each object that had an internal form shows the sections, '
+ 'required fields and create defaults you want, from the field groups and the field rules.',
'Opening New and Edit on each object that had an internal form shows the sections, required fields and '
+ 'create defaults you want, from the field groups and the field rules.',
relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'forms'] },
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#38859 — the icon and colour resolvers answer as of the render
* that made them, as the label resolver does (objectstack#38835).
*
* The sidebar's rows are memoised (`@object-ui/layout`'s `sameRowAnswers`,
* objectstack#37575) and compare the previous resolver with the new one by
* what each answers when the comparison runs. `MetadataProvider`'s object
* scopes are refs, so a resolver that read them live answered the landed
* colour for BOTH resolvers, the row was skipped, and the tile first drawn
* while the object's by-name read was on the wire stayed gray.
*
* The context is hand-rolled the way the provider behaves: one live scope
* store every published value reads (`readObjectScope`), and a NEW value on
* each landing over the same store.
*
* - a tile drawn while the read is on the wire takes the object's colour once
* it lands;
* - one icon or colour resolver answers what it first answered; a new
* resolver answers anew;
* - CONTROL: an object the scope never answers keeps the neutral tile.
*/

import '@testing-library/jest-dom/vitest';
import * as React from 'react';
import { afterEach, describe, expect, it } from 'vitest';
import { act, cleanup, render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import '@object-ui/components';
import { SidebarProvider } from '@object-ui/components';
import { MetadataCtx } from '@object-ui/react';
import { NavigationRenderer, type NavTargetColorResolver, type NavTargetIconResolver } from '@object-ui/layout';
import { useNavTargetColor, useNavTargetIcon } from './useNavTargetIcon';

/** Labelled entries, so only the tile depends on the object read. */
const NAVIGATION = [
{ id: 'nav_ticket', type: 'object', objectName: 'repairs_repair_ticket', label: 'Tickets' },
{ id: 'nav_gone', type: 'object', objectName: 'repairs_never_served', label: 'Never served' },
];

const TICKET = { name: 'repairs_repair_ticket', label: 'Repair Ticket', icon: 'wrench', color: 'orange' };

/** The provider's live scope store: the by-name answers landed so far. */
function liveScope() {
const store = { items: [] as Array<Record<string, unknown>> };
/** One published context value, as `MetadataProvider` builds one per version. */
const value = () => ({
apps: [],
get objects() {
return [];
},
dashboards: [],
reports: [],
pages: [],
loading: false,
error: null,
refresh: async () => {},
invalidate: () => {},
ensureType: async () => [],
getItem: async () => null,
getItemsByType: () => [],
// Nothing has loaded the whole registry: the sidebar reads by name.
getTypeStatus: () => 'idle' as const,
readObjectScope: (scope: { names?: readonly string[] }) => {
const objects = store.items.filter((it) => scope.names?.includes(it.name as string));
return { objects, served: objects, missing: [], settled: true };
},
});
return { store, value };
}

/** The sidebar, wired as `UnifiedSidebar` wires the two resolvers. */
function Sidebar() {
const resolveTargetIcon = useNavTargetIcon();
const resolveTargetColor = useNavTargetColor();
return (
<SidebarProvider defaultOpen>
<nav aria-label="Sidebar">
<NavigationRenderer
items={NAVIGATION as never}
basePath="/apps/repair_center"
resolveTargetIcon={resolveTargetIcon}
resolveTargetColor={resolveTargetColor}
/>
</nav>
</SidebarProvider>
);
}

function tree(value: unknown) {
return (
<MemoryRouter initialEntries={['/apps/repair_center/repairs_repair_ticket']}>
<MetadataCtx.Provider value={value as never}>
<Sidebar />
</MetadataCtx.Provider>
</MemoryRouter>
);
}

function tileOf(label: string): string | null | undefined {
return screen
.getByText(label)
.closest('[data-sidebar="menu-button"]')
?.querySelector('[data-object-icon-tile]')
?.getAttribute('data-object-icon-tile');
}

afterEach(() => {
cleanup();
});

describe('objectstack#38859 — a sidebar tile takes its object colour once the read lands', () => {
it('a tile first drawn while the by-name read is on the wire takes the colour after it lands', () => {
const { store, value } = liveScope();
const utils = render(tree(value()));
// Drawn before the read lands: the neutral gray tile.
expect(tileOf('Tickets')).toBe('gray');

// The read lands in the live store, and the provider publishes a new value.
store.items = [TICKET];
act(() => utils.rerender(tree(value())));

expect(tileOf('Tickets')).toBe('orange');
});

it('CONTROL: an object the scope never answers keeps the gray tile', () => {
const { store, value } = liveScope();
const utils = render(tree(value()));
store.items = [TICKET];
act(() => utils.rerender(tree(value())));
expect(tileOf('Never served')).toBe('gray');
});
});

describe('objectstack#38859 — one icon or colour resolver answers as of the render that made it', () => {
it('each resolver keeps its first answer over the live store; the next resolver answers anew', () => {
const { store, value } = liveScope();
const icons: NavTargetIconResolver[] = [];
const colors: NavTargetColorResolver[] = [];
function Probe() {
icons.push(useNavTargetIcon());
colors.push(useNavTargetColor());
return null;
}
const probe = (v: unknown) => (
<MetadataCtx.Provider value={v as never}>
<Probe />
</MetadataCtx.Provider>
);
const target = { kind: 'object', objectName: 'repairs_repair_ticket' } as const;

const utils = render(probe(value()));
const firstIcon = icons[icons.length - 1];
const firstColor = colors[colors.length - 1];
expect(firstIcon(target)).toBeUndefined();
expect(firstColor(target)).toBeUndefined();

store.items = [TICKET];
utils.rerender(probe(value()));
const nextIcon = icons[icons.length - 1];
const nextColor = colors[colors.length - 1];

expect(nextIcon).not.toBe(firstIcon);
expect(nextColor).not.toBe(firstColor);
// What the memoised row compares: the previous resolver answers what it drew.
expect(firstIcon(target)).toBeUndefined();
expect(firstColor(target)).toBeUndefined();
expect(nextIcon(target)).toBe('wrench');
expect(nextColor(target)).toBe('orange');
});
});
31 changes: 22 additions & 9 deletions ui/packages/app-shell/src/hooks/useNavTargetIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,40 @@
*
* It reads the object by name from the metadata cache the shell already holds
* (`readObjectsByName`, the same read `useNavTargetLabel({ byName: true })`
* makes for the entry's text), so the sidebar loads no extra list for it.
* Nothing is stored: a changed object icon shows on the next render. An object
* with no `icon`, or one not loaded yet, answers `undefined` and the row keeps
* the renderer's generic icon.
* makes for the entry's text), so the sidebar loads no extra list for it. An
* object with no `icon`, or one not loaded yet, answers `undefined` and the
* row keeps the renderer's generic icon.
*
* That read is live (the provider's object scopes are refs), and the sidebar's
* memoised rows compare the previous resolver with the new one by what each
* answers when the comparison runs. So, like `useNavTargetLabel`
* (objectstack#38835), each resolver keeps the first answer it gives for an
* object and gives it again: the previous resolver answers what its render
* drew, and a landing, which makes a new resolver, is a change the row sees.
* A changed object icon shows once the metadata changes. The same holds for
* {@link useNavTargetColor}.
*/

import { useMemo } from 'react';
import type { NavIconTarget, NavTargetColorResolver, NavTargetIconResolver } from '@object-ui/layout';
import { useMetadata } from '../providers/MetadataProvider.js';
import { readObjectsByName } from './useObjectPresence.js';
import { answeringOnce } from './useNavTargetLabel.js';

/** One key per object a resolver is asked about. */
const objectKey = (target: NavIconTarget): string => `${target.kind}/${target.objectName}`;

export function useNavTargetIcon(): NavTargetIconResolver {
const metadata = useMetadata();
return useMemo<NavTargetIconResolver>(
() => (target: NavIconTarget) => {
() => answeringOnce(objectKey, (target: NavIconTarget) => {
if (target.kind !== 'object') return undefined;
const def = readObjectsByName(metadata, [target.objectName]).find(
(item): item is { name: string; icon?: unknown } =>
!!item && typeof item === 'object' && (item as { name?: unknown }).name === target.objectName,
);
return typeof def?.icon === 'string' && def.icon.trim() !== '' ? def.icon : undefined;
},
}),
[metadata],
);
}
Expand All @@ -43,19 +55,20 @@ export function useNavTargetIcon(): NavTargetIconResolver {
* useNavTargetColor — the same read for the object's palette `color`
* (objectstack#35985), as a {@link NavTargetColorResolver}: the colour of the
* tile an `object` entry is drawn on. An object with no `color`, or one not
* loaded yet, answers `undefined` and the tile is the neutral gray.
* loaded yet, answers `undefined` and the tile is the neutral gray. Each
* resolver keeps its first answer per object, as {@link useNavTargetIcon} does.
*/
export function useNavTargetColor(): NavTargetColorResolver {
const metadata = useMetadata();
return useMemo<NavTargetColorResolver>(
() => (target: NavIconTarget) => {
() => answeringOnce(objectKey, (target: NavIconTarget) => {
if (target.kind !== 'object') return undefined;
const def = readObjectsByName(metadata, [target.objectName]).find(
(item): item is { name: string; color?: unknown } =>
!!item && typeof item === 'object' && (item as { name?: unknown }).name === target.objectName,
);
return typeof def?.color === 'string' && def.color !== '' ? def.color : undefined;
},
}),
[metadata],
);
}
Loading
Loading