From 78a1fc6e6adb15d296a14b84e1fe92cf28d32de0 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 12:41:39 +0000 Subject: [PATCH 1/9] feat(studio): a left menu of six domain groups replaces the top pillar nav Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- .../console/src/components/StudioRoute.tsx | 42 +-- .../views/metadata-admin/DirectoryPage.tsx | 27 +- .../PageShell.narrowHeader-12306.test.tsx | 2 +- .../views/metadata-admin/directoryScope.ts | 42 +++ .../src/views/metadata-admin/i18n.ts | 12 +- .../studio-locale.i18n.test.tsx | 4 +- .../views/studio-design/StudioBackToApp.tsx | 49 ++-- .../studio-design/StudioDesignSurface.tsx | 170 +++++------- .../src/views/studio-design/StudioMenu.tsx | 258 ++++++++++++++++++ .../views/studio-design/metadataArea.test.ts | 7 + .../src/views/studio-design/metadataArea.ts | 7 +- .../src/views/studio-design/studio-tokens.ts | 41 ++- .../views/studio-design/studioMenuModel.ts | 188 +++++++++++++ .../studioZhPillarNames-11801.test.ts | 9 +- .../__tests__/sidebar-cookie-restore.test.tsx | 24 ++ ui/packages/components/src/ui/sidebar.tsx | 8 +- ui/packages/i18n/src/namespaces/studio/en.ts | 19 +- ui/packages/i18n/src/namespaces/studio/zh.ts | 17 +- .../__tests__/shadcn-local-patches.test.ts | 22 +- ui/scripts/shadcn-local-patches.mjs | 61 ++++- 20 files changed, 786 insertions(+), 223 deletions(-) create mode 100644 ui/packages/app-shell/src/views/metadata-admin/directoryScope.ts create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx create mode 100644 ui/packages/app-shell/src/views/studio-design/studioMenuModel.ts diff --git a/ui/apps/console/src/components/StudioRoute.tsx b/ui/apps/console/src/components/StudioRoute.tsx index ea6d7583099..d2658c8809b 100644 --- a/ui/apps/console/src/components/StudioRoute.tsx +++ b/ui/apps/console/src/components/StudioRoute.tsx @@ -77,9 +77,6 @@ const StudioDesignSurface = lazy(() => const BuilderLanding = lazy(() => import('./studioBuilder').then((m) => ({ default: m.BuilderLanding })), ); -const StudioMetadataArea = lazy(() => - import('./studioBuilder').then((m) => ({ default: m.StudioMetadataArea })), -); /** * What a principal without `studio.access` sees, at the Studio URL they opened @@ -219,7 +216,7 @@ function StudioLanding() { } /** - * The console frame `/studio` screens without a package draw (objectui#11863): + * The console frame the `/studio` landing draws (objectui#11863): * the console's own top bar in its `studio` variant and the command palette in * its `studio` scope, around a body that loads with its route. */ @@ -244,21 +241,6 @@ function StudioConsoleFrame({ children }: { children: ReactNode }) { ); } -/** - * objectstack#28561 — the "All metadata" area's cross-package leg - * (`/studio/~all/metadata/*`, ADR-0146 D1): the environment catalog, served - * with no package. No package means no pillars, no package switcher and no - * package publish, so it is not the pillar builder: it is the area alone, in - * the frame the landing draws, which it is entered from. - */ -function StudioAllPackagesMetadata() { - return ( - - - - ); -} - /** * A package's pillar builder, which records the visit as a recent `package` * entry (objectui#11863), so the landing can list the packages an author was @@ -270,14 +252,14 @@ function StudioAllPackagesMetadata() { * which lands on the Data pillar — and no label: the landing labels it from the * package list it loads (objectui#11678's shape). Keyed on the package, not the * pillar, so moving between pillars of one package leaves the list as it is, - * and the provider writes nothing. The package-less scope (`~org`) is not a - * package and records nothing. + * and the provider writes nothing. The package-less scope (`~org`) and the + * cross-package leg (`~all`) are not packages and record nothing. */ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA }) { const { packageId } = useParams(); const { addRecentItem } = useRecentItems(); useEffect(() => { - if (!packageId || packageId === STUDIO_ORG_SCOPE_SEGMENT) return; + if (!packageId || packageId === STUDIO_ORG_SCOPE_SEGMENT || packageId === STUDIO_ALL_PACKAGES_SEGMENT) return; addRecentItem({ id: `package:${packageId}`, type: 'package', @@ -307,8 +289,7 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA }) * * `/studio` front door (pick / create a writable package) * `/studio/~org` the package-less scope lands on its one pillar - * `/studio/~all/metadata/*` the "All metadata" area across packages - * `/studio/~all/*` lands on that area + * `/studio/~all/*` lands on the "All metadata" area across packages * `/studio/:packageId` a package lands on its Data pillar * `/studio/:packageId/metadata/*` a package's "All metadata" area, in the builder * `/studio/:packageId/:tab` the pillar builder (a recent-package visit) @@ -329,6 +310,15 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA }) * cross-package segment (`metadataArea.ts` in app-shell says why it is not * `~org`); every `~all` URL outside the area lands on it, so none reaches the * pillar builder as a package id. + * + * objectstack#36899 — the cross-package leg (`/studio/~all/metadata/*`) is + * served by the generic area route, as `~org`'s pillar is by the generic pillar + * route: the SAME `StudioDesignSurface`, which reads `~all` as "no package" + * and draws the area alone, under the left menu every Studio page draws. It + * used to be the area in the landing's console frame, a second shell the + * author flipped into from the menu's Access group. The more specific + * `:packageId/metadata/*` outranks `~all/*` for an area URL; every other + * `~all` URL still lands on the area. */ export const studioRoutes = ( }> @@ -337,10 +327,6 @@ export const studioRoutes = ( path={STUDIO_ORG_SCOPE_SEGMENT} element={} /> - } - /> } diff --git a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx index 416d172ab95..619acee1ed3 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx @@ -39,7 +39,8 @@ import { } from './i18n.js'; import { buildPackageScopeOptions } from './package-scope.js'; import { diagnosticsHeaderTone, type DiagnosticsHeaderTone } from './diagnostics-tone.js'; -import { ENVIRONMENT_AREA_TYPES, SETUP_DATASOURCES_PATH, useMetadataAreaHost } from './metadataAreaHost.js'; +import { SETUP_DATASOURCES_PATH, useMetadataAreaHost } from './metadataAreaHost.js'; +import { scopeDirectoryEntries } from './directoryScope.js'; import { WritabilityBadge, typeStateWord } from './PageShell.js'; import { ENVIRONMENT_SCOPE_QUERY } from './catalog-scope.js'; import { usePackageCustomizations } from '../studio-design/CustomizationMark.js'; @@ -82,19 +83,6 @@ const DOMAIN_ORDER = [ 'other', ]; -/** - * Types intentionally hidden from the directory + list views. - * - * `field` is managed in-context via the parent object's edit form - * (master-detail widget). A flat global list of every field across - * every object is rarely useful and clutters the admin surface. - * - * `package` is the Studio scope container itself. It has a dedicated - * management surface for create/publish/import/export flows, so exposing it - * as scoped metadata would mean "view packages inside a package". - */ -const HIDDEN_TYPES = new Set(['field', 'package']); - export function MetadataDirectoryPage() { const client = useMetadataClient(); const { loading, error, entries } = useMetadataTypes(client); @@ -184,14 +172,13 @@ export function MetadataDirectoryPage() { // Base set: visible (non-hidden) metadata types contributed by the active // project package. Fail closed — show nothing until a concrete project // package is active, so system-only types never surface. + // The area's cross-package leg lists the environment catalog, every package's. const scopedEntries = React.useMemo( () => - entries.filter((e) => { - if (HIDDEN_TYPES.has(e.type)) return false; - // The area's cross-package leg: the environment catalog, every package's. - if (host && host.packageId === null) return ENVIRONMENT_AREA_TYPES.includes(e.type); - if (!activePackage) return false; - return (packagesByType[e.type] ?? []).includes(activePackage); + scopeDirectoryEntries(entries, { + environment: !!host && host.packageId === null, + packageId: activePackage, + packagesByType, }), [host, entries, activePackage, packagesByType], ); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PageShell.narrowHeader-12306.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PageShell.narrowHeader-12306.test.tsx index 6d138e60c2a..45bc6eaf7b7 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PageShell.narrowHeader-12306.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PageShell.narrowHeader-12306.test.tsx @@ -73,7 +73,7 @@ describe('PageShell compact header wraps instead of squeezing the breadcrumb (ob const meta = screen.getByTestId('page-shell-header-meta'); expect(nav.nextElementSibling).toBe(meta); // The chips, the subtitle, the stats and the actions all live in it. - expect(meta).toContainElement(screen.getByText('Security')); + expect(meta).toContainElement(screen.getByText('Access')); expect(meta).toContainElement(screen.getByText('Can be added')); expect(meta).toContainElement(screen.getByText('Permission set')); expect(meta).toContainElement(screen.getByText('Objects granted')); diff --git a/ui/packages/app-shell/src/views/metadata-admin/directoryScope.ts b/ui/packages/app-shell/src/views/metadata-admin/directoryScope.ts new file mode 100644 index 00000000000..7f3dea98fc5 --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/directoryScope.ts @@ -0,0 +1,42 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * Which metadata types a package's directory lists: one rule, read by the + * type directory (`DirectoryPage`) and by Studio's left menu (`StudioMenu`), + * so the menu and the directory never disagree on what a package holds. + */ + +import { ENVIRONMENT_AREA_TYPES } from './metadataAreaHost.js'; + +/** + * Types never listed. `field` is edited inside its object; `package` is the + * scope container itself, with its own management surface. + */ +export const HIDDEN_DIRECTORY_TYPES: ReadonlySet = new Set(['field', 'package']); + +/** + * The served type entries a directory lists, in served order: + * - the environment scope (Studio's cross-package leg): the environment + * catalog's types; + * - a package: the types the diagnostics sweep says that package contributes + * to (`packagesByType`), plus `always` — types listed even before the + * package holds one; + * - no package known yet: nothing (fail closed). + */ +export function scopeDirectoryEntries( + entries: readonly T[], + scope: { + environment: boolean; + packageId: string | null; + packagesByType: Readonly>; + always?: readonly string[]; + }, +): T[] { + return entries.filter((e) => { + if (HIDDEN_DIRECTORY_TYPES.has(e.type)) return false; + if (scope.environment) return ENVIRONMENT_AREA_TYPES.includes(e.type); + if (!scope.packageId) return false; + if (scope.always?.includes(e.type)) return true; + return (scope.packagesByType[e.type] ?? []).includes(scope.packageId); + }); +} diff --git a/ui/packages/app-shell/src/views/metadata-admin/i18n.ts b/ui/packages/app-shell/src/views/metadata-admin/i18n.ts index 4a06cade625..2cd7c426f5b 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/i18n.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/i18n.ts @@ -178,15 +178,19 @@ const TYPE_LABELS_ZH: Record = { picklist: '选项列表', }; +// ADR-0084 (amended 2026-11-24) — the registered domains are Studio's six menu +// groups, and `system` and `security` are drawn by the group names decision 11 +// gives them: Platform and Access. Every directory heading, chip and list badge +// says the same word as the menu. const DOMAIN_LABELS_EN: Record = { data: 'Data', ui: 'UI', automation: 'Automation', ai: 'AI', - system: 'System', + system: 'Platform', platform: 'Platform', identity: 'Identity', - security: 'Security', + security: 'Access', other: 'Other', }; @@ -195,10 +199,10 @@ const DOMAIN_LABELS_ZH: Record = { ui: '界面', automation: '自动化', ai: 'AI', - system: '系统', + system: '平台', platform: '平台', identity: '身份', - security: '安全', + security: '访问', other: '其他', }; diff --git a/ui/packages/app-shell/src/views/metadata-admin/studio-locale.i18n.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/studio-locale.i18n.test.tsx index 6b2b87dc724..8a7d2c87434 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/studio-locale.i18n.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/studio-locale.i18n.test.tsx @@ -37,8 +37,8 @@ const SAMPLE_KEYS = [ 'engine.studio.publish', 'engine.studio.saveDraft', 'engine.studio.cancel', - 'engine.studio.pillar.data', - 'engine.studio.pillar.access', + 'engine.studio.menu.orgFlows', + 'engine.studio.menu.owd', 'engine.studio.app.create', 'engine.studio.pkg.new', 'engine.studio.data.newObject', diff --git a/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx b/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx index 40ea9bbcca3..0d7f257dea1 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx @@ -6,19 +6,25 @@ * app; it replaced the Studio-home button, the package switcher and the * top-right Open app. * + * What it names is the CURRENT PACKAGE's app, never the app the author + * happened to come from (objectstack#36890 decision 5): Studio is the + * development surface of that package's app (ADR-0084, amended 2026-11-24). * Where it goes, first match wins ({@link studioBackTarget}): * - * 1. the app page the author came from — an app → Studio entry is an in-app + * 1. the app page the author came from, when that page is one of the + * package's own published apps — an app → Studio entry is an in-app * navigation, and `ConsoleLayout` records every app page - * (`utils/appReturnPage.ts`); the name is that app's; - * 2. opened directly (a Studio URL in a new tab, a reload), the package's - * own published app, on its first screen; - * 3. a package with no published app, and the package-less scope: the - * console's default landing (`useHomePath`), with no app name. A draft - * app has no running front-end yet, so it counts as none. + * (`utils/appReturnPage.ts`); + * 2. otherwise the package's own published app, on its first screen; + * 3. a package with no published app, the package-less scope (`~org`) and + * the cross-package leg (`~all`): the console's apps home + * (`useHomePath`), with no app name. A draft app has no running + * front-end yet, so it counts as none. * - * With no app to name, the name slot names the open package instead - * (objectstack#36748), so the bar still says what the author is building. + * With no app to name, the name slot names the open package — or the scope — + * instead (objectstack#36748, and the maintainer's ruling on #36899: show the + * package's name, go back to the apps home), so the bar still says what the + * author is building. * * Leaving asks first when a pillar holds unsaved work, like every other * header departure (`beforeNavigate`). @@ -64,13 +70,17 @@ export function studioBackTarget({ locale: string; landingPath: string; }): StudioBackTarget { - if (remembered) return { path: remembered.path, appLabel: remembered.label || remembered.app }; const [first] = apps; - if (packageId !== null && first) { - const segment = encodeURIComponent(apps.length > 1 ? first.name : packageId); - return { path: `/apps/${segment}`, appLabel: navItemLabelText(first.label, locale) || first.name }; - } - return { path: landingPath, appLabel: null }; + if (packageId === null || !first) return { path: landingPath, appLabel: null }; + const labelOf = (app: StudioAppTarget) => navItemLabelText(app.label, locale) || app.name; + // The page the author came from, when it is one of this package's apps: its + // record names the app by its route key, the app's name or the package id. + const cameFrom = remembered + ? (apps.find((a) => a.name === remembered.app) ?? (remembered.app === packageId ? first : undefined)) + : undefined; + if (remembered && cameFrom) return { path: remembered.path, appLabel: labelOf(cameFrom) }; + const segment = encodeURIComponent(apps.length > 1 ? first.name : packageId); + return { path: `/apps/${segment}`, appLabel: labelOf(first) }; } export function StudioBackToApp({ @@ -84,7 +94,8 @@ export function StudioBackToApp({ /** The open package, or `null` in the package-less scope. */ packageId: string | null; /** - * The open package's display name: the name slot shows it when there is no + * The open package's display name, or in the package-less scope and the + * cross-package leg the scope's: the name slot shows it when there is no * app to name (objectstack#36748). Absent while the package list loads. */ packageLabel?: string | null; @@ -103,9 +114,9 @@ export function StudioBackToApp({ const title = target.appLabel ? tFormat('engine.studio.backToAppTitle', locale, { app: target.appLabel }) : t('engine.studio.backToAppTitleNoApp', locale); - // objectstack#36748 — no app to name: the slot names the open package. The - // package-less scope has none, so it shows nothing there. - const fallbackLabel = packageId !== null ? packageLabel?.trim() || null : null; + // objectstack#36748 — no app to name: the slot names the open package, or + // the scope (the ruling on #36899 treats the package-less entry the same way). + const fallbackLabel = packageLabel?.trim() || null; const name = target.appLabel ?? fallbackLabel; return ( 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 9e913be10fb..ea4b0e8b572 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -15,7 +15,7 @@ */ import * as React from 'react'; -import { useParams, useNavigate, useSearchParams, useLocation, Link, Navigate } from 'react-router-dom'; +import { useParams, useNavigate, useSearchParams, useLocation, Navigate } from 'react-router-dom'; // The ONE draft-envelope reader (objectui#8181): unwrap AND strip the // framework's read decorations in one place. This file used to carry its own // copy that did the unwrap and skipped the strip. @@ -50,10 +50,7 @@ import { STUDIO_HEADER, STUDIO_HEADER_ICON_BUTTON, STUDIO_HEADER_PACKAGE_COLUMN, - STUDIO_HEADER_PILLAR_NAME, STUDIO_HEADER_WIDE_WORD, - STUDIO_HEADER_PILLAR, - STUDIO_HEADER_PILLAR_NAV, STUDIO_PILLARS_HOST, } from './studio-tokens.js'; import { @@ -93,19 +90,14 @@ import { TooltipTrigger, } from '@object-ui/components'; import { - Database, - Workflow, Loader2, Plus, GitBranch, Rocket, - Shield, PanelRightClose, PanelRightOpen, FileQuestion, PackageX, - Library, - type LucideIcon, } from 'lucide-react'; import { useMetadataClient } from '../metadata-admin/useMetadata.js'; // objectui#11773 — every draft save of an existing item sends the version its buffer was built on. @@ -144,7 +136,8 @@ import { isStudioOrgScope, studioOrgScopePath, } from './studioScope.js'; -import { STUDIO_METADATA_AREA, studioMetadataAreaPath } from './metadataArea.js'; +import { STUDIO_METADATA_AREA, isStudioAllPackagesScope } from './metadataArea.js'; +import { StudioMenu, StudioMenuProvider, StudioMenuTrigger } from './StudioMenu.js'; import { StudioMetadataArea } from './StudioMetadataArea.js'; import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js'; import { @@ -206,30 +199,15 @@ function formatBackfillReceipt(receipt: PublishBackfillReceipt, locale: string): .join(' · '); } -// objectui#12452 — Access is a segment of its own, and the "More" overflow that -// held it alone (objectui#5813) is retired. If a second overflow pillar is ever -// added, More returns with the objectui#11794 behaviour: its trigger keeps the -// name More whichever of its pillars is open. -// objectstack#36502 — the Interfaces pillar is retired: interfaces are designed -// in the running app's design mode (`studioInterfacesRetired.tsx`). Data, the -// first segment, is the Studio home. -const PILLARS: ReadonlyArray<{ key: string; label: string; Icon: LucideIcon }> = [ - { key: STUDIO_HOME_PILLAR, label: 'Data', Icon: Database }, - { key: 'automations', label: 'Automations', Icon: Workflow }, - { key: 'access', label: 'Access', Icon: Shield }, -]; -/** - * objectstack ADR-0146 D1 (#28561) — the "All metadata" area joins the four - * pillars in the header: a package's type directory, lists, generic item page, - * history and diagnostics (`StudioMetadataArea`). Not a pillar: it designs no - * type of its own, and its URLs are the area's (`/studio//metadata/…`, - * `metadataArea.ts`), so `PILLARS` and the not-found check do not hold it. - */ -const METADATA_AREA_TAB: { key: string; label: string; Icon: LucideIcon } = { - key: STUDIO_METADATA_AREA, - label: 'All metadata', - Icon: Library, -}; +// The pillar segments `/studio//` serves. objectstack#36899 +// (ADR-0084, amended) — they are no longer a navigation: Studio's one +// navigation is the left menu (`StudioMenu`), and these pages are where an +// object, a flow or a permission set opens until each becomes a full-screen +// item page. Data stays the Studio home. objectstack#36502 — the Interfaces +// pillar is retired (`studioInterfacesRetired.tsx`). The "All metadata" area +// (`/studio//metadata/…`, `metadataArea.ts`) is not a pillar, so the +// not-found check does not hold it. +const PILLARS: readonly string[] = [STUDIO_HOME_PILLAR, 'automations', 'access']; // objectstack#29988 — the pillar kit moved to its own module; re-exported for its pins. export { StudioHeldNotice, StudioReadOnlyLink, type StudioBaseCustomization }; @@ -305,14 +283,18 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re // The route segment: a package id, or the package-less scope's reserved // segment (objectui#11553, `studioScope.ts`). URLs are built from it. const scopeSegment = params.packageId ?? 'com.example.showcase'; - // `null` in the package-less scope. Every package-scoped read, write and - // publish below keys on this value, so none of them can be handed the - // reserved segment as though it named a package. - const packageId: string | null = isStudioOrgScope(scopeSegment) ? null : scopeSegment; + // objectstack#36899 — the "All metadata" area's cross-package leg (`~all`) + // is drawn in this shell too, so the left menu is the same on every Studio + // page: the area alone, with no package, no package actions and no slot. + const allScope = isStudioAllPackagesScope(scopeSegment); + // `null` in the package-less scope and on the cross-package leg. Every + // package-scoped read, write and publish below keys on this value, so none + // of them can be handed a reserved segment as though it named a package. + const packageId: string | null = isStudioOrgScope(scopeSegment) || allScope ? null : scopeSegment; const tab = area ?? params.tab ?? STUDIO_HOME_PILLAR; // objectstack#26708 — a segment no pillar has is a not-found state, never // a pillar it falls through to. - const pillarKnown = PILLARS.some((p) => p.key === tab); + const pillarKnown = PILLARS.includes(tab); const locale = useMetadataLocale(); // objectstack#36502 — a landing from an old Interfaces URL says once where // interface editing went. The landing's history state is read once and @@ -1225,7 +1207,7 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re const pillar = PILLAR_FOR_SURFACE_TYPE[target.type]; // objectui#11553 — the package-less scope has one pillar; a surface // owned by another is not in this scope, so nothing to navigate to. - const reachable = packageId !== null || pillar === STUDIO_ORG_SCOPE_PILLAR; + const reachable = !allScope && (packageId !== null || pillar === STUDIO_ORG_SCOPE_PILLAR); if (pillar && pillar !== tab && reachable) { if (!confirmLeavePillar()) return false; shellNavigate( @@ -1234,8 +1216,21 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re } setChangesOpen(false); }, - [tab, packageId, scopeSegment, confirmLeavePillar, shellNavigate], + [tab, allScope, packageId, scopeSegment, confirmLeavePillar, shellNavigate], ); + // objectstack#36899 — a menu entry that re-enters the open pillar on another + // `?surface=` (the default sharing overview, on the Access pillar) opens the + // pillar afresh, as arriving from any other page does: a pillar reads its + // deep link once, at mount (`useSurfaceDeepLink`). The shell's link guard + // lets a link to the page already shown through, so this asks first. + const [pillarEntry, setPillarEntry] = React.useState(0); + const reenterPillar = React.useCallback((): boolean => { + if (!confirmLeavePillar()) return false; + setPillarEntry((n) => n + 1); + return true; + }, [confirmLeavePillar]); + // objectstack#26708 — a package that is not there has no menu. + const showMenu = !pkgMissing; const publishButton = ( + ); +} + +/** + * 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. + */ +function useStudioMenuTypes(packageId: string | null, environment: boolean) { + const client = useMetadataClient(); + const { entries } = useMetadataTypes(client); + const { countsByType, packagesByType, 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 = React.useMemo( + () => + scopeDirectoryEntries(entries, { + environment, + packageId, + packagesByType, + always: STUDIO_MENU_DESIGNER_TYPES, + }), + [entries, environment, packageId, packagesByType], + ); + return { types, counts: countsByType }; +} + +export interface StudioMenuProps { + /** The `/studio/:segment` route segment: a package id, `~org` or `~all`. */ + segment: string; + locale: string; + /** + * An entry re-enters the page already open on another query (the default + * sharing overview, on the Access pillar). The host asks about unsaved work + * and remounts that page; `false` keeps the author where they are. + */ + onReenterPillar?: () => boolean; +} + +export function StudioMenu({ segment, locale, onReenterPillar }: StudioMenuProps): React.ReactElement { + const scope = studioMenuScope(segment); + const packageId = scope.kind === 'package' ? scope.packageId : null; + const { types, counts } = useStudioMenuTypes(packageId, scope.kind !== 'package'); + const { pathname, search } = useLocation(); + const { isMobile, setOpenMobile } = useSidebar(); + const [query, setQuery] = React.useState(''); + const searchId = React.useId(); + + const labels = new Map(types.map((e) => [e.type, translateMetadataType(e.type, locale, (e as { label?: string }).label)])); + const labelOf = (entry: StudioMenuEntry) => + entry.kind === 'type' ? (labels.get(entry.type ?? '') ?? entry.type ?? '') : t(ENTRY_LABEL_KEYS[entry.kind], locale); + + const current = studioMenuCurrentKey({ segment, pathname, search }); + const groups = buildStudioMenu({ scope, types, counts }) + .map((g) => ({ ...g, entries: g.entries.filter((e) => studioMenuEntryMatches(e, labelOf(e), query)) })) + .filter((g) => !query.trim() || g.entries.length > 0); + + return ( + + + + setQuery(e.target.value)} + /> + + + + + + ); +} diff --git a/ui/packages/app-shell/src/views/studio-design/metadataArea.test.ts b/ui/packages/app-shell/src/views/studio-design/metadataArea.test.ts index e492238eeb3..89e3445e93d 100644 --- a/ui/packages/app-shell/src/views/studio-design/metadataArea.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/metadataArea.test.ts @@ -78,6 +78,13 @@ describe('areaLocationRedirect — the query names the leg', () => { expect(areaLocationRedirect(STUDIO_ALL_PACKAGES_SEGMENT, '', '')).toBeNull(); expect(areaLocationRedirect(STUDIO_ALL_PACKAGES_SEGMENT, 'flow/f1', '?review=1')).toBeNull(); }); + + it('the package-less scope is never written into `?package=`: it lands on its flows (objectstack#36899)', () => { + expect(areaLocationRedirect('~org', '', '')).toBe('/studio/~org/automations'); + expect(areaLocationRedirect('~org', 'flow', '')).toBe('/studio/~org/automations'); + expect(areaLocationRedirect(STUDIO_ALL_PACKAGES_SEGMENT, 'flow', '?package=~org')).toBe('/studio/~org/automations'); + expect(areaLocationRedirect(PKG, 'flow', '?package=~org')).toBe('/studio/~org/automations'); + }); }); describe('areaItemPillarPath — a pillar type opens its pillar', () => { diff --git a/ui/packages/app-shell/src/views/studio-design/metadataArea.ts b/ui/packages/app-shell/src/views/studio-design/metadataArea.ts index 210c946d846..b24da5dc649 100644 --- a/ui/packages/app-shell/src/views/studio-design/metadataArea.ts +++ b/ui/packages/app-shell/src/views/studio-design/metadataArea.ts @@ -36,6 +36,7 @@ import { DESIGNER_SURFACE_PARAM, formatSurfaceParam } from '../metadata-admin/nav-selection.js'; import { CATALOG_SCOPE_PARAM, ENVIRONMENT_SCOPE } from '../metadata-admin/catalog-scope.js'; +import { isStudioOrgScope, studioOrgScopePath } from './studioScope.js'; /** The area's route segment, beside the pillars' (`/studio//metadata`). */ export const STUDIO_METADATA_AREA = 'metadata'; @@ -173,13 +174,17 @@ const ALL_PACKAGES_VALUE = 'all'; * it a save in the area would leave the package; * - the cross-package leg with no `?package=` stays as it is: a URL that * names no package lists across packages, and no page repairs one in - * (#29566). + * (#29566); + * - the package-less scope (`~org`, as the segment or as `?package=`) names + * no package, so it is never written into `?package=`: it has no area, and + * lands on its flows, the one leg Studio's menu offers it (#36899). * * `rest` is the path below the area's root as the URL spells it (encoded), * `''` at the root; `search` is the URL's query, with or without its `?`. */ export function areaLocationRedirect(segment: string, rest: string, search: string): string | null { const params = new URLSearchParams(search); + if (isStudioOrgScope(segment) || isStudioOrgScope(params.get('package'))) return studioOrgScopePath(); const allLeg = isStudioAllPackagesScope(segment); const tail = rest ? `/${rest}` : ''; const at = (leg: string) => { diff --git a/ui/packages/app-shell/src/views/studio-design/studio-tokens.ts b/ui/packages/app-shell/src/views/studio-design/studio-tokens.ts index 8138b0f47d9..2171bf6addd 100644 --- a/ui/packages/app-shell/src/views/studio-design/studio-tokens.ts +++ b/ui/packages/app-shell/src/views/studio-design/studio-tokens.ts @@ -13,44 +13,35 @@ */ /** - * Shell header (objectui#12509). From `sm` up: one 48 px row, a three-column - * grid so the pillar switcher centers. The right column never drops below its - * content (Create app, Changes, Publish), so on a tight row the switcher moves - * left and the package chip truncates instead of anything sliding under the - * switcher. Below `sm`: two rows, the package and its actions on the first, - * the switcher at full width on the second (`STUDIO_HEADER_PILLAR_NAV`). + * Shell header (objectui#12509). One 48 px row at every width, two columns: + * the left menu's control and the way back to the app at the left, the + * package actions at the right. The right column never drops below its + * content (Create app, Changes, Publish, Cancel, Save), so on a tight row the + * app's name truncates instead of anything sliding under the actions. + * objectstack#36899 — the pillar switcher that sat in a middle column (and on + * a second row below `sm`) is gone: the left menu is Studio's navigation. */ export const STUDIO_HEADER = - '@container/studio-header grid shrink-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 border-b px-3 py-2 sm:h-12 sm:grid-cols-[minmax(0,1fr)_auto_minmax(max-content,1fr)] sm:py-0'; -/** The pillar switcher: its own full-width row below `sm`, the middle column from `sm` up. */ -export const STUDIO_HEADER_PILLAR_NAV = - 'order-last col-span-2 flex items-center gap-0.5 rounded-lg bg-muted p-[3px] sm:order-none sm:col-span-1'; -/** One switcher segment: an equal share of the row below `sm`, its own width from `sm` up. */ -export const STUDIO_HEADER_PILLAR = - 'inline-flex h-7 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md px-2.5 text-[13px] transition-colors sm:flex-none sm:shrink-0 xl:px-3'; + '@container/studio-header grid h-12 shrink-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 border-b px-3'; /** * objectui#12611 — the header's left column is a container: its width is the * grid track's, so what it holds folds to the room the column really has (the - * pillar switcher and the actions beside it), never the viewport. + * actions beside it), never the viewport. * objectstack#36501 — it holds 「‹ Back to app」, the app's name and the * Studio mark, and the app's name is the piece that truncates. */ export const STUDIO_HEADER_PACKAGE_COLUMN = '@container'; /** - * objectstack#34725 — the pillar names, and the words of "All metadata" and - * Create app, answer the top bar's OWN width, not the viewport's: the right - * panel beside it is resizable now (the console drawer's 420 px, dragged up to - * the canvas's 520 px floor), so a 1163 px window can leave the bar 520 px. A - * viewport breakpoint kept the names on and pushed the bar's right end, the AI - * assistant's robot, under the panel. The thresholds are the bar widths the - * old breakpoints gave beside the old fixed slot: 724 px (1024 − 300) for the - * four pillar names, 920 px (1280 − 360) for the two longer words. Below them - * the names stay in the accessible name and the tooltip. Literal class - * strings: Tailwind finds a class by scanning source. + * objectstack#34725 — Create app's word answers the top bar's OWN width, not + * the viewport's: the right panel beside it is resizable (the console drawer's + * 420 px, dragged up to the canvas's 520 px floor), so a 1163 px window can + * leave the bar 520 px, and a viewport breakpoint pushed the bar's right end, + * the AI assistant's robot, under the panel. Below 920 px of bar the word stays + * in the accessible name and the tooltip. A literal class string: Tailwind + * finds a class by scanning source. */ -export const STUDIO_HEADER_PILLAR_NAME = 'sr-only @min-[724px]/studio-header:not-sr-only'; export const STUDIO_HEADER_WIDE_WORD = 'sr-only @min-[920px]/studio-header:not-sr-only'; /** Rail: 240 px, the sidebar surface, a right border. */ diff --git a/ui/packages/app-shell/src/views/studio-design/studioMenuModel.ts b/ui/packages/app-shell/src/views/studio-design/studioMenuModel.ts new file mode 100644 index 00000000000..b5266fd315c --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/studioMenuModel.ts @@ -0,0 +1,188 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * Studio's left menu, as data (objectstack ADR-0084, amended 2026-11-24; + * #36899): which groups it draws, the entries under each, where each entry + * goes, and which entry the open page is. Pure, so the rules are pinned + * without a render; `StudioMenu.tsx` draws it. + * + * ## Groups + * + * Six, one per domain the spec registers a metadata type under, in the + * amendment's order. A type's group is its served registry `domain`; the + * group's name is `translateMetadataDomain`'s, which draws `system` as + * Platform and `security` as Access (decision 11). + * + * ## Entries + * + * A type entry for each type the package's directory lists (the same rule, + * `scopeDirectoryEntries`), plus the types a designer creates in + * ({@link STUDIO_MENU_DESIGNER_TYPES}), so a package without an object, a flow + * or a permission set can still make its first. Each opens the type's list in + * the "All metadata" area; an item opened there that a pillar designs still + * opens its pillar until the pillars become full-screen pages + * (`areaItemPillarPath`). + * + * And four entries that open no type's list, each in the group of what it + * holds (the amendment's "Entries that are not a type"): + * - the organization's own flows (`~org`), under Automation; + * - the organization-wide default sharing overview, under Access (today the + * Access pillar's `?surface=owd:overview`; its own route is a later card's); + * - diagnostics, under Platform; + * - the cross-package environment catalog (`~all`), under Access. + * + * ## Scopes + * + * On a package, all six groups are drawn, an empty one included, so the menu + * reads the same on every package. The package-less scope (`~org`) and the + * cross-package leg (`~all`) name no package: their menu is the environment's + * — the organization's flows and the environment catalog's types — and only + * the groups that hold an entry are drawn. + */ + +import { ENVIRONMENT_SCOPE_QUERY } from '../metadata-admin/catalog-scope.js'; +import { SETUP_DATASOURCES_PATH } from '../metadata-admin/metadataAreaHost.js'; +import { DESIGNER_SURFACE_PARAM } from '../metadata-admin/nav-selection.js'; +import { + AREA_PILLAR_FOR_TYPE, + STUDIO_ALL_PACKAGES_SEGMENT, + STUDIO_METADATA_AREA, + isStudioAllPackagesScope, + studioMetadataAreaPath, + studioPillarItemPath, +} from './metadataArea.js'; +import { isStudioOrgScope, studioOrgScopePath } from './studioScope.js'; + +/** The menu's collapse state, kept apart from the app sidebar's `sidebar_state`. */ +export const STUDIO_MENU_COOKIE = 'studio_menu_state'; + +/** The six groups, in the amendment's order: each is a registered `domain`. */ +export const STUDIO_MENU_GROUPS = ['data', 'ui', 'automation', 'system', 'security', 'ai'] as const; +export type StudioMenuGroup = (typeof STUDIO_MENU_GROUPS)[number]; + +/** The types a designer creates in: listed on every package, holding one or not. */ +export const STUDIO_MENU_DESIGNER_TYPES: readonly string[] = Object.keys(AREA_PILLAR_FOR_TYPE); + +/** The OWD overview's address on the Access pillar (`AccessPillar`'s deep link). */ +const OWD_OVERVIEW_SURFACE = { type: 'owd', name: 'overview' } as const; + +export type StudioMenuEntryKind = 'type' | 'orgFlows' | 'owd' | 'diagnostics' | 'environment'; + +export interface StudioMenuEntry { + /** Unique within the menu: `type:` for a type, the kind otherwise. */ + key: string; + kind: StudioMenuEntryKind; + /** The metadata type a `type` entry lists. */ + type?: string; + to: string; + /** A `type` entry's served item count; absent when the sweep did not say. */ + count?: number; +} + +export interface StudioMenuGroupModel { + group: StudioMenuGroup; + entries: StudioMenuEntry[]; +} + +/** Which scope the menu is drawn for, from the `/studio/:segment` route segment. */ +export type StudioMenuScope = { kind: 'package'; packageId: string } | { kind: 'org' } | { kind: 'all' }; + +export function studioMenuScope(segment: string): StudioMenuScope { + if (isStudioOrgScope(segment)) return { kind: 'org' }; + if (isStudioAllPackagesScope(segment)) return { kind: 'all' }; + return { kind: 'package', packageId: segment }; +} + +function typeEntryPath(scope: StudioMenuScope, type: string): string { + if (scope.kind !== 'package') { + return `${studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT)}/${encodeURIComponent(type)}?${ENVIRONMENT_SCOPE_QUERY}`; + } + // ADR-0146 D1 — a datasource is Setup's runtime configuration, as its directory tile says. + if (type === 'datasource') return SETUP_DATASOURCES_PATH; + const pkg = encodeURIComponent(scope.packageId); + return `${studioMetadataAreaPath(scope.packageId)}/${encodeURIComponent(type)}?package=${pkg}`; +} + +/** + * The menu's groups and entries. `types` are the served type entries the + * directory rule already scoped to this menu (`scopeDirectoryEntries`), in + * served order; a type whose domain is none of the six is not drawn. + */ +export function buildStudioMenu(input: { + scope: StudioMenuScope; + types: ReadonlyArray<{ type: string; domain?: string }>; + counts: Readonly>; +}): StudioMenuGroupModel[] { + const { scope, types, counts } = input; + const groups = new Map(STUDIO_MENU_GROUPS.map((g) => [g, []])); + for (const t of types) { + const entries = groups.get(t.domain as StudioMenuGroup); + if (!entries) continue; + entries.push({ key: `type:${t.type}`, kind: 'type', type: t.type, to: typeEntryPath(scope, t.type), count: counts[t.type] }); + } + groups.get('automation')!.push({ key: 'orgFlows', kind: 'orgFlows', to: studioOrgScopePath() }); + if (scope.kind === 'package') { + groups.get('system')!.push({ + key: 'diagnostics', + kind: 'diagnostics', + to: `${studioMetadataAreaPath(scope.packageId)}/_diagnostics`, + }); + groups.get('security')!.push({ + key: 'owd', + kind: 'owd', + to: studioPillarItemPath(scope.packageId, 'access', OWD_OVERVIEW_SURFACE), + }); + } + groups.get('security')!.push({ + key: 'environment', + kind: 'environment', + to: studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT), + }); + return STUDIO_MENU_GROUPS.map((group) => ({ group, entries: groups.get(group)! })).filter( + (g) => scope.kind === 'package' || g.entries.length > 0, + ); +} + +/** The entry keys of the type each pillar designs (the transition's pillar pages). */ +const PILLAR_TYPE: Readonly> = Object.fromEntries( + Object.entries(AREA_PILLAR_FOR_TYPE).map(([type, pillar]) => [pillar, type]), +); + +/** + * The entry the open page is (`aria-current`), or `null` when it is none of + * them (the area's type directory, a not-found pillar). + * + * - the package-less scope: its flows; + * - an area URL: its type, diagnostics, or on the cross-package leg's root + * the environment catalog; + * - a pillar page: the type the pillar designs — the OWD overview on the + * Access pillar while its `?surface=` names it. + */ +export function studioMenuCurrentKey(input: { segment: string; pathname: string; search: string }): string | null { + const { segment, pathname } = input; + if (isStudioOrgScope(segment)) return 'orgFlows'; + const search = new URLSearchParams(input.search); + const areaRoot = studioMetadataAreaPath(segment); + if (pathname === areaRoot || pathname.startsWith(`${areaRoot}/`)) { + const [first] = pathname.slice(areaRoot.length).split('/').filter(Boolean); + if (!first) return isStudioAllPackagesScope(segment) ? 'environment' : null; + if (first === '_diagnostics') return isStudioAllPackagesScope(segment) ? null : 'diagnostics'; + return `type:${decodeURIComponent(first)}`; + } + const prefix = `/studio/${encodeURIComponent(segment)}/`; + const raw = pathname.startsWith(prefix) ? pathname.slice(prefix.length) : ''; + const pillar = raw.split('/')[0]; + if (pillar === STUDIO_METADATA_AREA) return null; + if (pillar === 'access' && (search.get(DESIGNER_SURFACE_PARAM) ?? '').startsWith(`${OWD_OVERVIEW_SURFACE.type}:`)) { + return 'owd'; + } + const type = PILLAR_TYPE[pillar]; + return type ? `type:${type}` : null; +} + +/** Whether `entry` matches a menu search, by its label or its type's machine name. */ +export function studioMenuEntryMatches(entry: StudioMenuEntry, label: string, query: string): boolean { + const q = query.trim().toLowerCase(); + if (!q) return true; + return label.toLowerCase().includes(q) || (entry.type ?? '').toLowerCase().includes(q); +} diff --git a/ui/packages/app-shell/src/views/studio-design/studioZhPillarNames-11801.test.ts b/ui/packages/app-shell/src/views/studio-design/studioZhPillarNames-11801.test.ts index f39a7427655..e296b87b227 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioZhPillarNames-11801.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioZhPillarNames-11801.test.ts @@ -8,7 +8,8 @@ * designer tables' shared extractor (`readDesignerPairs` in * `ui/scripts/check-i18n-dead-keys.mjs`), so the population is the whole table * rather than a list of keys this file would have to keep. Its lit control: - * the extractor's zh value for `engine.studio.pillar.data` must be the one + * the extractor's zh value for `engine.studio.menu.orgFlows` (objectstack#36899 + * retired the pillar names with the top nav) must be the one * `t()` serves, so an extractor that read nothing cannot pass for "no 支柱". * * Moved out of `StudioDesignSurface.railLabels.test.tsx` when objectstack#36502 @@ -33,12 +34,12 @@ const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '.. describe('zh-CN names a pillar by its tab label (objectui#11801)', () => { it('no zh value in the designer string tables says 支柱', () => { - const ZH_DATA = t('engine.studio.pillar.data', 'zh-CN'); + const ZH_ORG_FLOWS = t('engine.studio.menu.orgFlows', 'zh-CN'); const tables = readTables(REPO_ROOT); const zh = tables.get('ENGINE_STRINGS_ZH'); // Lit control: the extractor reads the table `t()` serves. - expect(zh?.get('engine.studio.pillar.data')).toBe(ZH_DATA); - expect(ZH_DATA).toBe('数据'); + expect(zh?.get('engine.studio.menu.orgFlows')).toBe(ZH_ORG_FLOWS); + expect(ZH_ORG_FLOWS).toBe('组织级流程'); const offenders: string[] = []; for (const [name, table] of tables) { diff --git a/ui/packages/components/src/__tests__/sidebar-cookie-restore.test.tsx b/ui/packages/components/src/__tests__/sidebar-cookie-restore.test.tsx index dda078dc2a6..f2cce7bdc70 100644 --- a/ui/packages/components/src/__tests__/sidebar-cookie-restore.test.tsx +++ b/ui/packages/components/src/__tests__/sidebar-cookie-restore.test.tsx @@ -274,3 +274,27 @@ describe('readSidebarStateCookie', () => { expect(readSidebarStateCookie(COOKIE)).toBeUndefined(); }); }); + +describe('a provider with its own cookieName keeps its own state (objectstack#36899)', () => { + const OWN = 'studio_menu_state'; + + it('writes and reads its own cookie, and leaves the shared one alone', () => { + document.cookie = `${COOKIE}=true; path=/`; + render( + + + , + ); + fireEvent.click(screen.getByRole('button')); + expect(readSidebarStateCookie(OWN)).toBe(false); + expect(readSidebarStateCookie(COOKIE)).toBe(true); + + cleanup(); + const own = renderSidebar({ cookieName: OWN }); + expect(own.sequence[0]).toBe('collapsed'); + cleanup(); + // CONTROL — the default provider still reads the shared cookie. + const shared = renderSidebar(); + expect(shared.sequence[0]).toBe('expanded'); + }); +}); diff --git a/ui/packages/components/src/ui/sidebar.tsx b/ui/packages/components/src/ui/sidebar.tsx index 15cca610194..add5cccaf93 100644 --- a/ui/packages/components/src/ui/sidebar.tsx +++ b/ui/packages/components/src/ui/sidebar.tsx @@ -72,6 +72,7 @@ const SidebarProvider = React.forwardRef< defaultOpen?: boolean open?: boolean onOpenChange?: (open: boolean) => void + cookieName?: string } >( ( @@ -79,6 +80,7 @@ const SidebarProvider = React.forwardRef< defaultOpen = true, open: openProp, onOpenChange: setOpenProp, + cookieName = SIDEBAR_COOKIE_NAME, className, style, children, @@ -91,7 +93,7 @@ const SidebarProvider = React.forwardRef< // This is the internal state of the sidebar. // We use openProp and setOpenProp for control from outside the component. - const [_open, _setOpen] = React.useState(() => readSidebarStateCookie(SIDEBAR_COOKIE_NAME) ?? defaultOpen) + const [_open, _setOpen] = React.useState(() => readSidebarStateCookie(cookieName) ?? defaultOpen) const open = openProp ?? _open const setOpen = React.useCallback( (value: boolean | ((value: boolean) => boolean)) => { @@ -103,9 +105,9 @@ const SidebarProvider = React.forwardRef< } // This sets the cookie to keep the sidebar state. - document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}` + document.cookie = `${cookieName}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}` }, - [setOpenProp, open] + [setOpenProp, open, cookieName] ) // Helper to toggle the sidebar. diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index b9d885a8540..ede8edb0c30 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3493,16 +3493,23 @@ const STUDIO_EN: Record = { 'engine.studio.copilotChanges.discardConfirm': 'Discard every unpublished change in this package, yours included? This cannot be undone.', 'engine.studio.copilotChanges.discardFailed': 'Some changes could not be discarded: {items}.', 'engine.studio.copilotChanges.itemSeparator': ', ', - 'engine.studio.pillar.data': 'Data', - 'engine.studio.pillar.automations': 'Automations', - 'engine.studio.pillar.interfaces': 'Interfaces', - 'engine.studio.pillar.access': 'Access', + // objectstack#36899 — Studio's left menu (ADR-0084, amended): six groups, + // named by the domain dictionary, and the entries that open no type's list. + 'engine.studio.menu.label': 'Studio menu', + 'engine.studio.menu.search': 'Search the menu', + 'engine.studio.menu.noMatches': 'Nothing in the menu matches.', + 'engine.studio.menu.expand': 'Show the menu', + 'engine.studio.menu.collapse': 'Hide the menu', + 'engine.studio.menu.typeCount': '{count} types', + 'engine.studio.menu.itemCount': '{count} items', + 'engine.studio.menu.orgFlows': 'Organization flows', + 'engine.studio.menu.owd': 'Default sharing', + 'engine.studio.menu.diagnostics': 'Diagnostics', + 'engine.studio.menu.environment': 'Positions and permissions', // objectstack#36502 — the notice on a retired Interfaces link's landing. 'engine.studio.interfacesRetired.sentence': 'Interface edits have moved into the app.', 'engine.studio.interfacesRetired.backToApp': 'Back to the app', 'engine.studio.interfacesRetired.dismiss': 'Dismiss', - // objectstack#28561 — the "All metadata" area beside the pillars (ADR-0146 D1). - 'engine.studio.pillar.metadata': 'All metadata', // Header · package-level publish + app bridge 'engine.studio.changes': 'Changes', // objectstack#36501 — the top bar's left end: 「‹ Back to app」, the app's diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 27012b6511b..d42b05f0684 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3085,15 +3085,22 @@ const STUDIO_ZH: Record = { 'engine.studio.copilotChanges.discardConfirm': '放弃本包的全部未发布改动(包括你自己的)?此操作不可撤销。', 'engine.studio.copilotChanges.discardFailed': '有改动未能放弃:{items}。', 'engine.studio.copilotChanges.itemSeparator': '、', - 'engine.studio.pillar.data': '数据', - 'engine.studio.pillar.automations': '自动化', - 'engine.studio.pillar.interfaces': '界面', - 'engine.studio.pillar.access': '权限', + // objectstack#36899 — Studio 左侧菜单(ADR-0084 修订):六个分组,名称取自域词典,以及不打开类型列表的入口。 + 'engine.studio.menu.label': 'Studio 菜单', + 'engine.studio.menu.search': '搜索菜单', + 'engine.studio.menu.noMatches': '菜单里没有匹配的项。', + 'engine.studio.menu.expand': '展开菜单', + 'engine.studio.menu.collapse': '收起菜单', + 'engine.studio.menu.typeCount': '{count} 种类型', + 'engine.studio.menu.itemCount': '{count} 项', + 'engine.studio.menu.orgFlows': '组织级流程', + 'engine.studio.menu.owd': '默认共享', + 'engine.studio.menu.diagnostics': '诊断', + 'engine.studio.menu.environment': '岗位与权限', // objectstack#36502 — 旧「界面」链接落地时的提示。 'engine.studio.interfacesRetired.sentence': '界面的修改已经搬到应用里', 'engine.studio.interfacesRetired.backToApp': '回到应用', 'engine.studio.interfacesRetired.dismiss': '关闭', - 'engine.studio.pillar.metadata': '全部元数据', // Header · package-level publish + app bridge 'engine.studio.changes': '变更', 'engine.studio.backToApp': '返回应用', diff --git a/ui/scripts/__tests__/shadcn-local-patches.test.ts b/ui/scripts/__tests__/shadcn-local-patches.test.ts index 3821cda5921..46411cd4fa3 100644 --- a/ui/scripts/__tests__/shadcn-local-patches.test.ts +++ b/ui/scripts/__tests__/shadcn-local-patches.test.ts @@ -358,9 +358,27 @@ describe('shadcn local patches — application to fresh upstream (objectstack#55 } }); - it('sidebar declares no patch outside those three families', () => { + /** + * The eighth family: the provider's own cookie name (objectstack#36899), so + * Studio's left menu keeps its collapse state apart from the app sidebar's. + * The four halves are listed because any one alone leaves the read and the + * write naming different cookies, or a name nothing declares. + */ + it('sidebar declares the cookie-name patches', () => { + const ids = LOCAL_PATCHES.sidebar + .filter((p: { issue: string }) => p.issue === 'objectstack#36899') + .map((p: { id: string }) => p.id); + expect(ids).toEqual([ + 'sidebar-cookie-name-prop', + 'sidebar-cookie-name-destructure', + 'sidebar-cookie-name-write', + 'sidebar-cookie-name-write-deps', + ]); + }); + + it('sidebar declares no patch outside those four families', () => { const issues = [...new Set(LOCAL_PATCHES.sidebar.map((p: { issue: string }) => p.issue))].sort(); - expect(issues).toEqual(['objectui#10859', 'objectui#11464', 'objectui#4234']); + expect(issues).toEqual(['objectstack#36899', 'objectui#10859', 'objectui#11464', 'objectui#4234']); }); /** diff --git a/ui/scripts/shadcn-local-patches.mjs b/ui/scripts/shadcn-local-patches.mjs index 7efc3c3621a..15afdcb6765 100644 --- a/ui/scripts/shadcn-local-patches.mjs +++ b/ui/scripts/shadcn-local-patches.mjs @@ -157,12 +157,64 @@ const sidebarCookieReadPatches = [ 'the first render, not applied after one expanded paint. Precedence is ' + 'cookie > `defaultOpen`; the controlled `open` prop still wins, because ' + 'it is applied downstream of this state (`openProp ?? _open`). ' + - 'SIDEBAR_COOKIE_NAME is passed in so the cookie name keeps exactly one ' + - 'spelling — the write side\'s.', + 'The provider\'s `cookieName` (default SIDEBAR_COOKIE_NAME, the ' + + '`sidebar-cookie-name-*` patches below) is passed in so the read and the ' + + 'write name the same cookie.', find: 'const [_open, _setOpen] = React.useState(defaultOpen)', replace: - 'const [_open, _setOpen] = React.useState(() => readSidebarStateCookie(SIDEBAR_COOKIE_NAME) ?? defaultOpen)', - marker: 'readSidebarStateCookie(SIDEBAR_COOKIE_NAME)', + 'const [_open, _setOpen] = React.useState(() => readSidebarStateCookie(cookieName) ?? defaultOpen)', + marker: 'readSidebarStateCookie(cookieName)', + occurrences: 1, + }, +]; + +/** + * The sidebar cookie-name patches (objectstack#36899). + * + * `SidebarProvider` reads and writes ONE cookie, `sidebar_state`, so a second + * provider in the same console (Studio's left menu) would share the app + * sidebar's collapse state: collapsing one collapsed the other on the next + * load. A `cookieName` prop, defaulting to `SIDEBAR_COOKIE_NAME`, lets a + * provider keep its own; every existing provider passes none and is unchanged. + * The read above takes the same prop. + * + * @type {LocalPatch[]} + */ +const sidebarCookieNamePatches = [ + { + id: 'sidebar-cookie-name-prop', + issue: 'objectstack#36899', + reason: 'Declares the provider\'s optional `cookieName` prop beside `onOpenChange`.', + find: ' onOpenChange?: (open: boolean) => void\n', + replace: ' onOpenChange?: (open: boolean) => void\n cookieName?: string\n', + marker: ' cookieName?: string\n', + occurrences: 1, + }, + { + id: 'sidebar-cookie-name-destructure', + issue: 'objectstack#36899', + reason: 'Reads the prop, defaulting to the one name every existing provider uses.', + find: ' onOpenChange: setOpenProp,\n', + replace: ' onOpenChange: setOpenProp,\n cookieName = SIDEBAR_COOKIE_NAME,\n', + marker: 'cookieName = SIDEBAR_COOKIE_NAME,', + occurrences: 1, + }, + { + id: 'sidebar-cookie-name-write', + issue: 'objectstack#36899', + reason: 'Writes the collapse state under the provider\'s own cookie name.', + find: 'document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}', + replace: 'document.cookie = `${cookieName}=${openState}', + marker: '`${cookieName}=${openState}', + occurrences: 1, + }, + { + id: 'sidebar-cookie-name-write-deps', + issue: 'objectstack#36899', + reason: 'The write\'s callback depends on the name it writes.', + find: ' [setOpenProp, open]\n', + replace: ' [setOpenProp, open, cookieName]\n', + marker: '[setOpenProp, open, cookieName]', occurrences: 1, }, ]; @@ -956,6 +1008,7 @@ export const LOCAL_PATCHES = { 'import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"', ), sidebar: [ + ...sidebarCookieNamePatches, ...sidebarCookieReadPatches, ...sidebarOptionalContextPatches, ...sidebarOffcanvasStateQualifierPatches, From 1d78299a81a62884282877d4967374ca2698a212 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 12:48:48 +0000 Subject: [PATCH 2/9] test(studio): the pillar-nav pins read the left menu The eight surface tests that read the top pillar nav now read the left menu: its groups, its type entries (links to the area's lists), the entry each page marks current, and the leave guard on its links. The narrow-header pin reads the header's one two-column row; the back-to-app pins follow decision 5 (the current package's app, never a remembered one). A model test pins the menu's groups, entries, links and current-entry rule. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- ...DesignSurface.accessSegment-12452.test.tsx | 114 ++++++-------- ...udioDesignSurface.backToApp-36501.test.tsx | 37 +++-- ...DesignSurface.heldDataLeave-26705.test.tsx | 29 ++-- ...DesignSurface.heldFlowLeave-26705.test.tsx | 29 ++-- ...gnSurface.interfacesRetired-36502.test.tsx | 34 ++-- ...oDesignSurface.metadataArea-28561.test.tsx | 45 +++--- ...oDesignSurface.narrowHeader-12509.test.tsx | 146 +++--------------- ...tudioDesignSurface.notFound-26708.test.tsx | 50 +++--- ...tudioDesignSurface.pillarNavGuard.test.tsx | 138 +++++++++-------- .../studio-design/studioMenuModel.test.ts | 117 ++++++++++++++ 10 files changed, 399 insertions(+), 340 deletions(-) create mode 100644 ui/packages/app-shell/src/views/studio-design/studioMenuModel.test.ts diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSegment-12452.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSegment-12452.test.tsx index 1fec71ba33b..c6cb343b7e5 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSegment-12452.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.accessSegment-12452.test.tsx @@ -1,34 +1,24 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * objectui#12452 — Access is a segment of the Studio pillar nav, and the More - * overflow that held it alone is gone. + * objectui#12452, objectstack#36899 — Access is a place of its own in Studio's + * navigation. * - * Since objectui#5813 Access sat in a "More" popover beside the primary - * pillars, and objectui#11794 pinned that trigger's name. The overflow held one - * pillar, so it was a one-item menu. The epic's decision A (objectui#12446) - * puts Access in the segmented control as a first-class pillar and retires - * More; this file replaces the More trigger's pin. + * objectui#12452 made Access a first-class segment of the pillar nav and + * retired the "More" overflow that held it alone. objectstack#36899 replaced + * the pillar nav with the left menu of six domain groups (ADR-0084, amended): + * Access is now a group, and the Access pillar is reached from its + * permission-set entry. This file keeps the two facts the segment's pins held, + * read on the menu: * - * Two facts are pinned: + * 1. The menu's Access group holds the permission-set entry, a real router + * link, with no "More" trigger anywhere; the group carries the shield glyph, + * the Data group's is not it. + * 2. With the Access pillar open (under any package id) that entry is the + * current page and carries the active state; with Data open it carries + * neither, and the object entry carries both. * - * 1. The nav reads Data, Automations, Access (objectstack#36502 retired the - * Interfaces segment that stood third), each a real router link to its - * pillar, with no trigger of any kind beside them. Access carries the - * shield glyph, compared with lucide's own `Shield`. - * 2. With Access open (under any package id) the Access segment is the current - * page and carries the active look the open primary pillar carries; with - * Data open it carries neither, and Data carries both. - * - * A third fact, "leaving an unsaved pillar through Access asks as through - * Data does", was read on the Interfaces pillar's nav edit, the one pillar - * other than Access that reported an unsaved edit; it retired with that - * pillar. The surface's one leave guard stays pinned from Access itself in - * `pillarNavGuard`. - * - * The package-less scope's single pillar stays pinned where it is: - * `packageLessFlows-11553` asserts no Access link there. Re-clicking the open - * Access segment is `pillarNavGuard`'s case. + * Leaving an unsaved pillar is `pillarNavGuard`'s case. * * Rendered through the real `StudioDesignSurface`; only data I/O and heavy * docks are doubled. @@ -39,7 +29,7 @@ import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, screen, cleanup, within } from '@testing-library/react'; import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; -import { Shield } from 'lucide-react'; +import { ShieldCheck } from 'lucide-react'; const PKG = 'com.acme.app'; @@ -98,7 +88,11 @@ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { useMetadataTypes: () => ({ loading: false, error: null, - entries: [{ type: 'permission', label: 'Permission', allowEnvironmentOverlay: true }], + entries: [ + { type: 'object', label: 'Object', domain: 'data' }, + { type: 'flow', label: 'Flow', domain: 'automation' }, + { type: 'permission', label: 'Permission', domain: 'security', allowEnvironmentOverlay: true }, + ], }), }; }); @@ -125,7 +119,7 @@ vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null })); vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null })); import { StudioDesignSurface } from './StudioDesignSurface'; -import { t } from '../metadata-admin/i18n'; +import { translateMetadataDomain } from '../metadata-admin/i18n'; // 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'; @@ -150,11 +144,9 @@ window.matchMedia = ((query: string) => ({ const key = (type: string, name: string) => `${type}/${name}`; -const DATA = t('engine.studio.pillar.data', 'en'); -const AUTOMATIONS = t('engine.studio.pillar.automations', 'en'); -const ACCESS = t('engine.studio.pillar.access', 'en'); -/** The class tokens the open pillar's segment carries (objectui#12459). */ -const ACTIVE = ['bg-background', 'font-medium', 'text-foreground', 'shadow-sm']; +const ACCESS = translateMetadataDomain('security', 'en'); +const OBJECT_ENTRY = 'studio-menu-entry-type:object'; +const PERMISSION_ENTRY = 'studio-menu-entry-type:permission'; // This environment ships no window.confirm: the surface's leave prompt. let confirmSpy: ReturnType; @@ -197,62 +189,54 @@ function renderAt(path: string) { ); } -const pillarNav = () => screen.getByTestId('studio-pillar-nav'); -const segment = (name: string) => within(pillarNav()).getByRole('link', { name }); +const menu = () => screen.getByTestId('studio-menu'); +const entry = (testId: string) => within(menu()).getByTestId(testId); -/** The markup of lucide's own `Shield`, for the Access segment's glyph. */ +/** The markup of lucide's own `ShieldCheck`, the Access group's glyph. */ function shieldMarkup(): string { - const { container, unmount } = render(); + const { container, unmount } = render(); const markup = container.querySelector('svg')!.innerHTML; unmount(); return markup; } -describe('Studio pillar nav: Access is a segment of its own, and More is gone (objectui#12452)', () => { - it('reads Data, Automations, Access, each a link to its pillar, with no trigger beside them', async () => { +describe('Studio menu: Access is a group of its own, and More is gone (objectui#12452, objectstack#36899)', () => { + it('the Access group holds the permission-set entry, a link to the area list, with no More trigger', async () => { renderAt(`/studio/${PKG}/data`); await screen.findByTestId('studio-shell-header'); - const links = within(pillarNav()).getAllByRole('link'); - // objectstack#28561 — the "All metadata" area follows the pillars. - // objectstack#36502 — Interfaces is retired: no segment, no link. - expect(links.map((a) => a.textContent)).toEqual([DATA, AUTOMATIONS, ACCESS, t('engine.studio.pillar.metadata', 'en')]); - expect(links.map((a) => a.getAttribute('href'))).toEqual( - ['data', 'automations', 'access', 'metadata'].map((p) => `/studio/${PKG}/${p}`), + const group = within(menu()).getByTestId('studio-menu-group-security'); + expect(group).toHaveTextContent(ACCESS); + expect(within(group).getByTestId(PERMISSION_ENTRY)).toHaveAttribute( + 'href', + `/studio/${PKG}/metadata/permission?package=${PKG}`, ); - // No More trigger, under its old test id or any other name. - expect(within(pillarNav()).queryAllByRole('button')).toEqual([]); expect(screen.queryByTestId('studio-nav-more')).toBeNull(); - // The shield glyph the overflow entry carried; the Data segment's is not it. + expect(screen.queryByTestId('studio-pillar-nav')).toBeNull(); const shield = shieldMarkup(); - expect(segment(ACCESS).querySelector('svg')!.innerHTML).toBe(shield); - expect(segment(DATA).querySelector('svg')!.innerHTML).not.toBe(shield); + expect(group.querySelector('svg')!.innerHTML).toBe(shield); + expect(within(menu()).getByTestId('studio-menu-group-data').querySelector('svg')!.innerHTML).not.toBe(shield); }); - it.each(['app.objectstack.hotcrm', PKG])('with Access open in %s, Access is the current page and carries the active look', async (pkg) => { + it.each(['app.objectstack.hotcrm', PKG])('with Access open in %s, the permission-set entry is the current page', async (pkg) => { fetchPackagesMock.mockResolvedValue([{ id: pkg, name: 'Pkg', writable: true, namespace: 'pkg' }]); renderAt(`/studio/${pkg}/access`); await screen.findByTestId('studio-shell-header'); - const access = segment(ACCESS); + const access = entry(PERMISSION_ENTRY); expect(access).toHaveAttribute('aria-current', 'page'); - expect(access).toHaveClass(...ACTIVE); - expect(access.querySelector('svg')).toHaveClass('text-primary'); - // No other segment is the open one. - for (const name of [DATA, AUTOMATIONS]) { - expect(segment(name)).not.toHaveAttribute('aria-current'); - expect(segment(name)).not.toHaveClass('shadow-sm'); - } + expect(access).toHaveAttribute('data-active', 'true'); + expect(entry(OBJECT_ENTRY)).not.toHaveAttribute('aria-current'); + expect(entry(OBJECT_ENTRY)).toHaveAttribute('data-active', 'false'); }); - it('control: with Data open, Access carries neither, and Data carries both', async () => { + it('control: with Data open, the permission-set entry carries neither, and the object entry carries both', async () => { renderAt(`/studio/${PKG}/data`); await screen.findByTestId('studio-shell-header'); - expect(segment(ACCESS)).not.toHaveAttribute('aria-current'); - expect(segment(ACCESS)).not.toHaveClass('shadow-sm'); - expect(segment(ACCESS).querySelector('svg')).not.toHaveClass('text-primary'); - expect(segment(DATA)).toHaveAttribute('aria-current', 'page'); - expect(segment(DATA)).toHaveClass(...ACTIVE); + expect(entry(PERMISSION_ENTRY)).not.toHaveAttribute('aria-current'); + expect(entry(PERMISSION_ENTRY)).toHaveAttribute('data-active', 'false'); + expect(entry(OBJECT_ENTRY)).toHaveAttribute('aria-current', 'page'); + expect(entry(OBJECT_ENTRY)).toHaveAttribute('data-active', 'true'); }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.backToApp-36501.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.backToApp-36501.test.tsx index 9951fd18d90..8ec2e8b67ea 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.backToApp-36501.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.backToApp-36501.test.tsx @@ -5,14 +5,18 @@ * app's name and the Studio mark; the Studio-home button, the package switcher * and the top-right Open app are gone. * - * 1. Entered from an app (the app layout recorded the page, as - * `ConsoleLayout` does on every app route), the link names that app and - * returns to that very page, query included. + * 1. Entered from one of the package's apps (the app layout recorded the + * page, as `ConsoleLayout` does on every app route), the link names that + * app and returns to that very page, query included. A recorded page of + * another package's app is not it: the epic's decision 5 (objectstack + * #36890, #36899) names the current package's app, never the remembered + * one, so the link reads as 2. * 2. Opened directly (no record), it names the package's published app and * lands on its first screen; with several apps, the first, by its name. * 3. A package with no published app (none, or only a draft) goes to the - * console's default landing; with no app to name, the name slot names the - * package instead (objectstack#36748). + * console's apps home (`useHomePath`, the launcher); with no app to name, + * the name slot names the package instead (objectstack#36748, the + * maintainer's decision-5 ruling on #36899). * * The REAL `StudioDesignSurface` and metadata client over a fetch stub that * serves the package list, the package's apps and objects. The running app is @@ -161,14 +165,16 @@ describe('「‹ Back to app」 returns to the app page the author came from (ob expect(await screen.findByTestId('running-app')).toHaveTextContent(`/apps/${OWN}/opportunity?view=open`); }); - it('an app other than the package\'s own is the one named and returned to', async () => { + it('a page of another package\'s app is not named: the current package\'s app is (decision 5, objectstack#36899)', async () => { rememberAppReturnPage({ path: '/apps/service/opportunity', app: 'service', label: 'Service desk' }); renderAt(`/studio/${OWN}/data`); const link = await backLink(); // Read the name while the header is still on screen; the click leaves Studio. - expect(within(header()).getByTestId('studio-back-app-name')).toHaveTextContent('Service desk'); + await waitFor(() => expect(within(header()).getByTestId('studio-back-app-name')).toHaveTextContent('Sales'), { + timeout: 8000, + }); fireEvent.click(link); - expect(await screen.findByTestId('running-app')).toHaveTextContent(/^\/apps\/service\/opportunity$/); + expect(await screen.findByTestId('running-app')).toHaveTextContent(new RegExp(`^/apps/${OWN.replace(/\./g, '\\.')}$`)); }); }); @@ -254,9 +260,14 @@ describe('studioBackTarget — the order of the three answers (objectstack#36501 const sales = { name: 'sales', label: 'Sales' }; const service = { name: 'service', label: { en: 'Service', 'zh-CN': '服务台' } }; const base = { packageId: OWN, locale: 'en-US', landingPath: '/landing' }; - it('a recorded page wins over the package app', () => { - const remembered = { path: '/apps/x/y?z=1', app: 'x', label: 'X app' }; - expect(studioBackTarget({ ...base, remembered, apps: [sales] })).toEqual({ path: '/apps/x/y?z=1', appLabel: 'X app' }); + it('a recorded page of one of the package\'s apps wins; one of another package\'s app does not (decision 5)', () => { + const own = { path: '/apps/sales/y?z=1', app: 'sales', label: 'Sales (recorded)' }; + expect(studioBackTarget({ ...base, remembered: own, apps: [sales] })).toEqual({ path: '/apps/sales/y?z=1', appLabel: 'Sales' }); + // The package id is the route key of a package's one app. + const byPackage = { path: `/apps/${OWN}/y`, app: OWN, label: 'Sales' }; + expect(studioBackTarget({ ...base, remembered: byPackage, apps: [sales] })).toEqual({ path: `/apps/${OWN}/y`, appLabel: 'Sales' }); + const foreign = { path: '/apps/x/y?z=1', app: 'x', label: 'X app' }; + expect(studioBackTarget({ ...base, remembered: foreign, apps: [sales] })).toEqual({ path: `/apps/${OWN}`, appLabel: 'Sales' }); }); it('no record: the package id addresses its one app; the name addresses the first of several', () => { expect(studioBackTarget({ ...base, remembered: null, apps: [sales] })).toEqual({ path: `/apps/${OWN}`, appLabel: 'Sales' }); @@ -265,7 +276,9 @@ describe('studioBackTarget — the order of the three answers (objectstack#36501 appLabel: 'Service', }); }); - it('no record and no app, or the package-less scope: the landing, unnamed', () => { + it('no app, or the package-less scope: the apps home, unnamed, whatever is recorded', () => { + const foreign = { path: '/apps/x/y', app: 'x', label: 'X app' }; + expect(studioBackTarget({ ...base, remembered: foreign, apps: [] })).toEqual({ path: '/landing', appLabel: null }); expect(studioBackTarget({ ...base, remembered: null, apps: [] })).toEqual({ path: '/landing', appLabel: null }); expect(studioBackTarget({ ...base, packageId: null, remembered: null, apps: [sales] })).toEqual({ path: '/landing', diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx index 17dc3a019be..10534ce6e41 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldDataLeave-26705.test.tsx @@ -45,7 +45,13 @@ const mockClient = vi.hoisted(() => ({ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { const mod = await importOriginal(); - return { ...mod, useMetadataClient: () => mockClient, useMetadataTypes: () => ({ entries: [] }) }; + return { ...mod, useMetadataClient: () => mockClient, // objectstack#36899 — the registry serves the designer types the left menu lists. + useMetadataTypes: () => ({ + entries: [ + { type: 'object', domain: 'data' }, + { type: 'flow', domain: 'automation' }, + ], + }), }; }); vi.mock('./packages-io', async (importOriginal) => { @@ -140,6 +146,8 @@ async function openTask(): Promise { } /> + {/* objectstack#36899 — a menu type entry opens that type's area list. */} + } /> , ); @@ -160,29 +168,28 @@ function reloadAsks(): boolean { return e.defaultPrevented; } -const pillarLink = (name: string) => within(screen.getByTestId('studio-pillar-nav')).getByRole('link', { name }); +/** objectstack#36899 — the left menu's entry for a type: a link to that type's area list. */ +const menuEntry = (type: string) => within(screen.getByTestId('studio-menu')).getByTestId(`studio-menu-entry-type:${type}`); const railRow = (label: string) => within(screen.getByTestId('studio-rail-data')).getByRole('button', { name: label }); describe('a held Data field guards every departure (objectstack#26705)', () => { - it('leaving the pillar asks; Cancel keeps the held field, OK leaves and clears the guard', async () => { + it('leaving the pillar through the menu asks; Cancel keeps the held field, OK leaves and clears the guard', async () => { await openTask(); await holdAPicklist(); confirmSpy.mockReturnValueOnce(false); - fireEvent.click(pillarLink('Automations')); + fireEvent.click(menuEntry('flow')); expect(confirmSpy).toHaveBeenCalledTimes(1); expect(confirmSpy).toHaveBeenCalledWith(LEAVE_QUESTION); expect(screen.getByTestId('studio-held')).toBeInTheDocument(); expect(screen.getByTestId('studio-rail-data')).toBeInTheDocument(); confirmSpy.mockReturnValueOnce(true); - fireEvent.click(pillarLink('Automations')); + fireEvent.click(menuEntry('flow')); expect(confirmSpy).toHaveBeenCalledTimes(2); - await screen.findByTestId('studio-rail-automations'); + await screen.findByTestId('area-landed'); // The unmounted pillar took its hold back: nothing is asked any more. expect(reloadAsks()).toBe(false); - fireEvent.click(pillarLink('Data')); - expect(confirmSpy).toHaveBeenCalledTimes(2); }); it('opening another object in the rail asks; Cancel keeps the held field, OK opens the other object', async () => { @@ -215,14 +222,14 @@ describe('a held Data field guards every departure (objectstack#26705)', () => { }); // CONTROL: nothing held, nothing asked. - it('with no edit held, the rail, the reload and the pillar link never ask', async () => { + it('with no edit held, the rail, the reload and the menu link never ask', async () => { await openTask(); fireEvent.click(railRow('Note')); await openObjectIs('acme_note'); expect(reloadAsks()).toBe(false); - fireEvent.click(pillarLink('Automations')); - await screen.findByTestId('studio-rail-automations'); + fireEvent.click(menuEntry('flow')); + await screen.findByTestId('area-landed'); expect(confirmSpy).not.toHaveBeenCalled(); }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx index 14dd683e310..f12ff505fc3 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx @@ -61,7 +61,13 @@ const mockClient = vi.hoisted(() => ({ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { const mod = await importOriginal(); - return { ...mod, useMetadataClient: () => mockClient, useMetadataTypes: () => ({ entries: [] }) }; + return { ...mod, useMetadataClient: () => mockClient, // objectstack#36899 — the registry serves the designer types the left menu lists. + useMetadataTypes: () => ({ + entries: [ + { type: 'object', domain: 'data' }, + { type: 'flow', domain: 'automation' }, + ], + }), }; }); vi.mock('./packages-io', async (importOriginal) => { @@ -150,6 +156,8 @@ async function openFlow(): Promise { } /> + {/* objectstack#36899 — a menu type entry opens that type's area list. */} + } /> , ); @@ -171,28 +179,27 @@ function reloadAsks(): boolean { return e.defaultPrevented; } -const pillarLink = (name: string) => within(screen.getByTestId('studio-pillar-nav')).getByRole('link', { name }); +/** objectstack#36899 — the left menu's entry for a type: a link to that type's area list. */ +const menuEntry = (type: string) => within(screen.getByTestId('studio-menu')).getByTestId(`studio-menu-entry-type:${type}`); describe('a held flow step guards every departure (objectstack#26705)', () => { - it('leaving the pillar asks; Cancel keeps the held step, OK leaves and clears the guard', async () => { + it('leaving the pillar through the menu asks; Cancel keeps the held step, OK leaves and clears the guard', async () => { await openFlow(); await holdANotifyStep(); confirmSpy.mockReturnValueOnce(false); - fireEvent.click(pillarLink('Data')); + fireEvent.click(menuEntry('object')); expect(confirmSpy).toHaveBeenCalledTimes(1); expect(confirmSpy).toHaveBeenCalledWith(LEAVE_QUESTION); expect(screen.getByTestId('studio-held')).toBeInTheDocument(); expect(screen.getByTestId('studio-rail-automations')).toBeInTheDocument(); confirmSpy.mockReturnValueOnce(true); - fireEvent.click(pillarLink('Data')); + fireEvent.click(menuEntry('object')); expect(confirmSpy).toHaveBeenCalledTimes(2); - await screen.findByTestId('studio-rail-data'); + await screen.findByTestId('area-landed'); // The unmounted pillar took its hold back: nothing is asked any more. expect(reloadAsks()).toBe(false); - fireEvent.click(pillarLink('Automations')); - expect(confirmSpy).toHaveBeenCalledTimes(2); }); it('opening another flow in the rail asks; Cancel keeps the held step, OK opens the other flow', async () => { @@ -225,14 +232,14 @@ describe('a held flow step guards every departure (objectstack#26705)', () => { }); // CONTROL: nothing held, nothing asked. - it('with no edit held, the rail, the reload and the pillar link never ask', async () => { + it('with no edit held, the rail, the reload and the menu link never ask', async () => { await openFlow(); fireEvent.click(screen.getByTestId('auto-rail-row-reminder')); await screen.findByTitle('API name: reminder', undefined, { timeout: 8000 }); expect(reloadAsks()).toBe(false); - fireEvent.click(pillarLink('Data')); - await screen.findByTestId('studio-rail-data'); + fireEvent.click(menuEntry('object')); + await screen.findByTestId('area-landed'); expect(confirmSpy).not.toHaveBeenCalled(); }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.interfacesRetired-36502.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.interfacesRetired-36502.test.tsx index 9d38627b9bc..6f1e83ed86f 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.interfacesRetired-36502.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.interfacesRetired-36502.test.tsx @@ -17,7 +17,7 @@ * - the notice reads the card's sentence in zh-CN and its English in en, * and its link goes to the package's app, as 「‹ Back to app」 does; * - Dismiss hides it; - * - the pillar nav names no Interfaces segment; + * - the left menu (objectstack#36899) links no Interfaces page; * - CONTROL: an ordinary arrival on the Data pillar shows no notice. * * The URL arithmetic itself is `studioInterfacesRetired.test.ts`. Rendered @@ -28,7 +28,7 @@ import '@testing-library/jest-dom/vitest'; import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, screen, cleanup, fireEvent, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; +import { Link, MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; const PKG = 'com.acme.app'; @@ -87,7 +87,12 @@ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { useMetadataTypes: () => ({ loading: false, error: null, - entries: [{ type: 'permission', label: 'Permission', allowEnvironmentOverlay: true }], + // objectstack#36899 — the designer types the left menu lists. + entries: [ + { type: 'object', label: 'Object', domain: 'data' }, + { type: 'flow', label: 'Flow', domain: 'automation' }, + { type: 'permission', label: 'Permission', domain: 'security', allowEnvironmentOverlay: true }, + ], }), }; }); @@ -185,6 +190,11 @@ function renderAt(path: string) { } /> } /> + {/* objectstack#36899 — a menu type entry opens that type's area list; this stand-in links back to Data. */} + Data} + /> , @@ -246,24 +256,24 @@ describe('an old Interfaces URL lands on the Studio home (objectstack#36502)', ( expect(screen.getByTestId('studio-interfaces-retired')).toBeInTheDocument(); }); - it('leaving for another pillar takes the notice away, and coming back does not bring it', async () => { + it('leaving through the menu takes the notice away, and coming back does not bring it', async () => { renderAt(`/studio/${PKG}/interfaces`); await screen.findByTestId('studio-interfaces-retired'); - const nav = screen.getByTestId('studio-pillar-nav'); - fireEvent.click(within(nav).getByRole('link', { name: 'Automations' })); - await waitFor(() => expect(pathname()).toBe(`/studio/${PKG}/automations`)); + fireEvent.click(within(screen.getByTestId('studio-menu')).getByTestId('studio-menu-entry-type:flow')); + await waitFor(() => expect(pathname()).toBe(`/studio/${PKG}/metadata/flow`)); expect(notice()).toBeNull(); - fireEvent.click(within(nav).getByRole('link', { name: 'Data' })); + fireEvent.click(screen.getByTestId('back-to-data')); await waitFor(() => expect(pathname()).toBe(`/studio/${PKG}/data`)); + await screen.findByTestId('studio-shell-header'); expect(notice()).toBeNull(); }); - it('the pillar nav names no Interfaces segment', async () => { + it('the left menu links no Interfaces page', async () => { renderAt(`/studio/${PKG}/interfaces`); await screen.findByTestId('studio-shell-header'); - const nav = screen.getByTestId('studio-pillar-nav'); - expect(within(nav).getAllByRole('link').map((a) => a.getAttribute('href'))).not.toContain(`/studio/${PKG}/interfaces`); - expect(within(nav).getAllByRole('link').map((a) => a.textContent)).not.toContain('Interfaces'); + const links = within(screen.getByTestId('studio-menu')).getAllByRole('link'); + expect(links.map((a) => a.getAttribute('href'))).not.toContain(`/studio/${PKG}/interfaces`); + expect(links.map((a) => a.textContent)).not.toContain('Interfaces'); }); it('CONTROL: an ordinary arrival on the Data pillar shows no notice', async () => { 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 26727aaa11f..de051a782c0 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 @@ -2,9 +2,10 @@ /** * objectstack#28561 — the "All metadata" area in the builder (ADR-0146 D1): - * the header links it beside the four pillars, and the builder's body is the - * area on its route (`/studio//metadata/*`), which the console mounts - * as ``. + * the builder's body is the area on its route (`/studio//metadata/*`), + * which the console mounts as ``. Since + * objectstack#36899 the left menu is the way in: each type entry links that + * type's list in the area, and the area's pages mark their type current. * * The surface and the area are real here, and so is the one package-list read * both make (`GET /api/v1/packages`). The metadata-admin pages are stubs that @@ -41,7 +42,16 @@ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { return { ...actual, useMetadataClient: () => mockClient, - useMetadataTypes: () => ({ loading: false, error: null, entries: [] }), + // objectstack#36899 — the registry serves the designer types the left menu lists. + useMetadataTypes: () => ({ + loading: false, + error: null, + entries: [ + { type: 'object', domain: 'data' }, + { type: 'flow', domain: 'automation' }, + { type: 'permission', domain: 'security' }, + ], + }), }; }); @@ -96,7 +106,6 @@ vi.mock('./StudioBundleItemEditor.js', () => ({ })); import { StudioDesignSurface } from './StudioDesignSurface'; -import { t } from '../metadata-admin/i18n'; // 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'; @@ -160,7 +169,8 @@ function renderAt(path: string) { } const where = () => screen.getByTestId('where').textContent; -const nav = () => within(screen.getByTestId('studio-pillar-nav')); +const menu = () => within(screen.getByTestId('studio-menu')); +const current = () => menu().getByRole('link', { current: 'page' }); async function areaPage() { const el = await screen.findByTestId('area-page'); return { page: el.getAttribute('data-page'), host: JSON.parse(el.getAttribute('data-host') ?? 'null') }; @@ -185,13 +195,13 @@ afterEach(() => { }); describe('Studio: the "All metadata" area in the builder (objectstack#28561)', () => { - it('a pillar links the area beside the four pillars, not current', async () => { + it('on a pillar, the menu links each type\'s list in the area; the pillar\'s own type is current', async () => { servePackages(); renderAt(`/studio/${PACKAGE_ID}/data`); - const link = await waitFor(() => nav().getByRole('link', { name: t('engine.studio.pillar.metadata', 'en') })); - expect(link).toHaveAttribute('href', `/studio/${PACKAGE_ID}/metadata`); - expect(link).not.toHaveAttribute('aria-current'); - expect(nav().getByRole('link', { current: 'page' })).toHaveAttribute('href', `/studio/${PACKAGE_ID}/data`); + const flows = await waitFor(() => menu().getByTestId('studio-menu-entry-type:flow')); + expect(flows).toHaveAttribute('href', `/studio/${PACKAGE_ID}/metadata/flow?package=${PACKAGE_ID}`); + expect(flows).not.toHaveAttribute('aria-current'); + expect(current()).toHaveAttribute('data-testid', 'studio-menu-entry-type:object'); }); it('the area\'s route: the area is current, no pillar is, and its body is the package\'s directory', async () => { @@ -202,10 +212,9 @@ describe('Studio: the "All metadata" area in the builder (objectstack#28561)', ( host: { packageId: PACKAGE_ID, readOnly: false, basePath: `/studio/${PACKAGE_ID}/metadata` }, }); expect(where()).toBe(`/studio/${PACKAGE_ID}/metadata?package=${PACKAGE_ID}`); - const current = nav().getByRole('link', { current: 'page' }); - expect(current).toHaveAttribute('href', `/studio/${PACKAGE_ID}/metadata`); - // The builder's header stays: the package chip, its pillars, the area. - expect(nav().getAllByRole('link')).toHaveLength(4); + // The directory is no one entry's page; the builder's menu stays beside it. + expect(menu().queryByRole('link', { current: 'page' })).toBeNull(); + expect(menu().getByTestId('studio-menu-group-data')).toBeInTheDocument(); expect(screen.queryByTestId('studio-pillar-not-found')).toBeNull(); // The surface and the area share the one package-list read. expect(fetchMock.mock.calls.filter(([input]) => String(input) === '/api/v1/packages')).toHaveLength(1); @@ -213,9 +222,9 @@ describe('Studio: the "All metadata" area in the builder (objectstack#28561)', ( it('the pages below the area\'s root are the area\'s too', async () => { servePackages(); - renderAt(`/studio/${PACKAGE_ID}/metadata/translation?package=${PACKAGE_ID}`); + renderAt(`/studio/${PACKAGE_ID}/metadata/flow?package=${PACKAGE_ID}`); expect((await areaPage()).page).toBe('list'); - expect(nav().getByRole('link', { current: 'page' })).toHaveAttribute('href', `/studio/${PACKAGE_ID}/metadata`); + expect(current()).toHaveAttribute('data-testid', 'studio-menu-entry-type:flow'); }); it('a kernel package the switcher hides opens its area read-only', async () => { @@ -231,7 +240,7 @@ describe('Studio: the "All metadata" area in the builder (objectstack#28561)', ( servePackages(); renderAt(`/studio/${PHANTOM}/metadata`); expect(await screen.findByTestId('studio-package-not-found')).toBeInTheDocument(); - expect(nav().queryAllByRole('link')).toHaveLength(0); + expect(screen.queryByTestId('studio-menu')).toBeNull(); expect(screen.queryByTestId('studio-metadata-area')).toBeNull(); }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.narrowHeader-12509.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.narrowHeader-12509.test.tsx index 3e963ba64be..3a231d963d1 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.narrowHeader-12509.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.narrowHeader-12509.test.tsx @@ -1,135 +1,31 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * objectui#12509 — the Studio shell header on a narrow window. + * objectui#12509, objectstack#36899 — the Studio shell header on a narrow + * window. * - * Measured in a 558 px window, the one 48 px row put the switcher's Access - * segment under Changes and clipped Publish; at exactly 640 px the Create app - * button still sat under Access. The header is now: + * objectui#12509 measured a 558 px window where the one 48 px row put the + * pillar switcher's Access segment under Changes and clipped Publish, and gave + * the switcher a second row below 640 px. objectstack#36899 moved navigation + * out of the header into the left menu (a drawer below 768 px), so the header + * holds two things at every width: the menu toggle with 「‹ Back to app」 and + * the package name on the left, the package actions on the right. It is one + * 48 px row of two columns: the left one shrinks to nothing (the name + * truncates), the right one never drops below its content, so nothing sits + * under anything. * - * - below `sm` (640 px): two rows. Home, the package chip and the package - * actions on the first; the pillar switcher on the second at full width, - * each segment an equal share, icon-only, its name kept as the link's - * accessible name; - * - from `sm` up: one 48 px row, three columns, the switcher in the middle. - * The right column never drops below its content, so a tight row moves the - * switcher left and truncates the chip instead of overlapping. - * - * jsdom has no layout, so the pins read the Tailwind classes: the token - * strings split into their unprefixed (below `sm`) and `sm:` halves, and the - * real surface wearing those tokens. The 375 / 560 / 1280 px screenshots in - * the PR are the layout evidence. + * jsdom has no layout, so the pin reads the Tailwind classes of the token. The + * wide / narrow / collapsed screenshots in the PR are the layout evidence. */ -import '@testing-library/jest-dom/vitest'; -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { cleanup } from '@testing-library/react'; - -const PACKAGE_ID = 'app.n4rr'; - -vi.mock('sonner', () => ({ - toast: { error: vi.fn(), success: vi.fn(), info: vi.fn(), warning: vi.fn(), dismiss: vi.fn() }, - Toaster: () => null, -})); - -const mockClient = { - list: vi.fn(async () => []), - listDrafts: vi.fn(async () => []), - layered: vi.fn(async (_t: string, name: string) => ({ effective: { name } })), - getDraft: vi.fn(async () => null), - get: vi.fn(async () => undefined), - save: vi.fn(async () => ({})), -}; - -vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { - const actual = await importOriginal>(); - return { - ...actual, - useMetadataClient: () => mockClient, - useMetadataTypes: () => ({ loading: false, error: null, entries: [] }), - }; -}); - -vi.mock('@object-ui/react', async (importOriginal) => { - const actual = await importOriginal>(); - return { ...actual, useAdapter: () => ({}) }; -}); - -vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPanel: () => null })); -vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: () => null })); -vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null })); -vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null })); - -// The source loads `@objectstack/lint` lazily; paid here, at collection, not -// inside a case's clock (check:test-source-alias). -import '@objectstack/lint'; -import { STUDIO_HEADER, STUDIO_HEADER_PILLAR, STUDIO_HEADER_PILLAR_NAV } from './studio-tokens'; - -const answer = (body: unknown) => ({ ok: true, status: 200, json: async () => body }); - -/** A class string's two halves: what applies below `sm`, and what `sm:` sets from 640 px up. */ -function split(classes: string): { base: string[]; sm: string[] } { - const all = classes.split(/\s+/).filter(Boolean); - return { - base: all.filter((c) => !/^[a-z0-9]+:/.test(c)), - sm: all.filter((c) => c.startsWith('sm:')).map((c) => c.slice(3)), - }; -} +import { describe, expect, it } from 'vitest'; +import { STUDIO_HEADER } from './studio-tokens'; -beforeEach(() => { - vi.stubGlobal('matchMedia', (query: string) => ({ - matches: false, - media: query, - onchange: null, - addEventListener: () => {}, - removeEventListener: () => {}, - addListener: () => {}, - removeListener: () => {}, - dispatchEvent: () => false, - })); - vi.stubGlobal( - 'fetch', - vi.fn(async (input: unknown) => - String(input) === '/api/v1/packages' - ? answer({ - success: true, - data: { packages: [{ manifest: { id: PACKAGE_ID, name: 'Field Ops' }, writable: true }] }, - }) - : answer([]), - ), - ); -}); - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); -}); - -describe('Studio shell header below and above 640 px (objectui#12509)', () => { - it('below `sm` the header is a two-column grid with no fixed height; the switcher is its own full-width last row', () => { - const header = split(STUDIO_HEADER); - expect(header.base).toEqual(expect.arrayContaining(['grid', 'grid-cols-[minmax(0,1fr)_auto]', 'py-2', 'gap-y-2'])); - // Two rows cannot fit in 48 px: the fixed height is an `sm:` class only. - expect(header.base).not.toContain('h-12'); - - const nav = split(STUDIO_HEADER_PILLAR_NAV); - expect(nav.base).toEqual(expect.arrayContaining(['order-last', 'col-span-2', 'flex'])); - - const segment = split(STUDIO_HEADER_PILLAR); - expect(segment.base).toEqual(expect.arrayContaining(['flex-1', 'min-w-0', 'justify-center'])); +describe('Studio shell header at every width (objectui#12509, objectstack#36899)', () => { + it('is one 48 px row of two columns: a left column that shrinks, a right column that never drops below its content', () => { + const classes = STUDIO_HEADER.split(/\s+/).filter(Boolean); + expect(classes).toEqual(expect.arrayContaining(['grid', 'h-12', 'shrink-0', 'items-center', 'grid-cols-[minmax(0,1fr)_auto]'])); + // No breakpoint re-lays it out: the switcher's second row is gone. + expect(classes.filter((c) => /^[a-z0-9]+:/.test(c) && !c.startsWith('@container'))).toEqual([]); }); - - it('from `sm` up the header is one 48 px row of three columns; the right column never shrinks under its content', () => { - const header = split(STUDIO_HEADER); - expect(header.sm).toEqual( - expect.arrayContaining(['h-12', 'py-0', 'grid-cols-[minmax(0,1fr)_auto_minmax(max-content,1fr)]']), - ); - - const nav = split(STUDIO_HEADER_PILLAR_NAV); - expect(nav.sm).toEqual(expect.arrayContaining(['order-none', 'col-span-1'])); - - const segment = split(STUDIO_HEADER_PILLAR); - expect(segment.sm).toEqual(expect.arrayContaining(['flex-none', 'shrink-0'])); - }); - }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.notFound-26708.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.notFound-26708.test.tsx index 71ca26a6611..6c5611a7543 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.notFound-26708.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.notFound-26708.test.tsx @@ -6,10 +6,11 @@ * `/studio/` for an id the package list does not hold rendered the full * writable builder (New object, Create app, Publish) for a package that does * not exist, and every save there went to a phantom package. It now renders - * "package not found", with no pillars and no package actions, and a way back + * "package not found", with no menu and no package actions, and a way back * to the Studio landing. And `/studio//` for a segment no pillar * has fell through to the Interfaces pillar with nothing highlighted; it now - * renders a not-found state, the real pillars still linked above it. (The + * renders a not-found state, the left menu (objectstack#36899, which replaced + * the pillars above it) still beside it, nothing in it current. (The * Interfaces pillar itself retired with objectstack#36502: its old segment is * not "not found" but lands on the Data pillar, pinned last in this file.) * @@ -50,7 +51,16 @@ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { return { ...actual, useMetadataClient: () => mockClient, - useMetadataTypes: () => ({ loading: false, error: null, entries: [] }), + // objectstack#36899 — the registry serves the designer types the left menu lists. + useMetadataTypes: () => ({ + loading: false, + error: null, + entries: [ + { type: 'object', domain: 'data' }, + { type: 'flow', domain: 'automation' }, + { type: 'permission', domain: 'security' }, + ], + }), }; }); @@ -134,15 +144,19 @@ async function listAnswered(fetchMock: ReturnType): Promis }); } +const menu = () => screen.getByTestId('studio-menu'); +const menuLinks = () => within(menu()).getAllByRole('link'); + describe('Studio: a package id no package has renders "package not found" (objectstack#26708)', () => { - it.each(['data', 'automations', 'interfaces', 'access'])('%s: not found, no pillars, no package actions', async (pillar) => { + it.each(['data', 'automations', 'interfaces', 'access'])('%s: not found, no menu, no package actions', async (pillar) => { const fetchMock = servePackages(); renderAt(`/studio/${PHANTOM}/${pillar}`); const notFound = await screen.findByTestId('studio-package-not-found'); expect(notFound).toHaveTextContent(tFormat('engine.studio.notFound.package', 'en', { id: PHANTOM })); const header = screen.getByTestId('studio-shell-header'); - expect(within(screen.getByTestId('studio-pillar-nav')).queryAllByRole('link')).toHaveLength(0); + expect(screen.queryByTestId('studio-menu')).toBeNull(); + expect(within(header).queryByTestId('studio-menu-toggle')).toBeNull(); expect(within(header).queryByRole('button', { name: new RegExp(t('engine.studio.publish', 'en')) })).toBeNull(); expect(within(header).queryByRole('button', { name: new RegExp(t('engine.studio.changes', 'en')) })).toBeNull(); expect(within(header).queryByTitle(t('engine.studio.app.noneTitle', 'en'))).toBeNull(); @@ -163,8 +177,10 @@ describe('Studio: a package id no package has renders "package not found" (objec renderAt(`/studio/${PACKAGE_ID}/data`); await listAnswered(fetchMock); expect(screen.queryByTestId('studio-package-not-found')).toBeNull(); - // The three pillars and, objectstack#28561, the "All metadata" area. - expect(within(screen.getByTestId('studio-pillar-nav')).getAllByRole('link')).toHaveLength(4); + // objectstack#36899 — the left menu, its six groups drawn. + for (const group of ['data', 'ui', 'automation', 'system', 'security', 'ai']) { + expect(within(menu()).getByTestId(`studio-menu-group-${group}`)).toBeInTheDocument(); + } }); it('CONTROL — a kernel package the Studio landing hides is installed, never "not found"', async () => { @@ -179,34 +195,28 @@ describe('Studio: a package id no package has renders "package not found" (objec renderAt(`/studio/${PHANTOM}/data`); await listAnswered(fetchMock); expect(screen.queryByTestId('studio-package-not-found')).toBeNull(); - expect(within(screen.getByTestId('studio-pillar-nav')).getAllByRole('link')).toHaveLength(4); + expect(menuLinks().length).toBeGreaterThan(0); }); }); describe('Studio: a pillar segment no pillar has renders a not-found state (objectstack#26708)', () => { - it('names the segment, keeps the real pillars linked, and mounts no pillar', async () => { + it('names the segment, keeps the menu beside it with nothing current, and mounts no pillar', async () => { servePackages(); renderAt(`/studio/${PACKAGE_ID}/bogus_pillar`); const notFound = await screen.findByTestId('studio-pillar-not-found'); expect(notFound).toHaveTextContent(tFormat('engine.studio.notFound.pillar', 'en', { pillar: 'bogus_pillar' })); - const links = within(screen.getByTestId('studio-pillar-nav')).getAllByRole('link'); - expect(links.map((a) => a.getAttribute('href'))).toEqual([ - `/studio/${PACKAGE_ID}/data`, - `/studio/${PACKAGE_ID}/automations`, - `/studio/${PACKAGE_ID}/access`, - `/studio/${PACKAGE_ID}/metadata`, - ]); + const links = menuLinks(); + expect(links.map((a) => a.getAttribute('href'))).toContain(`/studio/${PACKAGE_ID}/metadata/object?package=${PACKAGE_ID}`); for (const link of links) expect(link).not.toHaveAttribute('aria-current'); }); it('CONTROL — the retired interfaces segment is not "not found": it lands on the Data pillar (objectstack#36502)', async () => { servePackages(); renderAt(`/studio/${PACKAGE_ID}/interfaces`); - const current = await waitFor(() => - within(screen.getByTestId('studio-pillar-nav')).getByRole('link', { current: 'page' }), - ); - expect(current).toHaveAttribute('href', `/studio/${PACKAGE_ID}/data`); + // The Data pillar's entry in the menu is its type's, Objects. + const current = await waitFor(() => within(menu()).getByRole('link', { current: 'page' })); + expect(current).toHaveAttribute('data-testid', 'studio-menu-entry-type:object'); expect(screen.queryByTestId('studio-pillar-not-found')).toBeNull(); expect(screen.getByTestId('studio-interfaces-retired')).toBeInTheDocument(); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx index a84c246ab8e..bfe995a301b 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx @@ -1,29 +1,31 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * Studio header — unsaved-changes guard on SPA navigation (objectui#2600). + * Studio — unsaved-changes guard on SPA navigation (objectui#2600). * - * The pillar links and 「‹ Back to app」 (objectstack#36501; it replaced the - * Home button and the PackageSwitcher, whose package switch the shell seam - * below still guards for every other door) are pure react-router client - * navigation, so the editors' `beforeunload` guard never - * fires; before this guard existed they unmounted a dirty pillar silently and - * discarded its unsaved edits. Pillars now mirror their dirty state up to the - * surface (same `onDirtyChange` contract as the Access rail guard, PR #2588), - * and every header-driven departure gates on a native confirm: + * The left menu's entries (objectstack#36899; they replaced the pillar links) + * and 「‹ Back to app」 (objectstack#36501) are pure react-router client + * navigation, so the editors' `beforeunload` guard never fires; before this + * guard existed they unmounted a dirty pillar silently and discarded its + * unsaved edits. Pillars mirror their dirty state up to the surface (same + * `onDirtyChange` contract as the Access rail guard, PR #2588), and every + * departure from the surface's chrome gates on a native confirm: * - * • dirty + pillar switch → confirm; cancel keeps the pillar and its edits, + * • dirty + a menu entry that leaves the pillar → confirm; cancel keeps the + * pillar and its edits, * • dirty + 「‹ Back to app」 → same confirm; cancel stays, confirm leaves, - * • dirty OWD overview rows + pillar switch → same confirm (the pillar - * folds the overview's report into the same bit, objectui#2600 follow-up), + * • dirty OWD overview rows + leaving → same confirm (the pillar folds the + * overview's report into the same bit, objectui#2600 follow-up), + * • dirty + the menu's default-sharing entry, which re-enters the open + * Access pillar on another query (remounting it) → same confirm, once; + * cancel keeps the edit, confirm opens the overview, * • clean navigation never prompts, - * • re-clicking the open pillar never prompts (nothing unmounts), * • a confirmed discard clears the guard (the pillar resets on unmount). * * objectui#13253 — a dirty pillar also registers with the shell's * unsaved-edits seam, so a shell departure (a header menu, the palette, the - * inbox, the AI entry) asks too. The seam's capture-phase link guard now asks - * before a pillar link leaves, so the pillar links ask once, not twice. The + * inbox, the AI entry) asks too. The seam's capture-phase link guard asks + * before a menu link leaves, so a menu entry asks once, not twice. The * window's URL is kept at the router's, as `BrowserRouter` keeps it, because * that guard reads the window's URL to skip a link to the page already shown. * @@ -49,7 +51,12 @@ vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { useMetadataTypes: () => ({ loading: false, error: null, - entries: [{ type: 'permission', label: 'Permission', allowEnvironmentOverlay: true }], + // objectstack#36899 — the designer types the left menu lists. + entries: [ + { type: 'object', label: 'Object', domain: 'data' }, + { type: 'flow', label: 'Flow', domain: 'automation' }, + { type: 'permission', label: 'Permission', domain: 'security', allowEnvironmentOverlay: true }, + ], }), }; }); @@ -187,6 +194,8 @@ async function renderSurfaceOnAccess() { } /> + {/* objectstack#36899 — a menu type entry opens that type's area list. */} + } /> } /> } /> @@ -198,10 +207,21 @@ async function renderSurfaceOnAccess() { } -/** objectui#12452 — Access is a segment of the pillar nav (the More overflow - * that held it retired): click its real router Link. */ -async function clickAccessInNav() { - fireEvent.click(await within(screen.getByTestId('studio-pillar-nav')).findByRole('link', { name: 'Access' })); +/** objectstack#36899 — a left-menu entry: a real router Link. */ +const menuEntry = (key: string) => within(screen.getByTestId('studio-menu')).getByTestId(`studio-menu-entry-${key}`); +/** The entry that leaves the Access pillar: the flows' list in the area. */ +const leave = () => fireEvent.click(menuEntry('type:flow')); +/** The entry that re-enters the open Access pillar on its default-sharing overview. */ +const reenterOnOwd = () => fireEvent.click(menuEntry('owd')); + +/** The departure is done and nothing is held: a shell departure goes at once. */ +async function leftAndGuardCleared(asked: number) { + await screen.findByTestId('area-landed'); + expect(screen.queryByText('set_a')).not.toBeInTheDocument(); + const go = vi.fn(); + confirmUnsavedLeave(go); + expect(go).toHaveBeenCalledTimes(1); + expect(confirmSpy).toHaveBeenCalledTimes(asked); } /** @@ -241,85 +261,71 @@ const matrixEditSurvived = () => { expect(within(row).getByRole('checkbox', { name: 'a_account Read' })).not.toBeChecked(); }; -/** The switch landed: the Automations segment is the current page (objectstack#36502 retired Interfaces, the switch these cases used to make). */ -async function landedOnAutomations() { - await waitFor(() => expect(screen.getByRole('link', { name: 'Automations' })).toHaveAttribute('aria-current', 'page')); -} - -describe('Studio header — unsaved pillar edits guard (#2600)', () => { - it('asks before a pillar switch when dirty; cancel keeps the pillar and its edits', async () => { +describe('Studio — unsaved pillar edits guard (#2600)', () => { + it('asks before a menu entry leaves the pillar when dirty; cancel keeps the pillar and its edits', async () => { await renderSurfaceOnAccess(); dirtyTheMatrix(); confirmSpy.mockReturnValueOnce(false); - fireEvent.click(screen.getByRole('link', { name: 'Automations' })); + leave(); expect(confirmSpy).toHaveBeenCalledTimes(1); expect(inSetHeader().getByTitle('set_a')).toBeInTheDocument(); matrixEditSurvived(); - // Confirming the same switch discards and lands on the Automations pillar. + // Confirming the same departure discards and leaves; the unmounted + // pillar reset the guard. confirmSpy.mockReturnValueOnce(true); - fireEvent.click(screen.getByRole('link', { name: 'Automations' })); - expect(confirmSpy).toHaveBeenCalledTimes(2); - await landedOnAutomations(); - expect(screen.queryByText('set_a')).not.toBeInTheDocument(); - - // The discarded pillar reset the guard on unmount — walking back to - // Access must NOT prompt again. - await clickAccessInNav(); + leave(); expect(confirmSpy).toHaveBeenCalledTimes(2); - await findInSetHeader('set_a'); + await leftAndGuardCleared(2); }); - it('gates a pillar switch on dirty OWD overview rows (#2600 follow-up)', async () => { + it('gates leaving on dirty OWD overview rows (#2600 follow-up)', async () => { await renderSurfaceOnAccess(); - // Swap the main panel to the (real) OWD overview and edit a row so the - // panel's dirty report crosses AccessPillar into the surface guard. - fireEvent.click(screen.getByRole('button', { name: 'Who can see which records' })); - await screen.findByTestId('owd-internal-a_account'); - // The dial is the shared Select (objectui#11865): open it and pick, as a user does. - const owdPrivate = t('engine.studio.settings.sharingPrivate', 'en-US'); - fireEvent.keyDown(screen.getByTestId('owd-internal-a_account'), { key: 'ArrowDown' }); - const listbox = await screen.findByRole('listbox'); - fireEvent.click(within(listbox).getByRole('option', { name: owdPrivate })); + const owdPrivate = await dirtyTheOwdOverview(); confirmSpy.mockReturnValueOnce(false); - fireEvent.click(screen.getByRole('link', { name: 'Automations' })); + leave(); expect(confirmSpy).toHaveBeenCalledTimes(1); // Still on the overview, edit intact. expect(screen.getByTestId('owd-internal-a_account').textContent).toBe(owdPrivate); - // Confirming discards and leaves; the unmounting pillar resets the guard, - // so walking back to Access must NOT prompt again. confirmSpy.mockReturnValueOnce(true); - fireEvent.click(screen.getByRole('link', { name: 'Automations' })); + leave(); expect(confirmSpy).toHaveBeenCalledTimes(2); - await landedOnAutomations(); - - await clickAccessInNav(); - expect(confirmSpy).toHaveBeenCalledTimes(2); - await findInSetHeader('set_a'); + await leftAndGuardCleared(2); }); - it('switches pillars without prompting when clean', async () => { + it('leaves without prompting when clean', async () => { await renderSurfaceOnAccess(); - - fireEvent.click(screen.getByRole('link', { name: 'Automations' })); - + leave(); expect(confirmSpy).not.toHaveBeenCalled(); - await landedOnAutomations(); + await screen.findByTestId('area-landed'); }); - it('never prompts when re-clicking the open pillar (nothing unmounts)', async () => { + it('the default-sharing entry re-enters the open pillar: dirty, it asks once; cancel keeps the edit, confirm opens the overview', async () => { await renderSurfaceOnAccess(); dirtyTheMatrix(); - await clickAccessInNav(); - - expect(confirmSpy).not.toHaveBeenCalled(); + confirmSpy.mockReturnValueOnce(false); + reenterOnOwd(); + expect(confirmSpy).toHaveBeenCalledTimes(1); expect(inSetHeader().getByTitle('set_a')).toBeInTheDocument(); matrixEditSurvived(); + + confirmSpy.mockReturnValueOnce(true); + reenterOnOwd(); + expect(confirmSpy).toHaveBeenCalledTimes(2); + await screen.findByTestId('owd-internal-a_account'); + expect(menuEntry('owd')).toHaveAttribute('aria-current', 'page'); + }); + + it('CONTROL: clean, the default-sharing entry opens the overview without asking', async () => { + await renderSurfaceOnAccess(); + reenterOnOwd(); + await screen.findByTestId('owd-internal-a_account'); + expect(confirmSpy).not.toHaveBeenCalled(); }); it('gates 「‹ Back to app」; cancel stays, confirm leaves Studio (objectstack#36501)', async () => { diff --git a/ui/packages/app-shell/src/views/studio-design/studioMenuModel.test.ts b/ui/packages/app-shell/src/views/studio-design/studioMenuModel.test.ts new file mode 100644 index 00000000000..2170f5e2ab0 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/studioMenuModel.test.ts @@ -0,0 +1,117 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36899 — Studio's left menu as data (ADR-0084, amended): six + * groups in the amendment's order, a type in the group of its served domain, + * the four entries that open no type's list in the groups of what they hold, + * and the entry each Studio page marks current. + */ + +import { describe, expect, it } from 'vitest'; +import { + STUDIO_MENU_GROUPS, + buildStudioMenu, + studioMenuCurrentKey, + studioMenuEntryMatches, + studioMenuScope, +} from './studioMenuModel'; + +const PKG = 'com.example.crm'; +const TYPES = [ + { type: 'object', domain: 'data' }, + { type: 'view', domain: 'ui' }, + { type: 'flow', domain: 'automation' }, + { type: 'datasource', domain: 'system' }, + { type: 'permission', domain: 'security' }, + { type: 'agent', domain: 'ai' }, + { type: 'legacy', domain: 'identity' }, +]; + +const keysOf = (menu: ReturnType) => + Object.fromEntries(menu.map((g) => [g.group, g.entries.map((e) => e.key)])); + +describe('the menu groups (objectstack#36899, ADR-0084 amended)', () => { + it('are the six registered domains, in the amendment\'s order', () => { + expect(STUDIO_MENU_GROUPS).toEqual(['data', 'ui', 'automation', 'system', 'security', 'ai']); + }); + + it('a package: every type in its domain\'s group, and the four entries that are not a type', () => { + const menu = buildStudioMenu({ scope: studioMenuScope(PKG), types: TYPES, counts: { object: 4 } }); + expect(keysOf(menu)).toEqual({ + data: ['type:object'], + ui: ['type:view'], + automation: ['type:flow', 'orgFlows'], + system: ['type:datasource', 'diagnostics'], + security: ['type:permission', 'owd', 'environment'], + ai: ['type:agent'], + }); + const entry = (key: string) => menu.flatMap((g) => g.entries).find((e) => e.key === key)!; + expect(entry('type:object')).toMatchObject({ to: `/studio/${PKG}/metadata/object?package=${PKG}`, count: 4 }); + expect(entry('type:view').count).toBeUndefined(); + // ADR-0146 D1 — runtime configuration is Setup's. + expect(entry('type:datasource').to).toBe('/apps/setup/metadata/datasource'); + expect(entry('orgFlows').to).toBe('/studio/~org/automations'); + expect(entry('diagnostics').to).toBe(`/studio/${PKG}/metadata/_diagnostics`); + expect(entry('owd').to).toBe(`/studio/${PKG}/access?surface=owd%3Aoverview`); + expect(entry('environment').to).toBe('/studio/~all/metadata'); + }); + + it('a package draws all six groups, an empty one included', () => { + const menu = buildStudioMenu({ scope: studioMenuScope(PKG), types: [], counts: {} }); + expect(menu.map((g) => g.group)).toEqual(STUDIO_MENU_GROUPS); + expect(keysOf(menu).data).toEqual([]); + }); + + it.each(['~org', '~all'])('%s: the environment\'s menu, only the groups that hold an entry', (segment) => { + const types = [ + { type: 'position', domain: 'security' }, + { type: 'permission', domain: 'security' }, + ]; + const menu = buildStudioMenu({ scope: studioMenuScope(segment), types, counts: {} }); + expect(keysOf(menu)).toEqual({ + automation: ['orgFlows'], + security: ['type:position', 'type:permission', 'environment'], + }); + expect(menu.flatMap((g) => g.entries).find((e) => e.key === 'type:position')!.to).toBe( + '/studio/~all/metadata/position?scope=environment', + ); + }); +}); + +describe('the current entry (aria-current)', () => { + const current = (segment: string, path: string) => { + const [pathname, query = ''] = path.split('?'); + return studioMenuCurrentKey({ segment, pathname, search: query ? `?${query}` : '' }); + }; + + it('an area page is its type, diagnostics, or nothing at the directory', () => { + expect(current(PKG, `/studio/${PKG}/metadata/view`)).toBe('type:view'); + expect(current(PKG, `/studio/${PKG}/metadata/view/v1/history`)).toBe('type:view'); + expect(current(PKG, `/studio/${PKG}/metadata/_diagnostics`)).toBe('diagnostics'); + expect(current(PKG, `/studio/${PKG}/metadata`)).toBeNull(); + }); + + it('a pillar page is the type it designs; the Access pillar on its OWD overview is that entry', () => { + expect(current(PKG, `/studio/${PKG}/data?surface=object:account`)).toBe('type:object'); + expect(current(PKG, `/studio/${PKG}/automations`)).toBe('type:flow'); + expect(current(PKG, `/studio/${PKG}/access?surface=permission:admin`)).toBe('type:permission'); + expect(current(PKG, `/studio/${PKG}/access?surface=owd:overview`)).toBe('owd'); + expect(current(PKG, `/studio/${PKG}/bogus`)).toBeNull(); + }); + + it('the package-less scope is its flows; the cross-package leg\'s root is the environment catalog', () => { + expect(current('~org', '/studio/~org/automations')).toBe('orgFlows'); + expect(current('~all', '/studio/~all/metadata')).toBe('environment'); + expect(current('~all', '/studio/~all/metadata/position')).toBe('type:position'); + }); +}); + +describe('the menu search', () => { + const entry = { key: 'type:permission', kind: 'type' as const, type: 'permission', to: '/' }; + it('matches the label or the machine name, case-insensitive; an empty query matches all', () => { + expect(studioMenuEntryMatches(entry, 'Permission Sets', 'sets')).toBe(true); + expect(studioMenuEntryMatches(entry, '权限集', 'PERMISSION')).toBe(true); + expect(studioMenuEntryMatches(entry, 'Permission Sets', 'flow')).toBe(false); + expect(studioMenuEntryMatches(entry, 'Permission Sets', ' ')).toBe(true); + }); +}); From 06bbeb7273c25911d5d892891fa2ddfae2edc086 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 12:52:21 +0000 Subject: [PATCH 3/9] test(studio): the menu's own pins, its routes in the console, an e2e page The menu's render pins (its own cookie, the drawer, the current entry, the search, focus order), the console's cross-package leg on the builder route and the entry gate before the menu's targets, a Chromium page for the menu's geometry, and the changeset. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- .changeset/36899-studio-left-menu.md | 20 ++ .../StudioRoute.metadataArea-28561.test.tsx | 41 ++-- .../StudioRoute.recentPackage-11863.test.tsx | 8 + ui/e2e/studio-left-menu-36899.spec.ts | 229 ++++++++++++++++++ .../views/studio-design/StudioMenu.test.tsx | 198 +++++++++++++++ 5 files changed, 481 insertions(+), 15 deletions(-) create mode 100644 .changeset/36899-studio-left-menu.md create mode 100644 ui/e2e/studio-left-menu-36899.spec.ts create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx diff --git a/.changeset/36899-studio-left-menu.md b/.changeset/36899-studio-left-menu.md new file mode 100644 index 00000000000..752a5992f97 --- /dev/null +++ b/.changeset/36899-studio-left-menu.md @@ -0,0 +1,20 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/components': patch +'@object-ui/i18n': patch +'@object-ui/console': patch +--- + +feat(studio): a collapsible left menu of six groups replaces the top pillar nav + +Clause-②: no +Metadata-protocol: none + +ADR-0084 (amended) · #36899, part of #36890. + +- **Studio's one navigation is a left menu.** The top bar's Data / Automations / Access / All metadata switcher is gone. Every Studio page (a package's pillars and area, the package-less flows `~org`, and the cross-package leg `~all`) draws the same menu of six groups: Data, Interface, Automation, Platform, Access, AI. Each group lists the metadata types the package holds (the directory's own rule, `scopeDirectoryEntries`), with a type count per group and an item count per type, and a search box that narrows the entries. A type entry opens that type's list in the area; an item of an object, flow or permission set still opens its designer. Four entries are not a type: Organization flows (`~org`, under Automation), Default sharing (the Access pillar's OWD overview, under Access), Diagnostics (under Platform) and Positions and permissions (the environment catalog on `~all`, under Access). +- **It collapses like the app sidebar, under its own cookie.** It is the app sidebar's primitive: the header's toggle hides and shows it, the state survives a reload under `studio_menu_state` (never the app sidebar's `sidebar_state`), and below 768 px it is a drawer. `SidebarProvider` (`@object-ui/components`) takes a new optional `cookieName` prop for that; the default is unchanged. +- **The domain dictionary names `system` Platform / 平台 and `security` Access / 访问**, the amended ADR-0084's group names (`translateMetadataDomain`). +- **`~all` is drawn in the builder's shell.** `/studio/~all/metadata/*` is served by the same route as a package's area, so it has the left menu too; the landing's frame no longer draws it. A `~org` area URL (or `?package=~org`) now lands on the package-less flows instead of being read as a package. +- **「‹ Back to app」 names the current package's app** (decision 5), never a remembered app of another package; a package with no app names the package and goes to the apps home. +- Changes and Publish stay at the right end of the top bar, beside Cancel and Save. diff --git a/ui/apps/console/src/components/StudioRoute.metadataArea-28561.test.tsx b/ui/apps/console/src/components/StudioRoute.metadataArea-28561.test.tsx index 9fd9f5d872b..cdc411daca5 100644 --- a/ui/apps/console/src/components/StudioRoute.metadataArea-28561.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.metadataArea-28561.test.tsx @@ -9,10 +9,12 @@ * the route hands it `area="metadata"`. `:packageId/:tab` matches one * segment, so without this route an area URL such as * `/studio/crm/metadata/flow` matched nothing. - * - The cross-package leg (`/studio/~all/metadata/*`) is the area alone, with - * no package, in the frame the landing draws. Every other `~all` URL lands - * on it, so none reaches the pillar builder as a package id. - * - The entry gate decides first, as for every Studio URL. + * - The cross-package leg (`/studio/~all/metadata/*`) is the same builder + * route with `~all` as its segment (objectstack#36899): the surface draws + * the area alone, with no package, beside the left menu every Studio page + * has. Every other `~all` URL lands on it, so none reaches a pillar. + * - The entry gate decides first, as for every Studio URL, the left menu's + * targets included. * * The builder module is mocked with markers (as in * `StudioRoute.lazyBuilder-11798.test.tsx`); the gate, the frame and the @@ -139,28 +141,37 @@ describe('/studio — the "All metadata" area\'s routes (objectstack#28561)', () expect(surface).toHaveAttribute('data-area', ''); }); - it('the cross-package leg is the area alone, with no package, in the landing\'s frame', async () => { + it('the cross-package leg is the builder with its area open on `~all` (objectstack#36899: one shell, one menu)', async () => { renderStudio('/studio/~all/metadata/permission?scope=environment'); - const area = await screen.findByTestId('studio-metadata-area'); - expect(area).toHaveAttribute('data-package', 'null'); - expect(screen.queryByTestId('studio-pillar-builder')).toBeNull(); - // The console's own top bar frames it; its brand links home. - expect(screen.getByRole('link', { name: 'ObjectOS home' })).toHaveAttribute('href', '/home'); + const surface = await screen.findByTestId('studio-pillar-builder'); + expect(surface).toHaveAttribute('data-package', '~all'); + expect(surface).toHaveAttribute('data-area', 'metadata'); + // The landing's frame (the console's top bar) no longer draws it. + expect(screen.queryByRole('link', { name: 'ObjectOS home' })).toBeNull(); + expect(screen.queryByTestId('studio-metadata-area')).toBeNull(); expect(location()).toBe('/studio/~all/metadata/permission?scope=environment'); }); it.each(['/studio/~all', '/studio/~all/data', '/studio/~all/flow/f1'])( - '%s lands on the cross-package area, never on the builder as a package id', + '%s lands on the cross-package area, never on a pillar', async (url) => { renderStudio(url); - expect(await screen.findByTestId('studio-metadata-area')).toBeInTheDocument(); + const surface = await screen.findByTestId('studio-pillar-builder'); expect(location()).toBe('/studio/~all/metadata'); - expect(screen.queryByTestId('studio-pillar-builder')).toBeNull(); + expect(surface).toHaveAttribute('data-area', 'metadata'); + expect(surface).toHaveAttribute('data-package', '~all'); }, ); - it.each(['/studio/~all/metadata', '/studio/com.example.crm/metadata'])( - 'a principal the gate refuses gets neither leg: %s', + it.each([ + '/studio/~all/metadata', + '/studio/com.example.crm/metadata', + // objectstack#36899 — the left menu's targets that are not an area list. + '/studio/~org/automations', + '/studio/com.example.crm/access?surface=owd%3Aoverview', + '/studio/com.example.crm/metadata/_diagnostics', + ])( + 'a principal the gate refuses gets none of them: %s', async (url) => { permissionsFetch = answer(['setup.access']); renderStudio(url); diff --git a/ui/apps/console/src/components/StudioRoute.recentPackage-11863.test.tsx b/ui/apps/console/src/components/StudioRoute.recentPackage-11863.test.tsx index 5f552388e2b..e33c7d32c2d 100644 --- a/ui/apps/console/src/components/StudioRoute.recentPackage-11863.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.recentPackage-11863.test.tsx @@ -199,6 +199,14 @@ describe('/studio/PKG/TAB records the package as a recent entry (objectui#11863) expect(persisted()).toBeNull(); }); + it('the cross-package leg is not a package either, now the builder draws it (objectstack#36899)', async () => { + renderStudio('/studio/~all/metadata/permission?scope=environment'); + await screen.findByTestId('studio-pillar-builder'); + + expect(recent()).toEqual([]); + expect(persisted()).toBeNull(); + }); + it('a principal the entry gate refuses records nothing: the visit is recorded behind the gate', async () => { permissionsFetch = async () => jsonResponse({ authenticated: true, systemPermissions: ['setup.access'] }); renderStudio('/studio/com.acme.crm/data'); diff --git a/ui/e2e/studio-left-menu-36899.spec.ts b/ui/e2e/studio-left-menu-36899.spec.ts new file mode 100644 index 00000000000..e3bbb7b1673 --- /dev/null +++ b/ui/e2e/studio-left-menu-36899.spec.ts @@ -0,0 +1,229 @@ +import { test, expect, type Page } from '@playwright/test'; +import { compile } from 'tailwindcss'; +import { build, type Plugin, type Rollup } from 'vite'; +import { readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import os from 'node:os'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { uiRoot } from '../scripts/ui-root.mjs'; + +/** + * TEST PAGE for objectstack#36899: Studio's left menu, laid out in Chromium. + * + * jsdom has no layout engine. The unit tests (`StudioMenu.test.tsx`) pin what + * the menu lists, its current entry, its search and its cookie; this page + * proves where it is drawn: docked at the left of a wide window with the + * content beside it, off the canvas once collapsed with the content taking the + * full width, still collapsed after a reload (Studio's own cookie, on a real + * http origin), and a drawer over the page at phone width. + * + * REAL: `StudioMenuProvider`, `StudioMenuTrigger`, `StudioMenu` and everything + * they import (the sidebar primitive, the menu model, the i18n), bundled by + * Vite from source, and the real Tailwind theme compiled for the classes on + * the page. FIXTURES: the metadata reads (`useMetadata`) answer three served + * types and one count; the frame is the surface's own (`StudioMenuProvider` + * around a header and a body row), not the whole surface. + */ + +const REPO_ROOT = uiRoot(); +const source = (rel: string) => path.join(REPO_ROOT, rel); + +const MENU = source('packages/app-shell/src/views/studio-design/StudioMenu.tsx'); +const THEME_CSS = source('packages/components/src/index.css'); +const ORIGIN = 'http://studio-menu.test'; +const ENTRY = '\0studio-left-menu:entry'; +const METADATA_STUB = '\0studio-left-menu:useMetadata'; + +function workspaceSources(): Plugin { + return { + name: 'studio-left-menu-workspace-src', + enforce: 'pre', + async resolveId(id, importer) { + if (id.endsWith('/useMetadata.js') && importer?.endsWith('StudioMenu.tsx')) return METADATA_STUB; + const m = /^@object-ui\/([a-z0-9-]+)(?:\/(.+))?$/.exec(id); + if (!m) return null; + const [, pkg, sub] = m; + const target = + pkg === 'types' && sub === 'zod' + ? source('packages/types/src/zod/index.zod.ts') + : source(`packages/${pkg}/src${sub ? `/${sub}` : ''}`); + const resolved = await this.resolve(target, importer, { skipSelf: true }); + if (!resolved) throw new Error(`${id} did not resolve to a source file under ${target}`); + return resolved; + }, + load(id) { + if (id !== METADATA_STUB) return null; + return ` +const ENTRIES = [ + { type: 'object', domain: 'data' }, + { type: 'flow', domain: 'automation' }, + { type: 'permission', domain: 'security' }, +]; +export const useMetadataClient = () => ({}); +export const useMetadataTypes = () => ({ loading: false, error: null, entries: ENTRIES }); +export const useGlobalDiagnostics = () => ({ countsByType: { object: 12 }, packagesByType: {}, reload: () => {} }); +`; + }, + }; +} + +function entry(): Plugin { + const code = ` +import * as React from 'react'; +import { createRoot } from 'react-dom/client'; +import { MemoryRouter } from 'react-router-dom'; +import { StudioMenu, StudioMenuProvider, StudioMenuTrigger } from ${JSON.stringify(MENU)}; + +const h = React.createElement; +createRoot(document.getElementById('root')).render( + h(MemoryRouter, { initialEntries: ['/studio/com.acme.app/metadata/object?package=com.acme.app'] }, + h(StudioMenuProvider, { className: 'h-screen min-h-0 overflow-hidden bg-background text-foreground' }, + h('div', { className: 'flex min-w-0 flex-1 flex-col' }, + h('header', { className: 'flex h-12 shrink-0 items-center border-b px-3' }, h(StudioMenuTrigger, { locale: 'en' })), + h('div', { className: 'relative flex min-h-0 flex-1 overflow-hidden' }, + h(StudioMenu, { segment: 'com.acme.app', locale: 'en' }), + h('main', { id: 'content', className: 'min-h-0 min-w-0 flex-1 p-4' }, 'List'))))) +); +`; + return { + name: 'studio-left-menu-entry', + resolveId: (id) => (id === 'studio-left-menu:entry' ? ENTRY : null), + load: (id) => (id === ENTRY ? code : null), + }; +} + +async function bundlePage(): Promise { + const result = await build({ + configFile: false, + root: REPO_ROOT, + cacheDir: path.join(os.tmpdir(), 'objectui-studio-left-menu'), + logLevel: 'error', + mode: 'production', + define: { 'process.env.NODE_ENV': JSON.stringify('production') }, + plugins: [workspaceSources(), entry()], + build: { + write: false, + minify: false, + target: 'es2022', + modulePreload: false, + reportCompressedSize: false, + rollupOptions: { input: 'studio-left-menu:entry', output: { format: 'es', codeSplitting: false } }, + }, + }); + const outputs = (Array.isArray(result) ? result : [result]) as Rollup.RollupOutput[]; + const chunks = outputs.flatMap((o) => o.output).filter((o): o is Rollup.OutputChunk => o.type === 'chunk'); + if (chunks.length !== 1) throw new Error(`expected one bundled chunk, got ${chunks.length}`); + return chunks[0].code; +} + +async function tailwindFor(candidates: string[]): Promise { + const requireFromComponents = createRequire(source('packages/components/package.json')); + const twEntry = requireFromComponents.resolve('tailwindcss/index.css'); + const compiler = await compile(readFileSync(THEME_CSS, 'utf8'), { + base: path.dirname(THEME_CSS), + loadStylesheet: async (id: string, base: string) => { + const file = id === 'tailwindcss' ? twEntry : path.resolve(base, id); + return { path: file, base: path.dirname(file), content: readFileSync(file, 'utf8') }; + }, + loadModule: async (id: string) => { + const file = requireFromComponents.resolve(id); + const mod = await import(pathToFileURL(file).href); + return { path: file, base: path.dirname(file), module: mod.default ?? mod }; + }, + }); + return compiler.build(candidates); +} + +let bundle = ''; +let css = ''; + +/** Serve the page on a real http origin (the cookie needs one) and wait for the menu's toggle. */ +async function open(page: Page, width: number): Promise { + await page.setViewportSize({ width, height: 720 }); + await page.route(`${ORIGIN}/**`, (route) => + route.fulfill({ + contentType: 'text/html', + body: `
`, + }), + ); + await page.goto(`${ORIGIN}/`); + await page.waitForSelector('[data-testid="studio-menu-toggle"]', { timeout: 30_000 }); + await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))); +} + +const rect = (page: Page, selector: string) => + page.locator(selector).first().evaluate((el) => { + const r = el.getBoundingClientRect(); + return { left: Math.round(r.left), right: Math.round(r.right), width: Math.round(r.width) }; + }); +/** The docked panel (the sidebar primitive's fixed box). */ +const PANEL = '[data-side="left"][data-state] > div[data-sidebar="sidebar"]'; + +test.beforeAll(async ({ browser }) => { + test.setTimeout(240_000); + bundle = await bundlePage(); + // The stylesheet: the classes the page draws in all three states. + const page = await browser.newPage(); + const seen = new Set(); + const collect = async () => + (await page.evaluate(() => + [...document.querySelectorAll('[class]')].flatMap((el) => (el.getAttribute('class') ?? '').split(/\s+/)), + )).forEach((c) => c && seen.add(c)); + await open(page, 1280); + await collect(); + await page.getByTestId('studio-menu-toggle').click(); + await collect(); + await open(page, 390); + await page.getByTestId('studio-menu-toggle').click(); + await page.waitForSelector('[role="dialog"]'); + await collect(); + await page.close(); + css = await tailwindFor([...seen]); +}); + +test.describe('Studio left menu (objectstack#36899)', () => { + test('wide: docked at the left, six groups, the content beside it', async ({ page }, testInfo) => { + await open(page, 1280); + const panel = await rect(page, PANEL); + const content = await rect(page, '#content'); + expect(panel.left).toBe(0); + expect(panel.width).toBe(256); + expect(content.left).toBeGreaterThanOrEqual(panel.right - 1); + for (const g of ['data', 'ui', 'automation', 'system', 'security', 'ai']) { + await expect(page.getByTestId(`studio-menu-group-${g}`)).toBeVisible(); + } + await testInfo.attach('wide', { body: await page.screenshot(), contentType: 'image/png' }); + }); + + test('collapsed: off the canvas, the content takes the full width, and a reload keeps it', async ({ page }, testInfo) => { + await open(page, 1280); + await page.getByTestId('studio-menu-toggle').click(); + await expect(page.locator('[data-side="left"][data-state="collapsed"]')).toHaveCount(1); + await expect.poll(async () => (await rect(page, PANEL)).right).toBeLessThanOrEqual(0); + await expect.poll(async () => (await rect(page, '#content')).left).toBe(0); + const cookies = await page.context().cookies(ORIGIN); + expect(cookies.find((c) => c.name === 'studio_menu_state')?.value).toBe('false'); + expect(cookies.find((c) => c.name === 'sidebar_state')).toBeUndefined(); + await testInfo.attach('collapsed', { body: await page.screenshot(), contentType: 'image/png' }); + + await page.reload(); + await page.waitForSelector('[data-testid="studio-menu-toggle"]'); + await expect(page.locator('[data-side="left"][data-state="collapsed"]')).toHaveCount(1); + await expect(page.getByTestId('studio-menu-toggle')).toHaveAttribute('aria-expanded', 'false'); + }); + + test('phone: a drawer, closed until the toggle opens it, inside the viewport', async ({ page }, testInfo) => { + await open(page, 390); + await expect(page.getByTestId('studio-menu')).toHaveCount(0); + await page.getByTestId('studio-menu-toggle').click(); + const drawer = page.getByRole('dialog'); + await expect(drawer.getByTestId('studio-menu')).toBeVisible(); + const box = await drawer.evaluate((el) => el.getBoundingClientRect().toJSON()); + expect(box.left).toBeGreaterThanOrEqual(0); + expect(box.right).toBeLessThanOrEqual(390); + await testInfo.attach('narrow', { body: await page.screenshot(), contentType: 'image/png' }); + await drawer.getByTestId('studio-menu-entry-type:flow').click(); + await expect(page.getByRole('dialog')).toHaveCount(0); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx new file mode 100644 index 00000000000..8a2b1f8ccf8 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx @@ -0,0 +1,198 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36899 — Studio's left menu as the author meets it. + * + * 1. Collapsing it is kept across a reload under Studio's own cookie + * (`studio_menu_state`); the app sidebar's (`sidebar_state`) is not + * touched, so collapsing one never collapses the other. + * 2. Below 768 px it is a drawer: closed until the toggle opens it, and + * choosing an entry closes it. + * 3. The open page's entry is the current page (`aria-current`); every other + * entry is not. + * 4. The search narrows the entries by name, and says so when none match. + * 5. Focus order: the toggle, then the search, then the entries. + * + * The provider, the sidebar primitive and the router are real; only the + * metadata reads are doubled. + */ + +import '@testing-library/jest-dom/vitest'; +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'; + +vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { + const actual = await importOriginal>(); + return { + ...actual, + useMetadataClient: () => ({}), + useMetadataTypes: () => ({ + loading: false, + error: null, + entries: [ + { type: 'object', domain: 'data' }, + { type: 'flow', domain: 'automation' }, + { type: 'permission', domain: 'security' }, + ], + }), + useGlobalDiagnostics: () => ({ countsByType: { object: 3 }, packagesByType: {}, reload: () => {} }), + }; +}); + +import { StudioMenu, StudioMenuProvider, StudioMenuTrigger } from './StudioMenu'; +import { STUDIO_MENU_COOKIE } from './studioMenuModel'; + +const PKG = 'com.acme.app'; + +function clearCookies() { + for (const entry of document.cookie.split(';')) { + const name = entry.split('=')[0]?.trim(); + if (name) document.cookie = `${name}=; path=/; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 GMT`; + } +} + +const cookie = (name: string) => + document.cookie + .split(';') + .map((c) => c.trim().split('=')) + .find(([k]) => k === name)?.[1]; + +function setWidth(px: number) { + Object.defineProperty(window, 'innerWidth', { configurable: true, value: px }); + vi.stubGlobal('matchMedia', (query: string) => ({ + matches: px < 768, + media: query, + onchange: null, + addEventListener: () => {}, + removeEventListener: () => {}, + addListener: () => {}, + removeListener: () => {}, + dispatchEvent: () => false, + })); +} + +function Where() { + const { pathname, search } = useLocation(); + return {`${pathname}${search}`}; +} + +function Shell() { + return ( + +
+ +
+ +
+ ); +} + +function renderAt(path: string) { + return render( + + + } /> + + + , + ); +} + +const toggle = () => screen.getByTestId('studio-menu-toggle'); +const entry = (key: string) => screen.getByTestId(`studio-menu-entry-${key}`); +/** The docked menu's open state, as the sidebar primitive draws it. */ +const docked = () => document.querySelector('[data-side="left"][data-state]')?.getAttribute('data-state'); + +beforeEach(() => { + clearCookies(); + setWidth(1280); +}); + +afterEach(() => { + cleanup(); + clearCookies(); + vi.unstubAllGlobals(); +}); + +describe('the menu collapses and keeps it across a reload, under its own cookie', () => { + it('collapsing writes studio_menu_state, leaves sidebar_state alone, and a remount comes back collapsed', () => { + document.cookie = 'sidebar_state=true; path=/'; + const first = renderAt(`/studio/${PKG}/data`); + expect(docked()).toBe('expanded'); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + + fireEvent.click(toggle()); + expect(docked()).toBe('collapsed'); + expect(toggle()).toHaveAttribute('aria-expanded', 'false'); + expect(cookie(STUDIO_MENU_COOKIE)).toBe('false'); + expect(cookie('sidebar_state')).toBe('true'); + + first.unmount(); + renderAt(`/studio/${PKG}/data`); + expect(docked()).toBe('collapsed'); + }); + + it('CONTROL: the app sidebar collapsed does not collapse the menu', () => { + document.cookie = 'sidebar_state=false; path=/'; + renderAt(`/studio/${PKG}/data`); + expect(docked()).toBe('expanded'); + }); +}); + +describe('below 768 px the menu is a drawer', () => { + it('closed until the toggle opens it; choosing an entry closes it', async () => { + setWidth(390); + renderAt(`/studio/${PKG}/data`); + await waitFor(() => expect(toggle()).toHaveAttribute('aria-expanded', 'false')); + expect(screen.queryByTestId('studio-menu')).toBeNull(); + + fireEvent.click(toggle()); + const drawer = await screen.findByRole('dialog'); + fireEvent.click(within(drawer).getByTestId('studio-menu-entry-type:flow')); + expect(screen.getByTestId('where')).toHaveTextContent(`/studio/${PKG}/metadata/flow?package=${PKG}`); + await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull()); + }); +}); + +describe('the current entry and the search', () => { + it('the open page\'s entry is the current page, and only it', () => { + renderAt(`/studio/${PKG}/metadata/flow?package=${PKG}`); + expect(entry('type:flow')).toHaveAttribute('aria-current', 'page'); + const others = within(screen.getByTestId('studio-menu')) + .getAllByRole('link') + .filter((a) => a !== entry('type:flow')); + expect(others.length).toBeGreaterThan(0); + for (const a of others) expect(a).not.toHaveAttribute('aria-current'); + }); + + it('draws each group\'s type count and an entry\'s item count', () => { + renderAt(`/studio/${PKG}/data`); + expect(screen.getByTestId('studio-menu-group-count-data')).toHaveTextContent('1'); + expect(entry('type:object')).toHaveTextContent(/3$/); + }); + + it('narrows the entries by name, and says so when none match', () => { + renderAt(`/studio/${PKG}/data`); + const search = screen.getByTestId('studio-menu-search'); + expect(search).toHaveAccessibleName('Search the menu'); + + fireEvent.change(search, { target: { value: 'flow' } }); + const links = within(screen.getByTestId('studio-menu')).getAllByRole('link'); + expect(links.map((a) => a.getAttribute('data-testid'))).toEqual(['studio-menu-entry-type:flow']); + + fireEvent.change(search, { target: { value: 'zzz-nothing' } }); + expect(within(screen.getByTestId('studio-menu')).queryAllByRole('link')).toEqual([]); + expect(screen.getByTestId('studio-menu-no-matches')).toHaveAttribute('role', 'status'); + }); + + it('focus order: the toggle, then the search, then the entries', () => { + renderAt(`/studio/${PKG}/data`); + const order = [toggle(), screen.getByTestId('studio-menu-search'), entry('type:object')]; + for (let i = 1; i < order.length; i += 1) { + expect(order[i - 1].compareDocumentPosition(order[i]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + } + for (const el of order) expect(el.getAttribute('tabindex') ?? '0').not.toBe('-1'); + expect(screen.getByRole('navigation', { name: 'Studio menu' })).toBe(screen.getByTestId('studio-menu')); + }); +}); From b9018320e323da78b007e989ef7211318656c9e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 13:09:35 +0000 Subject: [PATCH 4/9] fix(studio): re-entering the open pillar remounts it on the new query The default-sharing entry re-enters the Access pillar on another query. The pillar reads its deep link once, at mount, and the router may apply the navigation in a later render than the click's own state updates, so the remount now waits for the new query to be the router's. The package-less scope's pins read the left menu. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- .changeset/36899-studio-left-menu.md | 2 +- ...ignSurface.packageLessFlows-11553.test.tsx | 27 +++++++++++-------- ...tudioDesignSurface.pillarNavGuard.test.tsx | 10 ++++++- .../studio-design/StudioDesignSurface.tsx | 14 ++++++++-- .../views/studio-design/StudioMenu.test.tsx | 3 ++- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/.changeset/36899-studio-left-menu.md b/.changeset/36899-studio-left-menu.md index 752a5992f97..227fc8eedd9 100644 --- a/.changeset/36899-studio-left-menu.md +++ b/.changeset/36899-studio-left-menu.md @@ -12,7 +12,7 @@ Metadata-protocol: none ADR-0084 (amended) · #36899, part of #36890. -- **Studio's one navigation is a left menu.** The top bar's Data / Automations / Access / All metadata switcher is gone. Every Studio page (a package's pillars and area, the package-less flows `~org`, and the cross-package leg `~all`) draws the same menu of six groups: Data, Interface, Automation, Platform, Access, AI. Each group lists the metadata types the package holds (the directory's own rule, `scopeDirectoryEntries`), with a type count per group and an item count per type, and a search box that narrows the entries. A type entry opens that type's list in the area; an item of an object, flow or permission set still opens its designer. Four entries are not a type: Organization flows (`~org`, under Automation), Default sharing (the Access pillar's OWD overview, under Access), Diagnostics (under Platform) and Positions and permissions (the environment catalog on `~all`, under Access). +- **Studio's one navigation is a left menu.** The top bar's Data / Automations / Access / All metadata switcher is gone. Every Studio page (a package's pillars and area, the package-less flows `~org`, and the cross-package leg `~all`) draws the same menu of six groups: Data, UI, Automation, Platform, Access, AI (数据、界面、自动化、平台、访问、AI). Each group lists the metadata types the package holds (the directory's own rule, `scopeDirectoryEntries`), with a type count per group and an item count per type, and a search box that narrows the entries. A type entry opens that type's list in the area; an item of an object, flow or permission set still opens its designer. Four entries are not a type: Organization flows (`~org`, under Automation), Default sharing (the Access pillar's OWD overview, under Access), Diagnostics (under Platform) and Positions and permissions (the environment catalog on `~all`, under Access). - **It collapses like the app sidebar, under its own cookie.** It is the app sidebar's primitive: the header's toggle hides and shows it, the state survives a reload under `studio_menu_state` (never the app sidebar's `sidebar_state`), and below 768 px it is a drawer. `SidebarProvider` (`@object-ui/components`) takes a new optional `cookieName` prop for that; the default is unchanged. - **The domain dictionary names `system` Platform / 平台 and `security` Access / 访问**, the amended ADR-0084's group names (`translateMetadataDomain`). - **`~all` is drawn in the builder's shell.** `/studio/~all/metadata/*` is served by the same route as a package's area, so it has the left menu too; the landing's frame no longer draws it. A `~org` area URL (or `?package=~org`) now lands on the package-less flows instead of being read as a package. diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageLessFlows-11553.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageLessFlows-11553.test.tsx index eff1f02b66e..d239e7025f0 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageLessFlows-11553.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageLessFlows-11553.test.tsx @@ -23,7 +23,7 @@ import '@testing-library/jest-dom/vitest'; import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/react'; +import { render, screen, fireEvent, cleanup, waitFor, within } from '@testing-library/react'; import { MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-router-dom'; const SHOWCASE = 'com.example.showcase'; @@ -270,21 +270,26 @@ describe('the package-less scope lists a package-less flow and opens it editable expect(saved!.options?.packageId).toBeUndefined(); }); - it('offers its one pillar, no Create app, no package copilot, and names no app beside 「‹ Back to app」', async () => { + it('offers its one page, no Create app, no package copilot, and names the scope beside 「‹ Back to app」', async () => { renderAt('/studio/~org/automations'); await openedFlow('qa_urgent_alert_clone'); - expect(screen.getByRole('link', { name: /Automations/ })).toHaveAttribute('href', '/studio/~org/automations'); - expect(screen.queryByRole('link', { name: /^Data$/ })).not.toBeInTheDocument(); - expect(screen.queryByRole('link', { name: /Interfaces/ })).not.toBeInTheDocument(); - // objectui#12452 — Access is a package pillar segment now, not a More entry. - expect(screen.queryByRole('link', { name: /Access/ })).not.toBeInTheDocument(); - // objectstack#28561 — nor the "All metadata" area: a package's, beside its pillars. - expect(screen.queryByRole('link', { name: /All metadata/ })).not.toBeInTheDocument(); + // objectstack#36899 — the left menu: the scope's flows are its current + // entry; no package pillar, area or Interfaces page is offered. + const menu = within(screen.getByTestId('studio-menu')); + const flows = menu.getByTestId('studio-menu-entry-orgFlows'); + expect(flows).toHaveAttribute('href', '/studio/~org/automations'); + expect(flows).toHaveAttribute('aria-current', 'page'); + for (const a of menu.getAllByRole('link')) { + expect(a.getAttribute('href')).not.toMatch(/^\/studio\/~org\/(data|access|interfaces|metadata)/); + } + expect(menu.queryByTestId('studio-menu-entry-owd')).toBeNull(); + expect(menu.queryByTestId('studio-menu-entry-diagnostics')).toBeNull(); expect(screen.queryByRole('button', { name: /Create app/ })).not.toBeInTheDocument(); expect(chatDock.mounts).toBe(0); - // objectstack#36501 — no app owns the scope, so the back link names none. - expect(screen.getByTestId('studio-back')).toHaveTextContent(/^Back to app·Studio$/); + // objectstack#36501, decision 5 (objectstack#36899) — no app owns the + // scope, so the name slot names the scope, as for a package with no app. + expect(screen.getByTestId('studio-back')).toHaveTextContent(/^Back to app·Organization flows·Studio$/); // No "New" flow here: authoring stays package-first. expect(screen.queryByTitle('New automation')).not.toBeInTheDocument(); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx index bfe995a301b..484243c5a11 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.pillarNavGuard.test.tsx @@ -39,7 +39,7 @@ import '@testing-library/jest-dom/vitest'; import '@objectstack/lint'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; let clientImpl: any; @@ -188,6 +188,11 @@ afterEach(() => { window.history.replaceState(null, '', '/'); }); +/** The router's query, so a case can wait for the pillar to mirror its open set into it. */ +function SearchProbe() { + return {useLocation().search}; +} + async function renderSurfaceOnAccess() { window.history.replaceState(null, '', '/studio/app.a/access'); render( @@ -199,6 +204,7 @@ async function renderSurfaceOnAccess() { } /> } /> +
, ); // First set auto-selects; wait for its matrix row so the whole editor (not @@ -323,6 +329,8 @@ describe('Studio — unsaved pillar edits guard (#2600)', () => { it('CONTROL: clean, the default-sharing entry opens the overview without asking', async () => { await renderSurfaceOnAccess(); + // As an author's click comes after it: the pillar has mirrored its open set. + await waitFor(() => expect(decodeURIComponent(screen.getByTestId('router-search').textContent ?? '')).toContain('permission:set_a')); reenterOnOwd(); await screen.findByTestId('owd-internal-a_account'); expect(confirmSpy).not.toHaveBeenCalled(); 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 ea4b0e8b572..9191449163c 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -1222,13 +1222,23 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re // `?surface=` (the default sharing overview, on the Access pillar) opens the // pillar afresh, as arriving from any other page does: a pillar reads its // deep link once, at mount (`useSurfaceDeepLink`). The shell's link guard - // lets a link to the page already shown through, so this asks first. + // lets a link to the page already shown through, so this asks first. The + // 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. const [pillarEntry, setPillarEntry] = React.useState(0); + const reentryPending = React.useRef(false); + const currentSearch = useLocation().search; const reenterPillar = React.useCallback((): boolean => { if (!confirmLeavePillar()) return false; - setPillarEntry((n) => n + 1); + reentryPending.current = true; return true; }, [confirmLeavePillar]); + React.useLayoutEffect(() => { + if (!reentryPending.current) return; + reentryPending.current = false; + setPillarEntry((n) => n + 1); + }, [currentSearch]); // objectstack#26708 — a package that is not there has no menu. const showMenu = !pkgMissing; diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx index 8a2b1f8ccf8..051d3c440b5 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.test.tsx @@ -179,7 +179,8 @@ describe('the current entry and the search', () => { fireEvent.change(search, { target: { value: 'flow' } }); const links = within(screen.getByTestId('studio-menu')).getAllByRole('link'); - expect(links.map((a) => a.getAttribute('data-testid'))).toEqual(['studio-menu-entry-type:flow']); + // "flow" names the flow type and the organization's flows. + expect(links.map((a) => a.getAttribute('data-testid'))).toEqual(['studio-menu-entry-type:flow', 'studio-menu-entry-orgFlows']); fireEvent.change(search, { target: { value: 'zzz-nothing' } }); expect(within(screen.getByTestId('studio-menu')).queryAllByRole('link')).toEqual([]); From 214400bd3582771756fcf0fb56d1444b8f872ff9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 13:31:34 +0000 Subject: [PATCH 5/9] test(studio): the menu's e2e page reads the panel after its slide-in Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- ui/e2e/studio-left-menu-36899.spec.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ui/e2e/studio-left-menu-36899.spec.ts b/ui/e2e/studio-left-menu-36899.spec.ts index e3bbb7b1673..cc24a12b5ac 100644 --- a/ui/e2e/studio-left-menu-36899.spec.ts +++ b/ui/e2e/studio-left-menu-36899.spec.ts @@ -157,8 +157,8 @@ const rect = (page: Page, selector: string) => const r = el.getBoundingClientRect(); return { left: Math.round(r.left), right: Math.round(r.right), width: Math.round(r.width) }; }); -/** The docked panel (the sidebar primitive's fixed box). */ -const PANEL = '[data-side="left"][data-state] > div[data-sidebar="sidebar"]'; +/** The docked panel (the sidebar primitive's inner box, which fills its fixed container). */ +const PANEL = '[data-side="left"][data-state] [data-sidebar="sidebar"]'; test.beforeAll(async ({ browser }) => { test.setTimeout(240_000); @@ -188,7 +188,9 @@ test.describe('Studio left menu (objectstack#36899)', () => { const panel = await rect(page, PANEL); const content = await rect(page, '#content'); expect(panel.left).toBe(0); - expect(panel.width).toBe(256); + // 16rem, less the container's 1 px right border. + expect(panel.width).toBeGreaterThanOrEqual(255); + expect(panel.width).toBeLessThanOrEqual(256); expect(content.left).toBeGreaterThanOrEqual(panel.right - 1); for (const g of ['data', 'ui', 'automation', 'system', 'security', 'ai']) { await expect(page.getByTestId(`studio-menu-group-${g}`)).toBeVisible(); @@ -219,9 +221,10 @@ test.describe('Studio left menu (objectstack#36899)', () => { await page.getByTestId('studio-menu-toggle').click(); const drawer = page.getByRole('dialog'); await expect(drawer.getByTestId('studio-menu')).toBeVisible(); - const box = await drawer.evaluate((el) => el.getBoundingClientRect().toJSON()); - expect(box.left).toBeGreaterThanOrEqual(0); - expect(box.right).toBeLessThanOrEqual(390); + // Read once the slide-in has finished. + const box = () => drawer.evaluate((el) => el.getBoundingClientRect().toJSON() as { left: number; right: number }); + await expect.poll(async () => (await box()).left).toBeGreaterThanOrEqual(0); + expect((await box()).right).toBeLessThanOrEqual(390); await testInfo.attach('narrow', { body: await page.screenshot(), contentType: 'image/png' }); await drawer.getByTestId('studio-menu-entry-type:flow').click(); await expect(page.getByRole('dialog')).toHaveCount(0); From df57661bb93c4fd7436030199f5f13c67258afe2 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 13:48:47 +0000 Subject: [PATCH 6/9] test(studio): the held-flow leave pin pays the lint load at collection The surface under test reaches a dynamic import of @objectstack/lint, so the edited test file imports it at module top, as its held-data sibling does: the first load is paid during collection, never inside a case's clocked window (check:test-source-alias). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- .../StudioDesignSurface.heldFlowLeave-26705.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx index f12ff505fc3..6ee5f47d165 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.heldFlowLeave-26705.test.tsx @@ -86,6 +86,9 @@ vi.mock('@object-ui/react', async (importOriginal) => { vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () => null })); vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null })); +// The source under test reaches a dynamic import of `@objectstack/lint`: its first +// load is paid here, at collection, never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; import { StudioDesignSurface } from './StudioDesignSurface'; import { createEmptyDataSource } from './__tests__/emptyDataSource'; import { registerMetadataPreview } from '../metadata-admin/preview-registry'; From 1f7534d18f12f01cb997c69251fe5acd15052c32 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 14:10:08 +0000 Subject: [PATCH 7/9] fix(studio): the menu's group labels carry the icon-mode hiding classes; three pins read the menu The left menu's SidebarGroupLabel carries HIDDEN_ICON_LABEL_NOT_FOCUSABLE, as every call site of the primitive does (the call-site pin enumerates them). Three surface pins that still read the retired pillar links now read the menu: the package-list failure keeps the menu and its toggle, and the header's first way out is Back to app right after the menu toggle. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziBCAytAzzCu3iPBFR --- .../StudioDesignSurface.homeLoop-12513.test.tsx | 12 ++++++++---- ...dioDesignSurface.packageListErrorPosture.test.tsx | 6 ++++-- .../app-shell/src/views/studio-design/StudioMenu.tsx | 12 +++++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.homeLoop-12513.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.homeLoop-12513.test.tsx index dcf4892f883..57f4938e078 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.homeLoop-12513.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.homeLoop-12513.test.tsx @@ -3,7 +3,7 @@ /** * objectui#12513 — the Studio home loop. Inside a package the header's first * button and the package switcher's first row both returned to the Studio - * landing (`/studio`); objectstack#36501 replaced both with 「‹ Back to app」, + * landing (`/studio`); objectstack#36501 replaced both with 「‹ Back to app」 (since objectstack#36899 right after the menu toggle), * and the first case below now says so. The Organization flows empty block's way out to * Setup › Packaged automation retired with that page's flows half (objectstack * ADR-0146 D11, N-28): the block now says where a packaged flow is changed, @@ -212,14 +212,18 @@ function renderAt(url: string) { } describe('Studio home loop (objectui#12513)', () => { - it('the header’s first button is 「‹ Back to app」 now, not Studio home (objectstack#36501)', async () => { + it('the header’s first way out is 「‹ Back to app」 now, not Studio home (objectstack#36501)', async () => { // The Studio-home button and the switcher's Studio-home row were removed - // with the switcher: the landing is reached from the app. + // with the switcher: the landing is reached from the app. objectstack#36899 + // — the left menu's show / hide control leads the bar, so the way out is + // the button right after it. renderAt(`/studio/${SHOWCASE}/automations`); const back = await screen.findByTestId('studio-back-to-app'); const header = screen.getByTestId('studio-shell-header'); - expect(within(header).getAllByRole('button')[0]).toBe(back); + const buttons = within(header).getAllByRole('button'); + expect(buttons[0]).toBe(within(header).getByTestId('studio-menu-toggle')); + expect(buttons[1]).toBe(back); expect(within(header).queryByRole('button', { name: 'Studio home' })).toBeNull(); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageListErrorPosture.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageListErrorPosture.test.tsx index a97ef2176c3..240a372c584 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageListErrorPosture.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageListErrorPosture.test.tsx @@ -129,8 +129,10 @@ describe('Studio top bar — package-list fetch failure is reported, not swallow renderSurface(); await waitFor(() => expect(toastError).toHaveBeenCalled()); - // The rest of the header survived the failure. - expect(screen.getByRole('link', { name: 'Automations' })).toBeInTheDocument(); + // The rest of the chrome survived the failure: the menu toggle and, since + // objectstack#36899, the left menu that replaced the pillar links. + expect(screen.getByTestId('studio-menu-toggle')).toBeInTheDocument(); + expect(screen.getByRole('navigation', { name: 'Studio menu' })).toBeInTheDocument(); // …and its way out still works (objectstack#36501): no app is known, so // it goes to the console's landing. fireEvent.click(screen.getByTestId('studio-back-to-app')); 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 b57a5ae5548..e67b46ef034 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx @@ -60,6 +60,16 @@ const GROUP_ICONS: Record = { ai: Sparkles, }; +/** + * objectui#12795 — every `SidebarGroupLabel` call site hides its label from + * focus and the accessibility tree in the icon sidebar (the primitive's own + * `opacity-0` leaves it reachable). This menu is `offcanvas`, never `icon`, so + * the classes never apply here; it carries them as every call site does. + */ +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]'; + const ENTRY_LABEL_KEYS: Record, string> = { orgFlows: 'engine.studio.menu.orgFlows', owd: 'engine.studio.menu.owd', @@ -200,7 +210,7 @@ export function StudioMenu({ segment, locale, onReenterPillar }: StudioMenuProps const typeCount = entries.filter((e) => e.kind === 'type').length; return ( - +