diff --git a/.changeset/36900-studio-cmdk.md b/.changeset/36900-studio-cmdk.md
new file mode 100644
index 00000000000..58e0cef1e26
--- /dev/null
+++ b/.changeset/36900-studio-cmdk.md
@@ -0,0 +1,18 @@
+---
+'@object-ui/app-shell': patch
+'@object-ui/console': patch
+---
+
+feat(studio): ⌘K on every Studio design page lists the package's whole menu and its items
+
+Clause-②: no
+Metadata-protocol: none
+
+Studio redesign: an author switches between items with ×, ‹ › and ⌘K · #36900, part of #36890.
+
+- **⌘K / Ctrl+K opens the command palette on every Studio design page.** That covers a package's pages and its "All metadata" area, the organization's own flows, and the cross-package positions-and-permissions catalog. Until now only the Studio start page had a palette, and the cross-package catalog had lost the one it used to have.
+- **On a package it lists the left menu, group by group**: Data, UI, Automation, Platform, Access, AI (数据、界面、自动化、平台、访问、AI), in the menu's order and under the menu's names. Each group holds the menu's own entries (each type's list, Organization flows, Default sharing, Diagnostics, Positions and permissions), then every item of the types it lists, the package's customizations included. Each item shows its type on the right; a customization is marked "Customization of" the package's name. The packages stay listed, so another package is one pick away. On a package the palette no longer lists every package's objects and flows: the package's own items replace them. The organization's flows and the cross-package catalog keep those lists and add their own menu entries.
+- **A pick opens what the menu and the lists open**: an object, a flow or a permission set in its designer, any other item on its own page in "All metadata", exactly where its list row leads. A menu entry goes where the menu entry goes.
+- **It never drops unsaved work silently.** A pick, like Studio's Back to app, asks first whenever the page holds unsaved edits, the "All metadata" item page's included. A pick of the page already open on another view (Default sharing, from the Access page) reopens that page on it; a pick of the page already shown just closes the palette.
+- The query matches an item by its label, its name or its type, and a menu entry by its label, its type or its group. While the package's lists are still loading, an empty result says "Searching…". The item lists are read only once the palette opens.
+- Pressing Escape to close a dialog over a full-screen item editor (the palette, for one) no longer also leaves full screen.
diff --git a/ui/e2e/studio-left-menu-36899.spec.ts b/ui/e2e/studio-left-menu-36899.spec.ts
index cc24a12b5ac..9ac183bfa73 100644
--- a/ui/e2e/studio-left-menu-36899.spec.ts
+++ b/ui/e2e/studio-left-menu-36899.spec.ts
@@ -40,7 +40,10 @@ function workspaceSources(): Plugin {
name: 'studio-left-menu-workspace-src',
enforce: 'pre',
async resolveId(id, importer) {
- if (id.endsWith('/useMetadata.js') && importer?.endsWith('StudioMenu.tsx')) return METADATA_STUB;
+ // objectstack#36900 — the menu's reads live in `studioMenuData.ts`, beside the menu.
+ if (id.endsWith('/useMetadata.js') && (importer?.endsWith('StudioMenu.tsx') || importer?.endsWith('studioMenuData.ts'))) {
+ return METADATA_STUB;
+ }
const m = /^@object-ui\/([a-z0-9-]+)(?:\/(.+))?$/.exec(id);
if (!m) return null;
const [, pkg, sub] = m;
diff --git a/ui/packages/app-shell/README.md b/ui/packages/app-shell/README.md
index ddab6aa11e8..b24a2b4849e 100644
--- a/ui/packages/app-shell/README.md
+++ b/ui/packages/app-shell/README.md
@@ -1424,11 +1424,32 @@ record search. Its open state and the command that opens it are provided by
`CommandPalette` has two scopes. Inside an app it takes `apps`, `activeApp`,
`objects`, `onAppChange` and an optional `dataSource`, and searches that app.
-`` takes no other prop: it is the palette of the
-`/studio` landing, a frame outside every app, which the console mounts under its
-own `CommandPaletteProvider`. It leaves out every app-scoped group and the
-full-search command (their links start with `/apps/APP`), and lists the Studio's
-packages, their objects and their flows, each opening its Studio page. The
+`` is the palette of Studio, outside every app.
+It leaves out every app-scoped group and the full-search command (their links
+start with `/apps/APP`), and lists the Studio's packages, their objects and their
+flows, each opening its Studio page. On the `/studio` landing the console mounts
+it with no other prop, under its own `CommandPaletteProvider`.
+
+On a Studio design page, `StudioDesignSurface` mounts it itself, with an optional
+`surface` prop (a `StudioPaletteSurface`; objectstack#36900). The surface mounts
+its own `CommandPaletteProvider` unless a host above it already mounts one.
+
+- `renderGroups({ query, open, onLoadingChange })` returns the page's own groups:
+ `StudioPaletteGroups`, which draws the left menu's six groups (the menu's data
+ shared through `StudioMenuDataProvider`, read once per page). On a package each
+ group also holds every item of its types, read from the type's list as its
+ list page reads it. They are drawn above the packages and mounted only while
+ the palette is open. `open` closes the palette and opens a Studio address;
+ `onLoadingChange` keeps the empty result on "Searching…" while a list is read.
+- `packageScope: true` (a package's page) drops every package's objects and
+ flows: the page's groups list that package's items instead.
+- `open(to)` is the page's departure (`openStudioPaletteAddress`). It asks the
+ shell's unsaved-edits seam (`confirmUnsavedLeave`), so every registered editor
+ is asked about, the "All metadata" item page included, then navigates. A pick
+ of the page already open on another query re-enters it once the router shows
+ that query; a pick of the page already shown only closes the palette.
+
+The
header's search trigger is drawn wherever a provider is mounted, so `AppHeader`
with `variant="studio"` shows it there. Inside an app, on every route
(`system/*` included) from the `lg` breakpoint up, `AppHeader` draws it as the
diff --git a/ui/packages/app-shell/src/chrome/CommandPalette.tsx b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
index 3096d971246..f6ac95f3f48 100644
--- a/ui/packages/app-shell/src/chrome/CommandPalette.tsx
+++ b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
@@ -15,7 +15,10 @@
* app. On `/studio` (`scope="studio"`), a frame outside every app, it has no
* app-scoped group and no full-search command, whose links all start with
* `/apps/APP`; it lists the Studio's packages, objects and flows instead, each
- * opening its Studio page.
+ * opening its Studio page. On a Studio design page (objectstack#36900) the page
+ * hands the palette its own groups (`surface`): on a package, every type and
+ * item of that package by the left menu's groups, in place of every package's
+ * objects and flows.
*
* A failure inside the palette closes it and leaves the console mounted; the
* next open draws a fresh palette (objectui#13387).
@@ -123,6 +126,45 @@ interface AppCommandPaletteProps {
*/
interface StudioCommandPaletteProps {
scope: 'studio';
+ /**
+ * The Studio design page the palette is open on (objectstack#36900), which
+ * hands it that page's own groups; omitted on the `/studio` landing.
+ */
+ surface?: StudioPaletteSurface;
+}
+
+/** What a scope's own groups are handed while the palette is open (objectstack#36900). */
+export interface StudioPaletteGroupsProps {
+ /** The typed query, matched with `matchesPaletteQuery`. */
+ query: string;
+ /** Closes the palette and opens a Studio address, through the page's {@link StudioPaletteSurface.open}. */
+ open: (to: string) => void;
+ /** Whether a read the groups wait on is still in flight: the empty palette says "Searching…" meanwhile. */
+ onLoadingChange: (loading: boolean) => void;
+}
+
+/**
+ * A Studio design page's half of the palette (objectstack#36900): the page
+ * knows its scope, its unsaved work and how it re-enters itself, so it draws
+ * its own groups and opens what is picked. The palette stays free of the
+ * page's reads: they load with the page, never with the console.
+ */
+export interface StudioPaletteSurface {
+ /**
+ * Whether the page is one package's. Its groups then list that package's
+ * items, so the palette does not also list every package's objects and
+ * flows; the package-less scope and the cross-package leg keep them.
+ */
+ packageScope: boolean;
+ /** The page's groups for the query, drawn above the packages; mounted only while the palette is open. */
+ renderGroups: (props: StudioPaletteGroupsProps) => ReactNode;
+ /**
+ * Opens a Studio address the palette picked, after it closes: the page asks
+ * the shell's unsaved-edits seam (every editor that registered edits, not
+ * only the page's own), and re-enters itself when the address is the page
+ * already open on another query (`openStudioPaletteAddress`).
+ */
+ open: (to: string) => void;
}
type CommandPaletteProps = AppCommandPaletteProps | StudioCommandPaletteProps;
@@ -372,8 +414,15 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
// objectui#11863 — the Studio's packages, objects and flows, read only while
// the palette is open in the `studio` scope, matched like the entries above.
- const studio = useStudioPaletteEntries(open && inStudio);
+ //
+ // objectstack#36900 — on a design page the page draws its own groups, and
+ // on a package those list its items in place of every package's objects
+ // and flows. What the palette picks there opens through the page.
+ const surface = inStudio ? props.surface : undefined;
+ const studio = useStudioPaletteEntries(open && inStudio, !surface?.packageScope);
const studioMatches = (entry: StudioPaletteEntry) => matches(entry.label, entry.name);
+ const openStudio = (to: string) => (surface ? runCommand(() => surface.open(to)) : leaveTo(to));
+ const [surfaceLoading, setSurfaceLoading] = useState(false);
const studioPackages = studio.packages.filter(studioMatches);
const studioObjects = studio.objects.filter(studioMatches);
const studioFlows = studio.flows.filter(studioMatches);
@@ -585,7 +634,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
/>
- {isSearching || studio.loading ? (
+ {isSearching || studio.loading || surfaceLoading ? (
)}
+ {/* objectstack#36900 — a Studio design page's own groups, first. */}
+ {open && surface?.renderGroups({ query: inputValue, open: openStudio, onLoadingChange: setSurfaceLoading })}
+
{/* Studio (objectui#11863): packages, objects and flows, `studio` scope only */}
{studioPackages.length > 0 && (
@@ -775,7 +827,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
kind="studio-package"
entry={entry}
Icon={Boxes}
- onOpen={() => leaveTo(entry.href)}
+ onOpen={() => openStudio(entry.href)}
/>
))}
@@ -788,7 +840,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
kind="studio-object"
entry={entry}
Icon={Database}
- onOpen={() => leaveTo(entry.href)}
+ onOpen={() => openStudio(entry.href)}
/>
))}
@@ -801,7 +853,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
kind="studio-flow"
entry={entry}
Icon={Workflow}
- onOpen={() => leaveTo(entry.href)}
+ onOpen={() => openStudio(entry.href)}
/>
))}
@@ -1056,8 +1108,12 @@ const NO_STUDIO_ENTRIES: StudioPaletteEntries = { packages: [], objects: [], flo
* cache list. Until the package list answers nothing is listed, so no entry
* is drawn without its package. If that read fails, the packaged entries are
* left out; the landing behind the palette shows the same read's error.
+ *
+ * `crossPackageItems` false (a package's design page, objectstack#36900)
+ * lists the packages alone: the page lists its own package's items, and the
+ * objects and flows of every package are neither read nor listed.
*/
-function useStudioPaletteEntries(enabled: boolean): StudioPaletteEntries {
+function useStudioPaletteEntries(enabled: boolean, crossPackageItems = true): StudioPaletteEntries {
const metadata = useMetadata();
const { t } = useObjectTranslation();
const [packages, setPackages] = useState(null);
@@ -1082,9 +1138,10 @@ function useStudioPaletteEntries(enabled: boolean): StudioPaletteEntries {
// Read only while open: each read starts that type's fetch when it has not
// been loaded yet, and the provider re-renders this palette when it answers.
- const objectItems: StudioServedItem[] = metadata.objects;
- const flowItems: StudioServedItem[] = metadata.getItemsByType('flow');
+ const objectItems: StudioServedItem[] = crossPackageItems ? metadata.objects : [];
+ const flowItems: StudioServedItem[] = crossPackageItems ? metadata.getItemsByType('flow') : [];
const typeLoading = (type: string) => {
+ if (!crossPackageItems) return false;
const status = metadata.getTypeStatus?.(type);
return status === 'idle' || status === 'loading';
};
diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.detailTabs-36901.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.detailTabs-36901.test.tsx
index 0e5dc2aa5b5..ed78c5daab3 100644
--- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.detailTabs-36901.test.tsx
+++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.detailTabs-36901.test.tsx
@@ -201,4 +201,28 @@ describe('carry-forward N2 — Esc reaches the non-Radix fullscreen first', () =
expect(await screen.findByTestId('list-page')).toBeInTheDocument();
expect(where()).toBe('/studio/com.acme.app/metadata/canvas_36901?package=com.acme.app');
});
+
+ it('objectstack#36900 — an Esc a dialog above already took (the command palette closing) leaves the fullscreen and the page alone', async () => {
+ open('canvas_36901', '?package=com.acme.app');
+ await screen.findByTestId('canvas-stub');
+ fireEvent.click(screen.getByTitle(t('engine.edit.fullscreen', 'en-US')));
+ expect(screen.getByTitle(t('engine.edit.exitFullscreen', 'en-US'))).toBeInTheDocument();
+
+ // A Radix layer takes its Escape in the capture phase and marks it handled.
+ const takenByDialog = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') e.preventDefault();
+ };
+ document.addEventListener('keydown', takenByDialog, true);
+ try {
+ fireEvent.keyDown(document.body, { key: 'Escape' });
+ } finally {
+ document.removeEventListener('keydown', takenByDialog, true);
+ }
+ expect(screen.getByTitle(t('engine.edit.exitFullscreen', 'en-US'))).toBeInTheDocument();
+ expect(where()).toBe('/studio/com.acme.app/metadata/canvas_36901/w1?package=com.acme.app');
+
+ // CONTROL: the next Esc nobody took leaves the fullscreen.
+ fireEvent.keyDown(document.body, { key: 'Escape' });
+ await waitFor(() => expect(screen.getByTitle(t('engine.edit.fullscreen', 'en-US'))).toBeInTheDocument());
+ });
});
diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.leaveGuard-13231.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.leaveGuard-13231.test.tsx
index bfc7237bedb..20873e1fafc 100644
--- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.leaveGuard-13231.test.tsx
+++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.leaveGuard-13231.test.tsx
@@ -20,10 +20,13 @@
*/
import '@testing-library/jest-dom/vitest';
+// The source under test reaches a dynamic import of this module: its first load is paid here, at collection, never inside a case's clock (`check:test-source-alias`).
+import '@objectstack/lint';
import * as React from 'react';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
-import { Link, MemoryRouter, Route, Routes } from 'react-router-dom';
+import { Link, MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom';
+import { CommandItem } from '@object-ui/components';
import { z } from 'zod';
import { ComponentRegistry } from '@object-ui/core';
import { DocSchema } from '@objectstack/spec/system';
@@ -89,6 +92,9 @@ import { registerDefaultMetadataSchemas } from './default-schemas';
import { registerBuiltinPreviews } from './previews';
import { t } from './i18n';
import { confirmUnsavedLeave } from '../../chrome/unsavedEdits';
+import { CommandPalette, type StudioPaletteSurface } from '../../chrome/CommandPalette';
+import { CommandPaletteProvider } from '../../context/CommandPaletteProvider';
+import { openStudioPaletteAddress } from '../studio-design/studioPaletteModel';
const DOC_JSON_SCHEMA = z.toJSONSchema(DocSchema as unknown as z.ZodType) as Record;
client.current = new MetadataClient({ baseUrl: '', fetch: vi.fn(serve) as unknown as typeof fetch });
@@ -220,3 +226,82 @@ describe('MetadataResourceEditPage registers its unsaved draft with the shell se
expect(confirmSpy).not.toHaveBeenCalled();
});
});
+
+/**
+ * objectstack#36900 (L1 M1) — a Studio palette pick leaves this page the way
+ * the Studio surface opens it (`openStudioPaletteAddress`): through the seam,
+ * so the page's own registered draft is asked about, though the surface's own
+ * unsaved bit never saw it. The real page and the real palette; the surface's
+ * groups are one entry.
+ */
+describe('a Studio palette pick asks before it drops this page\'s unsaved draft (objectstack#36900)', () => {
+ function StudioPalette() {
+ const navigate = useNavigate();
+ const { pathname, search } = useLocation();
+ const surface: StudioPaletteSurface = {
+ packageScope: true,
+ renderGroups: ({ open }) => (
+ open('/metadata/doc')}>
+ All docs
+
+ ),
+ open: (to) => openStudioPaletteAddress(to, { pathname, search }, { navigate, reenter: () => true }),
+ };
+ return ;
+ }
+
+ // The studio palette reads the package list when it opens: an empty one.
+ beforeEach(() => {
+ vi.stubGlobal('fetch', vi.fn(async () => json(200, { data: [] })));
+ });
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ async function openGuideWithPalette() {
+ active.set('doc/guide', { name: 'guide', label: 'Guide', content: '# Live', group: 'reference' });
+ render(
+
+
+
+
+ } />
+ Docs list} />
+
+
+ ,
+ );
+ expect(await source()).toHaveValue('# Live');
+ await settle();
+ }
+
+ async function pickAllDocs() {
+ fireEvent.keyDown(document, { key: 'k', ctrlKey: true });
+ const item = await screen.findByText('All docs');
+ fireEvent.click(item);
+ await settle();
+ }
+
+ it("Cancel keeps the page and the draft; OK leaves", async () => {
+ await openGuideWithPalette();
+ await editSource();
+
+ await pickAllDocs();
+ expect(confirmSpy).toHaveBeenCalledTimes(1);
+ expect(confirmSpy).toHaveBeenCalledWith(QUESTION);
+ expect(screen.queryByText('Docs list')).toBeNull();
+ expect(await source()).toHaveValue('# Live, edited');
+
+ confirmSpy.mockReturnValue(true);
+ await pickAllDocs();
+ expect(confirmSpy).toHaveBeenCalledTimes(2);
+ expect(await screen.findByText('Docs list')).toBeTruthy();
+ });
+
+ it('CONTROL: a clean page leaves at once, asking nothing', async () => {
+ await openGuideWithPalette();
+ await pickAllDocs();
+ expect(await screen.findByText('Docs list')).toBeTruthy();
+ expect(confirmSpy).not.toHaveBeenCalled();
+ });
+});
diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx
index 962ff6009a7..105156195ca 100644
--- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx
+++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx
@@ -1717,11 +1717,13 @@ function MetadataResourceEditPageImpl({
document.body.style.overflow = prev;
};
}, [isFullscreen]);
- // Escape exits fullscreen.
+ // Escape exits fullscreen. objectstack#36900 — not an Escape a dialog over
+ // the page (the command palette, a confirm) already took to close itself:
+ // Radix's dismissable layer marks the one it acts on `defaultPrevented`.
React.useEffect(() => {
if (typeof window === 'undefined' || !isFullscreen) return;
function onKey(e: KeyboardEvent) {
- if (e.key === 'Escape') {
+ if (e.key === 'Escape' && !e.defaultPrevented) {
e.preventDefault();
setIsFullscreen(false);
}
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx
index de051a782c0..eea40c4c4b4 100644
--- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx
+++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx
@@ -18,6 +18,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
import { useMetadataAreaHost } from '../metadata-admin/metadataAreaHost';
+import { useRegisterUnsavedEdits } from '../../chrome/unsavedEdits';
const PACKAGE_ID = 'app.r34d';
const KERNEL_ID = 'com.objectstack.platform';
@@ -29,7 +30,7 @@ vi.mock('sonner', () => ({
}));
const mockClient = {
- list: vi.fn(async () => []),
+ list: vi.fn(async (_type?: string): Promise => []),
listDrafts: vi.fn(async () => []),
layered: vi.fn(async (_t: string, name: string) => ({ effective: { name } })),
getDraft: vi.fn(async () => null),
@@ -65,8 +66,13 @@ vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: ()
vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null }));
vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null }));
+/** objectstack#36900 — the item page holds unsaved edits, registered with the shell's seam as `ResourceEditPage` does. */
+const itemPage = vi.hoisted(() => ({ dirty: false }));
+const ITEM_QUESTION = 'Discard the edits on this item?';
+
function PageStub({ page }: { page: string }) {
const host = useMetadataAreaHost();
+ useRegisterUnsavedEdits(page === 'item' && itemPage.dirty, ITEM_QUESTION);
return ;
}
vi.mock('../metadata-admin/index.js', () => ({
@@ -109,6 +115,9 @@ import { StudioDesignSurface } from './StudioDesignSurface';
// The source under test reaches dynamic imports of `@objectstack/lint`; their first
// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`).
import '@objectstack/lint';
+// objectstack#36900 — the surface mounts the command palette, which reaches the
+// record preview's `lazy()` detail entry: its first load is paid here too.
+import '@object-ui/plugin-detail';
const answer = (body: unknown) => ({ ok: true, status: 200, json: async () => body });
@@ -274,3 +283,142 @@ describe('the area\'s form editor in the builder (objectstack#28569)', () => {
expect(await screen.findByTestId('studio-changes-count')).toHaveTextContent('1');
});
});
+
+/**
+ * objectstack#36900 — ⌘K on the builder's pages: the surface mounts the
+ * command palette with its own groups, on a package's pillars and area and on
+ * the cross-package leg, and a pick leaves through the surface.
+ */
+describe('⌘K on the builder (objectstack#36900)', () => {
+ const overlay = () => document.querySelector('[data-testid="overlay:command-palette"]');
+ const paletteItem = (value: string) => document.querySelector(`[cmdk-item][data-value="${value}"]`);
+
+ it("on a package's pillar, Ctrl+K opens the palette with the menu's entries, and a pick opens through the surface", async () => {
+ servePackages();
+ renderAt(`/studio/${PACKAGE_ID}/data`);
+ await waitFor(() => menu().getByTestId('studio-menu-entry-type:flow'));
+ expect(overlay()).toBeNull();
+
+ fireEvent.keyDown(document, { key: 'k', ctrlKey: true });
+ await waitFor(() => expect(overlay()).not.toBeNull());
+ expect(where()).toBe(`/studio/${PACKAGE_ID}/data?palette=1`);
+ await waitFor(() => expect(paletteItem('studio-entry type:flow')).not.toBeNull());
+ expect(paletteItem('studio-entry orgFlows')).not.toBeNull();
+
+ fireEvent.click(paletteItem('studio-entry type:flow')!);
+ expect((await areaPage()).page).toBe('list');
+ expect(where()).toBe(`/studio/${PACKAGE_ID}/metadata/flow?package=${PACKAGE_ID}`);
+ expect(overlay()).toBeNull();
+ expect(current()).toHaveAttribute('data-testid', 'studio-menu-entry-type:flow');
+ });
+
+ it('on the cross-package leg, Ctrl+K opens the palette again, with the environment menu', async () => {
+ servePackages();
+ renderAt('/studio/~all/metadata');
+ await areaPage();
+
+ fireEvent.keyDown(document, { key: 'k', ctrlKey: true });
+ await waitFor(() => expect(overlay()).not.toBeNull());
+ await waitFor(() => expect(paletteItem('studio-entry environment')).not.toBeNull());
+ expect(paletteItem('studio-entry diagnostics')).toBeNull();
+ });
+
+ it('a package that is not there has no menu, and its palette lists the packages instead', async () => {
+ servePackages();
+ renderAt(`/studio/${PHANTOM}/data?palette=1`);
+ expect(await screen.findByTestId('studio-package-not-found')).toBeInTheDocument();
+ await waitFor(() => expect(document.querySelector('[cmdk-item][data-value^="studio-package Field Ops "]')).not.toBeNull());
+ expect(document.querySelector('[cmdk-item][data-value^="studio-entry "]')).toBeNull();
+ });
+});
+
+/**
+ * objectstack#36900 (L1 M1, S5) — a pick from the palette leaves through the
+ * shell's unsaved-edits seam, so an editor below the surface that registers
+ * its own edits (the "All metadata" item page) is asked about too, and so is
+ * the header's Back to app; Default sharing picked on the Access pillar
+ * remounts the pillar on its own deep link.
+ */
+describe('⌘K and the header ask before they drop edits the item page holds (objectstack#36900)', () => {
+ const overlay = () => document.querySelector('[data-testid="overlay:command-palette"]');
+ const paletteItem = (value: string) => document.querySelector(`[cmdk-item][data-value="${value}"]`);
+ const ITEM_URL = `/studio/${PACKAGE_ID}/metadata/agent/a1?package=${PACKAGE_ID}`;
+ let confirmSpy: ReturnType;
+
+ beforeEach(() => {
+ itemPage.dirty = true;
+ confirmSpy = vi.fn(() => false);
+ vi.stubGlobal('confirm', confirmSpy);
+ });
+ afterEach(() => {
+ itemPage.dirty = false;
+ });
+
+ async function pickFlowList() {
+ fireEvent.keyDown(document, { key: 'k', ctrlKey: true });
+ await waitFor(() => expect(paletteItem('studio-entry type:flow')).not.toBeNull());
+ fireEvent.click(paletteItem('studio-entry type:flow')!);
+ }
+
+ it("a palette pick asks the item page's question: Cancel keeps the page, OK leaves", async () => {
+ servePackages();
+ renderAt(ITEM_URL);
+ expect((await areaPage()).page).toBe('item');
+
+ await pickFlowList();
+ expect(confirmSpy).toHaveBeenCalledTimes(1);
+ expect(confirmSpy).toHaveBeenCalledWith(ITEM_QUESTION);
+ await waitFor(() => expect(overlay()).toBeNull());
+ expect(where()).toBe(ITEM_URL);
+ expect((await areaPage()).page).toBe('item');
+
+ confirmSpy.mockReturnValue(true);
+ await pickFlowList();
+ expect(confirmSpy).toHaveBeenCalledTimes(2);
+ expect((await areaPage()).page).toBe('list');
+ expect(where()).toBe(`/studio/${PACKAGE_ID}/metadata/flow?package=${PACKAGE_ID}`);
+ });
+
+ it("the header's Back to app asks the item page's question too: Cancel keeps the page", async () => {
+ servePackages();
+ renderAt(ITEM_URL);
+ expect((await areaPage()).page).toBe('item');
+ fireEvent.click(await screen.findByTestId('studio-back-to-app'));
+ expect(confirmSpy).toHaveBeenCalledWith(ITEM_QUESTION);
+ expect(where()).toBe(ITEM_URL);
+ });
+
+ it('CONTROL — a clean item page: the pick leaves at once and asks nothing', async () => {
+ itemPage.dirty = false;
+ servePackages();
+ renderAt(ITEM_URL);
+ expect((await areaPage()).page).toBe('item');
+ await pickFlowList();
+ expect((await areaPage()).page).toBe('list');
+ expect(confirmSpy).not.toHaveBeenCalled();
+ });
+
+ it('Default sharing picked on the Access pillar remounts the pillar on its overview', async () => {
+ itemPage.dirty = false;
+ mockClient.list.mockImplementation(async (type?: string) =>
+ type === 'permission' ? [{ name: 'sales_rep', label: 'Sales Rep', _packageId: PACKAGE_ID }] : [],
+ );
+ try {
+ servePackages();
+ renderAt(`/studio/${PACKAGE_ID}/access?surface=permission%3Asales_rep`);
+ await screen.findByTestId('access-rail-set-sales_rep');
+ expect(screen.queryByTestId('owd-overview')).toBeNull();
+
+ fireEvent.keyDown(document, { key: 'k', ctrlKey: true });
+ await waitFor(() => expect(paletteItem('studio-entry owd')).not.toBeNull());
+ fireEvent.click(paletteItem('studio-entry owd')!);
+
+ expect(await screen.findByTestId('owd-overview')).toBeInTheDocument();
+ expect(where()).toBe(`/studio/${PACKAGE_ID}/access?surface=owd%3Aoverview`);
+ expect(overlay()).toBeNull();
+ expect(confirmSpy).not.toHaveBeenCalled();
+ } finally {
+ mockClient.list.mockImplementation(async () => []);
+ }
+ });
+});
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx
index 4051b0f6fa9..09a8f70dd38 100644
--- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx
+++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx
@@ -69,7 +69,6 @@ import {
type NewFlowTrigger,
} from './AutomationsFlowRail.js';
import {
- confirmDropUnsavedWork,
CreateTakenNotice,
findTakenIdentifier,
type StudioBaseCustomization,
@@ -133,7 +132,7 @@ import {
studioOrgScopePath,
} from './studioScope.js';
import { STUDIO_METADATA_AREA, isStudioAllPackagesScope } from './metadataArea.js';
-import { StudioMenu, StudioMenuProvider, StudioMenuTrigger } from './StudioMenu.js';
+import { StudioMenu, StudioMenuDataProvider, StudioMenuProvider, StudioMenuTrigger } from './StudioMenu.js';
import { StudioMetadataArea } from './StudioMetadataArea.js';
import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js';
import {
@@ -142,7 +141,11 @@ import {
import { SurfaceDeepLinkProvider } from './surfaceDeepLinkChannel.js';
import { buildAppSkeleton, type AppNavSeed } from './skeletons.js';
import { t, tFormat, useMetadataLocale } from '../metadata-admin/i18n.js';
-import { useRegisterUnsavedEdits } from '../../chrome/unsavedEdits.js';
+import { confirmUnsavedLeave, useRegisterUnsavedEdits } from '../../chrome/unsavedEdits.js';
+import { CommandPalette, type StudioPaletteSurface } from '../../chrome/CommandPalette.js';
+import { CommandPaletteProvider, useCommandPaletteProviderMounted } from '../../context/CommandPaletteProvider.js';
+import { StudioPaletteGroups } from './StudioPaletteGroups.js';
+import { openStudioPaletteAddress, studioSamePageSearch } from './studioPaletteModel.js';
import { CreateItemDialog } from './CreateItemDialog.js';
// objectui#11787 — the shared draft autosave, moved to its own module unchanged.
import {
@@ -470,10 +473,21 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re
// unsaved work, and every guard below reads this one bit. objectstack#36511
// — so does an edit waiting for the top bar's Save.
const unsavedPillarWork = pillarDirty || heldEdit !== null || saveBar.dirty;
- const confirmLeavePillar = React.useCallback(
- () => confirmDropUnsavedWork(unsavedPillarWork, locale),
- [unsavedPillarWork, locale],
- );
+ // objectstack#36900 — every departure this surface starts asks the shell's
+ // unsaved-edits seam, not only this surface's own bit: the seam holds this
+ // surface's work (registered below with the same question) AND every editor
+ // below it that registers its own, the "All metadata" item page
+ // (`ResourceEditPage`) among them, whose edits this bit never sees. So the
+ // palette's picks, the header's Back to app, the retired-Interfaces notice
+ // and a request to open another pillar's surface all ask before they drop
+ // either kind of edit. `true`: nothing would be lost, or the author agreed.
+ const confirmLeavePillar = React.useCallback((): boolean => {
+ let agreed = false;
+ confirmUnsavedLeave(() => {
+ agreed = true;
+ });
+ return agreed;
+ }, []);
// Browser-native "leave site?" prompt on tab close / reload while a pillar
// is dirty. The matrix editor installs its own (double registration is
// harmless); the Interfaces nav editor has none, so this closes that gap.
@@ -1221,22 +1235,67 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re
// remount waits for the new query to be the router's: the router may apply
// a navigation in a later render than the click's own state updates, and a
// pillar remounted before it would capture the old deep link.
+ // objectstack#36900 — it waits for the query it was asked for, not for the
+ // next query change: the command palette closes itself (its `?palette=`
+ // goes) before the pick navigates, and that first change must not remount
+ // the pillar on the old deep link.
const [pillarEntry, setPillarEntry] = React.useState(0);
- const reentryPending = React.useRef(false);
+ const reentryPending = React.useRef(null);
const currentSearch = useLocation().search;
- const reenterPillar = React.useCallback((): boolean => {
- if (!confirmLeavePillar()) return false;
- reentryPending.current = true;
- return true;
- }, [confirmLeavePillar]);
+ const reenterPillar = React.useCallback(
+ (search: string): boolean => {
+ if (!confirmLeavePillar()) return false;
+ reentryPending.current = search;
+ return true;
+ },
+ [confirmLeavePillar],
+ );
React.useLayoutEffect(() => {
- if (!reentryPending.current) return;
- reentryPending.current = false;
+ const expected = reentryPending.current;
+ if (expected === null || !studioSamePageSearch(currentSearch, expected)) return;
+ reentryPending.current = null;
setPillarEntry((n) => n + 1);
}, [currentSearch]);
// objectstack#26708 — a package that is not there has no menu.
const showMenu = !pkgMissing;
+ // objectstack#36900 — ⌘K on every design page (decision 7 of #36890: an
+ // author switches items by ×, by ‹ › and by ⌘K). The palette lists this
+ // scope's menu, and on a package its items (`StudioPaletteGroups`); a pick
+ // leaves the way a menu entry does: it asks about unsaved work, and an
+ // address that is the page already open on another query re-enters the
+ // page, which reads its deep link once, at mount. The palette's own
+ // `?palette=` is not part of the page's query. A package that is not there
+ // has no menu, so its palette is the landing's.
+ const currentPathname = useLocation().pathname;
+ const openFromPalette = React.useCallback(
+ (to: string) =>
+ openStudioPaletteAddress(
+ to,
+ { pathname: currentPathname, search: currentSearch },
+ { navigate: shellNavigate, reenter: reenterPillar },
+ ),
+ [currentPathname, currentSearch, reenterPillar, shellNavigate],
+ );
+ const paletteLabel = packageId !== null && pkgEntry?.id === packageId ? pkgEntry.name : undefined;
+ const paletteSurface = React.useMemo(
+ () =>
+ showMenu
+ ? {
+ packageScope: packageId !== null,
+ renderGroups: (groupsProps) => (
+
+ ),
+ open: openFromPalette,
+ }
+ : undefined,
+ [showMenu, packageId, scopeSegment, paletteLabel, openFromPalette],
+ );
+ // A host that already mounts a command palette above this surface keeps
+ // its own: a second provider would toggle the one `?palette=` twice per
+ // ⌘K, and a second palette would draw a second dialog.
+ const paletteHosted = useCommandPaletteProviderMounted();
+
const publishButton = (
)}
{groups.map(({ group, entries }) => {
- const Icon = GROUP_ICONS[group];
+ const Icon = STUDIO_MENU_GROUP_ICONS[group];
const labelId = `${searchId}-${group}`;
const typeCount = entries.filter((e) => e.kind === 'type').length;
return (
@@ -237,7 +230,7 @@ export function StudioMenu({ segment, locale, onReenterPillar }: StudioMenuProps
if (e.defaultPrevented) return;
const [to, query = ''] = entry.to.split('?');
const reenters = to === pathname && `?${query}` !== search;
- if (reenters && onReenterPillar && !onReenterPillar()) {
+ if (reenters && onReenterPillar && !onReenterPillar(query ? `?${query}` : '')) {
e.preventDefault();
return;
}
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.surfaceScope-36900.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.surfaceScope-36900.test.tsx
new file mode 100644
index 00000000000..1afddd4d038
--- /dev/null
+++ b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.surfaceScope-36900.test.tsx
@@ -0,0 +1,417 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * objectstack#36900 — ⌘K on a Studio design page: the palette lists that
+ * page's left menu and, on a package, every item of every type it holds
+ * (`StudioPaletteGroups` handed to the palette as its `surface`).
+ *
+ * 1. On a package: the menu's groups, in its order, under the menu's names,
+ * each with the menu's own entries and the items of its types, from the
+ * package and its `.custom` pair only, kept by the list page's own rule
+ * (its `include` and predicate); every package's objects and flows
+ * are neither read nor listed; the packages still are.
+ * 2. A pick opens through the page (`surface.open`): an item at the address
+ * the one builder gives, a menu entry where the menu entry goes.
+ * 3. The query matches an item by label, name or type, a menu entry by its
+ * label, type or group.
+ * 4. While a list is still read, an empty result says "Searching…".
+ * 5. No item list is read until the palette opens; the types come from the
+ * menu's own data (`StudioMenuDataProvider`). CONTROL: opened, it reads.
+ * 6. On the cross-package leg (`~all`) the menu's environment entries join
+ * every package's objects and flows, as on the landing.
+ *
+ * Real subjects: `CommandPalette`, `CommandPaletteProvider` (opened by its
+ * `?palette=1` deep link), `StudioPaletteGroups`, the menu model and the
+ * address builder, and an `en` `I18nProvider`. The metadata reads are doubled
+ * (the menu's own seam, as `StudioMenu.test.tsx` doubles them).
+ */
+
+import '@testing-library/jest-dom/vitest';
+import * as React from 'react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { cleanup, fireEvent, render, waitFor } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import { createI18n, I18nProvider } from '@object-ui/i18n';
+import { MetadataCtx, type MetadataContextValue } from '@object-ui/react';
+
+const reads = vi.hoisted(() => {
+ const PKG = 'com.acme.crm';
+ const PAIR = 'com.acme.crm.custom';
+ const LISTS: Record = {
+ object: [
+ { name: 'crm_account', label: 'Account', _packageId: PKG },
+ { name: 'hr_employee', label: 'Employee', _packageId: 'com.acme.hr' },
+ ],
+ hook: [
+ { name: 'on_lead_created', label: 'On lead created', _packageId: PAIR },
+ // Hidden by the type's own list predicate, as its list page hides it.
+ { name: 'legacy_hook', label: 'Legacy', _packageId: PKG, legacy: true },
+ ],
+ dashboard: [{ name: 'crm_pipeline', label: 'Pipeline', _packageId: PKG }],
+ flow: [{ name: 'crm_onboard', label: 'Onboard account', _packageId: PKG }],
+ permission: [{ name: 'sales_rep', label: 'Sales Rep', _packageId: PKG }],
+ datasource: [{ name: 'crm_db', label: 'CRM database', _packageId: PKG }],
+ };
+ const state = { calls: [] as string[], options: {} as Record, hold: null as Promise | null };
+ const client = {
+ list: async (type: string, options?: unknown) => {
+ state.calls.push(type);
+ state.options[type] = options;
+ if (state.hold) await state.hold;
+ return LISTS[type] ?? [];
+ },
+ };
+ return { PKG, PAIR, state, client };
+});
+
+vi.mock('../metadata-admin/useMetadata', async (importOriginal) => {
+ const actual = await importOriginal>();
+ return {
+ ...actual,
+ useMetadataClient: () => reads.client,
+ useMetadataTypes: () => ({
+ loading: false,
+ error: null,
+ entries: [
+ { type: 'object', domain: 'data' },
+ { type: 'hook', domain: 'data' },
+ { type: 'datasource', domain: 'system' },
+ { type: 'dashboard', domain: 'ui' },
+ { type: 'flow', domain: 'automation' },
+ { type: 'permission', domain: 'security' },
+ { type: 'position', domain: 'security' },
+ { type: 'agent', domain: 'ai' },
+ ],
+ }),
+ useGlobalDiagnostics: () => ({
+ loading: false,
+ countsByType: { object: 1 },
+ // The agent type is served, but this package holds none: not listed.
+ packagesByType: { hook: [reads.PKG], dashboard: [reads.PKG], datasource: [reads.PKG], agent: ['com.acme.hr'] },
+ reload: () => {},
+ }),
+ };
+});
+
+vi.mock('@object-ui/auth', async (importOriginal) => ({
+ ...(await importOriginal>()),
+ useAuth: () => ({ user: { id: 'u1' }, activeOrganization: null }),
+}));
+
+// The palette reaches the record preview's `lazy()` detail entry: load it at
+// module scope, so its cost is paid at import (ui/AGENTS.md, lazy boundaries).
+import '@object-ui/plugin-detail';
+import { CommandPalette, type StudioPaletteSurface } from '../../chrome/CommandPalette';
+import { CommandPaletteProvider } from '../../context/CommandPaletteProvider';
+import { StudioPaletteGroups } from './StudioPaletteGroups';
+import { StudioMenuDataProvider } from './StudioMenu';
+import { registerMetadataResource } from '../metadata-admin/registry';
+import { studioMenuGroupLabel } from './studioMenuGroupLabel';
+import { tFormat, translateMetadataType } from '../metadata-admin/i18n';
+
+const { PKG, PAIR } = reads;
+
+// The hook list as its list page reads it: served with an `include`, and a
+// predicate that hides legacy rows.
+registerMetadataResource({
+ type: 'hook',
+ listInclude: 'grants',
+ listFilter: (item: Record) => item.legacy !== true,
+} as never);
+
+/** The landing's metadata cache, counting what the cross-package lists read. */
+function metadataCache() {
+ const cacheReads: string[] = [];
+ const value: MetadataContextValue = {
+ apps: [],
+ get objects() {
+ cacheReads.push('object');
+ return [{ name: 'hr_employee', label: 'Employee', _packageId: 'com.acme.hr' }];
+ },
+ dashboards: [],
+ reports: [],
+ pages: [],
+ loading: false,
+ error: null,
+ refresh: async () => {},
+ invalidate: () => {},
+ ensureType: async () => [],
+ getItem: async () => null,
+ getItemsByType: (type: string) => {
+ cacheReads.push(type);
+ return [];
+ },
+ getTypeStatus: () => 'ready',
+ };
+ return { value, cacheReads };
+}
+
+let fetchMock: ReturnType;
+
+beforeEach(() => {
+ reads.state.calls = [];
+ reads.state.options = {};
+ reads.state.hold = null;
+ fetchMock = vi.fn(async (url: string) => {
+ if (String(url).endsWith('/api/v1/packages')) {
+ return {
+ ok: true,
+ status: 200,
+ json: async () => ({
+ data: [
+ { manifest: { id: PKG, name: 'Acme CRM' }, writable: true },
+ { manifest: { id: 'com.acme.hr', name: 'People' }, writable: true },
+ ],
+ }),
+ };
+ }
+ throw new Error(`unexpected request: ${url}`);
+ });
+ vi.stubGlobal('fetch', fetchMock);
+});
+
+afterEach(() => {
+ cleanup();
+ vi.unstubAllGlobals();
+});
+
+function mount(segment: string, opts: { at?: string; packageScope?: boolean } = {}) {
+ const cache = metadataCache();
+ const open = vi.fn();
+ const surface: StudioPaletteSurface = {
+ packageScope: opts.packageScope ?? true,
+ renderGroups: (props) => ,
+ open,
+ };
+ render(
+
+
+
+
+
+
+
+
+
+
+ ,
+ );
+ return { open, cacheReads: cache.cacheReads };
+}
+
+function type(query: string) {
+ const input = document.querySelector('[cmdk-input]');
+ if (!input) throw new Error('the palette did not open');
+ fireEvent.change(input, { target: { value: query } });
+}
+
+/** The rendered group headings, in order. */
+function headings(): string[] {
+ return Array.from(document.querySelectorAll('[cmdk-group-heading]')).map((el) => (el.textContent ?? '').trim());
+}
+
+/** The cmdk value of every rendered item that starts with `prefix`. */
+function values(prefix: string): string[] {
+ return Array.from(document.querySelectorAll(`[cmdk-item][data-value^="${prefix}"]`)).map(
+ (el) => el.getAttribute('data-value') ?? '',
+ );
+}
+
+function pick(value: string) {
+ const item = document.querySelector(`[cmdk-item][data-value="${value}"]`);
+ if (!item) throw new Error(`no rendered item is "${value}"`);
+ fireEvent.click(item);
+}
+
+const itemsListed = () => waitFor(() => expect(values('studio-item ').length).toBeGreaterThan(0));
+const group = (g: Parameters[0]) => studioMenuGroupLabel(g, 'en');
+
+describe("on a package, the palette lists the left menu and the package's items (objectstack#36900)", () => {
+ it("draws the menu's groups in its order, with the menu's entries and the items of the package and its pair", async () => {
+ const { cacheReads } = mount(PKG);
+ await itemsListed();
+
+ // The menu's six groups, the empty AI one left out, then the
+ // packages and the theme commands. No cross-package Objects / Flows.
+ expect(headings()).toEqual([
+ group('data'),
+ group('ui'),
+ group('automation'),
+ group('system'),
+ group('security'),
+ 'Packages',
+ 'Preferences',
+ ]);
+ expect(values('studio-entry ')).toEqual([
+ 'studio-entry type:object',
+ 'studio-entry type:hook',
+ 'studio-entry type:dashboard',
+ 'studio-entry type:flow',
+ 'studio-entry orgFlows',
+ 'studio-entry type:datasource',
+ 'studio-entry diagnostics',
+ 'studio-entry type:permission',
+ 'studio-entry owd',
+ 'studio-entry environment',
+ ]);
+ // Another package's object, and the datasource (Setup's), are not items.
+ expect(values('studio-item ')).toEqual([
+ `studio-item object ${PKG} crm_account`,
+ `studio-item hook ${PAIR} on_lead_created`,
+ `studio-item dashboard ${PKG} crm_pipeline`,
+ `studio-item flow ${PKG} crm_onboard`,
+ `studio-item permission ${PKG} sales_rep`,
+ ]);
+ expect(reads.state.calls).not.toContain('datasource');
+ // The list page's own read and rule: its `include`, and its predicate.
+ expect(reads.state.options.hook).toEqual({ include: 'grants' });
+ expect(values('studio-item hook ')).toEqual([`studio-item hook ${PAIR} on_lead_created`]);
+ expect(values('studio-package ')).toHaveLength(2);
+ expect(values('studio-object ')).toEqual([]);
+ expect(values('studio-flow ')).toEqual([]);
+ expect(cacheReads).toEqual([]);
+ });
+
+ it("names an item by its label and its type, and a customization by the package's name, never the pair's id", async () => {
+ mount(PKG);
+ await itemsListed();
+ const text = (value: string) =>
+ (document.querySelector(`[cmdk-item][data-value="${value}"]`)?.textContent ?? '').trim();
+ expect(text(`studio-item object ${PKG} crm_account`)).toBe(`Account${translateMetadataType('object', 'en')}`);
+ expect(text(`studio-item hook ${PAIR} on_lead_created`)).toBe(
+ `On lead created${translateMetadataType('hook', 'en')} · ${tFormat('engine.customizationMark.customizationOf', 'en', { baseName: 'Acme CRM' })}`,
+ );
+ const shownText = Array.from(document.querySelectorAll('[cmdk-item]')).map((el) => el.textContent ?? '');
+ expect(shownText.filter((x) => x.includes('.custom'))).toEqual([]);
+ });
+
+ /** Mount, pick one entry and read what the page was asked to open: a pick closes the palette. */
+ async function openedBy(value: string): Promise {
+ const { open } = mount(PKG);
+ await itemsListed();
+ pick(value);
+ const [to] = open.mock.calls.at(-1) ?? [];
+ cleanup();
+ return to;
+ }
+
+ it('opens an item through the page, at the address the one builder gives', async () => {
+ expect(await openedBy(`studio-item object ${PKG} crm_account`)).toBe(
+ '/studio/com.acme.crm/data?surface=object%3Acrm_account',
+ );
+ expect(await openedBy(`studio-item permission ${PKG} sales_rep`)).toBe(
+ '/studio/com.acme.crm/access?surface=permission%3Asales_rep',
+ );
+ expect(await openedBy(`studio-item dashboard ${PKG} crm_pipeline`)).toBe(
+ '/studio/com.acme.crm/metadata/dashboard/crm_pipeline?package=com.acme.crm',
+ );
+ expect(await openedBy(`studio-item hook ${PAIR} on_lead_created`)).toBe(
+ '/studio/com.acme.crm/metadata/hook/on_lead_created?package=com.acme.crm.custom',
+ );
+ });
+
+ it('opens a menu entry where the menu entry goes, and the palette closes', async () => {
+ expect(await openedBy('studio-entry type:hook')).toBe('/studio/com.acme.crm/metadata/hook?package=com.acme.crm');
+ expect(await openedBy('studio-entry orgFlows')).toBe('/studio/~org/automations');
+ expect(await openedBy('studio-entry owd')).toBe('/studio/com.acme.crm/access?surface=owd%3Aoverview');
+ expect(await openedBy('studio-entry diagnostics')).toBe('/studio/com.acme.crm/metadata/_diagnostics');
+
+ mount(PKG);
+ await itemsListed();
+ pick('studio-entry diagnostics');
+ await waitFor(() => expect(document.querySelector('[cmdk-input]')).toBeNull());
+ });
+
+ it("opens a package through the page too, and the palette's own landing navigation is not used", async () => {
+ const { open } = mount(PKG);
+ await itemsListed();
+ pick(values('studio-package People')[0]);
+ expect(open).toHaveBeenLastCalledWith('/studio/com.acme.hr/data');
+ });
+
+ it('matches an item by label, name or type, and a menu entry by label, type or group', async () => {
+ mount(PKG);
+ await itemsListed();
+
+ type('pipeline');
+ expect(values('studio-item ')).toEqual([`studio-item dashboard ${PKG} crm_pipeline`]);
+ expect(values('studio-entry ')).toEqual([]);
+
+ type('on_lead');
+ expect(values('studio-item ')).toEqual([`studio-item hook ${PAIR} on_lead_created`]);
+
+ type(translateMetadataType('hook', 'en'));
+ expect(values('studio-entry ')).toEqual(['studio-entry type:hook']);
+ expect(values('studio-item ')).toEqual([`studio-item hook ${PAIR} on_lead_created`]);
+
+ type(group('automation'));
+ expect(values('studio-entry ')).toEqual(['studio-entry type:flow', 'studio-entry orgFlows']);
+ expect(headings()).toEqual([group('automation')]);
+ });
+
+ it('says "Searching…" for an empty result while a list is read, and "No results" once read', async () => {
+ let release = () => {};
+ reads.state.hold = new Promise((resolve) => {
+ release = resolve;
+ });
+ mount(PKG);
+ await waitFor(() => expect(reads.state.calls.length).toBeGreaterThan(0));
+ type('zzzz');
+ await waitFor(() => expect(document.querySelector('[cmdk-empty]')?.textContent).toContain('Searching'));
+ release();
+ await waitFor(() => expect(document.querySelector('[cmdk-empty]')?.textContent).toContain('No results'));
+ });
+
+ it('a query typed before the lists answer: the row that arrives is selected, and Enter opens it', async () => {
+ let release = () => {};
+ reads.state.hold = new Promise((resolve) => {
+ release = resolve;
+ });
+ const { open } = mount(PKG);
+ await waitFor(() => expect(reads.state.calls.length).toBeGreaterThan(0));
+ // A menu entry is selected at open; the query filters it away, and the
+ // row it asks for mounts only when the lists answer (cmdk selects it then).
+ type('pipeline');
+ expect(values('studio-item ')).toEqual([]);
+ release();
+ const row = `studio-item dashboard ${PKG} crm_pipeline`;
+ await waitFor(() =>
+ expect(document.querySelector(`[cmdk-item][data-value="${row}"]`)?.getAttribute('data-selected')).toBe('true'),
+ );
+ fireEvent.keyDown(document.querySelector('[cmdk-input]')!, { key: 'Enter' });
+ expect(open).toHaveBeenLastCalledWith('/studio/com.acme.crm/metadata/dashboard/crm_pipeline?package=com.acme.crm');
+ });
+
+ it('reads nothing until the palette opens', async () => {
+ const { cacheReads } = mount(PKG, { at: `/studio/${PKG}/data` });
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ expect(document.querySelector('[cmdk-input]')).toBeNull();
+ expect(reads.state.calls).toEqual([]);
+ expect(fetchMock).not.toHaveBeenCalled();
+ expect(cacheReads).toEqual([]);
+ });
+
+ it("CONTROL — opened, it reads each listed type's list", async () => {
+ mount(PKG);
+ await itemsListed();
+ expect([...reads.state.calls].sort()).toEqual(['dashboard', 'flow', 'hook', 'object', 'permission']);
+ });
+});
+
+describe('on the cross-package leg, the menu joins every package\'s objects and flows (objectstack#36900)', () => {
+ it("lists the environment menu's entries, reads no item list, and keeps the landing's groups", async () => {
+ const { cacheReads } = mount('~all', { at: '/studio/~all/metadata?palette=1', packageScope: false });
+ await waitFor(() => expect(values('studio-object ').length).toBeGreaterThan(0));
+
+ expect(values('studio-entry ')).toEqual([
+ 'studio-entry orgFlows',
+ 'studio-entry type:permission',
+ 'studio-entry type:position',
+ 'studio-entry environment',
+ ]);
+ expect(values('studio-item ')).toEqual([]);
+ expect(reads.state.calls).toEqual([]);
+ expect(cacheReads).toContain('object');
+ expect(cacheReads).toContain('flow');
+ });
+});
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
new file mode 100644
index 00000000000..088b69af49b
--- /dev/null
+++ b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
@@ -0,0 +1,224 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * The groups the command palette lists on a Studio design page
+ * (objectstack#36900): the left menu's groups, in its order, each with the
+ * menu's own entries and, on a package, every item of the types it lists.
+ * What it lists and where each entry opens is `studioPaletteModel.ts`; this
+ * file reads it and draws it inside the palette.
+ *
+ * ## What it reads, and when
+ *
+ * The types and their counts are the left menu's own data
+ * (`StudioMenuDataProvider`, which the surface mounts once for the page), so
+ * the palette and the menu never disagree on which types a package holds and
+ * opening the palette re-reads neither. The items are read only while the
+ * palette is open (it mounts this component inside its open dialog): on a
+ * package, each listed type's served list, the read the type's own list page
+ * makes (its `include` too), kept by that page's own rule (`scopeListRows`). A
+ * list that fails to answer lists none of its items: the type's list page
+ * shows that read's error, and its menu entry is still offered here.
+ *
+ * ## Matched, not filtered by cmdk
+ *
+ * The palette turns cmdk's own filter off (objectui#13387); every entry here
+ * is matched with the palette's one matcher (`matchesPaletteQuery`): a menu
+ * entry by its label, its type's machine name and its group's name; an item by
+ * its label, its name and its type's label.
+ */
+
+import * as React from 'react';
+import { List, Building2, Share2, Activity, KeyRound, type LucideIcon } from 'lucide-react';
+import { CommandGroup, CommandItem } from '@object-ui/components';
+import { useObjectTranslation } from '@object-ui/i18n';
+import { matchesPaletteQuery } from '../../chrome/paletteMatch.js';
+import type { StudioPaletteGroupsProps } from '../../chrome/CommandPalette.js';
+import { resolveKeyedI18nLabel } from '../../utils/index.js';
+import { t, tFormat, translateMetadataType, useMetadataLocale } from '../metadata-admin/i18n.js';
+import { resolveResourceConfig } from '../metadata-admin/registry.js';
+import { useMetadataClient, type RichMetadataTypeEntry } from '../metadata-admin/useMetadata.js';
+import { STUDIO_MENU_ENTRY_LABEL_KEYS, STUDIO_MENU_GROUP_ICONS, useStudioMenuData } from './studioMenuData.js';
+import { studioMenuGroupLabel } from './studioMenuGroupLabel.js';
+import { buildStudioMenu, studioMenuScope, type StudioMenuEntry } from './studioMenuModel.js';
+import {
+ STUDIO_PALETTE_ITEMLESS_TYPES,
+ buildStudioPaletteGroups,
+ studioPaletteItemAddress,
+ studioPaletteItemsOf,
+ studioPalettePairId,
+ type StudioPaletteItem,
+} from './studioPaletteModel.js';
+
+/** The icon each menu entry draws in the palette: a type's list, or the page it opens. */
+const ENTRY_ICONS: Record = {
+ type: List,
+ orgFlows: Building2,
+ owd: Share2,
+ diagnostics: Activity,
+ environment: KeyRound,
+};
+
+/**
+ * The items of a package's palette: each listed type's served list, kept by
+ * the list page's rule for the package and its pair. `types` is `null` until
+ * the menu's data has settled, so the lists are read once, for the types the
+ * menu settled on. The read is keyed on the package and the type names, never
+ * on the identity of the `types` array (`ui/AGENTS.md` #10).
+ */
+function useStudioPaletteItems(
+ packageId: string | null,
+ types: readonly RichMetadataTypeEntry[] | null,
+): { items: StudioPaletteItem[]; loading: boolean } {
+ const client = useMetadataClient();
+ const key = packageId && types ? `${packageId}|${types.map((e) => e.type).join(',')}` : null;
+ const typesRef = React.useRef(types);
+ React.useLayoutEffect(() => {
+ typesRef.current = types;
+ });
+ const [read, setRead] = React.useState<{ key: string; items: StudioPaletteItem[] } | null>(null);
+ React.useEffect(() => {
+ const listed = typesRef.current;
+ if (!key || !packageId || !listed) return;
+ let cancelled = false;
+ const pairId = studioPalettePairId(packageId);
+ Promise.all(
+ listed
+ .filter((entry) => !STUDIO_PALETTE_ITEMLESS_TYPES.has(entry.type))
+ .map(async (entry) => {
+ const config = resolveResourceConfig(entry.type, entry);
+ try {
+ const rows = await client.list(
+ entry.type,
+ config.listInclude ? { include: config.listInclude } : undefined,
+ );
+ return studioPaletteItemsOf(entry.type, rows ?? [], {
+ packageId,
+ pairId,
+ primaryKey: config.primaryKey,
+ listFilter: config.listFilter,
+ });
+ } catch {
+ return [];
+ }
+ }),
+ ).then((lists) => {
+ if (!cancelled) setRead({ key, items: lists.flat() });
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [client, packageId, key]);
+ if (!packageId) return { items: [], loading: false };
+ if (!key || read?.key !== key) return { items: [], loading: true };
+ return { items: read.items, loading: false };
+}
+
+export interface StudioPaletteGroupsComponentProps extends StudioPaletteGroupsProps {
+ /** The `/studio/:segment` the palette is open on: a package id, `~org` or `~all`. */
+ segment: string;
+ /** The open package's name, as the header shows it; its `.custom` items are named "Customization of" it. */
+ packageLabel?: string;
+}
+
+export function StudioPaletteGroups({
+ segment,
+ packageLabel,
+ query,
+ open,
+ onLoadingChange,
+}: StudioPaletteGroupsComponentProps): React.ReactElement | null {
+ const locale = useMetadataLocale();
+ const { t: translate } = useObjectTranslation();
+ const scope = studioMenuScope(segment);
+ const packageId = scope.kind === 'package' ? scope.packageId : null;
+
+ // The left menu's own data, read once for the page (`StudioMenuDataProvider`).
+ const shared = useStudioMenuData();
+ const data = shared && shared.segment === segment ? shared : null;
+ const types = data?.types ?? [];
+ const settled = data?.settled ?? false;
+ const { items, loading: itemsLoading } = useStudioPaletteItems(packageId, settled ? types : null);
+
+ const loading = !settled || itemsLoading;
+ const onLoadingChangeRef = React.useRef(onLoadingChange);
+ React.useLayoutEffect(() => {
+ onLoadingChangeRef.current = onLoadingChange;
+ });
+ React.useEffect(() => {
+ onLoadingChangeRef.current(loading);
+ }, [loading]);
+ React.useEffect(() => () => onLoadingChangeRef.current(false), []);
+
+ if (!data) return null;
+
+ const served = new Map(types.map((e) => [e.type, e]));
+ const typeLabel = (type: string) =>
+ translateMetadataType(type, locale, (served.get(type) as { label?: string } | undefined)?.label);
+ const entryLabel = (entry: StudioMenuEntry) =>
+ entry.kind === 'type' ? typeLabel(entry.type ?? '') : t(STUDIO_MENU_ENTRY_LABEL_KEYS[entry.kind], locale);
+ const itemLabel = (item: StudioPaletteItem) =>
+ resolveKeyedI18nLabel(item.label as Parameters[0], translate) || item.name;
+ // ADR-0146 D3 — an item of the package's customization package is named as
+ // the list marks it, by the package's name, never by the pair's raw id.
+ const itemDetail = (item: StudioPaletteItem) =>
+ item.packageId === packageId
+ ? typeLabel(item.type)
+ : `${typeLabel(item.type)} · ${tFormat('engine.customizationMark.customizationOf', locale, {
+ baseName: packageLabel || packageId || '',
+ })}`;
+
+ const groups = buildStudioPaletteGroups(buildStudioMenu({ scope, types, counts: data.counts }), items);
+
+ return (
+ <>
+ {groups.map(({ group, entries: groupEntries, items: groupItems }) => {
+ const groupLabel = studioMenuGroupLabel(group, locale);
+ const shownEntries = groupEntries.filter((entry) =>
+ matchesPaletteQuery(query, [entryLabel(entry), entry.type, groupLabel]),
+ );
+ const shownItems = groupItems.filter((item) =>
+ matchesPaletteQuery(query, [itemLabel(item), item.name, typeLabel(item.type)]),
+ );
+ if (shownEntries.length === 0 && shownItems.length === 0) return null;
+ const ItemIcon = STUDIO_MENU_GROUP_ICONS[group];
+ return (
+
+ {shownEntries.map((entry) => {
+ const Icon = ENTRY_ICONS[entry.kind];
+ return (
+ open(entry.to)}
+ >
+
+ {entryLabel(entry)}
+ {entry.count !== undefined && (
+
+ {tFormat('engine.studio.menu.itemCount', locale, { count: entry.count })}
+
+ )}
+
+ );
+ })}
+ {shownItems.map((item) => (
+ open(studioPaletteItemAddress(segment, item))}
+ >
+
+ {itemLabel(item)}
+
+ {itemDetail(item)}
+
+
+ ))}
+
+ );
+ })}
+ >
+ );
+}
diff --git a/ui/packages/app-shell/src/views/studio-design/studioMenuData.ts b/ui/packages/app-shell/src/views/studio-design/studioMenuData.ts
new file mode 100644
index 00000000000..10fc1b1d116
--- /dev/null
+++ b/ui/packages/app-shell/src/views/studio-design/studioMenuData.ts
@@ -0,0 +1,101 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * Studio's left menu, its served data and its drawing vocabulary, shared by
+ * the menu (`StudioMenu.tsx`) and the command palette's Studio groups
+ * (`StudioPaletteGroups.tsx`, objectstack#36900), so the two draw the same
+ * types, icons and names and the page reads the data once.
+ */
+
+import * as React from 'react';
+import { Database, Layers, Settings, ShieldCheck, Sparkles, Workflow, type LucideIcon } from 'lucide-react';
+import {
+ useGlobalDiagnostics,
+ useMetadataClient,
+ useMetadataTypes,
+ type RichMetadataTypeEntry,
+} from '../metadata-admin/useMetadata.js';
+import { scopeDirectoryEntries } from '../metadata-admin/directoryScope.js';
+import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js';
+import {
+ STUDIO_MENU_DESIGNER_TYPES,
+ studioMenuScope,
+ type StudioMenuEntry,
+ type StudioMenuGroup,
+} from './studioMenuModel.js';
+
+/** Each group's icon: the menu's, and the palette's for the group's items (objectstack#36900). */
+export const STUDIO_MENU_GROUP_ICONS: Readonly> = {
+ data: Database,
+ ui: Layers,
+ automation: Workflow,
+ system: Settings,
+ security: ShieldCheck,
+ ai: Sparkles,
+};
+
+/** The names of the entries that are not a type; the palette names them the same way (objectstack#36900). */
+export const STUDIO_MENU_ENTRY_LABEL_KEYS: Readonly, string>> = {
+ orgFlows: 'engine.studio.menu.orgFlows',
+ owd: 'engine.studio.menu.owd',
+ diagnostics: 'engine.studio.menu.diagnostics',
+ environment: 'engine.studio.menu.environment',
+};
+
+/** The menu's served data, for one `/studio/:segment` (see {@link useStudioMenuTypes}). */
+export interface StudioMenuData {
+ /** The segment the data was read for. */
+ segment: string;
+ /** The served type entries the directory's rule scoped to this menu, in served order. */
+ types: RichMetadataTypeEntry[];
+ /** Each type's served item count; empty when the sweep did not say. */
+ counts: Readonly>;
+ /** Both reads have answered: the registry's types and the diagnostics sweep. */
+ settled: boolean;
+}
+
+/**
+ * The menu's served data: the registry's type entries, scoped by the
+ * directory's rule, and each type's item count from the diagnostics sweep the
+ * directory reads. Read again on the metadata-refresh pulse (a publish, a new
+ * item), so the counts follow.
+ */
+export function useStudioMenuTypes(segment: string): StudioMenuData {
+ const scope = studioMenuScope(segment);
+ const packageId = scope.kind === 'package' ? scope.packageId : null;
+ const client = useMetadataClient();
+ const { entries, loading: typesLoading } = useMetadataTypes(client);
+ const {
+ countsByType,
+ packagesByType,
+ loading: sweepLoading,
+ reload,
+ } = useGlobalDiagnostics(client, 'error', packageId ?? undefined);
+ const refresh = useMetadataRefreshNonce();
+ const reloadRef = React.useRef(reload);
+ React.useLayoutEffect(() => {
+ reloadRef.current = reload;
+ });
+ React.useEffect(() => {
+ if (refresh > 0) reloadRef.current();
+ }, [refresh]);
+ const types = scopeDirectoryEntries(entries, {
+ environment: scope.kind !== 'package',
+ packageId,
+ packagesByType,
+ always: STUDIO_MENU_DESIGNER_TYPES,
+ });
+ return { segment, types, counts: countsByType, settled: !typesLoading && !sweepLoading };
+}
+
+/**
+ * objectstack#36900 — the menu's data, read once for a whole Studio page: the
+ * surface provides it, and the menu and the command palette both draw from it,
+ * so opening the palette re-reads nothing the menu already holds.
+ */
+export const StudioMenuDataContext = React.createContext(null);
+
+/** The menu's data a `StudioMenuDataProvider` above holds, or `null` with none. */
+export function useStudioMenuData(): StudioMenuData | null {
+ return React.useContext(StudioMenuDataContext);
+}
diff --git a/ui/packages/app-shell/src/views/studio-design/studioPaletteModel-36900.test.ts b/ui/packages/app-shell/src/views/studio-design/studioPaletteModel-36900.test.ts
new file mode 100644
index 00000000000..3c27fa3164a
--- /dev/null
+++ b/ui/packages/app-shell/src/views/studio-design/studioPaletteModel-36900.test.ts
@@ -0,0 +1,222 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * objectstack#36900 — the command palette on a Studio design page, as data
+ * (`studioPaletteModel.ts`):
+ *
+ * 1. a package's items are its own and its `.custom` pair's, as its lists
+ * show them, named by the type's primary key;
+ * 2. an item opens through the one address builder: its pillar while one
+ * designs its type, else its area page on its owning package;
+ * 3. the groups are the left menu's, in its order, each with the items of
+ * the types it lists;
+ * 4. a pick leaves, re-enters the page open on another query, or stays;
+ * 5. leaving asks the shell's unsaved-edits seam (every registered editor,
+ * not only the surface's own work), and re-entering asks through the host.
+ */
+
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { registerUnsavedEdits } from '../../chrome/unsavedEdits';
+import { STUDIO_ITEM_PILLAR, studioItemPath, studioMetadataItemAddress } from './studioAddress';
+import { buildStudioMenu, studioMenuScope } from './studioMenuModel';
+import {
+ buildStudioPaletteGroups,
+ openStudioPaletteAddress,
+ studioPaletteDeparture,
+ studioPaletteItemAddress,
+ studioPaletteItemsOf,
+ studioPalettePairId,
+ studioSamePageSearch,
+} from './studioPaletteModel';
+
+const PKG = 'com.acme.crm';
+const PAIR = 'com.acme.crm.custom';
+
+describe("a package's palette lists its items and its pair's (ADR-0146 D3)", () => {
+ it('reads the package and its .custom pair; a pair has no pair of its own', () => {
+ expect(studioPalettePairId(PKG)).toBe(PAIR);
+ expect(studioPalettePairId(PAIR)).toBeNull();
+ });
+
+ it("keeps the two packages' rows, unwrapped, named by the type's key, once per name and package", () => {
+ const rows = [
+ { name: 'crm_account', label: 'Account', _packageId: PKG },
+ { item: { name: 'crm_lead', label: { key: 'crm.lead', defaultValue: 'Lead' }, _packageId: PAIR } },
+ { name: 'hr_employee', label: 'Employee', _packageId: 'com.acme.hr' },
+ { name: 'loose_thing', label: 'Loose' },
+ { name: '', _packageId: PKG },
+ { name: 'crm_account', label: 'Account (member)', _packageId: PKG },
+ null,
+ ];
+ expect(studioPaletteItemsOf('object', rows, { packageId: PKG, pairId: PAIR })).toEqual([
+ { type: 'object', name: 'crm_account', label: 'Account', packageId: PKG },
+ { type: 'object', name: 'crm_lead', label: { key: 'crm.lead', defaultValue: 'Lead' }, packageId: PAIR },
+ ]);
+ });
+
+ it("applies the type's list predicate and primary key", () => {
+ const rows = [
+ { id: 'welcome', name: 'ignored', _packageId: PKG },
+ { id: 'hidden', _packageId: PKG, container: true },
+ ];
+ expect(
+ studioPaletteItemsOf('email_template', rows, {
+ packageId: PKG,
+ pairId: null,
+ primaryKey: 'id',
+ listFilter: (item) => item.container !== true,
+ }).map((i) => i.name),
+ ).toEqual(['welcome']);
+ });
+});
+
+describe('an item opens through the one address builder (#36895)', () => {
+ it('opens a type a pillar designs in that pillar, as studioItemPath does', () => {
+ for (const type of Object.keys(STUDIO_ITEM_PILLAR)) {
+ expect(studioPaletteItemAddress(PKG, { type, name: 'x', packageId: PAIR })).toBe(studioItemPath(PKG, type, 'x'));
+ }
+ expect(studioPaletteItemAddress(PKG, { type: 'object', name: 'crm_account', packageId: PKG })).toBe(
+ '/studio/com.acme.crm/data?surface=object%3Acrm_account',
+ );
+ });
+
+ it('opens any other type on its area page, scoped to the package that owns it, as its list row links it', () => {
+ expect(studioPaletteItemAddress(PKG, { type: 'hook', name: 'on_lead', packageId: PAIR })).toBe(
+ studioMetadataItemAddress(PKG, 'hook', 'on_lead', { query: `package=${encodeURIComponent(PAIR)}` }),
+ );
+ expect(studioPaletteItemAddress(PKG, { type: 'dashboard', name: 'pipeline', packageId: PKG })).toBe(
+ '/studio/com.acme.crm/metadata/dashboard/pipeline?package=com.acme.crm',
+ );
+ });
+});
+
+describe("the palette's groups are the left menu's (decision 11)", () => {
+ const menu = buildStudioMenu({
+ scope: studioMenuScope(PKG),
+ types: [
+ { type: 'object', domain: 'data' },
+ { type: 'hook', domain: 'data' },
+ { type: 'dashboard', domain: 'ui' },
+ { type: 'flow', domain: 'automation' },
+ { type: 'permission', domain: 'security' },
+ { type: 'agent', domain: 'ai' },
+ ],
+ counts: {},
+ });
+
+ it("keeps the menu's six groups in order, with the menu's own entries, and puts each item under its type's group", () => {
+ const groups = buildStudioPaletteGroups(menu, [
+ { type: 'flow', name: 'onboard', label: 'Onboard', packageId: PKG },
+ { type: 'object', name: 'crm_account', label: 'Account', packageId: PKG },
+ { type: 'dashboard', name: 'pipeline', label: 'Pipeline', packageId: PKG },
+ { type: 'permission', name: 'sales_rep', label: 'Sales Rep', packageId: PAIR },
+ { type: 'hook', name: 'on_lead', label: 'On lead', packageId: PKG },
+ ]);
+ expect(groups.map((g) => g.group)).toEqual(['data', 'ui', 'automation', 'system', 'security', 'ai']);
+ expect(groups.map((g) => g.entries.map((e) => e.key))).toEqual(menu.map((g) => g.entries.map((e) => e.key)));
+ expect(groups.map((g) => g.items.map((i) => i.name))).toEqual([
+ ['crm_account', 'on_lead'],
+ ['pipeline'],
+ ['onboard'],
+ [],
+ ['sales_rep'],
+ [],
+ ]);
+ });
+
+ it('lists no item whose type the menu does not list', () => {
+ const groups = buildStudioPaletteGroups(menu, [{ type: 'translation', name: 'zh', label: 'zh', packageId: PKG }]);
+ expect(groups.flatMap((g) => g.items)).toEqual([]);
+ });
+});
+
+describe('a pick leaves, re-enters or stays, as a menu entry does (decision 12)', () => {
+ const at = { pathname: '/studio/com.acme.crm/access', search: '?surface=permission%3Asales_rep&palette=1' };
+
+ it('leaves for another page', () => {
+ expect(studioPaletteDeparture('/studio/com.acme.crm/data?surface=object%3Acrm_account', at)).toBe('leave');
+ });
+
+ it('re-enters the page open on another query', () => {
+ expect(studioPaletteDeparture('/studio/com.acme.crm/access?surface=owd%3Aoverview', at)).toBe('reenter');
+ });
+
+ it("stays on the page already shown, the palette's own keys and the order aside", () => {
+ expect(studioPaletteDeparture('/studio/com.acme.crm/access?surface=permission%3Asales_rep', at)).toBe('stay');
+ expect(
+ studioPaletteDeparture('/studio/x/metadata/hook?package=x&sort=name', {
+ pathname: '/studio/x/metadata/hook',
+ search: '?cmdk=1&sort=name&package=x',
+ }),
+ ).toBe('stay');
+ expect(studioPaletteDeparture('/studio/x/data', { pathname: '/studio/x/data', search: '?palette=1' })).toBe('stay');
+ });
+});
+
+describe('a pick leaves through the shell seam, and re-enters through the host (objectstack#36900 M1)', () => {
+ const at = { pathname: '/studio/com.acme.crm/metadata/hook/on_lead', search: '?package=com.acme.crm&palette=1' };
+ let release: (() => void) | null = null;
+ afterEach(() => {
+ release?.();
+ release = null;
+ vi.unstubAllGlobals();
+ });
+
+ /** This project has no DOM: the seam's `window` and `document`, with `confirm` as the test answers it. */
+ function stubBrowser(confirm: (message?: string) => boolean) {
+ const listeners = { addEventListener: () => {}, removeEventListener: () => {} };
+ vi.stubGlobal('window', { ...listeners, confirm });
+ vi.stubGlobal('document', listeners);
+ }
+
+ it('with an editor registered (the item page), leaving asks its question: Cancel stays, OK goes', () => {
+ const confirm = vi.fn((_message?: string) => false);
+ stubBrowser(confirm);
+ release = registerUnsavedEdits('Discard the item page edits?');
+ const navigate = vi.fn();
+ const reenter = vi.fn(() => true);
+
+ openStudioPaletteAddress('/studio/com.acme.crm/data?surface=object%3Acrm_account', at, { navigate, reenter });
+ expect(confirm).toHaveBeenCalledWith('Discard the item page edits?');
+ expect(navigate).not.toHaveBeenCalled();
+
+ confirm.mockReturnValue(true);
+ openStudioPaletteAddress('/studio/com.acme.crm/data?surface=object%3Acrm_account', at, { navigate, reenter });
+ expect(navigate).toHaveBeenCalledWith('/studio/com.acme.crm/data?surface=object%3Acrm_account');
+ expect(reenter).not.toHaveBeenCalled();
+ });
+
+ it('CONTROL — with nothing registered, leaving goes at once and asks nothing', () => {
+ const confirm = vi.fn((_message?: string) => false);
+ stubBrowser(confirm);
+ const navigate = vi.fn();
+ openStudioPaletteAddress('/studio/com.acme.crm/data', at, { navigate, reenter: () => true });
+ expect(confirm).not.toHaveBeenCalled();
+ expect(navigate).toHaveBeenCalledWith('/studio/com.acme.crm/data');
+ });
+
+ it('re-entering hands the host the query it must wait for, and goes only on its yes', () => {
+ const navigate = vi.fn();
+ const reenter = vi.fn(() => false);
+ const to = '/studio/com.acme.crm/metadata/hook/on_lead?package=com.acme.crm&sort=name';
+ openStudioPaletteAddress(to, at, { navigate, reenter });
+ expect(reenter).toHaveBeenCalledWith('?package=com.acme.crm&sort=name');
+ expect(navigate).not.toHaveBeenCalled();
+ reenter.mockReturnValue(true);
+ openStudioPaletteAddress(to, at, { navigate, reenter });
+ expect(navigate).toHaveBeenCalledWith(to);
+ });
+
+ it('the page already shown neither asks nor goes', () => {
+ const navigate = vi.fn();
+ const reenter = vi.fn(() => true);
+ openStudioPaletteAddress('/studio/com.acme.crm/metadata/hook/on_lead?package=com.acme.crm', at, { navigate, reenter });
+ expect(navigate).not.toHaveBeenCalled();
+ expect(reenter).not.toHaveBeenCalled();
+ });
+
+ it("the re-entry's query matches the router's once the palette's own key is gone, in any order", () => {
+ expect(studioSamePageSearch('?b=2&a=1&palette=1', '?a=1&b=2')).toBe(true);
+ expect(studioSamePageSearch('?surface=owd%3Aoverview', '?surface=permission%3Asales_rep')).toBe(false);
+ });
+});
diff --git a/ui/packages/app-shell/src/views/studio-design/studioPaletteModel.ts b/ui/packages/app-shell/src/views/studio-design/studioPaletteModel.ts
new file mode 100644
index 00000000000..120ab2ef967
--- /dev/null
+++ b/ui/packages/app-shell/src/views/studio-design/studioPaletteModel.ts
@@ -0,0 +1,208 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * The command palette on a Studio design page, as data (objectstack#36900;
+ * decision 7 of the Studio redesign epic #36890: an author switches items by
+ * × back to the list, by ‹ ›, or by ⌘K). Pure, so the rules are pinned without
+ * a render; `StudioPaletteGroups.tsx` draws it inside the palette.
+ *
+ * ## What it lists
+ *
+ * The left menu's groups, in the menu's order (`buildStudioMenu`, decision
+ * 11), each holding:
+ * - the menu's own entries of that group — a type's list, the organization's
+ * flows, the default sharing overview, diagnostics, the environment
+ * catalog — each opening where the menu entry opens;
+ * - on a package, the items of every type the group lists, read from the
+ * package and its `.custom` pair together (ADR-0146 D3, "on top, one
+ * surface"), as the type's list shows them.
+ *
+ * ## Where an item opens
+ *
+ * Through the one Studio address builder (`studioAddress.ts`, #36895), never a
+ * hand-built path: a type a pillar still designs opens that pillar through
+ * {@link studioItemPath}, and every other type opens its page in the "All
+ * metadata" area with the owning package on `?package=`, the address the
+ * type's list links the row to (ADR-0048). A designer card that moves its type
+ * to a full-screen page deletes the type's `STUDIO_ITEM_PILLAR` row, and the
+ * palette follows with no edit here.
+ */
+
+import { customizationPackageId } from '@objectstack/spec/kernel';
+import { COMMAND_PALETTE_PARAM } from '../../urlParams.js';
+import { confirmUnsavedLeave } from '../../chrome/unsavedEdits.js';
+import { scopeListRows } from '../metadata-admin/metadataListState.js';
+import { studioItemPath, studioItemPillar, studioMetadataItemAddress } from './studioAddress.js';
+import type { StudioMenuEntry, StudioMenuGroup, StudioMenuGroupModel } from './studioMenuModel.js';
+
+/** One item a package's palette lists. */
+export interface StudioPaletteItem {
+ type: string;
+ /** Its primary key: the name its list links it by. */
+ name: string;
+ /** The label as served: a string, or an i18n-keyed label the palette resolves. */
+ label: unknown;
+ /** The package that owns it: the open package, or its `.custom` pair. */
+ packageId: string;
+}
+
+/** One group of the palette: the menu's entries of the group, then its items. */
+export interface StudioPaletteGroup {
+ group: StudioMenuGroup;
+ entries: StudioMenuEntry[];
+ items: StudioPaletteItem[];
+}
+
+/**
+ * The types a package's palette reads no item of: a datasource is Setup's
+ * runtime configuration (ADR-0146 D1), so the menu's entry for it already
+ * leaves Studio and its items have no Studio page.
+ */
+export const STUDIO_PALETTE_ITEMLESS_TYPES: ReadonlySet = new Set(['datasource']);
+
+/** A package's `.custom` pair, whose items its palette also lists, or `null` when it has none. */
+export function studioPalettePairId(packageId: string): string | null {
+ const pair = customizationPackageId(packageId);
+ return pair.ok ? pair.value : null;
+}
+
+/**
+ * The items of one type a package's palette lists, from that type's served
+ * list read: the rows the type's list page holds for the package
+ * (`scopeListRows`, the page's own rule: the package and its pair, through the
+ * type's list predicate), each named by the type's primary key, as the list
+ * page names its rows. A row with no name is not listed; one name a package
+ * serves twice (two members of a bundle) is listed once, as ‹ › step through
+ * it.
+ */
+export function studioPaletteItemsOf(
+ type: string,
+ served: readonly unknown[],
+ options: {
+ packageId: string;
+ pairId: string | null;
+ primaryKey?: string;
+ listFilter?: (item: Record) => boolean;
+ },
+): StudioPaletteItem[] {
+ const key = options.primaryKey ?? 'name';
+ // A row may come wrapped as `{ item }`, as the list page unwraps it.
+ const rows = served.flatMap((raw) => {
+ const item = raw && typeof raw === 'object' && 'item' in raw ? (raw as { item: unknown }).item : raw;
+ return item && typeof item === 'object' ? [{ item: item as Record }] : [];
+ });
+ const scoped = scopeListRows(rows, {
+ listFilter: options.listFilter,
+ unscoped: false,
+ activePackage: options.packageId,
+ pairId: options.pairId,
+ });
+ const seen = new Set();
+ const items: StudioPaletteItem[] = [];
+ for (const { item } of scoped) {
+ const packageId = item._packageId as string;
+ const name = item[key];
+ if (typeof name !== 'string' || name === '') continue;
+ // A package id never holds `|`, so the pair is one key.
+ const id = `${packageId}|${name}`;
+ if (seen.has(id)) continue;
+ seen.add(id);
+ items.push({ type, name, label: item.label, packageId });
+ }
+ return items;
+}
+
+/**
+ * Where an item the palette lists opens, from the `/studio/:segment` it was
+ * listed on: its pillar while one designs its type, else its page in the
+ * area, scoped to the package that owns it.
+ */
+export function studioPaletteItemAddress(segment: string, item: Pick): string {
+ if (studioItemPillar(item.type)) return studioItemPath(segment, item.type, item.name);
+ return studioMetadataItemAddress(segment, item.type, item.name, {
+ query: `package=${encodeURIComponent(item.packageId)}`,
+ });
+}
+
+/**
+ * The palette's groups: the menu's groups in its order, each with the items
+ * of the types it lists. An item whose type has no entry in the menu is not
+ * listed: the palette lists what the menu does, and nothing beside it.
+ */
+export function buildStudioPaletteGroups(
+ menu: readonly StudioMenuGroupModel[],
+ items: readonly StudioPaletteItem[],
+): StudioPaletteGroup[] {
+ const groupOfType = new Map();
+ for (const { group, entries } of menu) {
+ for (const entry of entries) if (entry.kind === 'type' && entry.type) groupOfType.set(entry.type, group);
+ }
+ const itemsOf = new Map(menu.map(({ group }) => [group, []]));
+ for (const item of items) {
+ const group = groupOfType.get(item.type);
+ if (group) itemsOf.get(group)!.push(item);
+ }
+ return menu.map(({ group, entries }) => ({ group, entries, items: itemsOf.get(group)! }));
+}
+
+/**
+ * The palette overlay's own query keys: `CommandPaletteProvider` opens it on
+ * `?palette=` and reads the alias `?cmdk=`. Neither is part of a page's query.
+ */
+const PALETTE_QUERY_KEYS: readonly string[] = [COMMAND_PALETTE_PARAM, 'cmdk'];
+
+function pageQuery(query: string): string {
+ const params = new URLSearchParams(query);
+ for (const key of PALETTE_QUERY_KEYS) params.delete(key);
+ params.sort();
+ return params.toString();
+}
+
+/**
+ * What opening `to` from the palette does on the page at `pathname` +
+ * `search` (`search` with its `?`), the way the left menu's entries leave:
+ * - `'leave'`: another page; the surface asks about unsaved work, then goes;
+ * - `'reenter'`: the page already open on another query (the Access pillar
+ * on the default sharing overview); a pillar reads its deep link once, at
+ * mount, so the surface asks, then remounts it on the new query;
+ * - `'stay'`: the page already shown, the palette's own keys aside; nothing
+ * to open, nothing to ask.
+ */
+export function studioPaletteDeparture(
+ to: string,
+ at: { pathname: string; search: string },
+): 'leave' | 'reenter' | 'stay' {
+ const cut = to.indexOf('?');
+ const path = cut < 0 ? to : to.slice(0, cut);
+ if (path !== at.pathname) return 'leave';
+ return pageQuery(cut < 0 ? '' : to.slice(cut + 1)) === pageQuery(at.search) ? 'stay' : 'reenter';
+}
+
+/** Whether two searches (`?` optional) name the same page, the palette's own keys and the order aside. */
+export function studioSamePageSearch(a: string, b: string): boolean {
+ return pageQuery(a) === pageQuery(b);
+}
+
+/**
+ * Opens `to`, picked in the palette on the page at `at`, the way a menu entry
+ * leaves (decision 12 of the Studio redesign): another page asks the shell's
+ * unsaved-edits seam first (`confirmUnsavedLeave`: the open page's own edits
+ * and every editor below it that registered, the "All metadata" item page
+ * among them), then goes; the page already open on another query asks through
+ * the host's `reenter` (which remounts the page once the router shows that
+ * query), then goes; the page already shown stays.
+ */
+export function openStudioPaletteAddress(
+ to: string,
+ at: { pathname: string; search: string },
+ act: { navigate: (to: string) => void; reenter: (search: string) => boolean },
+): void {
+ const departure = studioPaletteDeparture(to, at);
+ if (departure === 'stay') return;
+ if (departure === 'leave') {
+ confirmUnsavedLeave(() => act.navigate(to));
+ return;
+ }
+ const cut = to.indexOf('?');
+ if (act.reenter(cut < 0 ? '' : to.slice(cut))) act.navigate(to);
+}