Skip to content

Commit 23cc54e

Browse files
committed
fix(app-shell): no list create on a kernel package, which has no pair; the create-dialog enumeration reaches each live title by one site or more (objectstack#36897)
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNtKtppbRbXmHGH8x
1 parent 1137895 commit 23cc54e

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

‎ui/packages/app-shell/src/views/studio-design/CreateItemDialog.oneLabel-11787.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ describe('Studio create dialogs say what the create does (objectui#11787, object
8181
}
8282
});
8383

84-
it('CONTROL — the enumeration reaches each live dialog once, the New permission set one included', () => {
84+
it('CONTROL — the enumeration reaches each live dialog, the New permission set one included', () => {
8585
const live = createDialogSites().filter((site) => LIVE_TITLES.includes(titleKeyOf(site) ?? ''));
86-
expect(live.map(titleKeyOf).sort()).toEqual([...LIVE_TITLES].sort());
86+
// An object and a flow are created from their pillar AND from the metadata
87+
// list (objectstack#36897, `MetadataListCreateDialog.tsx`): each title is
88+
// reached, by one site or more.
89+
expect([...new Set(live.map(titleKeyOf))].sort()).toEqual([...LIVE_TITLES].sort());
8790
for (const site of live) expect(site.submitLabel).toBe(LIVE_LABEL);
8891
});
8992

‎ui/packages/app-shell/src/views/studio-design/StudioMetadataArea.routes-28561.test.tsx‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,23 @@ describe("a read-only base's create opens in its .custom pair (objectstack#36897
242242
expect((await page()).host).not.toHaveProperty('pairCreate');
243243
});
244244

245+
it('a kernel package has no pair: no create is offered, and its create URL lands on the list', async () => {
246+
const ensurePackage = vi.fn();
247+
const kernelCustomization = { ...customizationOf(false, ensurePackage), base: KERNEL };
248+
render(
249+
<MemoryRouter initialEntries={[`/studio/${KERNEL}/metadata/agent/new?package=${KERNEL}`]}>
250+
<Where />
251+
<Routes>
252+
<Route path={`/studio/${KERNEL}/metadata/*`} element={<StudioMetadataArea packageId={KERNEL} customization={kernelCustomization} />} />
253+
</Routes>
254+
</MemoryRouter>,
255+
);
256+
const at = await page();
257+
expect(at.page).toBe('list');
258+
expect(at.host).not.toHaveProperty('pairCreate');
259+
expect(ensurePackage).not.toHaveBeenCalled();
260+
});
261+
245262
it('a walled door never asks, and lands on the list as before', async () => {
246263
const ensurePackage = vi.fn();
247264
mountCustomized(customizationOf(true, ensurePackage));

‎ui/packages/app-shell/src/views/studio-design/StudioMetadataArea.tsx‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,31 @@ const MetadataResourceHistoryPage = React.lazy(() =>
8585
* verdict rule is the one `parsePackages` applies. One request either way: the
8686
* readers of that endpoint share it (`packages-io.ts`).
8787
*/
88-
function useListedPackageWritable(packageId: string | null): boolean | null | undefined {
89-
const [answer, setAnswer] = React.useState<{ id: string; writable: boolean | null } | null>(null);
88+
function useListedPackageWritable(packageId: string | null): { writable: boolean | null | undefined; kernel: boolean } {
89+
const [answer, setAnswer] = React.useState<{ id: string; writable: boolean | null; kernel: boolean } | null>(null);
9090
React.useEffect(() => {
9191
if (packageId === null) return;
9292
let cancelled = false;
9393
fetchListedPackageManifests().then(
9494
(manifests) => {
95-
if (!cancelled) setAnswer({ id: packageId, writable: manifests.get(packageId)?.writable ?? null });
95+
if (cancelled) return;
96+
const listed = manifests.get(packageId);
97+
// objectstack#36897 — a kernel package (manifest scope `system` or
98+
// `cloud`) has no pair: the ensure door refuses it (ADR-0146 D3).
99+
const scope = listed?.manifest?.scope;
100+
setAnswer({ id: packageId, writable: listed?.writable ?? null, kernel: scope === 'system' || scope === 'cloud' });
96101
},
97102
() => {
98103
// The surface reports the failure once (its package-list toast).
99-
if (!cancelled) setAnswer({ id: packageId, writable: null });
104+
if (!cancelled) setAnswer({ id: packageId, writable: null, kernel: false });
100105
},
101106
);
102107
return () => {
103108
cancelled = true;
104109
};
105110
}, [packageId]);
106-
if (packageId === null) return null;
107-
return answer?.id === packageId ? answer.writable : undefined;
111+
if (packageId === null) return { writable: null, kernel: false };
112+
return answer?.id === packageId ? { writable: answer.writable, kernel: answer.kernel } : { writable: undefined, kernel: false };
108113
}
109114

110115
function AreaLoading({ locale }: { locale: string }): React.ReactElement {
@@ -182,15 +187,16 @@ function AreaItemOpen({
182187
* `<root>/:type/new`. A read-only package takes no new item of its own:
183188
* objectstack#36897 — on a read-only base the create is its `.custom` pair's
184189
* (ADR-0146 D3), asked of the ensure door and opened there; where the door
185-
* refuses this caller (`customization.walled`), or there is no base to pair,
190+
* refuses this caller (`customization.walled`), the package is a kernel
191+
* package (which has no pair), or there is no base to pair,
186192
* the create URL lands on the list, as before.
187193
*/
188194
function AreaCreate({ customization }: { customization: StudioBaseCustomization | null }): React.ReactElement {
189195
const { type = '' } = useParams<{ type: string }>();
190196
const { search } = useLocation();
191197
const host = useMetadataAreaHost();
192198
if (host?.readOnly) {
193-
if (customization && !customization.walled) {
199+
if (customization && host.pairCreate) {
194200
return <AreaPairedCreate type={type} search={search} customization={customization} />;
195201
}
196202
return <Navigate to={`${host.basePath}/${encodeURIComponent(type)}${search}`} replace />;
@@ -277,10 +283,11 @@ export function StudioMetadataArea({
277283
// manifests (see the hook). Unknown stays ungated, as on the pillars: the
278284
// server's write gate is the authority, and a failed probe must not lock an
279285
// author out of a writable package.
280-
const writable = useListedPackageWritable(packageId);
286+
const { writable, kernel } = useListedPackageWritable(packageId);
281287
const readOnly = packageId !== null && writable === false;
282-
// objectstack#36897 — the list offers a create exactly where `AreaCreate` opens one in the pair.
283-
const pairCreate = readOnly && !!customization && !customization.walled;
288+
// objectstack#36897 — the list offers a create exactly where `AreaCreate`
289+
// opens one in the pair; never on a kernel package, which has none.
290+
const pairCreate = readOnly && !kernel && !!customization && !customization.walled;
284291
const host = React.useMemo<MetadataAreaHost>(
285292
() => ({ packageId, readOnly, basePath, ...(pairCreate ? { pairCreate } : {}) }),
286293
[packageId, readOnly, basePath, pairCreate],

0 commit comments

Comments
 (0)