From 208afdc4d38ea6655971903c38a40905189b18d1 Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 24 Nov 2026 17:48:09 +0000
Subject: [PATCH 01/12] feat(studio): mount the command palette on every Studio
design page with the menu's groups
Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H
Co-authored-by: Claude
---
.../app-shell/src/chrome/CommandPalette.tsx | 74 ++++-
.../studio-design/StudioDesignSurface.tsx | 57 ++++
.../studio-design/StudioPaletteGroups.tsx | 257 ++++++++++++++++++
.../views/studio-design/studioPaletteModel.ts | 138 ++++++++++
4 files changed, 517 insertions(+), 9 deletions(-)
create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
create mode 100644 ui/packages/app-shell/src/views/studio-design/studioPaletteModel.ts
diff --git a/ui/packages/app-shell/src/chrome/CommandPalette.tsx b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
index 3096d971246..f91cc64348d 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,44 @@ 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
+ * about its unsaved work, and re-enters itself when the address is the page
+ * already open on another query.
+ */
+ open: (to: string) => void;
}
type CommandPaletteProps = AppCommandPaletteProps | StudioCommandPaletteProps;
@@ -372,8 +413,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 +633,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 +826,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
kind="studio-package"
entry={entry}
Icon={Boxes}
- onOpen={() => leaveTo(entry.href)}
+ onOpen={() => openStudio(entry.href)}
/>
))}
@@ -788,7 +839,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
kind="studio-object"
entry={entry}
Icon={Database}
- onOpen={() => leaveTo(entry.href)}
+ onOpen={() => openStudio(entry.href)}
/>
))}
@@ -801,7 +852,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
kind="studio-flow"
entry={entry}
Icon={Workflow}
- onOpen={() => leaveTo(entry.href)}
+ onOpen={() => openStudio(entry.href)}
/>
))}
@@ -1056,8 +1107,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 +1137,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/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx
index 4051b0f6fa9..763cc13810c 100644
--- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx
+++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx
@@ -143,6 +143,10 @@ 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 { CommandPalette, type StudioPaletteSurface } from '../../chrome/CommandPalette.js';
+import { CommandPaletteProvider } from '../../context/CommandPaletteProvider.js';
+import { COMMAND_PALETTE_PARAM } from '../../urlParams.js';
+import { StudioPaletteGroups } from './StudioPaletteGroups.js';
import { CreateItemDialog } from './CreateItemDialog.js';
// objectui#11787 — the shared draft autosave, moved to its own module unchanged.
import {
@@ -1237,6 +1241,39 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re
// 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) => {
+ const [path, query = ''] = to.split('?');
+ if (path !== currentPathname) {
+ if (confirmLeavePillar()) shellNavigate(to);
+ return;
+ }
+ if (samePageQuery(query, currentSearch)) return;
+ if (reenterPillar()) shellNavigate(to);
+ },
+ [currentPathname, currentSearch, confirmLeavePillar, reenterPillar, shellNavigate],
+ );
+ const paletteSurface = React.useMemo(
+ () =>
+ showMenu
+ ? {
+ packageScope: packageId !== null,
+ renderGroups: (groupsProps) => ,
+ open: openFromPalette,
+ }
+ : undefined,
+ [showMenu, packageId, scopeSegment, openFromPalette],
+ );
+
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 +306,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
index 635a95b210e..f9443f067ae 100644
--- 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
@@ -7,14 +7,16 @@
*
* 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; every package's objects and flows
+ * 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. Nothing is read until the palette opens. CONTROL: opened, it reads.
+ * 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.
*
@@ -40,16 +42,21 @@ const reads = vi.hoisted(() => {
{ 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 }],
+ 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[], hold: null as Promise | null };
+ const state = { calls: [] as string[], options: {} as Record, hold: null as Promise | null };
const client = {
- list: async (type: string) => {
+ list: async (type: string, options?: unknown) => {
state.calls.push(type);
+ state.options[type] = options;
if (state.hold) await state.hold;
return LISTS[type] ?? [];
},
@@ -97,11 +104,21 @@ 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 { translateMetadataType } from '../metadata-admin/i18n';
+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[] = [];
@@ -133,6 +150,7 @@ 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')) {
@@ -162,7 +180,7 @@ function mount(segment: string, opts: { at?: string; packageScope?: boolean } =
const open = vi.fn();
const surface: StudioPaletteSurface = {
packageScope: opts.packageScope ?? true,
- renderGroups: (props) => ,
+ renderGroups: (props) => ,
open,
};
render(
@@ -170,7 +188,9 @@ function mount(segment: string, opts: { at?: string; packageScope?: boolean } =
-
+
+
+
@@ -243,21 +263,26 @@ describe("on a package, the palette lists the left menu and the package's items
`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, its type on the right, and the pair beside the type', async () => {
+ 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')} · ${PAIR}`,
+ `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. */
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
index 57c7eaaf389..9765591031a 100644
--- a/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
+++ b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
@@ -7,16 +7,17 @@
* What it lists and where each entry opens is `studioPaletteModel.ts`; this
* file reads it and draws it inside the palette.
*
- * ## Read only while the palette is open
+ * ## What it reads, and when
*
- * The palette mounts this component inside its open dialog, so nothing here
- * is read on a page where ⌘K is never pressed. It reads what the left menu
- * reads, with the same rule (`scopeDirectoryEntries` over the registry's type
- * entries and the diagnostics sweep), so the palette and the menu never
- * disagree on which types a package holds; then, on a package, each of those
- * types' served list, the read the type's own list page makes. 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.
+ * 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
*
@@ -27,62 +28,28 @@
*/
import * as React from 'react';
-import {
- Activity,
- Building2,
- Database,
- KeyRound,
- Layers,
- List,
- Settings,
- Share2,
- ShieldCheck,
- Sparkles,
- Workflow,
- type LucideIcon,
-} from 'lucide-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 { scopeDirectoryEntries } from '../metadata-admin/directoryScope.js';
import { t, tFormat, translateMetadataType, useMetadataLocale } from '../metadata-admin/i18n.js';
import { resolveResourceConfig } from '../metadata-admin/registry.js';
-import {
- useGlobalDiagnostics,
- useMetadataClient,
- useMetadataTypes,
- type RichMetadataTypeEntry,
-} from '../metadata-admin/useMetadata.js';
+import { useMetadataClient, type RichMetadataTypeEntry } from '../metadata-admin/useMetadata.js';
+import { STUDIO_MENU_ENTRY_LABEL_KEYS, STUDIO_MENU_GROUP_ICONS, useStudioMenuData } from './StudioMenu.js';
import { studioMenuGroupLabel } from './studioMenuGroupLabel.js';
-import {
- STUDIO_MENU_DESIGNER_TYPES,
- buildStudioMenu,
- studioMenuScope,
- type StudioMenuEntry,
- type StudioMenuGroup,
-} from './studioMenuModel.js';
+import { buildStudioMenu, studioMenuScope, type StudioMenuEntry } from './studioMenuModel.js';
import {
STUDIO_PALETTE_ITEMLESS_TYPES,
buildStudioPaletteGroups,
studioPaletteItemAddress,
studioPaletteItemsOf,
- studioPalettePackages,
+ studioPalettePairId,
type StudioPaletteItem,
} from './studioPaletteModel.js';
-/** The icon an item of each group draws, the menu's group icon. */
-const GROUP_ICONS: Record = {
- data: Database,
- ui: Layers,
- automation: Workflow,
- system: Settings,
- security: ShieldCheck,
- ai: Sparkles,
-};
-
-/** The icon each menu entry draws: a type's list, or the page it opens. */
+/** 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,
@@ -91,26 +58,18 @@ const ENTRY_ICONS: Record = {
environment: KeyRound,
};
-/** The menu's own names of the entries that are not a type (`StudioMenu.tsx` names them so). */
-const ENTRY_LABEL_KEYS: Record, string> = {
- orgFlows: 'engine.studio.menu.orgFlows',
- owd: 'engine.studio.menu.owd',
- diagnostics: 'engine.studio.menu.diagnostics',
- environment: 'engine.studio.menu.environment',
-};
-
/**
- * The items of a package's palette: each listed type's served list, scoped to
- * the package and its pair. `types` is `null` until the menu's rule has
- * answered, 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 memoised `types` (`ui/AGENTS.md` #10).
+ * 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(
- client: ReturnType,
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(() => {
@@ -121,16 +80,20 @@ function useStudioPaletteItems(
const listed = typesRef.current;
if (!key || !packageId || !listed) return;
let cancelled = false;
- const packages = studioPalettePackages(packageId);
+ 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);
+ const rows = await client.list(
+ entry.type,
+ config.listInclude ? { include: config.listInclude } : undefined,
+ );
return studioPaletteItemsOf(entry.type, rows ?? [], {
- packages,
+ packageId,
+ pairId,
primaryKey: config.primaryKey,
listFilter: config.listFilter,
});
@@ -153,36 +116,28 @@ function useStudioPaletteItems(
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 {
+}: StudioPaletteGroupsComponentProps): React.ReactElement | null {
const locale = useMetadataLocale();
const { t: translate } = useObjectTranslation();
const scope = studioMenuScope(segment);
const packageId = scope.kind === 'package' ? scope.packageId : null;
- const environment = scope.kind !== 'package';
- // The left menu's reads and rule (`StudioMenu.tsx`), so the two agree.
- const client = useMetadataClient();
- const { entries, loading: typesLoading } = useMetadataTypes(client);
- const { countsByType, packagesByType, loading: sweepLoading } = useGlobalDiagnostics(
- client,
- 'error',
- packageId ?? undefined,
- );
- const types = scopeDirectoryEntries(entries, {
- environment,
- packageId,
- packagesByType,
- always: STUDIO_MENU_DESIGNER_TYPES,
- });
- const settled = !typesLoading && !sweepLoading;
- const { items, loading: itemsLoading } = useStudioPaletteItems(client, packageId, settled ? types : 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);
@@ -194,15 +149,25 @@ export function StudioPaletteGroups({
}, [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(ENTRY_LABEL_KEYS[entry.kind], locale);
+ 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: countsByType }), items);
+ const groups = buildStudioPaletteGroups(buildStudioMenu({ scope, types, counts: data.counts }), items);
return (
<>
@@ -215,7 +180,7 @@ export function StudioPaletteGroups({
matchesPaletteQuery(query, [itemLabel(item), item.name, typeLabel(item.type)]),
);
if (shownEntries.length === 0 && shownItems.length === 0) return null;
- const ItemIcon = GROUP_ICONS[group];
+ const ItemIcon = STUDIO_MENU_GROUP_ICONS[group];
return (
{shownEntries.map((entry) => {
@@ -247,7 +212,7 @@ export function StudioPaletteGroups({
{itemLabel(item)}
- {item.packageId === packageId ? typeLabel(item.type) : `${typeLabel(item.type)} · ${item.packageId}`}
+ {itemDetail(item)}
))}
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
index 6456a15a62e..3c27fa3164a 100644
--- 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
@@ -10,26 +10,32 @@
* 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.
+ * 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 { describe, expect, it } from 'vitest';
+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,
- studioPalettePackages,
+ 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', () => {
- expect(studioPalettePackages(PKG)).toEqual([PKG, PAIR]);
+ 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", () => {
@@ -42,7 +48,7 @@ describe("a package's palette lists its items and its pair's (ADR-0146 D3)", ()
{ name: 'crm_account', label: 'Account (member)', _packageId: PKG },
null,
];
- expect(studioPaletteItemsOf('object', rows, { packages: [PKG, PAIR] })).toEqual([
+ 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 },
]);
@@ -55,7 +61,8 @@ describe("a package's palette lists its items and its pair's (ADR-0146 D3)", ()
];
expect(
studioPaletteItemsOf('email_template', rows, {
- packages: [PKG],
+ packageId: PKG,
+ pairId: null,
primaryKey: 'id',
listFilter: (item) => item.container !== true,
}).map((i) => i.name),
@@ -145,3 +152,71 @@ describe('a pick leaves, re-enters or stays, as a menu entry does (decision 12)'
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
index 5af96f9c87d..120ab2ef967 100644
--- a/ui/packages/app-shell/src/views/studio-design/studioPaletteModel.ts
+++ b/ui/packages/app-shell/src/views/studio-design/studioPaletteModel.ts
@@ -30,6 +30,8 @@
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';
@@ -58,42 +60,47 @@ export interface StudioPaletteGroup {
*/
export const STUDIO_PALETTE_ITEMLESS_TYPES: ReadonlySet = new Set(['datasource']);
-/** The packages whose items one package's palette lists: the package, and its `.custom` pair when it has one. */
-export function studioPalettePackages(packageId: string): string[] {
+/** 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 ? [packageId, pair.value] : [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 open package and its pair own (`_packageId`), kept
- * by the type's own list predicate when it has one, 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.
+ * 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,
- rows: readonly unknown[],
+ served: readonly unknown[],
options: {
- packages: readonly string[];
+ 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 raw of rows) {
- // A row may come wrapped as `{ item }`, as the list page unwraps it.
- const item = (raw && typeof raw === 'object' && 'item' in raw ? (raw as { item: unknown }).item : raw) as
- | Record
- | null
- | undefined;
- if (!item || typeof item !== 'object') continue;
- const packageId = item._packageId;
- if (typeof packageId !== 'string' || !options.packages.includes(packageId)) continue;
- if (options.listFilter && !options.listFilter(item)) continue;
+ 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.
@@ -170,3 +177,32 @@ export function studioPaletteDeparture(
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);
+}
From 7c902cbc02ea7190a6c94a6d97374f2b8e897d94 Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 24 Nov 2026 21:03:14 +0000
Subject: [PATCH 08/12] docs(studio): document the palette's surface prop;
write the changeset in product terms
Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H
Co-authored-by: Claude
---
.changeset/36900-studio-cmdk.md | 13 ++++----
ui/packages/app-shell/README.md | 31 ++++++++++++++++---
.../app-shell/src/chrome/CommandPalette.tsx | 5 +--
3 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/.changeset/36900-studio-cmdk.md b/.changeset/36900-studio-cmdk.md
index 4f3419db932..58e0cef1e26 100644
--- a/.changeset/36900-studio-cmdk.md
+++ b/.changeset/36900-studio-cmdk.md
@@ -8,10 +8,11 @@ feat(studio): ⌘K on every Studio design page lists the package's whole menu an
Clause-②: no
Metadata-protocol: none
-Studio redesign decision 7 (switch items by ×, ‹ › and ⌘K) · #36900, part of #36890.
+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**: a package's pillars and "All metadata" area, the package-less flows (`~org`) and the cross-package leg (`~all`). Since the left menu replaced the top pillar nav, only the `/studio` landing had a palette, so `~all` 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, read from the package and its `.custom` pair together. Each item shows its type on the right, and a `.custom` item names that package too. The packages stay listed, so another package is one pick away. Every package's objects and flows are no longer listed there: the package's own items replace them. `~org` and `~all` keep those lists and add their own menu entries.
-- **What the palette opens comes from the one Studio address builder**: an object, a flow or a permission set opens in its designer, and any other item opens its page in the "All metadata" area on its owning package (`?package=`), the address its list row links to. A menu entry goes where the menu entry goes.
-- **It leaves the way the menu does.** With unsaved work on the page it asks first. A pick that is the page already open on another query (Default sharing, from the Access pillar) reopens that page on the new query. 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…". Nothing is read until the palette opens.
+- **⌘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/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 f91cc64348d..f6ac95f3f48 100644
--- a/ui/packages/app-shell/src/chrome/CommandPalette.tsx
+++ b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
@@ -160,8 +160,9 @@ export interface StudioPaletteSurface {
renderGroups: (props: StudioPaletteGroupsProps) => ReactNode;
/**
* Opens a Studio address the palette picked, after it closes: the page asks
- * about its unsaved work, and re-enters itself when the address is the page
- * already open on another query.
+ * 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;
}
From 840d86bfd4f1fb390be5b9afd25770851414b831 Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 24 Nov 2026 21:42:02 +0000
Subject: [PATCH 09/12] fix(studio): select the first palette row when a design
page's items arrive after the query; share the menu vocabulary from
studioMenuData.ts; Escape a dialog took leaves fullscreen alone
Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H
Co-authored-by: Claude
---
.../app-shell/src/chrome/CommandPalette.tsx | 17 ++-
.../src/views/studio-design/StudioMenu.tsx | 92 ++--------------
...oPaletteGroups.surfaceScope-36900.test.tsx | 19 ++++
.../studio-design/StudioPaletteGroups.tsx | 2 +-
.../src/views/studio-design/studioMenuData.ts | 101 ++++++++++++++++++
5 files changed, 144 insertions(+), 87 deletions(-)
create mode 100644 ui/packages/app-shell/src/views/studio-design/studioMenuData.ts
diff --git a/ui/packages/app-shell/src/chrome/CommandPalette.tsx b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
index f6ac95f3f48..afd8012a548 100644
--- a/ui/packages/app-shell/src/chrome/CommandPalette.tsx
+++ b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
@@ -24,7 +24,7 @@
* next open draws a fresh palette (objectui#13387).
*/
-import { useEffect, useState, useMemo, type ReactNode } from 'react';
+import { useEffect, useLayoutEffect, useRef, useState, useMemo, type ReactNode } from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
import {
Command,
@@ -423,6 +423,19 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
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);
+ // objectstack#36900 — a design page's items answer after the palette opens,
+ // often after the author has typed. cmdk selects a first row only when one
+ // mounts while it holds no value, and the value it holds is the row the
+ // query filtered away, so the rows that arrive later stayed unselected and
+ // Enter opened nothing. While no rendered row is selected, the first one is.
+ const listRef = useRef(null);
+ useLayoutEffect(() => {
+ if (!open || !surface) return;
+ const list = listRef.current;
+ if (!list || list.querySelector('[cmdk-item][data-selected="true"]')) return;
+ const first = list.querySelector('[cmdk-item]:not([aria-disabled="true"])')?.getAttribute('data-value');
+ if (first) setSelectedValue(first);
+ });
const studioPackages = studio.packages.filter(studioMatches);
const studioObjects = studio.objects.filter(studioMatches);
const studioFlows = studio.flows.filter(studioMatches);
@@ -632,7 +645,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
value={inputValue}
onValueChange={setInputValue}
/>
-
+
{isSearching || studio.loading || surfaceLoading ? (
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx
index 5366c6040b6..bac969b96da 100644
--- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx
+++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx
@@ -20,7 +20,7 @@
import * as React from 'react';
import { Link, useLocation } from 'react-router-dom';
-import { Database, Layers, PanelLeft, Settings, ShieldCheck, Sparkles, Workflow, type LucideIcon } from 'lucide-react';
+import { PanelLeft } from 'lucide-react';
import {
cn,
Sidebar,
@@ -36,36 +36,25 @@ import {
useSidebar,
} from '@object-ui/components';
import {
- useGlobalDiagnostics,
- useMetadataClient,
- useMetadataTypes,
- type RichMetadataTypeEntry,
-} from '../metadata-admin/useMetadata.js';
-import { scopeDirectoryEntries } from '../metadata-admin/directoryScope.js';
+ STUDIO_MENU_ENTRY_LABEL_KEYS,
+ STUDIO_MENU_GROUP_ICONS,
+ StudioMenuDataContext,
+ useStudioMenuData,
+ useStudioMenuTypes,
+ type StudioMenuData,
+} from './studioMenuData.js';
import { t, tFormat, translateMetadataType } from '../metadata-admin/i18n.js';
import { studioMenuGroupLabel } from './studioMenuGroupLabel.js';
-import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js';
import { STUDIO_HEADER_ICON_BUTTON } from './studio-tokens.js';
import {
STUDIO_MENU_COOKIE,
- STUDIO_MENU_DESIGNER_TYPES,
buildStudioMenu,
studioMenuCurrentKey,
studioMenuEntryMatches,
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,
-};
/**
* objectui#12795 — every `SidebarGroupLabel` call site hides its label from
@@ -77,13 +66,6 @@ const HIDDEN_ICON_LABEL_NOT_FOCUSABLE =
'group-data-[state=collapsed]:group-data-[collapsible=icon]:invisible ' +
'group-data-[state=collapsed]:group-data-[collapsible=icon]:transition-[margin,opacity,visibility]';
-/** 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 provider the surface mounts around its header and body: the app
@@ -124,59 +106,6 @@ export function StudioMenuTrigger({ locale }: { locale: string }): React.ReactEl
);
}
-/** 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.
- */
-const StudioMenuDataContext = React.createContext(null);
-
/** Reads the menu's data for `segment` once and hands it to the menu and the palette below. */
export function StudioMenuDataProvider({
segment,
@@ -189,11 +118,6 @@ export function StudioMenuDataProvider({
return {children};
}
-/** The menu's data a {@link StudioMenuDataProvider} above holds, or `null` with none. */
-export function useStudioMenuData(): StudioMenuData | null {
- return React.useContext(StudioMenuDataContext);
-}
-
export interface StudioMenuProps {
/** The `/studio/:segment` route segment: a package id, `~org` or `~all`. */
segment: string;
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
index f9443f067ae..ebd1db94d6d 100644
--- 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
@@ -362,6 +362,25 @@ describe("on a package, the palette lists the left menu and the package's items
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.
+ 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));
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
index 9765591031a..088b69af49b 100644
--- a/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
+++ b/ui/packages/app-shell/src/views/studio-design/StudioPaletteGroups.tsx
@@ -37,7 +37,7 @@ 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 './StudioMenu.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 {
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);
+}
From 7126dfea1398402809c8a6d3552b1265fc226950 Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 24 Nov 2026 21:47:53 +0000
Subject: [PATCH 10/12] revert(studio): drop the palette's first-row selection;
cmdk already selects a row that arrives late (measured live)
Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H
Co-authored-by: Claude
---
.../app-shell/src/chrome/CommandPalette.tsx | 17 ++---------------
...dioPaletteGroups.surfaceScope-36900.test.tsx | 3 ++-
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/ui/packages/app-shell/src/chrome/CommandPalette.tsx b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
index afd8012a548..f6ac95f3f48 100644
--- a/ui/packages/app-shell/src/chrome/CommandPalette.tsx
+++ b/ui/packages/app-shell/src/chrome/CommandPalette.tsx
@@ -24,7 +24,7 @@
* next open draws a fresh palette (objectui#13387).
*/
-import { useEffect, useLayoutEffect, useRef, useState, useMemo, type ReactNode } from 'react';
+import { useEffect, useState, useMemo, type ReactNode } from 'react';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
import {
Command,
@@ -423,19 +423,6 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
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);
- // objectstack#36900 — a design page's items answer after the palette opens,
- // often after the author has typed. cmdk selects a first row only when one
- // mounts while it holds no value, and the value it holds is the row the
- // query filtered away, so the rows that arrive later stayed unselected and
- // Enter opened nothing. While no rendered row is selected, the first one is.
- const listRef = useRef(null);
- useLayoutEffect(() => {
- if (!open || !surface) return;
- const list = listRef.current;
- if (!list || list.querySelector('[cmdk-item][data-selected="true"]')) return;
- const first = list.querySelector('[cmdk-item]:not([aria-disabled="true"])')?.getAttribute('data-value');
- if (first) setSelectedValue(first);
- });
const studioPackages = studio.packages.filter(studioMatches);
const studioObjects = studio.objects.filter(studioMatches);
const studioFlows = studio.flows.filter(studioMatches);
@@ -645,7 +632,7 @@ function CommandPaletteBody(props: CommandPaletteProps & { gates: NavMemberGates
value={inputValue}
onValueChange={setInputValue}
/>
-
+
{isSearching || studio.loading || surfaceLoading ? (
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
index ebd1db94d6d..1afddd4d038 100644
--- 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
@@ -369,7 +369,8 @@ describe("on a package, the palette lists the left menu and the package's items
});
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.
+ // 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();
From 5e181efb665e8861b5a14ed4ee8da9f062c5ac13 Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 24 Nov 2026 21:55:02 +0000
Subject: [PATCH 11/12] test(studio): pay the item page harness's lazy linter
load at module scope
Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H
Co-authored-by: Claude
---
.../metadata-admin/ResourceEditPage.leaveGuard-13231.test.tsx | 2 ++
1 file changed, 2 insertions(+)
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 68050265bff..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,6 +20,8 @@
*/
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';
From 7bbe1c54bfc008a05412701471c7795c3088ce2b Mon Sep 17 00:00:00 2001
From: Claude
Date: Tue, 24 Nov 2026 22:36:31 +0000
Subject: [PATCH 12/12] test(studio): the left-menu e2e stubs the menu's reads
where they now live (studioMenuData.ts)
Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H
Co-authored-by: Claude
---
ui/e2e/studio-left-menu-36899.spec.ts | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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;