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 = (