From ed0a6f5b6ad07659ada72e70033a8fb088fde181 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 18:51:59 +0000 Subject: [PATCH 01/21] feat(studio): send bare /studio to the last package or the package list Studio's entry no longer draws the package-card home: it opens the package the author was last in, else Setup > Packages (or the All metadata area for a principal who may not open it). The console's new-package doors land on Setup > Packages with New Package open (?new=package on the admin face), and the not-found state and the retired Setup redirects that name no package land on the package list. WIP: the BuilderLanding page and its tests are not deleted yet. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- ui/apps/console/src/AppContent.tsx | 7 +- .../console/src/components/StudioRoute.tsx | 115 +++++---------- .../console/src/components/studioBuilder.ts | 13 +- .../console/src/registerStudioComponents.tsx | 63 +++----- .../__tests__/RequireAiSurface.test.tsx | 2 +- .../src/console/ai/AiUnavailable.tsx | 7 +- .../app-shell/src/console/home/HomePage.tsx | 7 +- .../HomePage.desktopNoApps-36732.test.tsx | 2 +- .../HomePage.noAgentsBuildChip-26614.test.tsx | 11 +- .../app-shell/src/hooks/useAddAppEntries.ts | 4 +- ui/packages/app-shell/src/index.ts | 8 ++ .../__tests__/SidebarAppMenu-36112.test.tsx | 2 +- ...esPage.installedAppsUpdates-34722.test.tsx | 38 +++++ .../src/views/metadata-admin/PackagesPage.tsx | 22 +++ .../src/views/metadata-admin/packageSource.ts | 27 ++++ .../views/studio-design/PackageSwitcher.tsx | 17 +-- .../studio-design/StudioDesignSurface.tsx | 9 +- .../StudioEntryRedirect.test.tsx | 135 ++++++++++++++++++ .../studio-design/StudioEntryRedirect.tsx | 99 +++++++++++++ .../setupMetadataRedirect.test.ts | 7 +- .../studio-design/setupMetadataRedirect.ts | 11 +- .../views/studio-design/studioAddress.test.ts | 5 +- .../views/studio-design/studioAddressTable.ts | 11 +- .../views/studio-design/studioNewPackage.ts | 27 ++-- ui/packages/i18n/src/namespaces/studio/en.ts | 6 +- ui/packages/i18n/src/namespaces/studio/zh.ts | 2 +- 26 files changed, 459 insertions(+), 198 deletions(-) create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx create mode 100644 ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx diff --git a/ui/apps/console/src/AppContent.tsx b/ui/apps/console/src/AppContent.tsx index cdf3e490f21..44cc2862d0d 100644 --- a/ui/apps/console/src/AppContent.tsx +++ b/ui/apps/console/src/AppContent.tsx @@ -20,7 +20,7 @@ import { LocalizationFetchProvider } from './LocalizationFetchProvider'; import { FirstRunChecklist } from './pages/settings/FirstRunChecklist'; import { InAppFormRoute } from './components/InternalFormRoute'; import { APPROVAL_ACTION_OBJECT, APPROVAL_REQUEST_OBJECT, routeApprovalRecordReads } from './services/approvalRequestsDataSource'; -import { studioLandingPath } from '@object-ui/app-shell'; +import { SETUP_PACKAGES_PATH } from '@object-ui/app-shell'; const AppManagementPage = lazy(() => import('./pages/system/AppManagementPage').then(m => ({ default: m.AppManagementPage }))); const ProfilePage = lazy(() => import('./pages/system/ProfilePage').then(m => ({ default: m.ProfilePage }))); @@ -66,7 +66,8 @@ function ObjectRedirect() { // objectstack ADR-0146 D1 — straight to Studio's "All metadata" area, the // page Setup's `…/metadata/object` route opens there. const target = setupMetadataStudioPath(objectName ? `object/${objectName}` : 'object', location.search, location.hash); - return ; + // objectstack#36908 — a URL Studio has no page for lands on Setup → Packages. + return ; } /** @@ -176,7 +177,7 @@ function SystemObjectRedirect({ objectName }: { objectName: string }) { function SystemCatalogRedirect({ type }: { type: 'position' | 'permission' }) { // objectstack ADR-0146 D1 — the catalog is Studio's, in the "All metadata" // area's cross-package leg. - return ; + return ; } /** diff --git a/ui/apps/console/src/components/StudioRoute.tsx b/ui/apps/console/src/components/StudioRoute.tsx index f9c81b57b71..0e63e651f3b 100644 --- a/ui/apps/console/src/components/StudioRoute.tsx +++ b/ui/apps/console/src/components/StudioRoute.tsx @@ -34,14 +34,11 @@ * Studio exists for. The gate belongs here, in this app's router. */ -import { lazy, Suspense, useEffect, type ReactNode } from 'react'; +import { createContext, lazy, Suspense, useContext, useEffect, type ReactNode } from 'react'; import { Link, Navigate, Outlet, Route, useParams } from 'react-router-dom'; import { Lock } from 'lucide-react'; import { Button, Empty, EmptyTitle } from '@object-ui/components'; import { - AppHeader, - CommandPalette, - CommandPaletteProvider, LoadingFallback, LoadingScreen, STUDIO_ALL_PACKAGES_SEGMENT, @@ -60,11 +57,12 @@ import { ProtectedRoute } from './ProtectedRoute'; import { holdsStudioAccess, useStudioEntry } from './studioEntry'; /* - * The two builder screens load WITH THEIR ROUTE, not with the console - * (objectui#11798). Imported statically, `StudioDesignSurface` and - * `BuilderLanding` (and the modules only they reach, such as the pillar panels - * and the form designer) sat in the eager closure of every console page, for - * every user, on deployments where most principals can never enter Studio. + * The builder screens load WITH THEIR ROUTE, not with the console + * (objectui#11798). Imported statically, `StudioDesignSurface` (and the modules + * only it reaches, such as the pillar panels and the form designer) sat in the + * eager closure of every console page, for every user, on deployments where + * most principals can never enter Studio. Studio's entry + * (`StudioEntryRedirect`) rides in the same chunk. * * Only the builder is deferred. The gate above it (`StudioRoute` → * `RequireStudioAccess`) stays in this eager module on purpose: it decides @@ -76,10 +74,16 @@ import { holdsStudioAccess, useStudioEntry } from './studioEntry'; const StudioDesignSurface = lazy(() => import('./studioBuilder').then((m) => ({ default: m.StudioDesignSurface })), ); -const BuilderLanding = lazy(() => - import('./studioBuilder').then((m) => ({ default: m.BuilderLanding })), +const StudioEntryRedirect = lazy(() => + import('./studioBuilder').then((m) => ({ default: m.StudioEntryRedirect })), ); +/** + * The capability set the entry gate read, for the screens below it that choose + * by it (Studio's entry, objectstack#36908). Provided only around a holder. + */ +const StudioEntryPermissions = createContext(undefined); + /** * What a principal without `studio.access` sees, at the Studio URL they opened * (objectui#12035): one sentence saying Studio access is needed, and the way @@ -159,7 +163,9 @@ export function RequireStudioAccess({ return ; } - return <>{children}; + return ( + {children} + ); } /** Route element for the `/studio` subtree: auth, then entry capability, then children. */ @@ -174,84 +180,31 @@ export function StudioRoute() { } /** - * What a Studio builder screen shows INSIDE an already-painted frame while its - * chunk loads (objectui#11798): the `/studio` landing under its console header, - * and the `studio:builder` registry entry inside the app shell. One line of the - * shared `common.loading` text, as `registerAccountComponents` shows for its own - * lazy page. The full-screen pillar builder has no frame of its own, so it - * falls back to `LoadingFallback`, the splash the gate's pending state already - * shows, and the two waits read as one. `role="status"` lets assistive - * technology announce the wait, and it is what the tests find the line by. - */ -export function StudioBuilderLoading() { - const { t } = useObjectTranslation(); - return ( -
- {t('common.loading', { defaultValue: 'Loading…' })} -
- ); -} - -/** - * The `/studio` front door: pick or create a writable package, or open the - * organization's package-less flows. - * - * Its header is the console's own (objectui#11863): `AppHeader`'s `studio` - * variant, as `/home` mounts the `home` one, with the same account menu, inbox - * and help, and the brand, then a fixed Studio crumb. The brand links to - * `useHomePath()`, so the landing is never a navigation dead end, and it names - * the same home as `StudioDesignSurface`'s Home button one route apart - * (objectui#7256, objectui#7373). - * - * The frame mounts the command palette in its `studio` scope (objectui#11863): - * no app is active here, so it lists the Studio's packages, objects and flows - * instead of an app's entries. Under its `CommandPaletteProvider` the header - * draws the search trigger, as it does wherever a palette is mounted - * (objectui#11912), and `⌘K` opens it. - */ -function StudioLanding() { - return ( - - - - ); -} - -/** - * 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. + * Bare `/studio` (objectstack#36908, epic #36890 decision 9): Studio's entry, + * which draws no page. It opens the package the author was last in, else the + * package list: Setup → Packages for a principal who may open it, the "All + * metadata" area across packages otherwise (`StudioEntryRedirect` in + * app-shell). The package-card home it used to draw was removed; Studio is + * entered from an app or from Setup → Packages. */ -function StudioConsoleFrame({ children }: { children: ReactNode }) { +function StudioEntry() { + const systemPermissions = useContext(StudioEntryPermissions); return ( - -
- {/* The console top bar, 48 px like every console frame's - (objectui#12639): `@object-ui/app-shell` spells the class as - `CONSOLE_TOP_BAR`, and its `consoleTopBar.height-12639` test holds - this copy equal to it. */} -
- -
- -
- {/* The frame above stays painted while the body's chunk loads. */} - }>{children} -
-
-
+ }> + } /> + ); } /** * 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 - * last in. `useTrackRouteAsRecent` reads `/apps/APP` routes only, and this + * entry (objectui#11863), so Studio's entry (bare `/studio`, objectstack#36908) + * can open the package an author was last in. `useTrackRouteAsRecent` reads `/apps/APP` routes only, and this * module owns the `/studio` subtree, so the record is made here, behind the * entry gate: a refused principal never mounts this element. * * The entry is the package's IDENTITY — its id, and `href` its bare route, - * which lands on the Data pillar — and no label: the landing labels it from the + * which lands on the Data pillar — and no label: a reader 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`) and the @@ -289,7 +242,7 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA }) * REAL tree instead of a transcription of it — a transcription would be free to * agree with itself while `App.tsx` quietly mounted the builder ungated. * - * `/studio` front door (pick / create a writable package) + * `/studio` Studio's entry: the last package, else the package list * `/studio/~org` the package-less scope lands on its one pillar * `/studio/~all/*` lands on the "All metadata" area across packages * `/studio/:packageId` a package lands on its Data pillar @@ -324,7 +277,7 @@ function StudioPackageBuilder({ area }: { area?: typeof STUDIO_METADATA_AREA }) */ export const studioRoutes = ( }> - } /> + } /> } diff --git a/ui/apps/console/src/components/studioBuilder.ts b/ui/apps/console/src/components/studioBuilder.ts index a1a4c2d6559..6b7f7b97283 100644 --- a/ui/apps/console/src/components/studioBuilder.ts +++ b/ui/apps/console/src/components/studioBuilder.ts @@ -2,15 +2,14 @@ /** * The Studio builder's screens, as the ONE module the console loads them - * through (objectui#11798): the landing, the pillar builder, and the "All - * metadata" area's cross-package leg (objectstack#28561). + * through (objectui#11798): Studio's entry (objectstack#36908), the pillar + * builder, and the "All metadata" area's cross-package leg (objectstack#28561). * - * `StudioRoute.tsx` (the `/studio` subtree) and `registerStudioComponents.tsx` - * (the `studio:builder` registry entry) both reach these components through + * `StudioRoute.tsx` (the `/studio` subtree) reaches these components through * `import('./studioBuilder')`, behind a `lazy()` boundary. Nothing in the * console imports this module statically, and nothing may: that is what lets - * the bundler place `StudioDesignSurface`, `BuilderLanding` and the modules only - * they reach (such as the pillar panels and the form designer) in a chunk that + * the bundler place `StudioDesignSurface`, `StudioEntryRedirect` and the modules + * only they reach (such as the pillar panels and the form designer) in a chunk that * is fetched when a Studio screen first renders, instead of in the eager * closure every console page load pays for. * @@ -30,4 +29,4 @@ * one, and `pnpm check:eager-closure` weighs the bytes that would come back. */ -export { BuilderLanding, StudioDesignSurface, StudioMetadataArea } from '@object-ui/app-shell'; +export { StudioDesignSurface, StudioEntryRedirect, StudioMetadataArea } from '@object-ui/app-shell'; diff --git a/ui/apps/console/src/registerStudioComponents.tsx b/ui/apps/console/src/registerStudioComponents.tsx index fe9f00013b6..4f03f9f1e5c 100644 --- a/ui/apps/console/src/registerStudioComponents.tsx +++ b/ui/apps/console/src/registerStudioComponents.tsx @@ -3,59 +3,30 @@ /** * Studio builder component registration. * - * Binds the `studio:builder` registry key (referenced from the framework's - * Studio app navigation — the 「应用构建」 entry) to the builder landing page, - * so the application builder is reachable from the moment a user logs in: - * Home → Studio app → 应用构建 → pick/create a writable package → the - * full-screen pillar builder at `/studio/:packageId/:tab`. + * Binds the `studio:builder` registry key, referenced from the framework's + * Studio app navigation (the 「应用构建」 entry, + * `/apps//component/studio/builder`), to Studio's entry. * - * URL shape resolved by `ComponentNavView`: - * studio:builder → /apps//component/studio/builder + * It used to draw the Studio home's package cards inside the app shell. That + * home was removed (objectstack#36908, epic #36890 decision 9): Studio is + * entered from an app or from Setup → Packages. The entry stays reachable from + * this nav item by forwarding to bare `/studio`, whose ONE owner + * (`StudioRoute`) decides where it opens: the package the author was last in, + * else the package list. A second copy of that decision here would drift from + * it. * - * The standalone `/studio` route renders the same landing full-screen. - * - * ## Why `BuilderLanding` arrives through `lazy()`, and why that is real now - * - * This registration used to read `lazy(() => import('@object-ui/app-shell') - * .then((m) => ({ default: m.BuilderLanding })))`, and that laziness never - * existed (objectui#5486): the `import()` named the barrel this file and - * `App.tsx` already imported statically, so it could not move a module into - * another chunk. objectui#5486 made the registration truthful by importing the - * component directly, and left making the builder GENUINELY lazy to a separate - * measured card, because it meant taking the `/studio` route off the static - * import too. - * - * objectui#11798 is that card. The route and this entry now both reach the - * builder through `./components/studioBuilder`, a console-local module that - * nothing imports statically, so the `import()` is a boundary the bundler - * honours: `BuilderLanding`, `StudioDesignSurface` and what only they reach load - * when a Studio screen first renders. The PR records the eager closure before - * and after, read from the build's own `dist/eager-closure.json`. - * - * The registry still holds `studio:builder` from the moment the console boots, - * so `ComponentNavView` finds it as before; the entry renders a loading line - * until the chunk arrives, the way the sibling `registerAccountComponents.tsx` - * does for its lazy profile page. + * The registry holds `studio:builder` from the moment the console boots, so + * `ComponentNavView` finds it as before. Forwarding costs no chunk: the + * builder loads with the `/studio` route (objectui#11798). */ -import { lazy, Suspense } from 'react'; -import { registerAppComponent } from '@object-ui/app-shell'; - -import { StudioBuilderLoading } from './components/StudioRoute'; - -const BuilderLanding = lazy(() => - import('./components/studioBuilder').then((m) => ({ default: m.BuilderLanding })), -); +import { Navigate } from 'react-router-dom'; +import { registerAppComponent, studioLandingPath } from '@object-ui/app-shell'; registerAppComponent({ ref: 'studio:builder', label: '应用构建', source: '@object-ui/console', - // `BuilderLanding` takes no props, so the query props `ComponentNavView` - // passes are not forwarded; it ignored them when it was registered directly. - component: () => ( - }> - - - ), + // Takes no props: the query props `ComponentNavView` passes are not forwarded. + component: () => , }); diff --git a/ui/packages/app-shell/src/console/__tests__/RequireAiSurface.test.tsx b/ui/packages/app-shell/src/console/__tests__/RequireAiSurface.test.tsx index b39c19024b8..634ef36cff5 100644 --- a/ui/packages/app-shell/src/console/__tests__/RequireAiSurface.test.tsx +++ b/ui/packages/app-shell/src/console/__tests__/RequireAiSurface.test.tsx @@ -121,7 +121,7 @@ describe('RequireAiSurface', () => { renderGuardedAi(); const studio = screen.getByTestId('ai-unavailable-studio'); expect(studio).toHaveTextContent('«home.build.inStudio»'); - expect(studio).toHaveAttribute('href', '/studio?new=package'); + expect(studio).toHaveAttribute('href', '/apps/setup/component/developer/packages?face=admin&new=package'); }); it.each([ diff --git a/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx b/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx index 5c5be12ca40..f68ba0b37ff 100644 --- a/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx +++ b/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx @@ -15,7 +15,8 @@ * reach the AI service"; only the latter offers a retry. Either way there is a * way home, so the route never dead-ends. Where AI is simply not enabled, * Studio is the other way to build, so a session that may author is offered - * Studio's new-package flow beside it: the same entry, under the same label + * the new-package flow beside it (Setup → Packages with New Package open, + * which lands in Studio on the new package): the same entry, under the same label * and on the same terms, as Home's "New in Studio" chip (an admin, on a * runtime that offers authoring, holding the authoring capability). */ @@ -25,7 +26,7 @@ import { useWorkspaceAdminStatus } from '@object-ui/auth'; import { Button, Empty, EmptyDescription, EmptyTitle } from '@object-ui/components'; import { useCanAuthorMetadata } from '../../hooks/useCanAuthorMetadata.js'; import { isAiStudioEnabled } from '../../runtime-config.js'; -import { STUDIO_NEW_PACKAGE_PATH } from '../../views/studio-design/studioNewPackage.js'; +import { SETUP_NEW_PACKAGE_PATH } from '../../views/metadata-admin/packageSource.js'; export function AiUnavailable({ hasError, @@ -67,7 +68,7 @@ export function AiUnavailable({ )} {offerStudio && ( diff --git a/ui/packages/app-shell/src/console/home/HomePage.tsx b/ui/packages/app-shell/src/console/home/HomePage.tsx index e963c463a26..94f596c962f 100644 --- a/ui/packages/app-shell/src/console/home/HomePage.tsx +++ b/ui/packages/app-shell/src/console/home/HomePage.tsx @@ -89,7 +89,7 @@ import { usePublishAllDrafts } from '../../preview/usePublishAllDrafts.js'; import { fetchPackages } from '../../views/studio-design/packages-io.js'; import { resolveAiApiBase } from '../../hooks/useAiSurface.js'; import { isAiStudioEnabled, isMarketplaceEnabled } from '../../runtime-config.js'; -import { STUDIO_NEW_PACKAGE_PATH } from '../../views/studio-design/studioNewPackage.js'; +import { SETUP_NEW_PACKAGE_PATH } from '../../views/metadata-admin/packageSource.js'; import { useOpenAssistant } from '../../layout/chatDockControl.js'; import { isProductApp } from '../../utils/homePath.js'; import { useAddAppEntries, useMayAddApp } from '../../hooks/useAddAppEntries.js'; @@ -961,7 +961,8 @@ export function HomePage({ checklist }: HomePageProps = {}) { {/* objectstack#26614 — on a deployment whose agent catalog * is empty or absent, "Build an app" promises a build nothing * here can start. There the chip says what it opens instead, - * "New in Studio", and opens Studio's new-package flow; and + * "New in Studio", and opens New Package in Setup → Packages, + * which lands in Studio on the new package (objectstack#36908); and * since Studio is then the ONLY way to build, a session that * may not author gets no chip rather than a dimmed one (the * template chip beside it still carries the reason). With @@ -988,7 +989,7 @@ export function HomePage({ checklist }: HomePageProps = {}) { icon={Hammer} label={t('home.build.inStudio', { defaultValue: 'New in Studio' })} tone="soft" - onClick={() => navigate(STUDIO_NEW_PACKAGE_PATH)} + onClick={() => navigate(SETUP_NEW_PACKAGE_PATH)} disabledReason={undefined} reasonId={undefined} testId="home-build-in-studio" diff --git a/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx b/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx index 3800e17220c..43f3771d188 100644 --- a/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx +++ b/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx @@ -140,7 +140,7 @@ describe('HomePage — the desktop no-apps empty state (objectstack#36732)', () viewer.buildServed = false; render(); expect(screen.queryByTestId('home-no-apps-build-with-ai')).not.toBeInTheDocument(); - expect(screen.getByTestId('home-no-apps-new-in-studio')).toHaveAttribute('href', '/studio?new=package'); + expect(screen.getByTestId('home-no-apps-new-in-studio')).toHaveAttribute('href', '/apps/setup/component/developer/packages?face=admin&new=package'); expect(screen.getByTestId('home-no-apps-template')).toBeInTheDocument(); }); diff --git a/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx b/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx index 45008497bbd..307e738221c 100644 --- a/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx +++ b/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx @@ -11,7 +11,8 @@ * - with an agent in the catalog the chip is unchanged: "Build an app", to * `/studio`, dimmed with its reason for a session that may not author; * - with none it says what it opens, "New in Studio", and opens Studio's - * new-package flow (`STUDIO_NEW_PACKAGE_PATH`); + * new-package flow (`SETUP_NEW_PACKAGE_PATH`, Setup → Packages with New + * Package open since objectstack#36908); * - with none, a session that may not author gets no build chip at all, * while the template chip beside it still carries the reason; * - while the catalog has not answered, neither form is drawn, so neither @@ -154,7 +155,7 @@ vi.mock('../../deployment-notice/DeploymentNotice', () => ({ DeploymentNotice: ( // not inside a test's clock. import '@objectstack/lint'; import { HomePage } from '../HomePage'; -import { STUDIO_NEW_PACKAGE_PATH } from '../../../views/studio-design/studioNewPackage'; +import { SETUP_NEW_PACKAGE_PATH } from '../../../views/metadata-admin/packageSource'; beforeEach(() => { navigateMock.mockReset(); @@ -201,8 +202,8 @@ describe('with no agent in the catalog (objectstack#26614)', () => { expect(chip).toHaveTextContent('«home.build.inStudio»'); expect(screen.queryByTestId('home-build-app')).toBeNull(); await user.click(chip); - expect(navigateMock).toHaveBeenCalledWith(STUDIO_NEW_PACKAGE_PATH); - expect(STUDIO_NEW_PACKAGE_PATH).toBe('/studio?new=package'); + expect(navigateMock).toHaveBeenCalledWith(SETUP_NEW_PACKAGE_PATH); + expect(SETUP_NEW_PACKAGE_PATH).toBe('/apps/setup/component/developer/packages?face=admin&new=package'); }); it('a session that may not author gets no build chip; the template chip keeps the reason', async () => { @@ -229,7 +230,7 @@ describe('without the build agent in the catalog, the chip takes its Studio form expect(chip).toHaveTextContent('«home.build.inStudio»'); expect(screen.queryByTestId('home-build-app')).toBeNull(); await user.click(chip); - expect(navigateMock).toHaveBeenCalledWith(STUDIO_NEW_PACKAGE_PATH); + expect(navigateMock).toHaveBeenCalledWith(SETUP_NEW_PACKAGE_PATH); }); it('a session that may not author gets no build chip there', async () => { diff --git a/ui/packages/app-shell/src/hooks/useAddAppEntries.ts b/ui/packages/app-shell/src/hooks/useAddAppEntries.ts index dab6df502d1..402e09e9955 100644 --- a/ui/packages/app-shell/src/hooks/useAddAppEntries.ts +++ b/ui/packages/app-shell/src/hooks/useAddAppEntries.ts @@ -16,7 +16,7 @@ import { useWorkspaceAdminStatus } from '@object-ui/auth'; import { useCanAuthorMetadata } from './useCanAuthorMetadata.js'; import { useAiSurfaceEnabled } from './useAiSurface.js'; import { isAiStudioEnabled, isMarketplaceEnabled } from '../runtime-config.js'; -import { STUDIO_NEW_PACKAGE_PATH } from '../views/studio-design/studioNewPackage.js'; +import { SETUP_NEW_PACKAGE_PATH } from '../views/metadata-admin/packageSource.js'; import { studioLandingPath } from '../views/studio-design/studioAddress.js'; /** The marketplace, where templates and packages are installed from. */ @@ -57,7 +57,7 @@ export function useAddAppEntries(): AddAppEntry[] { entries.push( buildServed ? { key: 'build-with-ai', to: studioLandingPath(), label: t('home.buildWithAI', { defaultValue: 'Build with AI' }), icon: Hammer } - : { key: 'new-in-studio', to: STUDIO_NEW_PACKAGE_PATH, label: t('home.build.inStudio', { defaultValue: 'New in Studio' }), icon: Hammer }, + : { key: 'new-in-studio', to: SETUP_NEW_PACKAGE_PATH, label: t('home.build.inStudio', { defaultValue: 'New in Studio' }), icon: Hammer }, ); } if (isMarketplaceEnabled()) { diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index 716744bfd10..c56a40087d3 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -589,6 +589,10 @@ export { // The builder's front door: pick/create a writable package → pillar builder. // Standalone at `/studio` and embedded via the `studio:builder` component ref. export { BuilderLanding } from './views/studio-design/BuilderLanding.js'; +// objectstack#36908 — bare `/studio` draws no page: it opens the package the +// author was last in, else the package list. A host that declares the +// `/studio` routes mounts it as their index. +export { StudioEntryRedirect } from './views/studio-design/StudioEntryRedirect.js'; // The one Studio scope that is not a package (objectui#11553): the // organization's own package-less flows, at `/studio/~org/automations`. A host // that declares the `/studio` routes reads the reserved segment from here. @@ -611,6 +615,10 @@ export { StudioMetadataArea } from './views/studio-design/StudioMetadataArea.js' // area (the datasource's stays in Setup). A host whose legacy aliases forward // onto Setup's metadata routes lands them in one hop through this. export { setupMetadataStudioPath } from './views/studio-design/setupMetadataRedirect.js'; +// objectstack#36908 — Setup → Packages, the package list's administration +// face: where a host's legacy redirects that name no package land, now that +// Studio has no home page. +export { SETUP_PACKAGES_PATH } from './views/metadata-admin/packageSource.js'; // objectstack#36895 — the one builder of Studio addresses. A host that // declares the `/studio` routes, or links into them, spells every address // through these, never by hand (`studioAddress.guard.test.ts`). diff --git a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx index 6c95e33cd90..3021823a5c8 100644 --- a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx @@ -251,7 +251,7 @@ describe('「Add app」 offers building with AI only where the catalog serves bu catalog = [{ name: 'ask' }]; const choices = addChoices(); expect(choices.queryByTestId('sidebar-app-menu-add-build-with-ai')).toBeNull(); - expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute('href', '/studio?new=package'); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute('href', '/apps/setup/component/developer/packages?face=admin&new=package'); expect(choices.getByTestId('sidebar-app-menu-add-template')).toHaveAttribute('href', '/apps/setup/system/marketplace'); expect(choices.getByTestId('sidebar-app-menu-add-marketplace')).toHaveAttribute('href', '/apps/setup/system/marketplace'); }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx index bf7461432cb..112e0d1a86c 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx @@ -83,6 +83,7 @@ vi.mock('./PackageFormDialog', () => ({ import { resolveHref } from '@object-ui/layout'; import { PackagesPage, type InstalledPackageRow } from './PackagesPage'; import { t } from './i18n'; +import { SETUP_NEW_PACKAGE_PATH } from './packageSource'; // The page's package form reaches the CEL authoring helpers, which load these // two lazily; loaded here so their first load is paid at import, not inside a // test's clocked window. @@ -733,3 +734,40 @@ describe('Setup → Packages: the administration face (objectstack#36834)', () = } }); }); + +// --------------------------------------------------------------------------- +// objectstack#36908 — the console's new-package doors land on this face with +// New Package open (`SETUP_NEW_PACKAGE_PATH`), the Studio home that held that +// dialog having been removed. +// --------------------------------------------------------------------------- + +describe('Setup → Packages: the new-package deep link (objectstack#36908)', () => { + it('`?new=package` opens New Package on arrival and drops the param, keeping the face', async () => { + await serve({ packages: [CODE] }); + renderAt(SETUP_NEW_PACKAGE_PATH); + expect(SETUP_NEW_PACKAGE_PATH).toBe(`${ADMIN_URL}&new=package`); + + expect(await screen.findByTestId('stub-create-save')).toBeInTheDocument(); + await waitFor(() => expect(query().has('new')).toBe(false)); + expect(query().get('face')).toBe('admin'); + + // The create lands in Studio on the new package, as New Package does. + fireEvent.click(screen.getByTestId('stub-create-save')); + expect(await screen.findByTestId('where')).toHaveTextContent('/studio/app.fresh/data'); + }); + + it('CONTROL: the face without the param opens no dialog', async () => { + await serve({ packages: [CODE] }); + renderAt(ADMIN_URL); + await screen.findByTestId('pkg-row-com.acme.code'); + expect(screen.queryByTestId('stub-create-save')).toBeNull(); + }); + + it('on the development surface the param opens nothing, and is dropped', async () => { + await serve({ packages: [CODE] }); + renderAt(`${STUDIO_URL}?new=package`); + await screen.findByTestId('pkg-row-com.acme.code'); + await waitFor(() => expect(query().has('new')).toBe(false)); + expect(screen.queryByTestId('stub-create-save')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index f991b9b1dd1..c9912a9ce68 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -127,6 +127,8 @@ import { PACKAGE_SOURCES, PACKAGES_ADMIN_FACE, PACKAGES_FACE_PARAM, + PACKAGES_NEW_PACKAGE_VALUE, + PACKAGES_NEW_PARAM, PACKAGES_SOURCE_PARAM, PackageSourceRefusal, readPackagesFace, @@ -1853,6 +1855,26 @@ export function PackagesPage() { // development surface Studio opens (this page with no `face`). const adminFace = sourceFilter.face === 'admin'; + // objectstack#36908 — the console's new-package doors land here with New + // Package open (`SETUP_NEW_PACKAGE_PATH`, `?new=package` on this face), the + // way they used to land on the Studio home's create dialog. Read on arrival + // and dropped from the address with a replace, so a refresh or Back does not + // open the dialog again. The effect is keyed on the primitives it reads + // (ui/AGENTS.md #10). + const newParam = searchParams.get(PACKAGES_NEW_PARAM); + React.useEffect(() => { + if (newParam !== PACKAGES_NEW_PACKAGE_VALUE) return; + if (adminFace) setCreateOpen(true); + setSearchParams( + (prev) => { + const next = new URLSearchParams(prev); + next.delete(PACKAGES_NEW_PARAM); + return next; + }, + { replace: true }, + ); + }, [newParam, adminFace, setSearchParams]); + const filtered = React.useMemo(() => { const q = query.trim().toLowerCase(); return rows.filter((r) => { diff --git a/ui/packages/app-shell/src/views/metadata-admin/packageSource.ts b/ui/packages/app-shell/src/views/metadata-admin/packageSource.ts index 66a06a99cd2..74b13c3657f 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/packageSource.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/packageSource.ts @@ -184,3 +184,30 @@ export function packagesHref(basePath: string, source?: PackageSource): string { const path = `${basePath}/component/developer/packages`; return source ? `${path}?${PACKAGES_SOURCE_PARAM}=${source}` : path; } + +/** + * The administration face's new-package deep link, spelled as ONE URL query + * param (objectstack#36908): `?new=package` opens New Package on arrival, read + * once and dropped from the address, so a refresh or Back does not open it a + * second time. Page-local, like {@link PACKAGES_SOURCE_PARAM}. + */ +export const PACKAGES_NEW_PARAM = 'new'; + +/** The one value {@link PACKAGES_NEW_PARAM} takes. */ +export const PACKAGES_NEW_PACKAGE_VALUE = 'package'; + +/** + * Setup → Packages (objectstack#36834): the package list's administration + * face, hosted under the Setup app's address. Studio's entries that name no + * package land here since the Studio home was removed (objectstack#36908, + * epic decision 9): `/studio` with no remembered package, a package Studio + * cannot find, and a retired Setup page whose URL names none. + */ +export const SETUP_PACKAGES_PATH = `${packagesHref('/apps/setup')}?${PACKAGES_FACE_PARAM}=${PACKAGES_ADMIN_FACE}`; + +/** + * Setup → Packages with New Package open (objectstack#36908): the console's + * new-package doors (Home's and the `/ai` screen's 「New in Studio」, the + * 「Add app」 menu). The create lands in Studio on the new package. + */ +export const SETUP_NEW_PACKAGE_PATH = `${SETUP_PACKAGES_PATH}&${PACKAGES_NEW_PARAM}=${PACKAGES_NEW_PACKAGE_VALUE}`; diff --git a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx index eb26391cc0a..121f91d2e79 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx @@ -1,17 +1,15 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The package helpers Studio's surface and its landing share: the - * package-list toast id, the Studio landing path and the installed-row read. - * The top-bar package switcher that lived here with them, since - * objectstack#29988's move-only split, was removed by objectstack#36501: the - * top bar's left end is 「‹ Back to app」 (`StudioBackToApp.tsx`), and a - * package is picked in the app or on the Studio landing (`BuilderLanding`), - * whose cards also open the management sheet. + * The package helpers Studio's surface shares: the package-list toast id and + * the installed-row read. The top-bar package switcher that lived here with + * them, since objectstack#29988's move-only split, was removed by + * objectstack#36501: the top bar's left end is 「‹ Back to app」 + * (`StudioBackToApp.tsx`), and a package is picked in the app or in Setup → + * Packages (objectstack#36834, objectstack#36908). */ import type { InstalledPackageRow } from '../metadata-admin/PackagesPage.js'; -import { STUDIO_ROOT_PATH } from './studioAddress.js'; /** * One sonner id for EVERY `fetchPackages()` failure on this surface @@ -25,9 +23,6 @@ import { STUDIO_ROOT_PATH } from './studioAddress.js'; */ export const PACKAGE_LIST_TOAST_ID = 'studio-package-list'; -/** objectui#12513 — the Studio landing (`BuilderLanding`). */ -export const STUDIO_LANDING_PATH = STUDIO_ROOT_PATH; - /** * The record the standard detail/management sheet opens on: a package's full * installed row (manifest + status), read from `GET /api/v1/packages`, since diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx index 4051b0f6fa9..d4aef4394a5 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -62,7 +62,8 @@ import { navigationObjectOrder, } from './flowGrouping.js'; import { StudioRefusalStrip } from './StudioRefusalStrip.js'; -import { PACKAGE_LIST_TOAST_ID, STUDIO_LANDING_PATH } from './PackageSwitcher.js'; +import { PACKAGE_LIST_TOAST_ID } from './PackageSwitcher.js'; +import { SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; import { StudioBackToApp, type StudioAppTarget } from './StudioBackToApp.js'; import { FlowStatusDot, @@ -1510,8 +1511,10 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re testId="studio-package-not-found" sentence={tFormat('engine.studio.notFound.package', locale, { id: packageId })} action={ - } /> diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx new file mode 100644 index 00000000000..a21bf9117cc --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx @@ -0,0 +1,135 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36908 (epic #36890 decision 9) — bare `/studio` draws no page. + * It opens the package the author was last in, still named by the package + * list; otherwise the package list: Setup → Packages for a principal who may + * open it, the "All metadata" area across packages for one who may only enter + * Studio. The retired `/studio?new=package` bookmark lands on Setup's New + * Package. + * + * The recent store and the list read are stubbed at their modules: what is + * measured is where the entry SENDS the author, read off the router's + * location. + */ + +import '@testing-library/jest-dom/vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; + +const recent = vi.hoisted(() => ({ items: [] as Array<{ type: string; name: string }> })); +const listed = vi.hoisted(() => ({ read: async (): Promise> => new Set() })); + +vi.mock('../../context/RecentItemsProvider.js', () => ({ + useRecentItems: () => ({ recentItems: recent.items }), +})); +vi.mock('./packages-io.js', () => ({ + fetchListedPackageIds: () => listed.read(), +})); + +import { StudioEntryRedirect, studioEntryFallbackPath } from './StudioEntryRedirect'; + +const SETUP_PACKAGES = '/apps/setup/component/developer/packages?face=admin'; +const ALL_METADATA = '/studio/~all/metadata'; +const ADMIN = ['studio.access', 'setup.access', 'manage_platform_settings']; + +function Where() { + const { pathname, search } = useLocation(); + return
{`${pathname}${search}`}
; +} + +function renderEntry(url = '/studio', systemPermissions: string[] | undefined = ADMIN) { + return render( + + + } />} + /> + } /> + + , + ); +} + +const pkg = (name: string) => ({ type: 'package', name }); + +afterEach(() => { + cleanup(); + recent.items = []; + listed.read = async () => new Set(); +}); + +describe("Studio's entry: the package last opened (objectstack#36908)", () => { + it('opens the newest remembered package the list still names', async () => { + recent.items = [{ type: 'object', name: 'account' }, pkg('com.acme.crm'), pkg('com.acme.hr')]; + listed.read = async () => new Set(['com.acme.crm', 'com.acme.hr']); + renderEntry(); + expect(await screen.findByTestId('where')).toHaveTextContent(/^\/studio\/com\.acme\.crm$/); + }); + + it('passes over a remembered package the list no longer names', async () => { + recent.items = [pkg('com.acme.gone'), pkg('com.acme.hr')]; + listed.read = async () => new Set(['com.acme.hr']); + renderEntry(); + expect(await screen.findByTestId('where')).toHaveTextContent(/^\/studio\/com\.acme\.hr$/); + }); + + it('with no remembered package the list names, lands on the package list', async () => { + recent.items = [pkg('com.acme.gone')]; + listed.read = async () => new Set(['com.acme.hr']); + renderEntry(); + expect(await screen.findByTestId('where')).toHaveTextContent(SETUP_PACKAGES); + }); + + it('draws the pending element while the list is read, never a page of its own', async () => { + recent.items = [pkg('com.acme.crm')]; + let answer!: (ids: ReadonlySet) => void; + listed.read = () => new Promise((resolve) => (answer = resolve)); + renderEntry(); + expect(screen.getByTestId('pending')).toBeInTheDocument(); + answer(new Set(['com.acme.crm'])); + expect(await screen.findByTestId('where')).toHaveTextContent(/^\/studio\/com\.acme\.crm$/); + }); + + it('when the list cannot be read, opens the newest remembered package (Studio reports the read)', async () => { + recent.items = [pkg('com.acme.crm'), pkg('com.acme.hr')]; + listed.read = async () => { + throw new Error('503'); + }; + renderEntry(); + expect(await screen.findByTestId('where')).toHaveTextContent(/^\/studio\/com\.acme\.crm$/); + }); +}); + +describe("Studio's entry: the package list (objectstack#36908)", () => { + it('with nothing remembered, an administrator lands on Setup → Packages without reading the list', async () => { + const read = vi.fn(async () => new Set()); + listed.read = read; + renderEntry(); + expect(await screen.findByTestId('where')).toHaveTextContent(SETUP_PACKAGES); + expect(read).not.toHaveBeenCalled(); + }); + + it('a principal who may enter Studio but not Setup → Packages lands on the "All metadata" area', async () => { + renderEntry('/studio', ['studio.access', 'setup.access']); + expect(await screen.findByTestId('where')).toHaveTextContent(ALL_METADATA); + }); + + it('the fallback reads the two capabilities Setup → Packages is shown under, and holds nothing for no answer', () => { + expect(studioEntryFallbackPath(ADMIN)).toBe(SETUP_PACKAGES); + expect(studioEntryFallbackPath(['studio.access', 'manage_platform_settings'])).toBe(ALL_METADATA); + expect(studioEntryFallbackPath(['studio.access', 'setup.access'])).toBe(ALL_METADATA); + expect(studioEntryFallbackPath(undefined)).toBe(ALL_METADATA); + }); +}); + +describe('the retired `/studio?new=package` bookmark (objectstack#36908)', () => { + it("lands on Setup's New Package, whatever is remembered", async () => { + recent.items = [pkg('com.acme.crm')]; + listed.read = async () => new Set(['com.acme.crm']); + renderEntry('/studio?new=package'); + expect(await screen.findByTestId('where')).toHaveTextContent(`${SETUP_PACKAGES}&new=package`); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx new file mode 100644 index 00000000000..a167f8dcf0e --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx @@ -0,0 +1,99 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * `/studio` — Studio's entry, which draws no page of its own (objectstack#36908, + * epic #36890 decision 9). + * + * Studio is the development surface of a package, entered from an app or from + * Setup → Packages (objectstack#36834); the package-card home that bare + * `/studio` used to draw had no door and was removed. The address still + * answers, by sending the author where they would go next: + * + * 1. a package the author was last in — the newest `package` entry of the + * recent items the Studio route records (`StudioRoute`), still named by + * the package list — opens in Studio; + * 2. otherwise the package list: Setup → Packages for a principal who may + * open it, and Studio's "All metadata" area across packages + * (`/studio/~all/metadata`) for one who may enter Studio and not that + * Setup page ({@link studioEntryFallbackPath}). + * + * The retired `/studio?new=package` bookmark is forwarded to Setup's New + * Package (`studioNewPackage.ts`). + * + * A package deleted since the visit is passed over: the recent store is the + * user's, the list the active organization's, so an entry the list no longer + * names is not a package to open. When the list cannot be read, the newest + * entry opens anyway, and Studio reports the read itself. + */ + +import * as React from 'react'; +import { Navigate, useSearchParams } from 'react-router-dom'; +import { useRecentItems } from '../../context/RecentItemsProvider.js'; +import { SETUP_NEW_PACKAGE_PATH, SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; +import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaPath } from './metadataArea.js'; +import { fetchListedPackageIds } from './packages-io.js'; +import { studioPackagePath } from './studioAddress.js'; +import { STUDIO_NEW_PACKAGE_VALUE, STUDIO_NEW_PARAM } from './studioNewPackage.js'; + +/** + * The capabilities Setup → Packages is shown under: the Setup app's entry + * (`setup.access`) and the menu item's gate (`manage_platform_settings`, + * `nav_packages` in `setup-nav.contributions.ts`). + */ +const SETUP_PACKAGES_CAPABILITIES = ['setup.access', 'manage_platform_settings'] as const; + +/** + * Where Studio's entry goes when no remembered package opens: Setup → Packages + * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else the "All metadata" + * area across packages, which every principal who may enter Studio may open. + * `undefined` (no answer reported) holds nothing. + */ +export function studioEntryFallbackPath(systemPermissions: readonly string[] | undefined): string { + const held = new Set(systemPermissions ?? []); + return SETUP_PACKAGES_CAPABILITIES.every((c) => held.has(c)) + ? SETUP_PACKAGES_PATH + : studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT); +} + +export function StudioEntryRedirect({ + systemPermissions, + pending = null, +}: { + /** The principal's capability set, as Studio's entry gate read it. */ + systemPermissions: readonly string[] | undefined; + /** What is drawn while the package list is read. */ + pending?: React.ReactNode; +}): React.ReactElement | null { + const [searchParams] = useSearchParams(); + const { recentItems } = useRecentItems(); + // Newest first, as the store keeps them; a package once, at its newest. + const remembered = recentItems.filter((item) => item.type === 'package').map((item) => item.name); + const rememberedKey = remembered.join('\n'); + const [target, setTarget] = React.useState(null); + const fallback = studioEntryFallbackPath(systemPermissions); + const forwardNew = searchParams.get(STUDIO_NEW_PARAM) === STUDIO_NEW_PACKAGE_VALUE; + + React.useEffect(() => { + if (forwardNew || !rememberedKey) return; + let cancelled = false; + const ids = rememberedKey.split('\n'); + fetchListedPackageIds().then( + (listed) => { + const open = ids.find((id) => listed.has(id)); + if (!cancelled) setTarget(open ? studioPackagePath(open) : fallback); + }, + () => { + if (!cancelled) setTarget(studioPackagePath(ids[0])); + }, + ); + return () => { + cancelled = true; + }; + // Keyed on the primitives it reads (ui/AGENTS.md #10). + }, [forwardNew, rememberedKey, fallback]); + + if (forwardNew) return ; + if (!rememberedKey) return ; + if (target === null) return <>{pending}; + return ; +} diff --git a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts index 8ba32ff0c66..dd04191b242 100644 --- a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts @@ -120,12 +120,15 @@ describe('packagedAutomationStudioPath (ADR-0146 D11)', () => { }); describe('packagedActionsStudioPath (objectstack#34724)', () => { + // objectstack#36908 — a URL naming no package lands on Setup → Packages, + // the package list, since the Studio home was removed; that page reads its + // own query, so the retired page's query and fragment are not carried. it.each([ // [search, hash, expected] ['?package=crm', '', '/studio/crm/data?package=crm'], ['?package=com.acme.app&x=1', '#top', '/studio/com.acme.app/data?package=com.acme.app&x=1#top'], - ['', '', '/studio'], - ['?package=all', '', '/studio?package=all'], + ['', '', '/apps/setup/component/developer/packages?face=admin'], + ['?package=all', '#top', '/apps/setup/component/developer/packages?face=admin'], ])('%s%s → %s', (search, hash, expected) => { expect(packagedActionsStudioPath(search, hash)).toBe(expected); }); diff --git a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts index 5bd5542fec2..185cb36799f 100644 --- a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts +++ b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts @@ -18,7 +18,8 @@ */ import { STUDIO_ALL_PACKAGES_SEGMENT, areaLocationRedirect } from './metadataArea.js'; -import { studioHomePath, studioLandingPath, studioMetadataAreaAddress, studioPillarPath } from './studioAddress.js'; +import { studioHomePath, studioMetadataAreaAddress, studioPillarPath } from './studioAddress.js'; +import { SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; /** The one metadata type whose Setup pages stay in Setup (ADR-0146 D1). */ export const SETUP_KEPT_METADATA_TYPE = 'datasource'; @@ -81,13 +82,15 @@ export function packagedAutomationStudioPath(search: string, hash = ''): string * * With `?package=` (not `all`), that app's Data pillar, whose objects' * Actions views carry the switch, the query kept. With no package named (the - * page listed every package's actions), the Studio landing, which lists each - * installed app with its switched-off count. + * page listed every package's actions), Setup → Packages, the package list, + * which opens each app (objectstack#36908: the Studio home that listed every + * installed app with its switched-off count was removed). That page reads its + * own query, so the retired page's is not carried. */ export function packagedActionsStudioPath(search: string, hash = ''): string { const params = new URLSearchParams(search); const query = params.toString(); const pkg = params.get('package'); if (pkg && pkg !== 'all') return studioHomePath(pkg, { query, hash }); - return studioLandingPath({ query, hash }); + return SETUP_PACKAGES_PATH; } diff --git a/ui/packages/app-shell/src/views/studio-design/studioAddress.test.ts b/ui/packages/app-shell/src/views/studio-design/studioAddress.test.ts index 209034b8c31..7065f278e75 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioAddress.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioAddress.test.ts @@ -41,7 +41,7 @@ import { DESIGNER_SURFACE_VIEW_PARAM, } from './useSurfaceDeepLink.js'; import { STUDIO_CHANGES_PARAM, STUDIO_CHANGES_REVIEW } from './studioChangesLink.js'; -import { STUDIO_NEW_PACKAGE_PATH } from './studioNewPackage.js'; +import { STUDIO_NEW_PACKAGE_VALUE, STUDIO_NEW_PARAM } from './studioNewPackage.js'; import { retiredInterfacesTarget } from './studioInterfacesRetired.js'; import { studioOrgScopePath } from './studioScope.js'; import { AREA_PILLAR_FOR_TYPE, areaItemPillarPath, studioMetadataItemPath, studioPillarItemPath } from './metadataArea.js'; @@ -76,7 +76,8 @@ describe('studioPath — the one path builder (objectstack#36895)', () => { describe("today's addresses, byte for byte", () => { it('landing, package, pillar, home', () => { expect(studioLandingPath()).toBe('/studio'); - expect(STUDIO_NEW_PACKAGE_PATH).toBe('/studio?new=package'); + // objectstack#36908 — the retired new-package bookmark Studio's entry forwards. + expect(studioLandingPath({ query: `${STUDIO_NEW_PARAM}=${STUDIO_NEW_PACKAGE_VALUE}` })).toBe('/studio?new=package'); expect(studioPackagePath('com.acme.crm')).toBe('/studio/com.acme.crm'); expect(studioPillarPath('com.acme.crm', 'automations')).toBe('/studio/com.acme.crm/automations'); expect(studioHomePath('com.acme.crm')).toBe('/studio/com.acme.crm/data'); diff --git a/ui/packages/app-shell/src/views/studio-design/studioAddressTable.ts b/ui/packages/app-shell/src/views/studio-design/studioAddressTable.ts index c4730e3adb9..cb4a6e9486b 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioAddressTable.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioAddressTable.ts @@ -63,12 +63,17 @@ export interface StudioAddressFamily { } export const STUDIO_ADDRESS_FAMILIES: readonly StudioAddressFamily[] = Object.freeze([ - { id: 'landing', today: '/studio', builder: 'studioLandingPath', meaning: 'The front door: pick or create a writable package.' }, + { + id: 'landing', + today: '/studio', + builder: 'studioLandingPath', + meaning: "Studio's entry, no page of its own: the package last opened, else the package list (StudioEntryRedirect).", + }, { id: 'landing-new-package', today: `/studio?${STUDIO_NEW_PARAM}=${STUDIO_NEW_PACKAGE_VALUE}`, builder: 'studioLandingPath', - meaning: 'The front door with its create-package dialog open.', + meaning: "A retired bookmark: Studio's entry forwards it to Setup → Packages with New Package open.", }, { id: 'package', today: '/studio/', builder: 'studioPackagePath', meaning: `A package's Studio; the route lands it on its home pillar, \`${STUDIO_HOME_PILLAR}\`.` }, { id: 'pillar', today: '/studio//', builder: 'studioPillarPath', meaning: 'One pillar of a package: data, automations or access.' }, @@ -252,7 +257,7 @@ export const STUDIO_QUERY_PARAMS: readonly StudioQueryParamRow[] = Object.freeze { key: STUDIO_NEW_PARAM, values: STUDIO_NEW_PACKAGE_VALUE, - meaning: "The landing's create dialog. Landing only.", + meaning: "The retired new-package bookmark; Studio's entry forwards it to Setup's New Package. Entry only.", onMetadataAddress: 'verbatim', keptOnRetiredInterfaces: false, }, diff --git a/ui/packages/app-shell/src/views/studio-design/studioNewPackage.ts b/ui/packages/app-shell/src/views/studio-design/studioNewPackage.ts index d6deba2c848..758eb51544a 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioNewPackage.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioNewPackage.ts @@ -1,26 +1,21 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The Studio landing's new-package deep link: `/studio?new=package` opens the - * landing (`BuilderLanding`) with its create-package dialog already open. + * The retired Studio new-package deep link, `/studio?new=package`. * - * Its own module rather than an export of `BuilderLanding.tsx`: Home and the - * `/ai` route's no-assistant screen link here from the console's eager - * closure, while `BuilderLanding` is fetched with the lazy Studio chunk - * (`apps/console/src/components/studioBuilder.ts`), and a static import of it - * from either would pull it back into every page load. + * It opened the Studio home with its create-package dialog open. The home was + * removed (objectstack#36908, epic #36890 decision 9), and a package is + * created from Setup → Packages, which then lands in Studio on it + * (`SETUP_NEW_PACKAGE_PATH`, objectstack#36834). The console's own doors link + * there; a bookmark of the old address is forwarded there by Studio's entry + * (`StudioEntryRedirect`), so it still opens New Package. * - * `new` is a page-scoped param of the landing's own contract, so it is not - * listed in `urlParams.ts`; it collides with none of the names reserved there. + * `new` is a page-scoped param, so it is not listed in `urlParams.ts`; it + * collides with none of the names reserved there. */ -import { studioLandingPath } from './studioAddress.js'; - -/** The landing's query param that names what to create on arrival. */ +/** The retired deep link's query param, which named what to create on arrival. */ export const STUDIO_NEW_PARAM = 'new'; -/** The {@link STUDIO_NEW_PARAM} value that opens the create-package dialog. */ +/** The {@link STUDIO_NEW_PARAM} value that asked for a new package. */ export const STUDIO_NEW_PACKAGE_VALUE = 'package'; - -/** Studio's new-package flow: the landing, with the create-package dialog open. */ -export const STUDIO_NEW_PACKAGE_PATH = studioLandingPath({ query: `${STUDIO_NEW_PARAM}=${STUDIO_NEW_PACKAGE_VALUE}` }); diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 65a4b91d0d4..8f10ddda8b6 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3461,14 +3461,14 @@ const STUDIO_EN: Record = { 'engine.studio.close': 'Close', 'engine.studio.deselect': 'Clear selection', 'engine.studio.toggleRail': 'Toggle sidebar', - // objectui#12513 — the header's first button and the package switcher's - // first row: both return to the Studio landing (`/studio`). - 'engine.studio.landingHome': 'Studio home', // objectui#11795 — the one line a phone shows under the Studio header. 'engine.studio.desktopHint': 'Studio is built for a desktop screen.', // objectstack#26708 — the builder's not-found states: a package id the // package list does not hold, and a pillar segment Studio has no pillar for. 'engine.studio.notFound.package': 'Package not found. No package with the id "{id}" is installed here, so there is nothing to build in.', + // objectstack#36908 — the package-not-found state's way out: Setup → Packages, + // where Studio's entries that name no package land since the Studio home went. + 'engine.studio.notFound.packageList': 'Open the package list', 'engine.studio.notFound.pillar': 'This page does not exist. Studio has no "{pillar}" section; pick Data, Automations, Interfaces, Access or All metadata above.', 'engine.studio.aiCopilot': 'AI Assistant', // objectui#12725 — the Studio right slot: properties OR the copilot. diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 94b12e4f705..77f51395179 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3058,9 +3058,9 @@ const STUDIO_ZH: Record = { 'engine.studio.close': '关闭', 'engine.studio.deselect': '取消选择', 'engine.studio.toggleRail': '切换侧栏', - 'engine.studio.landingHome': 'Studio 首页', 'engine.studio.desktopHint': 'Studio 专为桌面屏幕设计。', 'engine.studio.notFound.package': '未找到包。本部署没有安装 ID 为“{id}”的包,因此无处可构建。', + 'engine.studio.notFound.packageList': '打开软件包列表', 'engine.studio.notFound.pillar': '页面不存在。Studio 没有“{pillar}”这一栏,请在上方选择数据、自动化、界面、权限或全部元数据。', 'engine.studio.aiCopilot': 'AI 助手', // objectui#12725 — Studio 右栏:属性或 AI 助手二选一。 From d876e429e307d723c7fb4ec9e04f1b707e8a4126 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 19:20:39 +0000 Subject: [PATCH 02/21] test(studio): convert the console and not-found pins to Studio's entry The StudioRoute pins now stub the entry instead of the package-card home; the two files that pinned only the home's console frame (its header crumb and its command palette) are deleted; studio:builder's registration test reads the forward to /studio; the not-found pin opens Setup > Packages. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- ...tudioComponents.builderLazy-11798.test.tsx | 84 +++---- .../StudioRoute.accessNotice-12035.test.tsx | 11 +- .../StudioRoute.landingI18n.test.tsx | 206 ------------------ .../StudioRoute.lazyBuilder-11798.test.tsx | 21 +- .../StudioRoute.metadataArea-28561.test.tsx | 6 +- .../StudioRoute.recentPackage-11863.test.tsx | 15 +- .../StudioRoute.searchPalette-11863.test.tsx | 177 --------------- .../src/components/StudioRoute.test.tsx | 40 ++-- ...tudioDesignSurface.notFound-26708.test.tsx | 21 +- .../studio-design/StudioEntryRedirect.tsx | 6 +- 10 files changed, 84 insertions(+), 503 deletions(-) delete mode 100644 ui/apps/console/src/components/StudioRoute.landingI18n.test.tsx delete mode 100644 ui/apps/console/src/components/StudioRoute.searchPalette-11863.test.tsx diff --git a/ui/apps/console/src/__tests__/registerStudioComponents.builderLazy-11798.test.tsx b/ui/apps/console/src/__tests__/registerStudioComponents.builderLazy-11798.test.tsx index cc2c8b0a3dd..f34b79c4439 100644 --- a/ui/apps/console/src/__tests__/registerStudioComponents.builderLazy-11798.test.tsx +++ b/ui/apps/console/src/__tests__/registerStudioComponents.builderLazy-11798.test.tsx @@ -1,40 +1,28 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * objectui#11798 — `studio:builder` is registered at boot, and the builder it - * renders loads only when that entry is first rendered. + * objectui#11798, objectstack#36908 — `studio:builder` is registered at boot, + * and it forwards to Studio's entry. * - * ## What this replaces, and why its old assertion is now the wrong one - * - * objectui#5486 pinned the opposite: that the builder rendered on the FIRST - * commit, with no Suspense boundary in front of it. That was right for its - * tree. The registration then wrapped `import('@object-ui/app-shell')`, the - * barrel this file and `App.tsx` imported statically, so the `lazy()` deferred - * nothing and only bought a fallback no user could see. objectui#5486 made the - * registration truthful and left genuine laziness to a separate measured card. - * - * objectui#11798 is that card. The registration now reaches `BuilderLanding` - * through `./components/studioBuilder`, a console-local module nothing imports - * statically, so the boundary is real: the builder's chunk leaves the eager - * closure (measured on the built console, see the PR), and the entry shows a - * loading line until it arrives. The property worth pinning therefore flips, - * and it is pinned the same way objectui#5486 pinned its own, by what React - * commits rather than by the source's spelling. - * - * ## The two halves + * The entry drew the Studio home's package cards inside the app shell, loaded + * with the builder's chunk (objectui#11798). That home was removed + * (objectstack#36908, epic #36890 decision 9), so the entry forwards to bare + * `/studio`, whose one owner (`StudioRoute`) opens the package the author was + * last in, else the package list. Forwarding renders nothing of the builder, + * so it loads nothing of it either. * * - REGISTRY: importing this module registers `studio:builder` and evaluates * nothing of the builder. `ComponentNavView` finds the entry the moment the * console boots, exactly as before. - * - RENDER: the entry commits its loading line first, then the landing once - * the module resolves. A boundary that deferred nothing (the objectui#5486 - * shape) commits the landing on the first commit and reds the first half. + * - RENDER: the entry lands on `/studio` and still evaluates nothing of the + * builder: the `/studio` route loads it behind its gate. */ import '@testing-library/jest-dom/vitest'; import { describe, it, expect, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; -import type { ComponentType, ReactNode } from 'react'; +import type { ComponentType } from 'react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; type Registration = { ref: string; label?: string; source?: string; component: ComponentType }; @@ -45,38 +33,19 @@ const { registrations, builderModuleLoads } = vi.hoisted(() => ({ // Mocked at the specifier the module under test imports, so the entry exercised // below is the production registration itself. The real barrel's surface is -// inherited (`check:vi-mock-inherit`); only the names this file's graph renders -// or records are overridden. +// inherited (`check:vi-mock-inherit`); only the registry is overridden. vi.mock('@object-ui/app-shell', async (importOriginal) => ({ ...(await importOriginal>()), registerAppComponent: (entry: Registration) => { registrations.push(entry); }, - // The barrel's own builder, as a marker: the entry must reach the landing - // only through the deferred module below, so registering this one instead - // commits the marker with no loading line and reds the render case. - BuilderLanding: () =>
, - // `StudioRoute.tsx` is imported for its shared loading line; these are the - // other names its module graph reads from the barrel. - ConnectedShell: ({ children }: { children?: ReactNode }) => <>{children}, - RequireOrganization: ({ children }: { children?: ReactNode }) => <>{children}, - RedirectWithSplash: () => null, - LoadingFallback: () => null, - LoadingScreen: () => null, - STUDIO_ORG_SCOPE_SEGMENT: '~org', - STUDIO_ORG_SCOPE_PILLAR: 'automations', - getProductName: () => 'ObjectOS', - useHomePath: () => '/home', })); // The deferred module. Its factory runs when the module is first imported, so // the count is the unit-level image of "the builder's chunk was fetched". vi.mock('../components/studioBuilder', () => { builderModuleLoads.count += 1; - return { - BuilderLanding: () =>
, - StudioDesignSurface: () => null, - }; + return { StudioEntryRedirect: () => null, StudioDesignSurface: () => null }; }); // Side-effect import, exactly as `main.tsx` performs it. @@ -88,7 +57,7 @@ function entryFor(ref: string): Registration { return found; } -describe('studio:builder registration (objectui#11798)', () => { +describe('studio:builder registration (objectui#11798, objectstack#36908)', () => { it('is registered at boot, and registering evaluates nothing of the builder', () => { const entry = entryFor('studio:builder'); expect(entry.source).toBe('@object-ui/console'); @@ -96,19 +65,18 @@ describe('studio:builder registration (objectui#11798)', () => { expect(builderModuleLoads.count).toBe(0); }); - it('commits a loading line first, then the landing once its module resolves', async () => { + it("forwards to Studio's entry, bare `/studio`, and loads nothing of the builder", async () => { const Builder = entryFor('studio:builder').component; - render(); + render( + + + } /> + } /> + + , + ); - // No `await`: the first commit. A boundary that deferred nothing would have - // committed the landing here, which is the objectui#5486 shape. - // The fallback is found by its role, not by its copy: the words are the - // translation catalogue's, and this file pins only that a wait is shown. - expect(screen.queryByTestId('builder-landing')).not.toBeInTheDocument(); - expect(screen.getByRole('status')).toBeInTheDocument(); - - expect(await screen.findByTestId('builder-landing')).toBeInTheDocument(); - expect(screen.queryByRole('status')).not.toBeInTheDocument(); - expect(builderModuleLoads.count).toBe(1); + expect(await screen.findByTestId('studio-entry')).toBeInTheDocument(); + expect(builderModuleLoads.count).toBe(0); }); }); diff --git a/ui/apps/console/src/components/StudioRoute.accessNotice-12035.test.tsx b/ui/apps/console/src/components/StudioRoute.accessNotice-12035.test.tsx index ed5aec4cd4e..e3b50783deb 100644 --- a/ui/apps/console/src/components/StudioRoute.accessNotice-12035.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.accessNotice-12035.test.tsx @@ -77,9 +77,10 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ LoadingFallback: () =>
, LoadingScreen: () =>
, getProductName: () => 'ObjectOS', - BuilderLanding: () => { + // objectstack#36908 — bare `/studio` is Studio's entry, which draws no page. + StudioEntryRedirect: () => { builderLanding(); - return
pick a package
; + return
entry
; }, StudioDesignSurface: () =>
, })); @@ -120,8 +121,8 @@ function inLanguage(language: Language) { beforeEach(() => { systemPermissions = []; builderLanding.mockClear(); - // The landing mounts the real `AppHeader`, which reads its user-scoped feeds - // on mount; each answers empty here, so no request leaves the process. + // A screen that mounts the real `AppHeader` reads its user-scoped feeds on + // mount; each answers empty here, so no request leaves the process. vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ data: [] }))); }); @@ -164,7 +165,7 @@ describe('CONTROL: a caller with Studio access enters Studio as today', () => { systemPermissions = [STUDIO_ENTRY_CAPABILITY]; renderStudio('/studio/'); - await waitFor(() => expect(screen.getByTestId('studio-front-door')).toBeInTheDocument()); + await waitFor(() => expect(screen.getByTestId('studio-entry')).toBeInTheDocument()); expect(builderLanding).toHaveBeenCalled(); expect(screen.getByTestId('pathname').textContent).toBe('/studio/'); expect(screen.queryByText(sentenceIn(lang))).not.toBeInTheDocument(); diff --git a/ui/apps/console/src/components/StudioRoute.landingI18n.test.tsx b/ui/apps/console/src/components/StudioRoute.landingI18n.test.tsx deleted file mode 100644 index 88d79d9de1c..00000000000 --- a/ui/apps/console/src/components/StudioRoute.landingI18n.test.tsx +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * The Studio front door's header speaks in keys, and no pack's language is - * hardcoded into it. - * - * objectui#10043 keyed the old wordmark's tooltip, which had shipped as a raw - * Chinese literal: user-visible text outside i18n entirely, which AGENTS.md - * commandment #-1 names by category ("component labels, buttons, titles, - * errors"). objectui#11863 (Q1) replaced that wordmark bar with the console's - * own header, `AppHeader`'s `studio` variant, so the tooltip and its key - * (`console.studio.backToHome`) are retired, and what this file pins now is the - * header's fixed Studio crumb, read from `console.studio.title`, through the - * REAL `studioRoutes` tree and the real `AppHeader`. - * - * ## Why `t` answers in no natural language here - * - * Same reason as `AppManagementPage.i18n.test.tsx`, and the same sentinel: a - * mock that echoed `defaultValue` would let a component that never called `t` - * at all pass every assertion, because a hardcoded literal and a correctly - * keyed lookup are indistinguishable the moment the pack agrees with the - * source. `t` therefore returns `«key»`, which is what a NON-English pack does - * to this header in the only respect that matters: the source language - * disappears. - * - * ## Two-sided, and the negative side carries its own control - * - * Naming the key is necessary and not sufficient — a stray Han literal could - * sit beside a correctly keyed one. So a second assertion sweeps the rendered - * landing for Han script. A script-class assertion is exactly the shape - * AGENTS.md's i18n forensics rule warns can go permanently vacuous, so the - * regex is pinned against a live positive built from a code point rather than - * trusted: without that control, a broken `HAN` would report "no Chinese on - * screen" forever, on a screen full of it. - * - * The Han sample is constructed with `String.fromCodePoint` rather than written - * out, so this file's own bytes stay ASCII under the commandment it enforces. - */ - -import '@testing-library/jest-dom/vitest'; -import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; -import { render, screen } from '@testing-library/react'; -import React from 'react'; -import { MemoryRouter, Routes, Route } from 'react-router-dom'; - -/** Auth facts. This file only ever drives the holder path. */ -const auth = { isAuthenticated: true, isLoading: false, user: { id: 'u1' } as unknown }; - -function jsonResponse(body: unknown, status = 200): Response { - return { - ok: status >= 200 && status < 300, - status, - headers: { get: () => null }, - json: async () => body, - } as unknown as Response; -} - -vi.mock('@object-ui/auth', async (importOriginal) => ({ - ...(await importOriginal>()), - useAuth: () => auth, - createAuthenticatedFetch: () => async () => - jsonResponse({ - authenticated: true, - userId: 'u1', - systemPermissions: ['studio.access'], - objects: {}, - fields: {}, - }), -})); - -// `AuthGuard` reaches `useAuth` through the auth package's OWN module graph, -// not through its entry point — the same seam `StudioRoute.test.tsx` documents. -vi.mock('../../../../packages/auth/src/useAuth', async (importOriginal) => ({ - ...(await importOriginal>()), - useAuth: () => auth, -})); - -// Barrel cost, measured in `StudioRoute.test.tsx`: an `importOriginal()` on -// `@object-ui/app-shell` transforms the whole graph on demand. Every name this -// file's graph reads is either overridden here or lives in `chrome/`, so pull -// that ONE submodule instead. -vi.mock('@object-ui/app-shell', async (importOriginal) => ({ - ...(await importOriginal>()), - ...(await vi.importActual>( - '../../../../packages/app-shell/src/chrome/index' - )), - ConnectedShell: ({ children }: { children?: React.ReactNode }) => <>{children}, - RequireOrganization: ({ children }: { children?: React.ReactNode }) => <>{children}, - LoadingFallback: () =>
, - LoadingScreen: () =>
, - getProductName: () => 'ObjectOS', - BuilderLanding: () =>
pick a package
, - StudioDesignSurface: () =>
, -})); - -/** - * A pack that speaks only in keys. `defaultValue` is dropped on purpose — it - * is the call site's own English, and honouring it here would hand the test - * back the very sentence it is trying to prove the header no longer hardcodes. - */ -vi.mock('@object-ui/i18n', async (importOriginal) => ({ - ...(await importOriginal>()), - useObjectTranslation: () => ({ - t: (key: string) => `«${key}»`, - }), -})); - -import { studioRoutes } from './StudioRoute'; - -/** The key the header's fixed Studio crumb must ask the catalogue for. */ -const CRUMB_KEY = 'console.studio.title'; - -/** The retired wordmark tooltip's key: nothing on the landing may ask for it. */ -const RETIRED_KEY = 'console.studio.backToHome'; - -/** - * Han script, the class the retired literal belonged to. `u` flag + a script - * property class, never ASCII `\w` — AGENTS.md's i18n forensics rule. - */ -const HAN = /\p{Script=Han}/u; - -/** Built, not written, so this file stays ASCII. U+4E2D is an ordinary Han ideograph. */ -const HAN_SAMPLE = String.fromCodePoint(0x4e2d); - -function renderStudioLanding() { - return render( - - - {studioRoutes} - home
} /> - login
} /> - - , - ); -} - -/** Every attribute value on the page: `textContent` never sees one. */ -function attributeValues(): string[] { - return Array.from(document.body.querySelectorAll('*')).flatMap((el) => - Array.from(el.attributes).map((a) => a.value), - ); -} - -beforeEach(() => { - vi.clearAllMocks(); - // The real `AppHeader` reads its user-scoped feeds (the inbox, approvals) and - // the AI agent catalogue on mount; each answers empty here, so no request - // leaves the process. - vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ data: [] }))); -}); - -afterEach(() => { - vi.unstubAllGlobals(); -}); - -describe('the Han sweep is a live instrument', () => { - it('matches Han script', () => { - expect(HAN.test(HAN_SAMPLE)).toBe(true); - }); - - it('does not match the English the packs carry for the crumb', () => { - expect(HAN.test('Studio')).toBe(false); - }); -}); - -describe('Studio landing header (objectui#11863, objectui#10043)', () => { - it("draws the console header's fixed Studio crumb, asked of the catalogue", async () => { - renderStudioLanding(); - - expect(await screen.findByText(`«${CRUMB_KEY}»`)).toBeInTheDocument(); - // The front door itself rendered under it. - expect(await screen.findByTestId('studio-front-door')).toBeInTheDocument(); - }); - - it('asks nothing of the retired wordmark tooltip key, in text or in any attribute', async () => { - renderStudioLanding(); - await screen.findByText(`«${CRUMB_KEY}»`); - - expect(document.body.textContent ?? '').not.toContain(RETIRED_KEY); - const values = attributeValues(); - // CONTROL: the sweep reads attributes at all. - expect(values.length).toBeGreaterThan(0); - expect(values.filter((v) => v.includes(RETIRED_KEY))).toEqual([]); - }); - - it('links the brand to the declared landing, which is the launcher here', async () => { - renderStudioLanding(); - await screen.findByText(`«${CRUMB_KEY}»`); - - expect(screen.getByTitle('ObjectOS').closest('a')).toHaveAttribute('href', '/home'); - }); - - it('renders no Han script anywhere on the landing, attributes included', async () => { - renderStudioLanding(); - await screen.findByTestId('studio-front-door'); - await screen.findByText(`«${CRUMB_KEY}»`); - - expect(HAN.test(document.body.textContent ?? '')).toBe(false); - - // `textContent` never sees an attribute, and the measured defect WAS an - // attribute — so sweep every one of them separately. - const values = attributeValues(); - expect(values.length).toBeGreaterThan(0); - expect(values.filter((v) => HAN.test(v))).toEqual([]); - }); -}); diff --git a/ui/apps/console/src/components/StudioRoute.lazyBuilder-11798.test.tsx b/ui/apps/console/src/components/StudioRoute.lazyBuilder-11798.test.tsx index 86db1c1dfd6..50869996f89 100644 --- a/ui/apps/console/src/components/StudioRoute.lazyBuilder-11798.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.lazyBuilder-11798.test.tsx @@ -6,7 +6,8 @@ * * ## What changed, and what this file pins about it * - * `StudioDesignSurface` and `BuilderLanding` used to be static imports of + * `StudioDesignSurface` and the Studio home (removed by objectstack#36908, whose + * entry, `StudioEntryRedirect`, rides in the same chunk) used to be static imports of * `StudioRoute.tsx`, so the builder sat in the eager closure of every console * page. They now arrive through `import('./studioBuilder')` behind `lazy()`. * The bundle half of that (which chunks a page load fetches) is measured on the @@ -79,7 +80,7 @@ vi.mock('../../../../packages/auth/src/useAuth', async (importOriginal) => ({ // count at zero, and reds the holder case. vi.mock('@object-ui/app-shell', async (importOriginal) => ({ ...(await importOriginal>()), - BuilderLanding: () =>
, + StudioEntryRedirect: () =>
, StudioDesignSurface: () =>
, ConnectedShell: ({ children }: { children?: React.ReactNode }) => <>{children}, RequireOrganization: ({ children }: { children?: React.ReactNode }) => <>{children}, @@ -97,7 +98,7 @@ const { builderModuleLoads } = vi.hoisted(() => ({ builderModuleLoads: { count: vi.mock('./studioBuilder', () => { builderModuleLoads.count += 1; return { - BuilderLanding: () =>
pick a package
, + StudioEntryRedirect: () =>
entry
, StudioDesignSurface: () =>
pillars
, }; }); @@ -127,9 +128,9 @@ const answer = (systemPermissions: string[]) => async () => beforeEach(() => { auth = { isAuthenticated: true, isLoading: false, user: { id: 'u1' } }; - // The landing mounts the real `AppHeader` (objectui#11863), which reads its - // user-scoped feeds and the AI agent catalogue on mount; each answers empty - // here, so no request leaves the process. The entry gate's own read goes + // A screen that mounts the real `AppHeader` reads its user-scoped feeds and + // the AI agent catalogue on mount; each answers empty here, so no request + // leaves the process. The entry gate's own read goes // through the mocked `createAuthenticatedFetch`, not this. vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ data: [] }))); }); @@ -176,15 +177,11 @@ describe('/studio/* — the builder module loads behind the gate (objectui#11798 expect(builderModuleLoads.count).toBe(1); }); - it('the front door renders inside its painted frame from the same module', async () => { + it("Studio's entry renders from the same module (objectstack#36908)", async () => { permissionsFetch = answer([STUDIO_ENTRY_CAPABILITY]); renderStudio('/studio'); - await waitFor(() => expect(screen.getByTestId('studio-front-door')).toBeInTheDocument()); - // The console header is the frame the landing's fallback sits under; its - // brand links home (objectui#11863), named 「PRODUCT home」 since - // objectui#12605. - expect(screen.getByRole('link', { name: 'ObjectOS home' })).toHaveAttribute('href', '/home'); + await waitFor(() => expect(screen.getByTestId('studio-entry')).toBeInTheDocument()); // Both `lazy()` declarations name one specifier, so one module serves both. expect(builderModuleLoads.count).toBe(1); }); 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 cdc411daca5..e03f4527ffa 100644 --- a/ui/apps/console/src/components/StudioRoute.metadataArea-28561.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.metadataArea-28561.test.tsx @@ -61,7 +61,7 @@ vi.mock('../../../../packages/auth/src/useAuth', async (importOriginal) => ({ // them only through `./studioBuilder`. vi.mock('@object-ui/app-shell', async (importOriginal) => ({ ...(await importOriginal>()), - BuilderLanding: () =>
, + StudioEntryRedirect: () =>
, StudioDesignSurface: () =>
, StudioMetadataArea: () =>
, ConnectedShell: ({ children }: { children?: React.ReactNode }) => <>{children}, @@ -81,7 +81,7 @@ function SurfaceMarker({ area }: { area?: string }) { } vi.mock('./studioBuilder', () => ({ - BuilderLanding: () =>
, + StudioEntryRedirect: () =>
, StudioDesignSurface: SurfaceMarker, StudioMetadataArea: ({ packageId }: { packageId: string | null }) => (
@@ -146,7 +146,7 @@ describe('/studio — the "All metadata" area\'s routes (objectstack#28561)', () 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. + // No console top bar frames it: the builder's own header is the only one. expect(screen.queryByRole('link', { name: 'ObjectOS home' })).toBeNull(); expect(screen.queryByTestId('studio-metadata-area')).toBeNull(); expect(location()).toBe('/studio/~all/metadata/permission?scope=environment'); 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 e33c7d32c2d..83668fe49aa 100644 --- a/ui/apps/console/src/components/StudioRoute.recentPackage-11863.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.recentPackage-11863.test.tsx @@ -3,7 +3,8 @@ /** * objectui#11863 (Q3) — a visit to a package's pillar builder is recorded as a * recent `package` entry, by IDENTITY and with no label (the objectui#11678 - * shape), so the `/studio` landing can list the packages an author was last in. + * shape), so Studio's entry (bare `/studio`, objectstack#36908) can open the + * package an author was last in. * * ## Why the route, and why this instrument * @@ -74,7 +75,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ })); vi.mock('./studioBuilder', () => ({ - BuilderLanding: () =>
pick a package
, + StudioEntryRedirect: () =>
entry
, StudioDesignSurface: () =>
pillars
, })); @@ -133,9 +134,9 @@ beforeEach(() => { auth = { isAuthenticated: true, isLoading: false, user: { id: 'u1' } }; permissionsFetch = holder; localStorage.clear(); - // The landing mounts the real `AppHeader` (objectui#11863), which reads its - // user-scoped feeds and the AI agent catalogue on mount; each answers empty - // here, so no request leaves the process. The entry gate's own read goes + // A screen that mounts the real `AppHeader` reads its user-scoped feeds and + // the AI agent catalogue on mount; each answers empty here, so no request + // leaves the process. The entry gate's own read goes // through the mocked `createAuthenticatedFetch`, not this. vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ data: [] }))); }); @@ -187,13 +188,13 @@ describe('/studio/PKG/TAB records the package as a recent entry (objectui#11863) expect(recent()).toEqual(JSON.parse(before ?? '[]')); }); - it('the package-less scope is not a package, and the landing is not a visit: neither records anything', async () => { + it("the package-less scope is not a package, and Studio's entry is not a visit: neither records anything", async () => { renderStudio('/studio/~org/automations'); await screen.findByTestId('studio-pillar-builder'); cleanup(); renderStudio('/studio'); - await screen.findByTestId('studio-front-door'); + await screen.findByTestId('studio-entry'); expect(recent()).toEqual([]); expect(persisted()).toBeNull(); diff --git a/ui/apps/console/src/components/StudioRoute.searchPalette-11863.test.tsx b/ui/apps/console/src/components/StudioRoute.searchPalette-11863.test.tsx deleted file mode 100644 index 02f3dbce4ec..00000000000 --- a/ui/apps/console/src/components/StudioRoute.searchPalette-11863.test.tsx +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#11863 (Q2) — the `/studio` landing mounts the command palette, in - * its `studio` scope, so the header's search trigger appears there and opens a - * palette that lists the Studio. - * - * Before it, only `ConsoleLayout` (inside an app) mounted a - * `CommandPaletteProvider`, and `AppHeader` draws its "Search ⌘K" trigger only - * under one (objectui#11912), so the landing's `studio` header had no search at - * all and `Ctrl+K` opened nothing. Pinned through the REAL `studioRoutes` tree, - * the real `AppHeader`, `CommandPaletteProvider` and `CommandPalette`, and the - * real `fetchPackages` over a stubbed `fetch`: - * - * - the header draws both triggers (desktop and compact) on `/studio`; - * - the desktop trigger and `Ctrl+K` each open the palette (`?palette=1`); - * - the palette lists the Studio's packages, and picking one opens its pillar - * builder through the real route tree. - * - * `t` answers in keys, as in `StudioRoute.landingI18n.test.tsx`, so a heading - * is read off the key it asks for. - */ - -import '@testing-library/jest-dom/vitest'; -import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; -import { render, screen, fireEvent } from '@testing-library/react'; -import React from 'react'; -import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom'; - -/** Auth facts. This file only ever drives the holder path. */ -const auth = { isAuthenticated: true, isLoading: false, user: { id: 'u1' } as unknown }; - -function jsonResponse(body: unknown, status = 200): Response { - return { - ok: status >= 200 && status < 300, - status, - headers: { get: () => null }, - json: async () => body, - } as unknown as Response; -} - -vi.mock('@object-ui/auth', async (importOriginal) => ({ - ...(await importOriginal>()), - useAuth: () => auth, - createAuthenticatedFetch: () => async () => - jsonResponse({ - authenticated: true, - userId: 'u1', - systemPermissions: ['studio.access'], - objects: {}, - fields: {}, - }), -})); - -// `AuthGuard` reaches `useAuth` through the auth package's OWN module graph, -// not through its entry point — the same seam `StudioRoute.test.tsx` documents. -vi.mock('../../../../packages/auth/src/useAuth', async (importOriginal) => ({ - ...(await importOriginal>()), - useAuth: () => auth, -})); - -// The same barrel seam as `StudioRoute.landingI18n.test.tsx`: `chrome/` is -// pulled whole, so `CommandPalette` is the real one. -vi.mock('@object-ui/app-shell', async (importOriginal) => ({ - ...(await importOriginal>()), - ...(await vi.importActual>( - '../../../../packages/app-shell/src/chrome/index' - )), - ConnectedShell: ({ children }: { children?: React.ReactNode }) => <>{children}, - RequireOrganization: ({ children }: { children?: React.ReactNode }) => <>{children}, - LoadingFallback: () =>
, - LoadingScreen: () =>
, - getProductName: () => 'ObjectOS', - BuilderLanding: () =>
pick a package
, - StudioDesignSurface: () =>
, -})); - -vi.mock('@object-ui/i18n', async (importOriginal) => ({ - ...(await importOriginal>()), - useObjectTranslation: () => ({ - t: (key: string) => `«${key}»`, - }), -})); - -import { studioRoutes } from './StudioRoute'; - -const DESKTOP = 'action:command-palette:open'; -const MOBILE = 'action:command-palette:open-mobile'; -const OVERLAY = 'overlay:command-palette'; - -function LocationProbe() { - const location = useLocation(); - return
; -} - -function renderStudio(at = '/studio') { - return render( - - - {studioRoutes} - home
} /> - login
} /> - - - , - ); -} - -function locationNow(): string { - return screen.getByTestId('location').getAttribute('data-path') ?? ''; -} - -beforeEach(() => { - vi.clearAllMocks(); - // The package list answers two packages; every other read (the header's - // feeds, the AI agent catalogue) answers empty, so no request leaves the - // process. - vi.stubGlobal( - 'fetch', - vi.fn(async (url: string) => - String(url).endsWith('/api/v1/packages') - ? jsonResponse({ - data: [ - { manifest: { id: 'com.acme.crm', name: 'Acme CRM' }, writable: true }, - { manifest: { id: 'com.acme.hr', name: 'People' }, writable: true }, - ], - }) - : jsonResponse({ data: [] }), - ), - ); -}); - -afterEach(() => { - vi.unstubAllGlobals(); -}); - -describe('the /studio landing mounts the command palette (objectui#11863, Q2)', () => { - it('draws the header search trigger, desktop and compact', async () => { - renderStudio(); - await screen.findByTestId('studio-front-door'); - - expect(screen.getByTestId(DESKTOP)).toBeInTheDocument(); - expect(screen.getByTestId(MOBILE)).toBeInTheDocument(); - // Closed until asked. - expect(screen.queryByTestId(OVERLAY)).not.toBeInTheDocument(); - }); - - it('opens the palette from the trigger, and it lists the Studio packages', async () => { - renderStudio(); - await screen.findByTestId('studio-front-door'); - - fireEvent.click(screen.getByTestId(DESKTOP)); - expect(await screen.findByTestId(OVERLAY)).toBeInTheDocument(); - expect(locationNow()).toBe('/studio?palette=1'); - - expect(await screen.findByText('«console.commandPalette.packages»')).toBeInTheDocument(); - expect(screen.getByText('Acme CRM')).toBeInTheDocument(); - expect(screen.getByText('People')).toBeInTheDocument(); - }); - - it('opens the palette on Ctrl+K', async () => { - renderStudio(); - await screen.findByTestId('studio-front-door'); - - fireEvent.keyDown(document, { key: 'k', ctrlKey: true }); - expect(await screen.findByTestId(OVERLAY)).toBeInTheDocument(); - expect(locationNow()).toBe('/studio?palette=1'); - }); - - it("picking a package opens that package's pillar builder", async () => { - renderStudio('/studio?palette=1'); - fireEvent.click(await screen.findByText('People')); - - expect(await screen.findByTestId('studio-pillar-builder')).toBeInTheDocument(); - expect(locationNow()).toBe('/studio/com.acme.hr/data'); - }); -}); diff --git a/ui/apps/console/src/components/StudioRoute.test.tsx b/ui/apps/console/src/components/StudioRoute.test.tsx index 6ae055d22eb..e126822136b 100644 --- a/ui/apps/console/src/components/StudioRoute.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.test.tsx @@ -100,7 +100,7 @@ vi.mock('../../../../packages/auth/src/useAuth', async (importOriginal) => ({ * metadata backend; what this file measures is whether the router ever reaches * them at all. */ -const builderLanding = vi.fn(); +const studioEntry = vi.fn(); const designSurface = vi.fn(); // `@object-ui/app-shell` is aliased to `packages/app-shell/src` @@ -126,9 +126,11 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
), getProductName: () => 'ObjectOS', - BuilderLanding: () => { - builderLanding(); - return
pick a package
; + // objectstack#36908 — bare `/studio` is Studio's entry, which draws no page: + // the stub records the capability set the gate hands it. + StudioEntryRedirect: ({ systemPermissions }: { systemPermissions?: string[] }) => { + studioEntry(systemPermissions); + return
entry
; }, StudioDesignSurface: () => { designSurface(); @@ -234,10 +236,10 @@ function answerWith(systemPermissions: unknown) { beforeEach(() => { auth = { isAuthenticated: true, isLoading: false, user: { id: 'u1' } }; fetchCalls = []; - builderLanding.mockClear(); + studioEntry.mockClear(); designSurface.mockClear(); answerWith(TENANT_OWNER_CAPS); - // The landing mounts the real `AppHeader` (objectui#11863), which reads its + // A screen that mounts the real `AppHeader` reads its // user-scoped feeds and the AI agent catalogue on mount; each answers empty // here, so no request leaves the process. The entry gate's own read goes // through the mocked `createAuthenticatedFetch`, not this. @@ -291,9 +293,9 @@ describe('/studio/* — the entry decision, both ways', () => { await expectRefusedAt('/studio/', '/home'); // The load-bearing half: not "a notice was drawn" but "the builder was // never mounted", so nothing inside it could render or fetch. - expect(builderLanding).not.toHaveBeenCalled(); + expect(studioEntry).not.toHaveBeenCalled(); expect(designSurface).not.toHaveBeenCalled(); - expect(screen.queryByTestId('studio-front-door')).not.toBeInTheDocument(); + expect(screen.queryByTestId('studio-entry')).not.toBeInTheDocument(); expect(screen.queryByTestId('studio-pillar-builder')).not.toBeInTheDocument(); expect(screen.queryByTestId('home-launcher')).not.toBeInTheDocument(); }); @@ -349,13 +351,14 @@ describe('/studio/* — the entry decision, both ways', () => { expect(designSurface).not.toHaveBeenCalled(); }); - it('NEGATIVE CONTROL: a holder still gets the front door, unchanged', async () => { + it("NEGATIVE CONTROL: a holder still gets Studio's entry, handed the set the gate read", async () => { // A gate that refused everyone would pass every assertion above. answerWith(OPERATOR_CAPS); renderStudioDeepLink('/studio/'); - await waitFor(() => expect(screen.getByTestId('studio-front-door')).toBeInTheDocument()); - expect(builderLanding).toHaveBeenCalled(); + await waitFor(() => expect(screen.getByTestId('studio-entry')).toBeInTheDocument()); + // objectstack#36908 — the entry chooses the package list by these. + expect(studioEntry).toHaveBeenCalledWith(OPERATOR_CAPS); expect(pathname()).toBe('/studio/'); // ...and is never shown the refusal (objectui#12035). expect(screen.queryByText(NOTICE)).not.toBeInTheDocument(); @@ -372,21 +375,6 @@ describe('/studio/* — the entry decision, both ways', () => { expect(screen.queryByText(NOTICE)).not.toBeInTheDocument(); }); - it("the front door's header brand walks back to the same home the gate's refusal names", async () => { - // Two affordances one route apart — this brand (the `studio` variant of - // `AppHeader` since objectui#11863, the wordmark before it) and the pillar - // builder's header Home button — must not name two different homes; that - // asymmetry is the defect objectui#7256 measured and objectui#7373 finished - // removing. - answerWith(OPERATOR_CAPS); - renderStudioDeepLink('/studio/', CONTROL_PLANE_APPS); - - await waitFor(() => expect(screen.getByTestId('studio-front-door')).toBeInTheDocument()); - // The mark is named 「PRODUCT home」 since objectui#12605 (the ruled - // accessible name: product name + home); its target is unchanged. - expect(screen.getByRole('link', { name: 'ObjectOS home' })).toHaveAttribute('href', '/home'); - }); - it('the package-less scope\'s bare leg lands on its one pillar, the builder mounted (objectui#11553)', async () => { // `~org` is the reserved segment for the organization's own, package-less // flows. Without its own leg it falls to `:packageId`, whose redirect 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 6c5611a7543..f6c7c7c112f 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,8 +6,9 @@ * `/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 menu and no package actions, and a way back - * to the Studio landing. And `/studio//` for a segment no pillar + * "package not found", with no menu and no package actions, and a way out + * to Setup → Packages, the package list (objectstack#36908: the Studio home + * it used to walk back to was removed). 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 left menu (objectstack#36899, which replaced * the pillars above it) still beside it, nothing in it current. (The @@ -26,7 +27,7 @@ import '@objectstack/lint'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react'; import * as React from 'react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; const PACKAGE_ID = 'app.r34d'; const KERNEL_ID = 'com.objectstack.platform'; @@ -99,11 +100,17 @@ function servePackages(opts: { fail?: boolean } = {}) { return fetchMock; } +/** Setup → Packages, with the query it was opened with. */ +function SetupPackages() { + const { search } = useLocation(); + return
{search}
; +} + function renderAt(path: string, surface: React.ReactElement = ) { render( - } /> + } /> , @@ -164,12 +171,12 @@ describe('Studio: a package id no package has renders "package not found" (objec expect(packageListReads(fetchMock)).toBe(1); }); - it('its one action walks back to the Studio landing', async () => { + it('its one action opens Setup → Packages, on its administration face', async () => { servePackages(); renderAt(`/studio/${PHANTOM}/data`); const notFound = await screen.findByTestId('studio-package-not-found'); - within(notFound).getByRole('button', { name: t('engine.studio.landingHome', 'en') }).click(); - expect(await screen.findByTestId('studio-landing')).toBeInTheDocument(); + within(notFound).getByRole('button', { name: t('engine.studio.notFound.packageList', 'en') }).click(); + expect(await screen.findByTestId('setup-packages')).toHaveTextContent('?face=admin'); }); it('CONTROL — a listed package renders its builder', async () => { diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx index a167f8dcf0e..1628279bdf7 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx @@ -28,7 +28,7 @@ import * as React from 'react'; import { Navigate, useSearchParams } from 'react-router-dom'; -import { useRecentItems } from '../../context/RecentItemsProvider.js'; +import { useRecentItems, type RecentNamedItem } from '../../context/RecentItemsProvider.js'; import { SETUP_NEW_PACKAGE_PATH, SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaPath } from './metadataArea.js'; import { fetchListedPackageIds } from './packages-io.js'; @@ -67,7 +67,9 @@ export function StudioEntryRedirect({ const [searchParams] = useSearchParams(); const { recentItems } = useRecentItems(); // Newest first, as the store keeps them; a package once, at its newest. - const remembered = recentItems.filter((item) => item.type === 'package').map((item) => item.name); + const remembered = recentItems + .filter((item): item is RecentNamedItem => item.type === 'package') + .map((item) => item.name); const rememberedKey = remembered.join('\n'); const [target, setTarget] = React.useState(null); const fallback = studioEntryFallbackPath(systemPermissions); From 8bcd30d3390f27f42c9a12b174a03d1decd0cf6f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 19:29:24 +0000 Subject: [PATCH 03/21] test(studio): drop the home's new-package deep-link pin Setup > Packages' admin face now owns that deep link, pinned in the PackagesPage administration-face harness. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- ...rLanding.newPackageDeepLink-26614.test.tsx | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.newPackageDeepLink-26614.test.tsx diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.newPackageDeepLink-26614.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.newPackageDeepLink-26614.test.tsx deleted file mode 100644 index 71833855f3d..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.newPackageDeepLink-26614.test.tsx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#26614 — `/studio?new=package` lands on the Studio landing with - * its create-package dialog open. - * - * Home's "New in Studio" chip and the `/ai` no-assistant screen link there - * (`STUDIO_NEW_PACKAGE_PATH`) on a deployment with no AI agent, where Studio is - * the way to build. What these cases pin, on the real `BuilderLanding` under a - * real router: the dialog opens on arrival, the param is dropped from the - * address with a replace (so a refresh does not reopen it), and the bare - * landing still opens with the dialog closed. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, render, screen, waitFor } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => []), - // The landing reads the list's ids beside its entries (the same request, - // objectstack#32615): both are answered by this double, never the network. - fetchListedPackageIds: vi.fn(async () => new Set()), - }; -}); - -// The dialog's form stack is not under test: the stand-in reports whether the -// landing asked for it open. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ - PackageFormDialog: ({ open, mode }: { open: boolean; mode: string }) => ( -
- ), -})); - -// The package-less flow count the landing draws (objectstack#34715) is not under -// test here: no flow belongs to no package, and no request leaves the file. -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, loadPackageLessSurfaces: vi.fn(async () => []) }; -}); - -import { BuilderLanding } from './BuilderLanding'; -import { STUDIO_NEW_PACKAGE_PATH } from './studioNewPackage'; - -afterEach(() => { - cleanup(); -}); - -function LocationProbe() { - const { pathname, search } = useLocation(); - return
{`${pathname}${search}`}
; -} - -function renderLandingAt(entry: string) { - return render( - - - - } /> - - , - ); -} - -describe('the new-package deep link (objectstack#26614)', () => { - it('opens the create-package dialog on arrival and drops the param from the address', async () => { - renderLandingAt(STUDIO_NEW_PACKAGE_PATH); - const dialog = screen.getByTestId('package-form-dialog'); - await waitFor(() => expect(dialog).toHaveAttribute('data-open', 'true')); - expect(dialog).toHaveAttribute('data-mode', 'create'); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent(/^\/studio$/)); - }); - - it('keeps any other param the address carries', async () => { - renderLandingAt(`${STUDIO_NEW_PACKAGE_PATH}&q=crm`); - await waitFor(() => - expect(screen.getByTestId('package-form-dialog')).toHaveAttribute('data-open', 'true'), - ); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent(/^\/studio\?q=crm$/)); - }); - - it('CONTROL — the bare landing opens with the dialog closed', async () => { - renderLandingAt('/studio'); - // Let the landing's package read settle before reading the dialog. - await screen.findByText(/./, { selector: 'h1' }); - expect(screen.getByTestId('package-form-dialog')).toHaveAttribute('data-open', 'false'); - expect(screen.getByTestId('location')).toHaveTextContent(/^\/studio$/); - }); - - it('an unknown value opens nothing', async () => { - renderLandingAt('/studio?new=flow'); - await screen.findByText(/./, { selector: 'h1' }); - expect(screen.getByTestId('package-form-dialog')).toHaveAttribute('data-open', 'false'); - }); -}); From 3198cff74c386834800fc07bcf643aa65cf544d8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 23:10:46 +0000 Subject: [PATCH 04/21] feat(studio): remove the Studio home; show customizations in Setup > Packages BuilderLanding, its tests and its dead engine.studio.landing.* strings are deleted. A read-only base's detail on Setup > Packages' admin face now draws what this deployment changed on it (the home's per-app line and Customizations panel), counting tab arrangements as customizations, with a Customize in Studio link. Stale references are re-pointed. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- .../areas/studio-authoring.json | 35 +- ...age-restart-acceptance.integration.test.ts | 6 +- .../src/apps/setup-packages-door.test.ts | 9 +- .../platform-objects/src/apps/studio.app.ts | 10 +- .../App.agentChatLink-10640.test.tsx | 2 +- .../src/__tests__/App.docsPortalLazy.test.tsx | 2 +- .../App.homePermissions-12700.test.tsx | 4 +- .../App.nativeShellMode-29039.test.tsx | 2 +- .../App.nativeShellOpenSet-29330.test.tsx | 2 +- .../App.uploadAltitude-10131.test.tsx | 2 +- .../__tests__/i18nAfterSignIn-12034.test.tsx | 2 +- .../src/__tests__/internalFormShell.test.tsx | 2 +- .../FormPage.routePermissions-29187.test.tsx | 2 +- .../src/components/StudioRoute.test.tsx | 2 +- ui/packages/app-shell/src/index.ts | 3 - ...rectoryPage.stateVocabulary-29705.test.tsx | 12 +- .../metadata-admin/PackageFormDialog.tsx | 2 +- .../PackagesPage.confirmFlows-11784.test.tsx | 4 +- ...esPage.installedAppsUpdates-34722.test.tsx | 56 ++ .../src/views/metadata-admin/PackagesPage.tsx | 30 +- .../views/metadata-admin/package-schema.ts | 2 +- ...lderLanding.accessibleNames-12510.test.tsx | 112 --- ...Landing.customizationCounts-28566.test.tsx | 486 ---------- ...uilderLanding.customizeCopy-29489.test.tsx | 118 --- ...lderLanding.duplicateIdRule-11855.test.tsx | 153 ---- ...erLanding.envCustomizations-34714.test.tsx | 386 -------- ...nding.environmentOverlayCopy-12171.test.ts | 150 ---- .../BuilderLanding.newAppDoor-36748.test.tsx | 249 ------ .../BuilderLanding.orgScope-11553.test.tsx | 136 --- ...BuilderLanding.packagesDoor-35196.test.tsx | 150 ---- ...ilderLanding.readonlyRoutes-11808.test.tsx | 160 ---- ...ilderLanding.recentPackages-11863.test.tsx | 399 --------- .../BuilderLanding.setupExit-12513.test.tsx | 93 -- .../BuilderLanding.taskOrder-34715.test.tsx | 221 ----- .../views/studio-design/BuilderLanding.tsx | 846 ------------------ .../LandingCustomizationsPanel.tsx | 281 ------ .../PackageCustomizationsPanel.test.tsx | 287 ++++++ .../PackageCustomizationsPanel.tsx | 283 ++++++ .../views/studio-design/PackageSwitcher.tsx | 124 +-- ...tudioDesignSurface.homeLoop-12513.test.tsx | 2 +- ...oDesignSurface.metadataArea-28561.test.tsx | 2 +- ...tudioDesignSurface.pillarNavGuard.test.tsx | 2 +- .../fetchInstalledPackageRow-7881.test.ts | 151 ---- .../noRetiredSetupLink-28578.test.ts | 2 +- .../noSetupMetadataLink-28578.test.ts | 2 +- ...ions-io.ts => packageCustomizationRows.ts} | 109 ++- .../packages-io.envelopeUserMessage.test.ts | 3 +- .../src/views/studio-design/packages-io.ts | 13 +- .../makerEmptyState-v1-scope-8329.test.ts | 3 +- ui/packages/i18n/src/locales/en.ts | 3 +- ui/packages/i18n/src/namespaces/studio/en.ts | 129 +-- ui/packages/i18n/src/namespaces/studio/zh.ts | 113 +-- 52 files changed, 868 insertions(+), 4491 deletions(-) delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizeCopy-29489.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.duplicateIdRule-11855.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.environmentOverlayCopy-12171.test.ts delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.newAppDoor-36748.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.orgScope-11553.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.packagesDoor-35196.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.readonlyRoutes-11808.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.setupExit-12513.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.taskOrder-34715.test.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx create mode 100644 ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx create mode 100644 ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx delete mode 100644 ui/packages/app-shell/src/views/studio-design/fetchInstalledPackageRow-7881.test.ts rename ui/packages/app-shell/src/views/studio-design/{landingCustomizations-io.ts => packageCustomizationRows.ts} (61%) diff --git a/docs/qa/platform-checklist/areas/studio-authoring.json b/docs/qa/platform-checklist/areas/studio-authoring.json index 465b188153f..cb3c7fe525f 100644 --- a/docs/qa/platform-checklist/areas/studio-authoring.json +++ b/docs/qa/platform-checklist/areas/studio-authoring.json @@ -2720,7 +2720,7 @@ "title": "Flows outside any package have their own Studio scope: /studio/~org offers only the Automations pillar, lists only package-less flows, opens them editable, saves drafts bound to no package and publishes each by reference", "since": "v18", "status": "active", - "revision": 4, + "revision": 5, "priority": "P2", "surface": "mixed", "personas": [ @@ -2734,7 +2734,7 @@ ] }, "steps": [ - "with no package-less flow yet, open /_console/studio: the landing draws no 'Flows in no app' entry (it is drawn only when there is at least one such flow, with the count); open /_console/studio/~org/automations directly: it offers one pillar only, no Create app, and an empty state that names the way to change a packaged flow ('No flows outside a package. To change a packaged flow, open its package and use New similar.', engine.studio.org.none) with no action and no link out of Studio (StudioDesignSurface.tsx, the auto-empty state: since ADR-0146 D11 no Setup page copies into this scope)", + "with no package-less flow yet, open /_console/studio/~org/automations directly (the Studio left menu carries its entry under Automations since #36899; the Studio home that drew a 'Flows in no app' card was removed by #36908): it offers one pillar only, no Create app, and an empty state that names the way to change a packaged flow ('No flows outside a package. To change a packaged flow, open its package and use New similar.', engine.studio.org.none) with no action and no link out of Studio (StudioDesignSurface.tsx, the auto-empty state: since ADR-0146 D11 no Setup page copies into this scope)", "write the package-less flow (fixtures.requires[1]); reload: the rail lists qa_org_raw and none of the showcase's packaged flows; GET /api/v1/meta/flow?package=com.example.showcase omits it, the unscoped list includes it", "open it: the canvas and the Enabled switch are editable; change a node label; let the autosave land; read GET /api/v1/meta/_drafts?type=flow — the draft row carries no package", "Publish → the review sheet lists only package-less flow drafts → Publish all; capture the network trace", @@ -2770,7 +2770,7 @@ ], "automated": { "kind": "unit", - "ref": "ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageLessFlows-11553.test.tsx (lists the clone only, opens it editable, one pillar, publishes by reference and nothing through the batch door) + BuilderLanding.orgScope-11553.test.tsx: jsdom evidence for all three clauses at the component layer; the live server reads stay the run's" + "ref": "ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.packageLessFlows-11553.test.tsx (lists the clone only, opens it editable, one pillar, publishes by reference and nothing through the batch door): jsdom evidence for all three clauses at the component layer; the live server reads stay the run's" }, "source": [ "ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx (readOnly is false for the package-less scope, objectui#11553; doPublish promotes package-less flow drafts one by one through publishDraft)", @@ -2792,7 +2792,8 @@ "ref": "#28345" }, { "revision": 3, "date": "2026-11-03", "change": "fixtures.requires[1] names a fixture that still makes a package-less flow, and steps[0], steps[1], steps[4], acceptance[0].verify and source[1] follow it. Since #28149 (ADR-0146 D4) the clone door lands its copy in the source's pair .custom, so QA run #29672's clone of showcase_urgent_task_alert answered packageId com.example.showcase.custom and made no package-less flow; the run substituted PUT /api/v1/meta/flow/qa_org_raw naming no package (200) and passed every clause on it. Read at base 339f63da30: ADR-0146 D11 closes a package-less write only onto an item a code package ships (packagelessOverlayWriteRefusal), so a fresh name stays writable, and a PUT with no ?mode= is an active save (meta-save-request.ts). The same run found steps[0]'s empty state stale: it now reads engine.studio.org.none with no Open in Setup link (StudioDesignSurface.tsx). The clauses are unchanged. Card #29679, from QA run #29672", "ref": "#29679" }, - { "revision": 4, "date": "2026-11-17", "change": "steps[0] no longer opens a landing entry when there is no package-less flow: since #34715 the Studio landing draws its 'Flows in no app' entry (formerly 'Organization flows') only when at least one such flow exists, with the count, so the step reads the entry's absence and opens the scope by its URL. The clauses are unchanged. Card #34715", "ref": "#34715" } + { "revision": 4, "date": "2026-11-17", "change": "steps[0] no longer opens a landing entry when there is no package-less flow: since #34715 the Studio landing draws its 'Flows in no app' entry (formerly 'Organization flows') only when at least one such flow exists, with the count, so the step reads the entry's absence and opens the scope by its URL. The clauses are unchanged. Card #34715", "ref": "#34715" }, + { "revision": 5, "date": "2026-11-24", "change": "steps[0] opens the scope by its URL alone and names its menu entry: the Studio home, whose 'Flows in no app' card it read, was removed (#36908), and the left menu carries the entry since #36899. automated.ref drops the deleted home pin. The clauses are unchanged. Card #36908", "ref": "#36908" } ] }, { @@ -5096,10 +5097,10 @@ }, { "id": "studio-authoring.package-customization-counts-and-marks", - "title": "The Studio landing says 'n customized, m switched off' for each read-only base, and the All metadata lists mark the pair's items 'Customized' or 'Added' with an 'only customizations' filter — every number read from GET /packages/:id/customizations", + "title": "Setup → Packages says 'n customized, m switched off' in each read-only base's detail, and the All metadata lists mark the pair's items 'Customized' or 'Added' with an 'only customizations' filter — every number read from GET /packages/:id/customizations", "since": "v18", "status": "active", - "revision": 3, + "revision": 4, "priority": "P2", "surface": "mixed", "personas": [ @@ -5118,17 +5119,17 @@ }, "steps": [ "GET /api/v1/packages/com.example.showcase/customizations and record counts.overrides, counts.extensions and counts.switchedOff and the listed items", - "open /_console/studio and read the read-only showcase card's line (data-testid studio-landing-customizations, data-state read), its pair link (studio-landing-customizations-pair) and its switched-off link (studio-landing-customizations-switched-off)", + "open /_console/apps/setup/component/developer/packages?face=admin, open the showcase row's detail and read its customizations section (data-testid pkg-detail-customizations-summary, data-state read), its rows (pkg-detail-customization, data-mode changed / added / arranged / switchedOff) and its Customize in Studio link (pkg-detail-customize)", "open /_console/studio/com.example.showcase/metadata: read the directory total (directory-customizations-total) and the per-type tile counts", "open the dashboard list of that area: read the mark on the overridden dashboard and on the pair's added item (customization-mark), then switch on the 'only customizations' filter (metadata-only-customizations) and read what remains", - "control: open the landing and a writable package's All metadata area with the network panel recording — the landing asks for no writable card, and the area's read of the writable package draws no line, no mark and no filter; and GET /api/v1/packages/com.example.showcase.custom/customizations" + "control: open an authored (writable) package's detail on the same page and a writable package's All metadata area with the network panel recording — the detail draws no customizations section and asks nothing, and the area's read of the writable package draws no line, no mark and no filter; and GET /api/v1/packages/com.example.showcase.custom/customizations" ], "acceptance": [ { - "clause": "the landing line reads 'n customized, m switched off' where n = counts.overrides + counts.extensions and m = counts.switchedOff of the served read — no number of the console's own", + "clause": "the detail's line reads 'n customized, m switched off' where n = counts.overrides + counts.extensions + counts.arrangements (#36833: an arrangement is a customization) and m = counts.switchedOff of the served read — no number of the console's own", "oracle": "dom", "verify": "after a screenshot confirms the card rendered, the line's numbers equal step 1's served counts (fetchPackageCustomizations computes none); the pair link's href names com.example.showcase.custom, and following it lands on the base's Studio (/_console/studio/com.example.showcase/data: Studio redirects a pair URL to its base, customizationPairBaseOf, ADR-0146 D3), whatever its title 'Open the customization package … in Studio' says; the switched-off link opens the Automations pillar", - "evidence": "the served read + the landing DOM read" + "evidence": "the served read + the detail DOM read" }, { "clause": "the All metadata area marks the pair's items — an override 'Customized', an item the pair adds 'Added' — and the 'only customizations' filter leaves exactly those; the directory's total and tiles match the served read", @@ -5137,9 +5138,9 @@ "evidence": "the directory and list DOM reads beside step 1" }, { - "clause": "a failed read draws no number and no mark — never a '0' — the landing asks for read-only bases only, a package with nothing customized draws nothing, and a pair id is never asked", + "clause": "a failed read draws no number and no mark — never a '0' — the detail asks for read-only bases only, a package with nothing customized draws nothing, and a pair id is never asked", "oracle": "network", - "verify": "step 5: the landing sends no customizations request for a writable card; the All metadata area of a writable package reads its customizations (usePackageCustomizations asks every package but a pair; metadataAreaHost.customizations-28568 pins that read for a package with no pair) and, the counts being zero, draws no total, no mark and no filter; the pair id answers 400 VALIDATION_ERROR naming its base (the console refuses it before sending). A failed read shows the muted couldn't-read line with the server's sentence, never a count — not staged live: BuilderLanding.customizationCounts-28566 and metadataAreaHost.customizations-28568 pin it", + "verify": "step 5: the detail sends no customizations request for a writable package; the All metadata area of a writable package reads its customizations (usePackageCustomizations asks every package but a pair; metadataAreaHost.customizations-28568 pins that read for a package with no pair) and, the counts being zero, draws no total, no mark and no filter; the pair id answers 400 VALIDATION_ERROR naming its base (the console refuses it before sending). A failed read shows the muted couldn't-read line with the server's sentence, never a count — not staged live: BuilderLanding.customizationCounts-28566 and metadataAreaHost.customizations-28568 pin it", "evidence": "the network trace + the pair-id refusal body" } ], @@ -5153,10 +5154,10 @@ ], "automated": { "kind": "unit", - "ref": "ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx + customizationMarks.test.ts + ui/packages/app-shell/src/views/metadata-admin/metadataAreaHost.customizations-28568.test.tsx (jsdom against a mocked read: acceptance[0]–[2]'s console half) + packages/runtime/src/domains/packages-customizations.test.ts (the route's three lists and counts, and the AGREEMENT that every listed override is the layered read's overlay). No pin reads a live deployment, and the live spec of #28579 slice 3 (ui/e2e/live/studio-customize-journey.spec.ts) does not read the counts or the marks, so every browser and api clause is the run's live leg" + "ref": "ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx + customizationMarks.test.ts + ui/packages/app-shell/src/views/metadata-admin/metadataAreaHost.customizations-28568.test.tsx (jsdom against a mocked read: acceptance[0]–[2]'s console half) + packages/runtime/src/domains/packages-customizations.test.ts (the route's three lists and counts, and the AGREEMENT that every listed override is the layered read's overlay). No pin reads a live deployment, and the live spec of #28579 slice 3 (ui/e2e/live/studio-customize-journey.spec.ts) does not read the counts or the marks, so every browser and api clause is the run's live leg" }, "source": [ - "ui/packages/app-shell/src/views/studio-design/packageCustomizations-io.ts#fetchPackageCustomizations (GET /api/v1/packages/:id/customizations, judged by GetPackageCustomizationsResponseSchema; a pair id refused before a request) + ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx#BuilderLanding (the card's line)", + "ui/packages/app-shell/src/views/studio-design/packageCustomizations-io.ts#fetchPackageCustomizations (GET /api/v1/packages/:id/customizations, judged by GetPackageCustomizationsResponseSchema; a pair id refused before a request) + ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx#PackageCustomizationsPanel (the detail's line and rows)", "ui/packages/app-shell/src/views/studio-design/customizationMarks.ts#customizationMarkOf + ui/packages/app-shell/src/views/studio-design/CustomizationMark.tsx#CustomizationMark + ui/packages/app-shell/src/views/metadata-admin/ResourceListPage.tsx (the only-customizations filter) + ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.tsx (the total and the tile counts)", "docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md D3 (one line per package on the landing) and D8 item 4 (the per-package customization read)", "#28566 (N-24) landed by PR #28634; #28568 (N-26b) by PR #28667; the read #28411 (N-15)" @@ -5179,6 +5180,12 @@ "date": "2026-11-04", "change": "acceptance[0].verify and fixtures.requires[2] corrected from QA run #29893 (W5-STUDIO, at 589049b0): the pair link's href names the pair, but Studio redirects a pair URL to its base (customizationPairBaseOf), and the pair-added fixture item may be written by API. Read at base f68b47ca", "ref": "#29906" + }, + { + "revision": 4, + "date": "2026-11-24", + "change": "the line moved from the removed Studio home to the read-only base's detail in Setup → Packages (#36908): title, steps[1], steps[4], acceptance[0] and [2], automated.ref and source re-pointed; acceptance[0] now counts counts.arrangements in n (#36833, closed into #36908). The All metadata half is unchanged", + "ref": "#36908" } ] }, diff --git a/packages/cli/test/package-restart-acceptance.integration.test.ts b/packages/cli/test/package-restart-acceptance.integration.test.ts index bf3233c273a..6f3ad223235 100644 --- a/packages/cli/test/package-restart-acceptance.integration.test.ts +++ b/packages/cli/test/package-restart-acceptance.integration.test.ts @@ -17,9 +17,9 @@ * * ## The three probes, and where each one's route comes from * - * 1. Studio writable list — Studio's builder landing (objectui - * `packages/app-shell/src/views/studio-design/BuilderLanding.tsx`, heading - * `engine.studio.landing.ownHeading` = "Your own apps") lists + * 1. Studio writable list — Studio's package readers (objectui + * `packages/app-shell/src/views/studio-design/packages-io.ts`; the Studio + * home that listed them as "Your own apps" was removed by #36908) read * `fetchPackages()` filtered to `writable`. `fetchPackages()` (`studio-design/packages-io.ts`) is ONE * read: `GET /api/v1/packages`, no query parameters; `parsePackages` drops * `scope: system | cloud` rows and takes the row's top-level `writable` diff --git a/packages/platform-objects/src/apps/setup-packages-door.test.ts b/packages/platform-objects/src/apps/setup-packages-door.test.ts index 5e8d7669155..ef0864bb840 100644 --- a/packages/platform-objects/src/apps/setup-packages-door.test.ts +++ b/packages/platform-objects/src/apps/setup-packages-door.test.ts @@ -23,11 +23,10 @@ // // The Studio every boot serves is the console's own, at `/_console/studio`: // the `@objectstack/studio` app this package declares (`studio.app.ts`) is not -// default-loaded (`apps/studio/src/index.ts`). Its served door to the full list -// is the console's, not a nav item: the Studio landing's "All packages" link and -// each package card's Manage, which opens the detail sheet with every action -// (#35196). The console pins that door -// (`ui/packages/app-shell/src/views/studio-design/BuilderLanding.packagesDoor-35196.test.tsx`). +// default-loaded (`apps/studio/src/index.ts`). The console's Studio home, whose +// "All packages" link and per-card Manage were the full list's served door +// (#35196), was removed (#36908); that door moves with #37139, and until then +// the development face is reached by its address. // // This file is the platform-objects half: what THIS package ships for each app. // Every direction is pinned, because each regression is silent at runtime — a diff --git a/packages/platform-objects/src/apps/studio.app.ts b/packages/platform-objects/src/apps/studio.app.ts index 4c842ed5bf2..8d6212813ac 100644 --- a/packages/platform-objects/src/apps/studio.app.ts +++ b/packages/platform-objects/src/apps/studio.app.ts @@ -104,12 +104,10 @@ export const STUDIO_APP: App = { icon: 'layout-dashboard', children: [ { - // The application builder's front door (ADR-0080/0084): pick or - // create a writable base package, then design in the full-screen - // pillar builder (/studio/:packageId/:tab). The console binds - // `studio:builder` to the BuilderLanding page — this makes the - // builder reachable from login (Home → Studio → App Builder) - // instead of being a URL-only surface. + // The application builder's entry (ADR-0080/0084). The console + // binds `studio:builder` to Studio's entry, bare `/studio`, which + // opens the package the author was last in, else the package list + // (#36908: the package-card home it used to draw was removed). id: 'nav_app_builder', type: 'component', label: 'App Builder', diff --git a/ui/apps/console/src/__tests__/App.agentChatLink-10640.test.tsx b/ui/apps/console/src/__tests__/App.agentChatLink-10640.test.tsx index 0e5400a1421..f6f5f1f58e1 100644 --- a/ui/apps/console/src/__tests__/App.agentChatLink-10640.test.tsx +++ b/ui/apps/console/src/__tests__/App.agentChatLink-10640.test.tsx @@ -96,7 +96,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => { // the chat drawer on the address); the probe reports what it was routed with. AiAddressRedirect: AiChatPageProbe, StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', }; diff --git a/ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx b/ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx index 70e528a4a1a..38cb3889438 100644 --- a/ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx +++ b/ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx @@ -108,7 +108,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ DefaultAcceptInvitationPage: stub('accept-invitation-page'), AiAddressRedirect: stub('ai-chat-page'), StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', })); diff --git a/ui/apps/console/src/__tests__/App.homePermissions-12700.test.tsx b/ui/apps/console/src/__tests__/App.homePermissions-12700.test.tsx index a95ef69dbbe..0cca64e524b 100644 --- a/ui/apps/console/src/__tests__/App.homePermissions-12700.test.tsx +++ b/ui/apps/console/src/__tests__/App.homePermissions-12700.test.tsx @@ -172,14 +172,14 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ // they render at phone width. usePhoneViewport: () => true, DefaultAppContent: () => , - BuilderLanding: () => , + StudioEntryRedirect: () => , StudioDesignSurface: () => , getProductName: () => 'ObjectOS', getFaviconUrl: () => '', })); // Chrome that decides nothing about visibility, by the module id `HomeLayout` -// and the Studio frame import it through. +// imports it through. vi.mock('../../../../packages/app-shell/src/layout/AppHeader', () => ({ AppHeader: () => null })); vi.mock('../../../../packages/app-shell/src/chrome/CommandPalette', () => ({ CommandPalette: () => null })); vi.mock('../../../../packages/app-shell/src/hooks/useAiSurface', async (importOriginal) => ({ diff --git a/ui/apps/console/src/__tests__/App.nativeShellMode-29039.test.tsx b/ui/apps/console/src/__tests__/App.nativeShellMode-29039.test.tsx index 896d50d3688..8cfba95bbae 100644 --- a/ui/apps/console/src/__tests__/App.nativeShellMode-29039.test.tsx +++ b/ui/apps/console/src/__tests__/App.nativeShellMode-29039.test.tsx @@ -99,7 +99,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ DefaultAcceptInvitationPage: stub('accept-invitation-page'), AiAddressRedirect: stub('ai-chat-page'), StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', })); diff --git a/ui/apps/console/src/__tests__/App.nativeShellOpenSet-29330.test.tsx b/ui/apps/console/src/__tests__/App.nativeShellOpenSet-29330.test.tsx index ddf3fe12a83..4d20319a27a 100644 --- a/ui/apps/console/src/__tests__/App.nativeShellOpenSet-29330.test.tsx +++ b/ui/apps/console/src/__tests__/App.nativeShellOpenSet-29330.test.tsx @@ -74,7 +74,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ DefaultAcceptInvitationPage: stub('accept-invitation-page'), AiAddressRedirect: stub('ai-chat-page'), StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', })); diff --git a/ui/apps/console/src/__tests__/App.uploadAltitude-10131.test.tsx b/ui/apps/console/src/__tests__/App.uploadAltitude-10131.test.tsx index 95c043f6c8e..03def081f10 100644 --- a/ui/apps/console/src/__tests__/App.uploadAltitude-10131.test.tsx +++ b/ui/apps/console/src/__tests__/App.uploadAltitude-10131.test.tsx @@ -158,7 +158,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ DefaultAcceptInvitationPage: stub('accept-invitation-page'), AiAddressRedirect: stub('ai-chat-page'), StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', })); diff --git a/ui/apps/console/src/__tests__/i18nAfterSignIn-12034.test.tsx b/ui/apps/console/src/__tests__/i18nAfterSignIn-12034.test.tsx index 173701c6f31..430c3dfaabf 100644 --- a/ui/apps/console/src/__tests__/i18nAfterSignIn-12034.test.tsx +++ b/ui/apps/console/src/__tests__/i18nAfterSignIn-12034.test.tsx @@ -84,7 +84,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ DefaultAcceptInvitationPage: stub('accept-invitation-page'), AiAddressRedirect: stub('ai-chat-page'), StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', // `ProtectedRoute` stays real; the shell it mounts is cut down to its diff --git a/ui/apps/console/src/__tests__/internalFormShell.test.tsx b/ui/apps/console/src/__tests__/internalFormShell.test.tsx index 267d0c9ad95..564f073e0c6 100644 --- a/ui/apps/console/src/__tests__/internalFormShell.test.tsx +++ b/ui/apps/console/src/__tests__/internalFormShell.test.tsx @@ -83,7 +83,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ DefaultAcceptInvitationPage: stub('accept-invitation-page'), AiAddressRedirect: stub('ai-chat-page'), StudioDesignSurface: stub('studio-design-surface'), - BuilderLanding: stub('builder-landing'), + StudioEntryRedirect: stub('studio-entry'), getProductName: () => 'ObjectOS', getFaviconUrl: () => '', // Consumed by InternalFormRoute to resolve the created-record target. diff --git a/ui/apps/console/src/components/FormPage.routePermissions-29187.test.tsx b/ui/apps/console/src/components/FormPage.routePermissions-29187.test.tsx index 975ccbe4206..ff0a9d0add5 100644 --- a/ui/apps/console/src/components/FormPage.routePermissions-29187.test.tsx +++ b/ui/apps/console/src/components/FormPage.routePermissions-29187.test.tsx @@ -133,7 +133,7 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({ // they render at phone width. usePhoneViewport: () => true, DefaultAppContent: () => null, - BuilderLanding: () => null, + StudioEntryRedirect: () => null, StudioDesignSurface: () => null, getProductName: () => 'ObjectOS', getFaviconUrl: () => '', diff --git a/ui/apps/console/src/components/StudioRoute.test.tsx b/ui/apps/console/src/components/StudioRoute.test.tsx index e126822136b..e8a38297b4c 100644 --- a/ui/apps/console/src/components/StudioRoute.test.tsx +++ b/ui/apps/console/src/components/StudioRoute.test.tsx @@ -22,7 +22,7 @@ * mounted the builder ungated. * * The two builder components are the only stubs, and they are SPIES: the - * assertion for a non-holder is that `BuilderLanding` / `StudioDesignSurface` + * assertion for a non-holder is that `StudioEntryRedirect` / `StudioDesignSurface` * were never CALLED, which is strictly stronger than "their DOM is absent" — * a component that never mounts cannot render an authoring affordance, a * Publish button, or fire the metadata reads behind them. `AuthGuard`, diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index 37e7d17f21b..2a95ad72253 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -594,9 +594,6 @@ export { export { registerStudioCanvasPreview, } from './views/studio-design/studio-canvas-preview.js'; -// The builder's front door: pick/create a writable package → pillar builder. -// Standalone at `/studio` and embedded via the `studio:builder` component ref. -export { BuilderLanding } from './views/studio-design/BuilderLanding.js'; // objectstack#36908 — bare `/studio` draws no page: it opens the package the // author was last in, else the package list. A host that declares the // `/studio` routes mounts it as their index. diff --git a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.stateVocabulary-29705.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.stateVocabulary-29705.test.tsx index 5fc6c96bad4..3f33eb0bbe6 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.stateVocabulary-29705.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/DirectoryPage.stateVocabulary-29705.test.tsx @@ -216,8 +216,8 @@ const VOCABULARY: ReadonlyArray<{ state: string; key: string; en: string; zh: st /** Every other key that draws one of the states, and the word it must carry. */ const SAME_WORD: ReadonlyArray<{ key: string; en: string; zh: string }> = [ { key: 'engine.directory.customizations.tile', en: 'customized', zh: '已定制' }, - { key: 'engine.studio.landing.customizations.customized', en: 'customized', zh: '已定制' }, - { key: 'engine.studio.landing.customizations.switchedOff', en: 'switched off', zh: '已停用' }, + { key: 'engine.packages.customizations.customized', en: 'customized', zh: '已定制' }, + { key: 'engine.packages.customizations.switchedOff', en: 'switched off', zh: '已停用' }, { key: 'engine.directory.hideReadOnly', en: 'read-only', zh: '只读' }, ]; @@ -366,8 +366,7 @@ describe('one word per state, the second pass (objectstack#29729)', () => { 'engine.studio.customize.restoreBody', 'engine.studio.customize.restoreFlowBody', 'engine.edit.resetConfirmBody', - 'engine.studio.landing.description', - 'engine.studio.landing.readonlyHint', + 'engine.packages.customizations.customize', 'engine.studio.area.formEditor.oneLocale', 'engine.studio.area.formEditor.translationWhole', ]; @@ -377,10 +376,9 @@ describe('one word per state, the second pass (objectstack#29729)', () => { expect(ZH[key]).not.toContain('自定义'); }); - it('the Customize button and the landing lines that quote it agree', () => { + it('the Customize button and the Setup package detail’s Customize link agree (objectstack#36908)', () => { expect(ZH['engine.studio.customize.action']).toBe('定制'); - expect(ZH['engine.studio.landing.description']).toContain('「定制」'); - expect(ZH['engine.studio.landing.readonlyHint']).toContain('「定制」'); + expect(ZH['engine.packages.customizations.customize']).toContain('定制'); }); // CONTROL: 自定义 meaning "user-defined" (a custom value, key, renderer, page diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx index 0e1015a2548..3ae725f1c32 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.tsx @@ -4,7 +4,7 @@ * PackageFormDialog — ONE modal for creating, editing, and viewing a package, * rendered from the spec-derived manifest form (`package-schema`) through the * generic {@link SchemaForm}. It replaces the three hand-rolled package forms - * (CreatePackageDialog / EditPackageDialog / the BuilderLanding inline form), + * (CreatePackageDialog / EditPackageDialog / the old Studio home's inline form), * each of which carried its own field list and id-validation regex — a package * created on one surface was rejected by another. * diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.confirmFlows-11784.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.confirmFlows-11784.test.tsx index 869cf774ff3..b899c433f30 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.confirmFlows-11784.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.confirmFlows-11784.test.tsx @@ -429,7 +429,7 @@ describe('Console Packages page — a delete there stays on the page (objectui#1 } /> - } /> + } /> } /> , @@ -448,7 +448,7 @@ describe('Console Packages page — a delete there stays on the page (objectui#1 await waitFor(() => expect(listReads()).toHaveLength(2)); await waitFor(() => expect(screen.queryByRole('button', { name: 'Delete package' })).toBeNull()); expect(screen.getByTestId('path').textContent).toBe(START); - expect(screen.queryByTestId('studio-landing')).toBeNull(); + expect(screen.queryByTestId('studio-entry')).toBeNull(); expect(screen.queryByTestId('elsewhere')).toBeNull(); }); }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx index 112e0d1a86c..088aeb0042f 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx @@ -201,6 +201,24 @@ async function serve({ if (/^\/api\/v1\/packages\/[^/]+$/.test(path) && method === 'DELETE') { return reply(200, { success: true, data: {} }); } + // objectstack#36908 — a read-only base's detail reads what this + // deployment changed on it: one tab arrangement, for every base. + const customized = /^\/api\/v1\/packages\/([^/]+)\/customizations$/.exec(path); + if (customized) { + const arrangements = [{ object: 'acme_task', key: 'relatedLists' }]; + return reply(200, { + success: true, + data: { + packageId: decodeURIComponent(customized[1]), + overrides: [], + extensions: [], + arrangements, + switchedOff: [], + contributions: [], + counts: { overrides: 0, extensions: 0, arrangements: 1, switchedOff: 0, contributions: 0 }, + }, + }); + } if (path === '/api/v1/cloud-connection/installed') return reply(404, {}); if (path === '/api/v1/marketplace/install-local' && method === 'GET') { return reply(200, { success: true, data: { items: installs } }); @@ -771,3 +789,41 @@ describe('Setup → Packages: the new-package deep link (objectstack#36908)', () expect(screen.queryByTestId('stub-create-save')).toBeNull(); }); }); + +// --------------------------------------------------------------------------- +// objectstack#36908 — the removed Studio home's "n customized, m switched off" +// and its "Customizations in this environment" panel are drawn in a read-only +// base's detail on this face (`PackageCustomizationsPanel.test.tsx` pins +// the panel itself). +// --------------------------------------------------------------------------- + +describe('Setup → Packages: a read-only base’s customizations in its detail (objectstack#36908)', () => { + it('a code package’s detail draws what this deployment changed on it, arrangements counted (objectstack#36833)', async () => { + await serve({ packages: [CODE] }); + renderAt(ADMIN_URL); + fireEvent.click(await screen.findByTestId('pkg-row-com.acme.code')); + const sheet = await screen.findByRole('dialog'); + + const section = within(sheet).getByTestId('pkg-detail-customizations'); + await waitFor(() => + expect(within(section).getByTestId('pkg-detail-customizations-summary')).toHaveTextContent('1 customized, 0 switched off'), + ); + expect(within(section).getByTestId('pkg-detail-customize')).toHaveAttribute('href', '/studio/com.acme.code/data'); + }); + + it('an authored package’s detail draws no customizations section: it is changed in place', async () => { + await serve({ packages: [AUTHORED] }); + renderAt(ADMIN_URL); + fireEvent.click(await screen.findByTestId('pkg-row-app.b2r4')); + const sheet = await screen.findByRole('dialog'); + expect(within(sheet).queryByTestId('pkg-detail-customizations')).toBeNull(); + }); + + it('CONTROL: the development surface’s detail draws no customizations section', async () => { + await serve({ packages: [CODE] }); + renderAt(STUDIO_URL); + fireEvent.click(await screen.findByTestId('pkg-row-com.acme.code')); + const sheet = await screen.findByRole('dialog'); + expect(within(sheet).queryByTestId('pkg-detail-customizations')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 82e31ef97b0..8a3b4c994d0 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -123,6 +123,8 @@ import type { InstalledPackageAtEitherStage } from '@objectstack/spec/api-assemb import type { PackagePublishResult } from '@objectstack/spec/system'; import type { ReassignOrphanedMetadataResponse } from '@objectstack/spec/api'; import { studioHomePath } from '../studio-design/studioAddress.js'; +import { PackageCustomizationsPanel } from '../studio-design/PackageCustomizationsPanel.js'; +import { isCustomizationPackage } from '@objectstack/spec/kernel'; import { PACKAGE_SOURCES, PACKAGES_ADMIN_FACE, @@ -615,8 +617,7 @@ function InstalledAppUpdateCell({ rowId, read }: { rowId: string; read: UpdateRe } /** - * A package's Studio address, the one the Studio landing's package card opens - * (`BuilderLanding`'s `open`): the builder on the package's Data pillar. The + * A package's Studio address: the builder on the package's Data pillar. The * administration face's create lands here, and its "Open in Studio" link * points here (objectstack#36834). */ @@ -725,7 +726,8 @@ export function PackageDetailSheet({ * View info, Disable / Enable and Delete, plus "Open in Studio" on an * authored package. Edit, Publish, Revert, Export, Duplicate, Adopt loose * items and the pending changes' Publish / Discard stay on the development - * face, which every other caller (Studio's landing and switcher) opens. + * face. On the administration face a read-only base also draws what this + * deployment changed on it (objectstack#36908). */ face?: PackagesFace; open: boolean; @@ -880,7 +882,7 @@ export function PackageDetailSheet({ // title shows. const displayName = pkg.manifest.name || id; const deleteArmed = deleteMode !== '' && deleteTyped.trim() === displayName.trim(); - // The spec's id rule (`isSpecPackageId`), the one the landing's duplicate form + // The spec's id rule (`isSpecPackageId`), the one the package id input // and the duplicate route judge by, not a second one (objectui#11855). const dupArmed = dupName.trim().length > 0 && isSpecPackageId(dupId.trim()); @@ -1113,7 +1115,7 @@ export function PackageDetailSheet({ }; // ADR-0070 D4 — duplicate this base into a NEW writable package - // (re-namespaced). The Studio landing's inline duplicate form, on this sheet + // (re-namespaced). An inline duplicate form, on this sheet // (objectui#11784): the same id input (`PackageIdInput`), the same id rule // (`isSpecPackageId`) and the same call (`duplicatePackage`, which also refuses // a 200 whose verdict is `success: false`), instead of a `window.prompt`. @@ -1259,6 +1261,20 @@ export function PackageDetailSheet({ )} + {/* objectstack#36908 — what this deployment changed on an installed + app, and the way into Studio to change it: the removed Studio + home's per-app line and "Customizations in this environment" panel, + drawn where an administrator now looks the app up. A read-only + base only: an authored package is changed in place, a `.custom` + pair is read through its base, and a kernel package takes no + customization. */} + {!authoring && !writable && !isKernel && !isCustomizationPackage(id) && ( + <> + + onOpenChange(false)} /> + + )} + {authoring && appBase && ( <> @@ -2436,8 +2452,8 @@ export function PackagesPage() { onOpenChange={setCreateOpen} onCreated={async (id) => { // objectstack#36834 — created from Setup, the empty package is - // designed next: straight into Studio on it, through the address the - // Studio landing's package card opens. The development surface stays + // designed next: straight into Studio on it, on its Data pillar. + // The development surface stays // where it is and shows the new row. if (adminFace) { forgetPackageListReads(); diff --git a/ui/packages/app-shell/src/views/metadata-admin/package-schema.ts b/ui/packages/app-shell/src/views/metadata-admin/package-schema.ts index 37d4976baed..857a411a01e 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/package-schema.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/package-schema.ts @@ -7,7 +7,7 @@ * {@link ./page-schema} / view-schema / report-schema. * * Why: package create / edit / view used to be THREE hand-rolled forms - * (CreatePackageDialog, EditPackageDialog, BuilderLanding's inline form) with + * (CreatePackageDialog, EditPackageDialog, the old Studio home's inline form) with * two DIFFERENT id regexes — a package created via one surface was rejected by * another, and neither matched what the server accepts. Rendering the * spec-derived form through {@link SchemaForm} gives one field definition and diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx deleted file mode 100644 index 5dba179cd4b..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.accessibleNames-12510.test.tsx +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#12510 — every card on the Studio home is named by the label the - * author sees on it (objectui#11862: label first). - * - * The 2026-10-15 test pass read the recent-package links, the writable and - * installed package cards, and the package-less flows card (now "Flows in no - * app", objectstack#34715) as controls with no name. The browser's computed tree names each one from its visible text; - * these cases pin that by querying each card by role and name, so a later - * restyle that hides the text from the tree (an `aria-hidden` on the label, an - * icon-only card) turns them red. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, render, screen, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; - -const packages = vi.hoisted(() => ({ list: [] as Array> })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => packages.list), - // The landing reads the list's ids beside its entries (the same request, - // objectstack#32615): both are answered by this double, never the network. - fetchListedPackageIds: vi.fn(async () => new Set(packages.list.map((p) => String(p.id)))), - }; -}); - -// The create dialog is closed throughout; its own names are pinned beside it. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); -// A read-only base's customization read (ADR-0146 D3) is not under test here: -// it stays pending, so no request leaves the file. -vi.mock('./packageCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - fetchPackageCustomizations: vi.fn(() => new Promise(() => {})), -})); -// One flow belongs to no package, so the landing draws that entry (objectstack#34715). -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, loadPackageLessSurfaces: vi.fn(async () => [{ type: 'flow', name: 'org_flow', label: 'Org flow' }]) }; -}); - -import { BuilderLanding } from './BuilderLanding'; -import { RecentItemsProvider } from '../../context/RecentItemsProvider'; - -/** The key `RecentItemsProvider` hydrates from with no signed-in user. */ -const STORAGE_KEY = 'objectui-recent-items'; - -afterEach(() => { - cleanup(); - localStorage.clear(); - packages.list = []; -}); - -function renderLanding() { - localStorage.setItem( - STORAGE_KEY, - JSON.stringify([ - { - id: 'package:app.objectstack.hotcrm', - type: 'package', - name: 'app.objectstack.hotcrm', - href: '/studio/app.objectstack.hotcrm', - visitedAt: '2026-10-15T09:00:00.000Z', - }, - ]), - ); - return render( - - - - } /> - - - , - ); -} - -describe('Studio home cards carry their visible label as their name (objectui#12510)', () => { - it('names the recent link, the package cards and the organization card by their labels', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'app.objectstack.hotcrm', name: 'HotCRM', writable: false, namespace: 'crm' }, - ]; - renderLanding(); - - const recent = await screen.findByTestId('studio-landing-recent'); - expect(within(recent).getByRole('link', { name: /HotCRM/ })).toHaveAttribute('href', '/studio/app.objectstack.hotcrm'); - - // The writable card: named by its label (its id is only its hover title, objectstack#35018). - expect(screen.getByRole('button', { name: /^Acme CRM\b/ })).toBeInTheDocument(); - // The installed (read-only) card: its label, and its Customize button named for it. - expect(screen.getByRole('button', { name: 'HotCRM' })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: 'Customize HotCRM' })).toBeInTheDocument(); - // The flows that belong to no package. - expect(await screen.findByTestId('studio-landing-org-scope')).toHaveAccessibleName(/^Flows in no app/); - expect(screen.getByRole('button', { name: /^New app of your own/ })).toBeInTheDocument(); - - // No button or link on the page is left without a name. - const unnamed = [...screen.getAllByRole('button'), ...screen.getAllByRole('link')].filter( - (el) => !el.textContent?.trim() && !el.getAttribute('aria-label') && !el.getAttribute('aria-labelledby'), - ); - expect(unnamed.map((el) => el.outerHTML.slice(0, 80))).toEqual([]); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx deleted file mode 100644 index 95b7b83109d..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * ADR-0146 D3 — each read-only base's Studio landing card says what this - * deployment changed on it, "n customized, m switched off", from the server's - * per-package customization read (`GET /api/v1/packages/:id/customizations`). - * - * The real `BuilderLanding` and the real reader (`packageCustomizations-io`) - * run under a real router; only the package list and the wire are stubbed. - * The stubbed answers are shaped by the route's declaration, - * `GetPackageCustomizationsResponseSchema`, inside the dispatcher envelope. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; -import { t, tFormat } from '../metadata-admin/i18n'; -import { resetRuntimeConfigForTesting } from '../../runtime-config'; - -const packages = vi.hoisted(() => ({ list: [] as Array> })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, fetchPackages: vi.fn(async () => packages.list) }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); - -import { BuilderLanding } from './BuilderLanding'; - -const HOTCRM = { id: 'hotcrm', name: 'HotCRM', writable: false, namespace: 'hotcrm' }; -const HOTCRM_PAIR = { id: 'hotcrm.custom', name: 'HotCRM customizations', writable: true, namespace: 'hotcrm_custom' }; -const SHOWCASE = { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }; -const WRITABLE = { id: 'com.acme.app', name: 'Acme', writable: true, namespace: 'acme' }; -/** A pair served read-only (code-shipped): still a pair, so still no line. */ -const READONLY_PAIR = { id: 'com.example.showcase.custom', name: 'Showcase pair', writable: false, namespace: 'showcase_custom' }; - -const CUSTOMIZATIONS_RE = /^\/api\/v1\/packages\/([^/]+)\/customizations$/; - -/** A served answer for `id`: `overrides` overrides, `extensions` field members, `switchedOff` flows. */ -function served(id: string, overrides: number, extensions: number, switchedOff: number) { - const data = { - packageId: id, - overrides: Array.from({ length: overrides }, (_, i) => ({ type: 'view', name: `view_${i}` })), - extensions: Array.from({ length: extensions }, (_, i) => ({ object: 'account', kind: 'field' as const, name: `field_${i}` })), - switchedOff: Array.from({ length: switchedOff }, (_, i) => ({ type: 'flow', name: `flow_${i}` })), - arrangements: [], - contributions: [], - counts: { overrides, extensions, switchedOff, arrangements: 0, contributions: 0 }, - }; - return { status: 200, body: { success: true, data } }; -} - -type Answer = { status: number; body: unknown } | 'never'; - -const OBJECT_LIST_RE = /\/meta\/object\?package=([^&]+)/; - -/** - * Stub the wire: each customization request is answered from `answers` by - * base id, and each object list (`/meta/object?package=`) from `objects` by - * package id when it names one; every request URL is recorded. - */ -function stubWire(answers: Record, objects: Record = {}) { - const requested: string[] = []; - const fetchMock = vi.fn(async (input: RequestInfo | URL) => { - const url = String(input); - requested.push(url); - const o = OBJECT_LIST_RE.exec(url); - const listed = o ? objects[decodeURIComponent(o[1])] : undefined; - if (listed) { - // A real Response: the metadata client reads its headers. - return new Response(JSON.stringify(listed), { - status: 200, - headers: { 'content-type': 'application/json' }, - }); - } - const m = CUSTOMIZATIONS_RE.exec(url); - const answer = m ? answers[decodeURIComponent(m[1])] : undefined; - if (answer === 'never') return new Promise(() => {}); - if (!answer) throw new Error(`unexpected request ${url}`); - return { - ok: answer.status >= 200 && answer.status < 300, - status: answer.status, - json: async () => answer.body, - text: async () => JSON.stringify(answer.body), - } as Response; - }); - vi.stubGlobal('fetch', fetchMock); - return { requested }; -} - -const customizationRequests = (requested: string[]) => requested.filter((u) => CUSTOMIZATIONS_RE.test(u)); - -function LocationProbe() { - const { pathname, search } = useLocation(); - return ( - <> -
{pathname}
-
{search}
- - ); -} - -function renderLanding() { - return render( - - - - } /> - } /> - } /> - - , - ); -} - -/** The card a package renders in: the element holding both its name and its links. */ -function cardOf(name: string): HTMLElement { - const card = screen.getByText(name).closest('.rounded-lg.border'); - if (!(card instanceof HTMLElement)) throw new Error(`no card found for ${name}`); - return card; -} - -const customizedText = (n: number) => tFormat('engine.studio.landing.customizations.customized', 'en-US', { customized: n }); -const switchedOffText = (n: number) => tFormat('engine.studio.landing.customizations.switchedOff', 'en-US', { switchedOff: n }); - -afterEach(() => { - cleanup(); - packages.list = []; - vi.unstubAllGlobals(); - resetRuntimeConfigForTesting(); -}); - -describe('Studio landing: a read-only base says "n customized, m switched off" (ADR-0146 D3)', () => { - it('reads 3 overrides + 1 extension and 2 switched off as "4 customized, 2 switched off", linking the pair and the Automations pillar', async () => { - packages.list = [HOTCRM_PAIR, HOTCRM]; - const { requested } = stubWire({ hotcrm: served('hotcrm', 3, 1, 2) }); - renderLanding(); - - const line = await within(await waitFor(() => cardOf('HotCRM'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'read')); - expect(line).toHaveTextContent('4 customized, 2 switched off'); - - const pairLink = within(line).getByTestId('studio-landing-customizations-pair'); - expect(pairLink).toHaveTextContent(customizedText(4)); - expect(pairLink).toHaveAttribute('href', '/studio/hotcrm.custom/data'); - const offLink = within(line).getByTestId('studio-landing-customizations-switched-off'); - expect(offLink).toHaveTextContent(switchedOffText(2)); - expect(offLink).toHaveAttribute('href', '/studio/hotcrm/automations'); - - fireEvent.click(pairLink); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/hotcrm.custom/data')); - // One read, for the base; never for its pair. - expect(customizationRequests(requested)).toEqual(['/api/v1/packages/hotcrm/customizations']); - }); - - it('reads a base with nothing changed as "No changes yet", with no number and no link (objectstack#34715)', async () => { - packages.list = [SHOWCASE]; - stubWire({ 'com.example.showcase': served('com.example.showcase', 0, 0, 0) }); - renderLanding(); - - const line = await within(await waitFor(() => cardOf('Showcase'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'read')); - expect(line).toHaveAttribute('data-changes', 'none'); - expect(line).toHaveTextContent(t('engine.studio.landing.customizations.none', 'en-US')); - expect(line.textContent).not.toMatch(/\d/); - expect(within(line).queryByRole('link')).not.toBeInTheDocument(); - }); - - it('reads a base with no pair and one switched-off item as "0 customized, 1 switched off", with no pair link', async () => { - packages.list = [SHOWCASE]; - stubWire({ 'com.example.showcase': served('com.example.showcase', 0, 0, 1) }); - renderLanding(); - - const line = await within(await waitFor(() => cardOf('Showcase'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'read')); - expect(line).toHaveTextContent('0 customized, 1 switched off'); - expect(within(line).queryByTestId('studio-landing-customizations-pair')).not.toBeInTheDocument(); - expect(within(line).getByText(customizedText(0))).not.toHaveAttribute('href'); - expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( - 'href', - '/studio/com.example.showcase/automations', - ); - }); - - it('shows no number on a failed read: a muted "couldn’t read" with the server’s sentence as its title', async () => { - packages.list = [SHOWCASE]; - const sentence = 'Metadata service not available'; - stubWire({ 'com.example.showcase': { status: 503, body: { success: false, error: { message: sentence } } } }); - renderLanding(); - - const line = await within(await waitFor(() => cardOf('Showcase'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'failed')); - expect(line).toHaveTextContent(t('engine.studio.landing.customizations.failed', 'en-US')); - expect(line).toHaveAttribute('title', expect.stringContaining(sentence)); - expect(line.textContent).not.toMatch(/\d/); - }); - - it('shows no number when the answer is one the route’s declaration refuses', async () => { - packages.list = [SHOWCASE]; - // `counts` missing: off-contract, so no count is read out of it. - stubWire({ - 'com.example.showcase': { status: 200, body: { success: true, data: { packageId: 'com.example.showcase', overrides: [] } } }, - }); - renderLanding(); - - const line = await within(await waitFor(() => cardOf('Showcase'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'failed')); - expect(line.textContent).not.toMatch(/\d/); - }); - - it('draws no line and sends no request for a writable package or a pair', async () => { - packages.list = [WRITABLE, HOTCRM_PAIR, READONLY_PAIR, SHOWCASE]; - const { requested } = stubWire({ 'com.example.showcase': served('com.example.showcase', 1, 0, 0) }); - renderLanding(); - - await screen.findByText('HotCRM customizations'); - await waitFor(() => - expect(within(cardOf('Showcase')).getByTestId('studio-landing-customizations')).toHaveAttribute('data-state', 'read'), - ); - expect(within(cardOf('Acme')).queryByTestId('studio-landing-customizations')).not.toBeInTheDocument(); - // A pair whose base is not listed keeps its card, with no line. - expect(within(cardOf('HotCRM customizations')).queryByTestId('studio-landing-customizations')).not.toBeInTheDocument(); - // A pair whose base is listed has no card at all (#29691's describe below). - expect(screen.queryByText('Showcase pair')).not.toBeInTheDocument(); - expect(customizationRequests(requested)).toEqual(['/api/v1/packages/com.example.showcase/customizations']); - }); - - it('paints the landing before the counts arrive, with no number on the line', async () => { - packages.list = [HOTCRM, SHOWCASE]; - const { requested } = stubWire({ hotcrm: 'never', 'com.example.showcase': 'never' }); - renderLanding(); - - await screen.findByText('HotCRM'); - expect(screen.getByText('Showcase')).toBeInTheDocument(); - await waitFor(() => expect(customizationRequests(requested)).toHaveLength(2)); - for (const name of ['HotCRM', 'Showcase']) { - const line = within(cardOf(name)).getByTestId('studio-landing-customizations'); - expect(line).toHaveAttribute('data-state', 'loading'); - expect(line.textContent).not.toMatch(/\d/); - } - }); -}); - -/** - * objectstack#29691 (ADR-0146 D3) — the landing gives a base's `.custom` pair - * no card of its own: the pair is folded under its base, as the package - * switcher folds it, and the base's card carries it through its customized - * line and link. The pair's export and delete stay on the Packages page. - */ -/** A served answer for `id` whose switched-off items are exactly `items`. */ -function servedOff(id: string, items: Array<{ type: string; name: string }>) { - const data = { - packageId: id, - overrides: [], - extensions: [], - switchedOff: items, - arrangements: [], - contributions: [], - counts: { overrides: 0, extensions: 0, switchedOff: items.length, arrangements: 0, contributions: 0 }, - }; - return { status: 200, body: { success: true, data } }; -} - -describe('Studio landing: "m switched off" leads to the switched-off actions (objectstack#34724)', () => { - async function readLine() { - const line = await within(await waitFor(() => cardOf('Showcase'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'read')); - return line; - } - - it('one switched-off action: the count opens that action\'s page, where its switch reads off', async () => { - packages.list = [SHOWCASE]; - stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'action', name: 'showcase_mark_done' }]) }); - renderLanding(); - const line = await readLine(); - const off = within(line).getByTestId('studio-landing-customizations-switched-off'); - expect(off).toHaveTextContent(switchedOffText(1)); - expect(off).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action/showcase_mark_done'); - expect(off).toHaveAttribute('title', t('engine.studio.landing.customizations.switchedOffActionsTitle', 'en-US')); - expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions')).not.toBeInTheDocument(); - }); - - it('several switched-off actions: the count opens the action list, and the line names each one as a link to its page', async () => { - packages.list = [SHOWCASE]; - stubWire({ - 'com.example.showcase': servedOff('com.example.showcase', [ - { type: 'action', name: 'showcase_mark_done' }, - { type: 'action', name: 'showcase_portfolio_snapshot' }, - ]), - }); - renderLanding(); - const line = await readLine(); - expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( - 'href', - '/studio/com.example.showcase/metadata/action', - ); - const named = within(line).getAllByTestId('studio-landing-customizations-switched-off-action'); - expect(named.map((a) => [a.textContent, a.getAttribute('href')])).toEqual([ - ['showcase_mark_done', '/studio/com.example.showcase/metadata/action/showcase_mark_done'], - ['showcase_portfolio_snapshot', '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot'], - ]); - expect(within(line).getByTestId('studio-landing-customizations-switched-off-actions')).toHaveTextContent( - /^, Actions: showcase_mark_done, showcase_portfolio_snapshot$/, - ); - expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions-more')).not.toBeInTheDocument(); - fireEvent.click(named[1]); - await waitFor(() => - expect(screen.getByTestId('location')).toHaveTextContent( - '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot', - ), - ); - }); - - it('more switched-off actions than the line names: the first three, then a "more" link to the list', async () => { - packages.list = [SHOWCASE]; - const names = ['a_one', 'a_two', 'a_three', 'a_four', 'a_five']; - stubWire({ 'com.example.showcase': servedOff('com.example.showcase', names.map((name) => ({ type: 'action', name }))) }); - renderLanding(); - const line = await readLine(); - expect( - within(line).getAllByTestId('studio-landing-customizations-switched-off-action').map((a) => a.textContent), - ).toEqual(['a_one', 'a_two', 'a_three']); - const more = within(line).getByTestId('studio-landing-customizations-switched-off-actions-more'); - expect(more).toHaveTextContent(tFormat('engine.studio.landing.customizations.switchedOffActionsMore', 'en-US', { count: 2 })); - expect(more).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action'); - }); - - it('flows and actions switched off: the count opens Automations, and the line names the action', async () => { - packages.list = [SHOWCASE]; - stubWire({ - 'com.example.showcase': servedOff('com.example.showcase', [ - { type: 'action', name: 'showcase_mark_done' }, - { type: 'flow', name: 'showcase_nightly' }, - ]), - }); - renderLanding(); - const line = await readLine(); - expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( - 'href', - '/studio/com.example.showcase/automations', - ); - const [action] = within(line).getAllByTestId('studio-landing-customizations-switched-off-action'); - expect(action).toHaveTextContent('showcase_mark_done'); - expect(action).toHaveAttribute('title', t('engine.studio.landing.customizations.switchedOffActionsTitle', 'en-US')); - expect(action).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action/showcase_mark_done'); - fireEvent.click(action); - await waitFor(() => - expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.example.showcase/metadata/action/showcase_mark_done'), - ); - }); - - // L2 M1 — an action declared inside its object has no item page: its switch - // is on the object's Actions view, which the link opens on it. - const TASK_OBJECT = { - name: 'showcase_task', - label: 'Task', - actions: [{ name: 'showcase_embedded_probe' }, { name: 'showcase_mark_done', objectName: 'showcase_task' }], - }; - const embeddedPath = '/studio/com.example.showcase/data?surface=object%3Ashowcase_task&action=showcase_embedded_probe'; - - it('one switched-off action its object holds: the count opens the object\'s Actions view on it', async () => { - packages.list = [SHOWCASE]; - const { requested } = stubWire( - { 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'action', name: 'showcase_embedded_probe' }]) }, - { 'com.example.showcase': [TASK_OBJECT, { name: 'showcase_invoice', label: 'Invoice' }] }, - ); - renderLanding(); - const off = within(await readLine()).getByTestId('studio-landing-customizations-switched-off'); - expect(off).toHaveAttribute('href', embeddedPath); - expect(requested.some((u) => OBJECT_LIST_RE.test(u))).toBe(true); - fireEvent.click(off); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.example.showcase/data')); - expect(screen.getByTestId('location-search')).toHaveTextContent('?surface=object%3Ashowcase_task&action=showcase_embedded_probe'); - }); - - it('several: each named action links where it is switched, its object\'s Actions view or its own page', async () => { - packages.list = [SHOWCASE]; - stubWire( - { - 'com.example.showcase': servedOff('com.example.showcase', [ - { type: 'action', name: 'showcase_embedded_probe' }, - { type: 'action', name: 'showcase_portfolio_snapshot' }, - ]), - }, - { 'com.example.showcase': [TASK_OBJECT] }, - ); - renderLanding(); - const named = within(await readLine()).getAllByTestId('studio-landing-customizations-switched-off-action'); - expect(named.map((a) => [a.textContent, a.getAttribute('href')])).toEqual([ - ['showcase_embedded_probe', embeddedPath], - ['showcase_portfolio_snapshot', '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot'], - ]); - }); - - it('the "Customizations in this environment" panel row of an action its object holds opens that object\'s Actions view too', async () => { - packages.list = [SHOWCASE]; - stubWire( - { - 'com.example.showcase': servedOff('com.example.showcase', [ - { type: 'action', name: 'showcase_embedded_probe' }, - { type: 'action', name: 'showcase_portfolio_snapshot' }, - ]), - }, - { 'com.example.showcase': [TASK_OBJECT] }, - ); - renderLanding(); - await readLine(); - const rows = await waitFor(() => { - const found = screen.getAllByTestId('studio-landing-env-customization'); - expect(found).toHaveLength(2); - return found; - }); - expect(rows.map((r) => r.querySelector('a')?.getAttribute('href'))).toEqual([ - embeddedPath, - '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot', - ]); - }); - - it('no object list read when nothing switched off is an action', async () => { - packages.list = [SHOWCASE]; - const { requested } = stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'flow', name: 'showcase_nightly' }]) }); - renderLanding(); - await readLine(); - expect(requested.some((u) => OBJECT_LIST_RE.test(u))).toBe(false); - }); - - it('flows only: the count opens Automations, with no actions link (unchanged)', async () => { - packages.list = [SHOWCASE]; - stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'flow', name: 'showcase_nightly' }]) }); - renderLanding(); - const line = await readLine(); - expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( - 'href', - '/studio/com.example.showcase/automations', - ); - expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions')).not.toBeInTheDocument(); - }); -}); - -describe('Studio landing: a base’s .custom pair has no card of its own (ADR-0146 D3)', () => { - /** Every package card the landing draws, by the package id each card carries. */ - const cardIds = () => - Array.from(document.querySelectorAll('[data-package-id]')).map((el) => el.getAttribute('data-package-id')); - - it('draws one card for a base and its writable pair: the base’s, with its customized count and the pair link', async () => { - packages.list = [HOTCRM, HOTCRM_PAIR, WRITABLE]; - stubWire({ hotcrm: served('hotcrm', 2, 1, 0) }); - renderLanding(); - - const line = await within(await waitFor(() => cardOf('HotCRM'))).findByTestId('studio-landing-customizations'); - await waitFor(() => expect(line).toHaveAttribute('data-state', 'read')); - expect(within(line).getByTestId('studio-landing-customizations-pair')).toHaveTextContent(customizedText(3)); - expect(within(line).getByTestId('studio-landing-customizations-pair')).toHaveAttribute('href', '/studio/hotcrm.custom/data'); - - // The pair draws no card, under 我的软件包 or anywhere else. - expect(screen.queryByText('HotCRM customizations')).not.toBeInTheDocument(); - expect(cardIds()).not.toContain('hotcrm.custom'); - // CONTROL: a writable package that is no pair keeps its card. - expect(cardIds()).toEqual(['hotcrm', 'com.acme.app']); - }); - - it('folds a read-only pair under its listed base too', async () => { - packages.list = [SHOWCASE, READONLY_PAIR]; - stubWire({ 'com.example.showcase': served('com.example.showcase', 1, 0, 0) }); - renderLanding(); - - await waitFor(() => cardOf('Showcase')); - expect(screen.queryByText('Showcase pair')).not.toBeInTheDocument(); - expect(cardIds()).toEqual(['com.example.showcase']); - }); - - it('keeps the card of a pair whose base is not listed', async () => { - packages.list = [HOTCRM_PAIR]; - stubWire({}); - renderLanding(); - - await waitFor(() => cardOf('HotCRM customizations')); - expect(cardIds()).toEqual(['hotcrm.custom']); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizeCopy-29489.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizeCopy-29489.test.tsx deleted file mode 100644 index 59737e014ab..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizeCopy-29489.test.tsx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#29489 — the Studio landing teaches the customization route that - * is open, not the package-less overlay objectstack ADR-0146 D11 closed. - * - * A package-less write onto an item a read-only package ships answers 403 - * NOT_OVERRIDABLE and names the base's `.custom` pair. The landing's page - * description and its read-only section hint used to send the user there - * ("customize them with an environment overlay"). objectstack#34715 then - * reworded both to say what the author can do, naming no mechanism: the open - * route is the Customize button each installed app's card carries. - * - * Read off the real `BuilderLanding`, rendered in English and in Chinese with a - * read-only package listed, so both strings are on the page. The expected - * words are the tables' own: the Customize action label. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, render, screen } from '@testing-library/react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; -import { I18nProvider, createI18n } from '@object-ui/i18n'; -import { t } from '../metadata-admin/i18n'; -import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config'; -// The landing's rows live in `@object-ui/i18n`'s `studio` namespace, whose `zh` -// catalogue is fetched on demand: resident before any case. -import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; -await loadStudioCatalogue('zh'); - -const packages = vi.hoisted(() => ({ list: [] as Array> })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, fetchPackages: vi.fn(async () => packages.list) }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); - -import { BuilderLanding } from './BuilderLanding'; - -const READ_ONLY = { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }; - -type Locale = 'en-US' | 'zh-CN'; -const LOCALES: ReadonlyArray = [ - ['en-US', 'en'], - ['zh-CN', 'zh'], -]; - -/** The retired route, in both languages the tables speak. */ -const ENVIRONMENT_OVERLAY = /environment overlay|环境覆盖/iu; - -afterEach(() => { - cleanup(); - packages.list = []; - vi.unstubAllGlobals(); - resetRuntimeConfigForTesting(); -}); - -/** The row for `key` in `locale`, which must exist: `t` echoes a missing key. */ -function row(key: string, locale: Locale): string { - const text = t(key, locale); - expect(text, `no ${locale} row for ${key}`).not.toBe(key); - return text; -} - -async function renderLanding(lang: 'en' | 'zh') { - resetRuntimeConfigForTesting(); - vi.stubGlobal( - 'fetch', - vi.fn(async () => { - const body = { features: { installLocal: false, marketplace: false } }; - return { ok: true, status: 200, json: async () => body, text: async () => JSON.stringify(body) } as Response; - }), - ); - await initRuntimeConfig(); - packages.list = [READ_ONLY]; - const landing = ( - - - } /> - - - ); - if (lang === 'en') return render(landing); - const zh = createI18n({ defaultLanguage: 'zh', detectBrowserLanguage: false, resources: { zh: {} } }); - return render({landing}); -} - -/** The page description: the paragraph right under the title row. */ -function descriptionElement(): HTMLElement { - const titleRow = screen.getByRole('heading', { level: 1 }).parentElement; - const description = titleRow?.nextElementSibling; - if (!(description instanceof HTMLElement)) throw new Error('no description under the landing title'); - return description; -} - -describe('Studio landing: a read-only package is customized through its Customize button, never an overlay (objectstack#29489)', () => { - for (const [locale, lang] of LOCALES) { - it(`${locale}: the description and the installed-apps hint offer no overlay, and the card carries Customize`, async () => { - await renderLanding(lang); - await screen.findByText('Showcase'); - - const shown = [ - descriptionElement().textContent ?? '', - screen.getByTestId('studio-landing-readonly-hint').textContent ?? '', - ]; - expect(shown).toEqual([row('engine.studio.landing.lead', locale), row('engine.studio.landing.appsHint', locale)]); - for (const text of shown) expect(text).not.toMatch(ENVIRONMENT_OVERLAY); - - expect(screen.getByTestId('studio-landing-customize')).toHaveTextContent(row('engine.studio.customize.action', locale)); - }); - } -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.duplicateIdRule-11855.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.duplicateIdRule-11855.test.tsx deleted file mode 100644 index b7d0afdd7e5..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.duplicateIdRule-11855.test.tsx +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#11855 — the Studio landing's *Duplicate* form judges the new - * package id by the spec's id rule, the one the duplicate route refuses by. - * - * Before: the form armed its button with a regex of its own, which refused - * `163.com.crm` (a digit-led segment the spec accepts) and let - * `com.acme.my_app`, `com.-x` and `a..b` through to the server's 400. It now - * judges by `ManifestSchema.shape.id`, through the same rule and wording as - * the *New package* dialog (objectui#11792). - * - * Each pin carries the verdict the server gives, written down as a literal and - * checked against the installed declaration, and is read off the real - * `BuilderLanding`: the button's state, the input's hint, and the wire. - */ - -import '@testing-library/jest-dom/vitest'; -import * as React from 'react'; -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; -import { ManifestSchema } from '@objectstack/spec/kernel'; -import { t, tFormat } from '../metadata-admin/i18n'; - -const SOURCE_ID = 'com.acme.crm'; - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => [{ id: SOURCE_ID, name: 'Acme CRM', writable: true, namespace: 'crm' }]), - }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); - -import { BuilderLanding } from './BuilderLanding'; - -type Call = { url: string; method: string; body: unknown }; -let calls: Call[]; - -beforeEach(() => { - calls = []; - vi.stubGlobal( - 'fetch', - vi.fn(async (url: string, init: RequestInit = {}) => { - const method = (init.method ?? 'GET').toUpperCase(); - const body = typeof init.body === 'string' && init.body ? JSON.parse(init.body) : undefined; - calls.push({ url, method, body }); - const text = JSON.stringify({ success: true, data: { success: true, copiedCount: 3, failedCount: 0 } }); - return { ok: true, status: 200, json: async () => JSON.parse(text), text: async () => text } as Response; - }), - ); -}); - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); -}); - -function LocationProbe() { - return
{useLocation().pathname}
; -} - -async function openDuplicateForm() { - render( - - - - } /> - } /> - - , - ); - fireEvent.click(await screen.findByTitle(t('engine.studio.landing.dupTitle', 'en-US'))); - // One form is open and the create dialog is stubbed out, so this input's - // hint and notice are the only ones on the page. - const idInput = (await screen.findByTestId('pkg-dup-id-input')) as HTMLInputElement; - const go = screen.getByRole('button', { name: t('engine.studio.landing.dupGo', 'en-US') }); - return { idInput, go }; -} - -const settle = () => new Promise((resolve) => setTimeout(resolve, 0)); - -const writes = () => calls.filter((c) => c.method !== 'GET'); - -/** The server's verdict on each id, as `ManifestSchema.shape.id` gives it. */ -const PINS: ReadonlyArray = [ - ['163.com.crm', true], // a segment may open with a digit - ['com.acme.my_app', false], // the spec admits no underscore - ['com.-x', false], // nor a segment opening with a hyphen - ['a..b', false], // nor an empty segment - ['com.example.myapp', true], // control: a plain valid id -]; - -describe('the landing Duplicate form judges the id as the server does (objectui#11855)', () => { - it('each pinned verdict is the installed declaration’s', () => { - for (const [id, accepted] of PINS) expect(ManifestSchema.shape.id.safeParse(id).success).toBe(accepted); - }); - - it.each(PINS)('%s: armed exactly when the server accepts it (%s)', async (id, accepted) => { - const { idInput, go } = await openDuplicateForm(); - fireEvent.change(idInput, { target: { value: id } }); - expect(idInput.value).toBe(id); - expect(go.hasAttribute('disabled')).toBe(!accepted); - expect(screen.queryByTestId('pkg-id-format-hint') === null).toBe(accepted); - - if (accepted) { - fireEvent.click(go); - await waitFor(() => expect(writes()).toHaveLength(1)); - expect(writes()[0]).toMatchObject({ - method: 'POST', - url: `/api/v1/packages/${SOURCE_ID}/duplicate`, - body: { targetPackageId: id }, - }); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent(`/studio/${id}/data`)); - } else { - // Neither door sends it: the button, nor Enter in the id field. - fireEvent.click(go); - fireEvent.keyDown(idInput, { key: 'Enter' }); - await settle(); - expect(writes()).toEqual([]); - } - }); - - it('control: the prefilled `-copy` id is armed without an edit', async () => { - const { idInput, go } = await openDuplicateForm(); - expect(idInput.value).toBe(`${SOURCE_ID}-copy`); - expect(go).not.toBeDisabled(); - expect(screen.queryByTestId('pkg-id-format-hint')).toBeNull(); - }); - - it('an underscore stays in the field and the hint is the shared rule’s, as in the New package dialog', async () => { - const { idInput } = await openDuplicateForm(); - fireEvent.change(idInput, { target: { value: 'com.acme.my_app' } }); - expect(idInput.value).toBe('com.acme.my_app'); - expect(screen.queryByTestId('pkg-id-stripped')).toBeNull(); - expect(screen.getByTestId('pkg-id-format-hint')).toHaveTextContent( - tFormat('engine.packages.idRule.formatHint', 'en-US', { example: 'com.acme.crm' }), - ); - }); - - it('a stripped keystroke shows the shared rule’s notice', async () => { - const { idInput } = await openDuplicateForm(); - fireEvent.change(idInput, { target: { value: 'com.acme.crm copy!' } }); - expect(idInput.value).toBe('com.acme.crmcopy'); - expect(screen.getByTestId('pkg-id-stripped')).toHaveTextContent( - t('engine.packages.idRule.strippedNotice', 'en-US'), - ); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx deleted file mode 100644 index 349cd687c2d..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#34714 — the Studio landing lists every change this deployment - * made to its installed apps in one panel, "Customizations in this - * environment". - * - * The real `BuilderLanding`, the real panel and the real customization reader - * (`packageCustomizations-io`) run under a real router; the package list, the - * wire of the customization route and the panel's label read are stubbed. The - * stubbed answers are shaped by the route's declaration - * (`GetPackageCustomizationsResponseSchema`) inside the dispatcher envelope. - * - * Acceptance: two installed apps with one change each and one switched-off - * flow draw 3 rows with the right app and mode, each opening its item; the - * panel's total equals the cards' "customized" plus "switched off"; with no - * change the panel is one line; an app whose read answers 403 is named as - * unreadable and the other app's rows still list. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; -import { I18nProvider, createI18n } from '@object-ui/i18n'; -import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; -await loadStudioCatalogue('zh'); - -const packages = vi.hoisted(() => ({ list: [] as Array> })); -const labels = vi.hoisted(() => ({ byApp: {} as Record> })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, fetchPackages: vi.fn(async () => packages.list) }; -}); -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); -// No flow belongs to no package; no request leaves the file for that count. -vi.mock('./packageSurfaces', async (importOriginal) => ({ - ...(await importOriginal()), - loadPackageLessSurfaces: vi.fn(async () => []), -})); -// The label read answers from `labels.byApp`; its own behaviour is pinned in the io case below. -vi.mock('./landingCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - loadCustomizationLabels: vi.fn(async (_client: unknown, appId: string) => labels.byApp[appId] ?? {}), -})); - -import { BuilderLanding } from './BuilderLanding'; -import { customizationRowsOf } from './landingCustomizations-io'; -import { LANDING_CUSTOMIZATION_ROWS_SHOWN } from './LandingCustomizationsPanel'; - -const HOTCRM = { id: 'app.objectstack.hotcrm', name: 'HotCRM', writable: false, namespace: 'crm' }; -const SERVICE = { id: 'app.objectstack.service', name: 'Service Desk', writable: false, namespace: 'svc' }; -const OWN = { id: 'com.acme.app', name: 'Acme', writable: true, namespace: 'acme' }; - -type Lists = { - overrides?: Array>; - extensions?: Array>; - switchedOff?: Array>; - contributions?: Array>; -}; -type Answer = { status: number; body: unknown }; - -/** A served answer for `id`, its counts derived from its lists as the route derives them. */ -function served(id: string, lists: Lists = {}): Answer { - const overrides = lists.overrides ?? []; - const extensions = lists.extensions ?? []; - const switchedOff = lists.switchedOff ?? []; - const contributions = lists.contributions ?? []; - return { - status: 200, - body: { - success: true, - data: { - packageId: id, - overrides, - extensions, - switchedOff, - arrangements: [], - contributions, - counts: { - overrides: overrides.length, - extensions: extensions.length, - switchedOff: switchedOff.length, - arrangements: 0, - contributions: contributions.length, - }, - }, - }, - }; -} - -const CUSTOMIZATIONS_RE = /^\/api\/v1\/packages\/([^/]+)\/customizations$/; - -/** Answer each customization request from `answers` by base id; any other request is refused. */ -function stubWire(answers: Record) { - const requested: string[] = []; - vi.stubGlobal( - 'fetch', - vi.fn(async (input: RequestInfo | URL) => { - const url = String(input); - requested.push(url); - const m = CUSTOMIZATIONS_RE.exec(url); - const answer = m ? answers[decodeURIComponent(m[1])] : undefined; - if (!answer) throw new Error(`unexpected request ${url}`); - return { - ok: answer.status >= 200 && answer.status < 300, - status: answer.status, - json: async () => answer.body, - text: async () => JSON.stringify(answer.body), - } as Response; - }), - ); - return { requested }; -} - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); - packages.list = []; - labels.byApp = {}; -}); - -function LocationProbe() { - const { pathname, search } = useLocation(); - return
{`${pathname}${search}`}
; -} - -function renderLanding(lang: 'en' | 'zh' = 'en') { - const landing = ( - - - - } /> - } /> - } /> - - - ); - if (lang === 'en') return render(landing); - const zh = createI18n({ defaultLanguage: 'zh', detectBrowserLanguage: false, resources: { zh: {} } }); - return render({landing}); -} - -const panel = () => screen.getByTestId('studio-landing-env-customizations'); -const rows = () => within(panel()).queryAllByTestId('studio-landing-env-customization'); -const rowLine = (row: HTMLElement) => - `${row.querySelector('a')?.textContent} | ${within(row).getByTestId('studio-landing-env-customization-meta').textContent}`; - -/** The cards' "customized" + "switched off", summed over every read card. */ -function cardSum(): number { - return screen - .getAllByTestId('studio-landing-customizations') - .filter((l) => l.getAttribute('data-state') === 'read') - .reduce((sum, l) => sum + [...(l.textContent ?? '').matchAll(/(\d+)/gu)].reduce((s, m) => s + Number(m[1]), 0), 0); -} - -/** Two apps, one change each, and one switched-off flow on HotCRM. */ -const ACCEPTANCE = { - [HOTCRM.id]: served(HOTCRM.id, { - overrides: [{ type: 'view', name: 'account_list' }], - switchedOff: [{ type: 'flow', name: 'lead_nurture' }], - // Another package's field on a HotCRM object: not this deployment's change. - contributions: [{ kind: 'field', object: 'account', name: 'erp_code', packageId: 'com.acme.erp' }], - }), - [SERVICE.id]: served(SERVICE.id, { extensions: [{ object: 'ticket', kind: 'field', name: 'region' }] }), -}; - -describe('Studio landing → Customizations in this environment (objectstack#34714)', () => { - it('two apps with one change each and one switched-off flow list 3 rows, each with its app and how it changed it', async () => { - packages.list = [HOTCRM, SERVICE, OWN]; - stubWire(ACCEPTANCE); - labels.byApp = { [HOTCRM.id]: { 'view:account_list': 'All accounts' } }; - renderLanding(); - - // The label arrives after the rows: a row is drawn on its name first. - await waitFor(() => - expect(rows().map(rowLine)).toEqual([ - 'All accounts | Changed · View · HotCRM', - 'lead_nurture | Switched off · Flow · HotCRM', - 'ticket.region | Added · Field · Service Desk', - ]), - ); - expect(rows().map((r) => `${r.getAttribute('data-app-id')}:${r.getAttribute('data-mode')}`)).toEqual([ - `${HOTCRM.id}:changed`, - `${HOTCRM.id}:switchedOff`, - `${SERVICE.id}:added`, - ]); - // The contributed field makes no row. - expect(panel().textContent).not.toContain('erp_code'); - }); - - it('each row opens its item in Studio: the item on its app’s metadata area, an added field on its object', async () => { - packages.list = [HOTCRM, SERVICE]; - stubWire(ACCEPTANCE); - renderLanding(); - - await waitFor(() => expect(rows()).toHaveLength(3)); - expect(rows().map((r) => r.querySelector('a')?.getAttribute('href'))).toEqual([ - '/studio/app.objectstack.hotcrm/metadata/view/account_list', - '/studio/app.objectstack.hotcrm/metadata/flow/lead_nurture', - '/studio/app.objectstack.service/metadata/object/ticket', - ]); - fireEvent.click(within(rows()[1]).getByRole('link')); - await waitFor(() => - expect(screen.getByTestId('location')).toHaveTextContent('/studio/app.objectstack.hotcrm/metadata/flow/lead_nurture'), - ); - expect(screen.getByTestId('area-item')).toBeInTheDocument(); - }); - - it('the panel’s total equals the cards’ customized + switched off', async () => { - packages.list = [HOTCRM, SERVICE]; - stubWire(ACCEPTANCE); - renderLanding(); - - await waitFor(() => expect(rows()).toHaveLength(3)); - await waitFor(() => expect(cardSum()).toBe(3)); - expect(screen.getByTestId('studio-landing-env-customizations-total')).toHaveTextContent('3'); - // One read per app serves the card and the panel. - const requested = vi.mocked(globalThis.fetch).mock.calls.map((c) => String(c[0])); - expect(requested.filter((u) => CUSTOMIZATIONS_RE.test(u)).sort()).toEqual([ - '/api/v1/packages/app.objectstack.hotcrm/customizations', - '/api/v1/packages/app.objectstack.service/customizations', - ]); - }); - - it('with no change anywhere the panel is one line, and draws no list', async () => { - packages.list = [HOTCRM, SERVICE]; - stubWire({ [HOTCRM.id]: served(HOTCRM.id), [SERVICE.id]: served(SERVICE.id) }); - renderLanding(); - - expect(await screen.findByTestId('studio-landing-env-customizations-empty')).toHaveTextContent( - 'No installed app has been changed in this environment yet.', - ); - expect(rows()).toHaveLength(0); - expect(screen.queryByTestId('studio-landing-env-customizations-total')).not.toBeInTheDocument(); - expect(screen.queryByTestId('studio-landing-env-customizations-search')).not.toBeInTheDocument(); - }); - - it('an app whose read answers 403 is named as unreadable, never counted as 0; the other app still lists', async () => { - packages.list = [HOTCRM, SERVICE]; - stubWire({ - [HOTCRM.id]: { status: 403, body: { success: false, error: { code: 'PERMISSION_DENIED', message: 'Not allowed to read customizations.' } } }, - [SERVICE.id]: ACCEPTANCE[SERVICE.id], - }); - renderLanding(); - - const unreadable = await screen.findByTestId('studio-landing-env-customizations-unreadable'); - expect(unreadable).toHaveTextContent('HotCRM: this app’s customizations could not be read.'); - expect(unreadable).toHaveAttribute('data-app-id', HOTCRM.id); - await waitFor(() => expect(rows()).toHaveLength(1)); - expect(rowLine(rows()[0])).toBe('ticket.region | Added · Field · Service Desk'); - expect(screen.getByTestId('studio-landing-env-customizations-total')).toHaveTextContent('1'); - expect(screen.queryByTestId('studio-landing-env-customizations-empty')).not.toBeInTheDocument(); - // The card says the same: failed, not "No changes yet". - const hotcrmCard = document.querySelector(`[data-package-id="${HOTCRM.id}"]`) as HTMLElement; - expect(within(hotcrmCard).getByTestId('studio-landing-customizations')).toHaveAttribute('data-state', 'failed'); - }); - - it('tabs narrow by kind, the search by text, and the rows group by app', async () => { - packages.list = [HOTCRM, SERVICE]; - stubWire(ACCEPTANCE); - renderLanding(); - await waitFor(() => expect(rows()).toHaveLength(3)); - - const tab = (key: string) => screen.getByTestId(`studio-landing-env-customizations-tab-${key}`); - expect(['all', 'fields', 'views', 'flows', 'switchedOff'].map((k) => tab(k).textContent)).toEqual([ - 'All 3', - 'New fields 1', - 'Forms and views 1', - 'Flows 1', - 'Switched off 1', - ]); - fireEvent.click(tab('fields')); - expect(rows().map((r) => r.getAttribute('data-mode'))).toEqual(['added']); - fireEvent.click(tab('switchedOff')); - expect(rows().map((r) => r.querySelector('a')?.textContent)).toEqual(['lead_nurture']); - fireEvent.click(tab('all')); - - fireEvent.change(screen.getByTestId('studio-landing-env-customizations-search'), { target: { value: 'service' } }); - expect(rows().map((r) => r.querySelector('a')?.textContent)).toEqual(['ticket.region']); - fireEvent.change(screen.getByTestId('studio-landing-env-customizations-search'), { target: { value: '' } }); - - fireEvent.click(screen.getByTestId('studio-landing-env-customizations-group')); - const groups = within(panel()).getAllByTestId('studio-landing-env-customizations-app'); - expect(groups.map((g) => [g.getAttribute('data-app-id'), within(g).getAllByTestId('studio-landing-env-customization').length])).toEqual([ - [HOTCRM.id, 2], - [SERVICE.id, 1], - ]); - }); - - it(`shows the first ${LANDING_CUSTOMIZATION_ROWS_SHOWN} rows, the rest behind "Show all"`, async () => { - const many = Array.from({ length: LANDING_CUSTOMIZATION_ROWS_SHOWN + 3 }, (_, i) => ({ type: 'view', name: `view_${i}` })); - packages.list = [HOTCRM]; - stubWire({ [HOTCRM.id]: served(HOTCRM.id, { overrides: many }) }); - renderLanding(); - - await waitFor(() => expect(rows()).toHaveLength(LANDING_CUSTOMIZATION_ROWS_SHOWN)); - const showAll = screen.getByTestId('studio-landing-env-customizations-show-all'); - expect(showAll).toHaveTextContent(`Show all ${many.length}`); - fireEvent.click(showAll); - expect(rows()).toHaveLength(many.length); - }); - - it('zh-CN: the panel speaks the card’s words — 本环境的定制, 改了原有的 / 新增的 / 已停用', async () => { - packages.list = [HOTCRM, SERVICE]; - stubWire(ACCEPTANCE); - renderLanding('zh'); - - await waitFor(() => expect(rows()).toHaveLength(3)); - expect(within(panel()).getByRole('heading', { level: 2 })).toHaveTextContent('本环境的定制'); - expect(rows().map((r) => within(r).getByTestId('studio-landing-env-customization-meta').textContent)).toEqual([ - '改了原有的 · 视图 · HotCRM', - '已停用 · 流程 · HotCRM', - '新增的 · 字段 · Service Desk', - ]); - expect(screen.getByTestId('studio-landing-env-customizations-tab-fields')).toHaveTextContent('新增字段'); - expect(screen.getByTestId('studio-landing-env-customizations-tab-views')).toHaveTextContent('表单与视图'); - }); -}); - -describe('the panel’s rows and labels (objectstack#34714)', () => { - it('one row per served override, extension and switched-off item; contributions make none', () => { - const read = (ACCEPTANCE[HOTCRM.id].body as { data: Parameters[1] }).data; - expect(customizationRowsOf(HOTCRM, read).map((r) => `${r.mode}:${r.type}:${r.name}`)).toEqual([ - 'changed:view:account_list', - 'switchedOff:flow:lead_nurture', - ]); - }); - - it('a switched-off action opens where it is switched: its object\'s Actions view when an object holds it, else its own page (objectstack#34724)', () => { - const read = { - overrides: [], - extensions: [], - switchedOff: [ - { type: 'action', name: 'clone_opportunity' }, - { type: 'action', name: 'export_all' }, - ], - }; - const hrefs = (objects?: Record) => - customizationRowsOf(HOTCRM, read, objects).map((r) => [r.name, r.href]); - expect(hrefs({ clone_opportunity: 'opportunity' })).toEqual([ - ['clone_opportunity', '/studio/app.objectstack.hotcrm/data?surface=object%3Aopportunity&action=clone_opportunity'], - ['export_all', '/studio/app.objectstack.hotcrm/metadata/action/export_all'], - ]); - // With no object read (none made, or it failed), every action opens its own page. - expect(hrefs()).toEqual([ - ['clone_opportunity', '/studio/app.objectstack.hotcrm/metadata/action/clone_opportunity'], - ['export_all', '/studio/app.objectstack.hotcrm/metadata/action/export_all'], - ]); - }); - - it('labels come from the app’s own list of each type with rows, a field’s from its object; a failed list keeps the names', async () => { - const { loadCustomizationLabels: real } = await vi.importActual( - './landingCustomizations-io', - ); - const rowsOf = customizationRowsOf(SERVICE, { - overrides: [{ type: 'view', name: 'ticket_list' }], - extensions: [{ object: 'ticket', kind: 'field', name: 'region' }], - switchedOff: [{ type: 'flow', name: 'escalate' }], - }); - const asked: string[] = []; - const client = { - list: vi.fn(async (type: string, options?: { packageId?: string }) => { - asked.push(`${type}@${options?.packageId}`); - if (type === 'flow') throw new Error('HTTP 500'); - if (type === 'view') return [{ name: 'ticket_list', label: { en: 'All tickets', zh: '全部工单' } }]; - if (type === 'object') return [{ name: 'ticket', label: 'Ticket', fields: { region: { label: 'Region' } } }]; - return []; - }), - }; - expect(await real(client, SERVICE.id, rowsOf, 'zh')).toEqual({ - 'view:ticket_list': '全部工单', - 'object:ticket': 'Ticket', - 'field:ticket.region': 'Region', - }); - expect(asked.sort()).toEqual(['flow@app.objectstack.service', 'object@app.objectstack.service', 'view@app.objectstack.service']); - // No row, no request. - client.list.mockClear(); - expect(await real(client, HOTCRM.id, rowsOf, 'en')).toEqual({}); - expect(client.list).not.toHaveBeenCalled(); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.environmentOverlayCopy-12171.test.ts b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.environmentOverlayCopy-12171.test.ts deleted file mode 100644 index e68f2b79120..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.environmentOverlayCopy-12171.test.ts +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#12171 — the Studio landing names the overlay axis that exists; - * objectstack#29489 — and the landing no longer offers that overlay at all. - * - * ADR-0131 D6 (objectstack) retired ADR-0005's per-organization overlay axis. - * The registry flag the landing points at is `allowEnvironmentOverlay`: may an - * environment overlay an item a package ships. Three landing strings still - * offered an "org overlay" (zh 「组织覆盖」): the page description, the - * read-only section's hint, and the tooltip on a read-only card's overlay link. - * A fourth string, the permission matrix's hint on a set a code package ships - * (`perm.readOnly.artifact.hint`), said "per-org overlay" (zh 「按组织覆盖」) - * in its parenthetical; the card's claim amendment added it to this pin. - * - * objectstack ADR-0146 D11 then closed the package-less write onto a packaged - * item (403 NOT_OVERRIDABLE, naming the base's `.custom` pair). The landing's - * two strings now teach the route that is open: Customize or New similar, - * saved in the package's `.custom` customization package. objectstack#34715 - * then replaced the two strings the landing renders with ones that say what - * the author can do and name no mechanism, the `.custom` package included. - * The permission hint still names the environment overlay, because it says - * that overlay is refused. - * - * ## The population - * - * Every designer string table, read through their shared extractor - * (`readDesignerPairs` in `ui/scripts/check-i18n-dead-keys.mjs`), then narrowed - * to the tables that carry these keys. No list of locales is kept here: a table - * added for another language joins the population by itself. - * - * ## The pins - * - * 1. No value of these keys, in any table that carries them, names the - * organization axis. - * 2. No landing value names the environment overlay or the `.custom` - * package. - * 3. Lit control on the matchers: the permission hint names the environment - * overlay in every table. A table in a language neither pattern speaks - * fails here, so pins 1 and 2 cannot pass on it by matching nothing. - * 4. Lit control on the reader: for every locale the module's own - * `SupportedLocale` union declares, the value `t()` serves is the one the - * extractor read, so an extractor that read some other table cannot pass. - */ - -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { describe, it, expect } from 'vitest'; -// @ts-expect-error — plain-JS gate script, intentionally untyped (`allowJs: false`) -import { readDesignerPairs } from '../../../../../scripts/check-i18n-dead-keys.mjs'; -import { t, type SupportedLocale } from '../metadata-admin/i18n'; -// The designer's `designer.*` / `perm.*` rows live in `@object-ui/i18n`'s `studio` -// namespace, whose `zh` catalogue is fetched on demand (objectstack#25922). -// Resident before any case, so the zh rows below read synchronously. -import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; -await loadStudioCatalogue('zh'); - -/** Local annotation, since the import above is untyped — the call site stays checked. */ -const readTables: (root: string) => Map> = readDesignerPairs; - -const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..'); - -/** - * The two strings `BuilderLanding` renders about installed apps: the page's - * lead and the installed-apps hint (objectstack#34715). The overlay link's - * tooltip retired with the link: the landing no longer links into Setup - * (objectstack ADR-0146 D1, N-28). - */ -const LANDING_KEYS = ['engine.studio.landing.lead', 'engine.studio.landing.appsHint'] as const; - -/** The hint `PermissionMatrixEditor` shows on a set a code package ships: it names the overlay it refuses. */ -const PERMISSION_HINT = 'perm.readOnly.artifact.hint'; - -const KEYS = [...LANDING_KEYS, PERMISSION_HINT] as const; - -/** The customization package a read-only package is paired with (objectstack ADR-0146 D3). */ -const CUSTOM_PAIR = /\.custom\b/u; - -/** The retired axis, in the languages the tables speak: "org", "per-org", "organization", 组织. */ -const ORGANIZATION_AXIS = /\borg(?:ani[sz]ation)?s?\b|组织/iu; - -/** The overlay axis, in the same languages: refused on a packaged item since objectstack ADR-0146 D11. */ -const ENVIRONMENT_OVERLAY = /\benvironment overlay\b|环境覆盖/iu; - -/** - * Every locale the module declares. `satisfies` makes the record complete over - * `SupportedLocale`, so a locale added to that union fails the type-check here - * until it is listed. - */ -const DECLARED_LOCALES = { 'en-US': true, 'zh-CN': true, 'zh-Hant': true } satisfies Record; - -function tablesCarryingKeys(): Array<[string, Map]> { - return [...readTables(REPO_ROOT)].filter(([, table]) => KEYS.some((key) => table.has(key))); -} - -describe('the read-only copy names no organization axis, and the landing offers no overlay (objectui#12171, objectstack#29489, objectstack#34715)', () => { - it('reads the tables t() serves', () => { - const read = tablesCarryingKeys(); - for (const locale of Object.keys(DECLARED_LOCALES)) { - for (const key of KEYS) { - const served = t(key, locale); - expect(served, `${locale} ${key} is missing from the table t() reads`).not.toBe(key); - expect( - read.some(([, table]) => table.get(key) === served), - `${locale} ${key}: the value t() serves is not among the values the extractor read`, - ).toBe(true); - } - } - }); - - it('no value of these keys names the organization axis', () => { - const offenders: string[] = []; - for (const [name, table] of tablesCarryingKeys()) { - for (const key of KEYS) { - const value = table.get(key); - if (value === undefined) offenders.push(`${name} ${key}: missing`); - else if (ORGANIZATION_AXIS.test(value)) offenders.push(`${name} ${key}: ${value}`); - } - } - expect(offenders).toEqual([]); - }); - - it('no landing value offers the environment overlay or names the .custom package', () => { - const offenders: string[] = []; - for (const [name, table] of tablesCarryingKeys()) { - for (const key of LANDING_KEYS) { - const value = table.get(key); - if (value === undefined) offenders.push(`${name} ${key}: missing`); - else if (ENVIRONMENT_OVERLAY.test(value)) offenders.push(`${name} ${key} offers the overlay: ${value}`); - else if (CUSTOM_PAIR.test(value)) offenders.push(`${name} ${key} names the .custom package: ${value}`); - } - } - expect(offenders).toEqual([]); - }); - - it('lit control: the mechanism pattern matches the retired landing copy it now keeps off the page', () => { - const retired = tablesCarryingKeys().map(([, table]) => table.get('engine.studio.landing.readonlyHint')); - expect(retired.filter((value) => value !== undefined).length).toBeGreaterThan(0); - for (const value of retired) if (value !== undefined) expect(value).toMatch(CUSTOM_PAIR); - }); - - it('lit control: the permission hint names the environment overlay in every table', () => { - const silent: string[] = []; - for (const [name, table] of tablesCarryingKeys()) { - const value = table.get(PERMISSION_HINT) ?? ''; - if (!ENVIRONMENT_OVERLAY.test(value)) silent.push(`${name}: ${value}`); - } - expect(silent).toEqual([]); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.newAppDoor-36748.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.newAppDoor-36748.test.tsx deleted file mode 100644 index 780e94039c2..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.newAppDoor-36748.test.tsx +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#36748 — the Studio landing's 「新建自己的应用」 ends with an app. - * - * 1. The card opens ONE dialog titled 「新建应用」/"New app", worded for an - * app: a no-code author reads 「应用」, never 「软件包」, on this door - * (the maintainer's ruling). - * 2. One confirm creates the package AND its app: the package `POST`, the - * app's draft under the first-write pin, then that one app's publish - * (objectstack#36511: a human-created item is live at once). The author - * lands in the new package's Studio, whose header names the app, and - * 「‹ Back to app」 opens it. - * 3. A taken app name refuses the whole confirm and writes nothing. - * - * The REAL `BuilderLanding`, `PackageFormDialog`, metadata client and - * `StudioDesignSurface` over a fetch stub that keeps the server's state: - * packages, published apps and app drafts. - */ - -import '@testing-library/jest-dom/vitest'; -import * as React from 'react'; -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'; -// The surface's reach loads `@objectstack/lint` lazily; pay that load during -// collection, not inside a case's clocked window (`check:test-source-alias`). -import '@objectstack/lint'; -import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; -await loadStudioCatalogue('zh'); - -let localeFixture: 'en-US' | 'zh-CN' = 'en-US'; -vi.mock('../metadata-admin/i18n', async (importOriginal) => ({ - ...(await importOriginal>()), - useMetadataLocale: () => localeFixture, -})); -vi.mock('@object-ui/react', async (importOriginal) => { - const actual = await importOriginal>(); - return { ...actual, useAdapter: () => ({}) }; -}); -vi.mock('sonner', () => ({ - toast: { warning: vi.fn(), error: vi.fn(), success: vi.fn(), info: vi.fn(), message: vi.fn(), dismiss: vi.fn() }, - Toaster: () => null, -})); -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 package-less flow count the landing draws is not under test here. -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, loadPackageLessSurfaces: vi.fn(async () => []) }; -}); - -import { toast } from 'sonner'; -import { BuilderLanding } from './BuilderLanding'; -import { StudioDesignSurface } from './StudioDesignSurface'; -import { t } from '../metadata-admin/i18n'; - -window.matchMedia = ((query: string) => ({ - matches: false, - media: query, - onchange: null, - addEventListener: () => {}, - removeEventListener: () => {}, - addListener: () => {}, - removeListener: () => {}, - dispatchEvent: () => false, -})) as unknown as typeof window.matchMedia; -(globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver = - (globalThis as unknown as { ResizeObserver?: unknown }).ResizeObserver ?? - class { - observe() {} - unobserve() {} - disconnect() {} - }; - -function json(body: unknown, status = 200): Response { - return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } }); -} - -interface Write { - method: string; - path: string; - search: URLSearchParams; - body: Record | null; -} - -const srv = { - packages: [] as Array>, - apps: [] as Array>, - appDrafts: [] as Array>, - writes: [] as Write[], -}; - -beforeEach(() => { - localeFixture = 'en-US'; - srv.packages = []; - srv.apps = []; - srv.appDrafts = []; - srv.writes = []; - vi.stubGlobal( - 'fetch', - vi.fn(async (input: unknown, init?: RequestInit) => { - const url = new URL(String(input), 'http://localhost'); - const path = url.pathname; - const method = init?.method ?? 'GET'; - if (method !== 'GET') { - const body = init?.body ? (JSON.parse(String(init.body)) as Record) : null; - srv.writes.push({ method, path, search: url.searchParams, body }); - if (method === 'POST' && path === '/api/v1/packages') { - const manifest = body?.manifest as Record; - srv.packages.push({ manifest, writable: true }); - return json({ success: true, data: { manifest } }, 201); - } - const draft = path.match(/^\/api\/v1\/meta\/app\/([^/]+)$/); - if (method === 'PUT' && draft) { - srv.appDrafts.push({ ...body, name: draft[1], type: 'app' }); - return json({ success: true, version: 'v1' }); - } - const publish = path.match(/^\/api\/v1\/meta\/app\/([^/]+)\/publish$/); - if (method === 'POST' && publish) { - const row = srv.appDrafts.find((d) => d.name === publish[1]); - srv.appDrafts = srv.appDrafts.filter((d) => d !== row); - if (row) srv.apps.push(row); - return json({ success: true, version: 'v2' }); - } - return json({ success: true }); - } - if (path === '/api/v1/packages') return json({ success: true, data: srv.packages }); - if (path === '/api/v1/meta/_drafts') { - return json({ drafts: url.searchParams.get('type') === 'app' ? srv.appDrafts : [] }); - } - if (path === '/api/v1/meta/app') return json(srv.apps); - if (path.endsWith('/layers')) return json({ code: null, overlay: null, overlayScope: null, effective: null }); - if (/^\/api\/v1\/meta\/[^/]+\/[^/]+$/.test(path)) return json({}, 404); - return json([]); - }) as unknown as typeof fetch, - ); -}); - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); - vi.mocked(toast.success).mockClear(); - vi.mocked(toast.error).mockClear(); -}); - -function RunningApp() { - const location = useLocation(); - return

{location.pathname}

; -} - -function renderLanding() { - return render( - - - } /> - } /> - } /> - - , - ); -} - -async function openNewAppDialog(): Promise { - fireEvent.click(await screen.findByTestId('studio-landing-new-app')); - return screen.findByRole('dialog'); -} - -const nameInput = (dialog: HTMLElement) => - within(dialog).getByLabelText(t('engine.packages.create.name', localeFixture), { exact: false }) as HTMLInputElement; - -const describeWrite = (w: Write) => `${w.method} ${w.path}`; - -describe('「新建自己的应用」 opens one dialog worded for an app (objectstack#36748)', () => { - it('titled 「新建应用」, its submit 「创建应用」, and no 「软件包」 anywhere on its face', async () => { - localeFixture = 'zh-CN'; - renderLanding(); - const dialog = await openNewAppDialog(); - expect(within(dialog).getByRole('heading', { name: '新建应用' })).toBeInTheDocument(); - fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } }); - expect(within(dialog).getByTestId('package-form-submit')).toHaveTextContent('创建应用'); - // Advanced opened too: its rows say 「应用 ID」. - fireEvent.click(within(dialog).getByTestId('package-form-advanced-toggle')); - expect(within(dialog).getByText('应用 ID')).toBeInTheDocument(); - expect(dialog.textContent).not.toMatch(/软件包/); - }); -}); - -describe('one confirm creates the package and its app, and the app opens (objectstack#36748)', () => { - it('package, app draft, app publish — then the header names the app and 「‹ Back to app」 opens it', async () => { - renderLanding(); - const dialog = await openNewAppDialog(); - fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } }); - await waitFor(() => expect(within(dialog).getByTestId('package-form-submit')).toBeEnabled()); - fireEvent.click(within(dialog).getByTestId('package-form-submit')); - - await waitFor(() => expect(srv.writes).toHaveLength(3), { timeout: 8000 }); - const [pkg, draft, publish] = srv.writes; - const manifest = pkg.body?.manifest as Record; - const packageId = String(manifest.id); - const namespace = String(manifest.namespace); - expect(srv.writes.map(describeWrite)).toEqual([ - 'POST /api/v1/packages', - `PUT /api/v1/meta/app/${namespace}`, - `POST /api/v1/meta/app/${namespace}/publish`, - ]); - // The app is the new package's, labelled with its name, written under the - // first-write pin, and that one item is published at its package. - expect(draft.search.get('package')).toBe(packageId); - expect(draft.search.get('mode')).toBe('draft'); - expect(draft.body?.label).toBe('Visits'); - expect(publish.search.get('package')).toBe(packageId); - expect(toast.success).toHaveBeenCalledWith(expect.stringMatching(/^Created app “Visits”/)); - expect(toast.error).not.toHaveBeenCalled(); - - // The author lands in the new package's Studio; the header names the app. - const header = await screen.findByTestId('studio-shell-header', undefined, { timeout: 8000 }); - await waitFor( - () => expect(within(header).getByTestId('studio-back-app-name')).toHaveAttribute('data-names', 'app'), - { timeout: 8000 }, - ); - expect(within(header).getByTestId('studio-back')).toHaveTextContent(/^Back to app·Visits·Studio$/); - // The app is live: no Create app is offered, and the back link opens it. - expect(within(header).queryByRole('button', { name: /Create app/ })).toBeNull(); - fireEvent.click(within(header).getByTestId('studio-back-to-app')); - expect(await screen.findByTestId('running-app')).toHaveTextContent(`/apps/${packageId}`); - }); - - it('an app name already taken refuses the confirm and writes nothing', async () => { - renderLanding(); - const dialog = await openNewAppDialog(); - fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } }); - await waitFor(() => expect(within(dialog).getByTestId('package-form-submit')).toBeEnabled()); - const namespace = (within(dialog).getByTestId('package-form-derived-summary').textContent ?? '').match( - /will start with (\w+?)_\./, - )?.[1]; - expect(namespace, 'the derived namespace is read off the dialog').toBeTruthy(); - // Both names the door would try are held by another package's apps. - srv.apps = [ - { name: namespace, label: 'Other visits' }, - { name: `${namespace}_app`, label: 'Other visits app' }, - ]; - fireEvent.click(within(dialog).getByTestId('package-form-submit')); - expect(await within(dialog).findByText(/already uses the identifier/)).toHaveTextContent('Other visits'); - expect(srv.writes).toEqual([]); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.orgScope-11553.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.orgScope-11553.test.tsx deleted file mode 100644 index b9e7d0d6807..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.orgScope-11553.test.tsx +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#11553 — Studio's home reaches the organization's package-less flows. - * - * Measured on the stock showcase: the home said "No writable packages yet" and - * its only entry was the read-only showcase package, whose Automations rail - * lists packaged flows and not the clone. A package-less flow matches no - * package card, so the home carries an entry of its own for them, and it is - * there whether or not a writable package exists. objectstack#34715: it is - * named "Flows in no app", carries how many there are, and is drawn only when - * there is at least one; a failed count still draws it, with no number. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; - -const packages = vi.hoisted(() => ({ list: [] as Array> })); -// The package-less flows the landing counts: an answer of N rows, or a failed read. -const packageLess = vi.hoisted(() => ({ answer: 1 as number | 'failed' })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => packages.list), - // The landing reads the list's ids beside its entries (the same request, - // objectstack#32615): both are answered by this double, never the network. - fetchListedPackageIds: vi.fn(async () => new Set(packages.list.map((p) => String(p.id)))), - }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); -// A read-only base's customization read (ADR-0146 D3) is not under test here: -// it stays pending, so no request leaves the file. -vi.mock('./packageCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - fetchPackageCustomizations: vi.fn(() => new Promise(() => {})), -})); - -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - loadPackageLessSurfaces: vi.fn(async () => { - if (packageLess.answer === 'failed') throw new Error('HTTP 503'); - return Array.from({ length: packageLess.answer }, (_, i) => ({ type: 'flow', name: `org_flow_${i}`, label: `Org flow ${i}` })); - }), - }; -}); - -import { BuilderLanding } from './BuilderLanding'; -import { loadPackageLessSurfaces } from './packageSurfaces'; - -afterEach(() => { - cleanup(); - packages.list = []; - packageLess.answer = 1; - vi.mocked(loadPackageLessSurfaces).mockClear(); -}); - -function LocationProbe() { - const { pathname } = useLocation(); - return
{pathname}
; -} - -function renderLanding() { - return render( - - - - } /> - } /> - - , - ); -} - -describe('Studio home → the package-less scope (objectui#11553)', () => { - it('offers the entry, with its count, on the measured shape: no writable package, one read-only package', async () => { - packages.list = [{ id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }]; - packageLess.answer = 2; - renderLanding(); - - const entry = await screen.findByTestId('studio-landing-org-scope'); - expect(entry).toHaveTextContent('Flows in no app'); - expect(screen.getByTestId('studio-landing-org-scope-count')).toHaveTextContent('2'); - expect(screen.getByText('Outside any app')).toBeInTheDocument(); - // The count is the scope's own union: one unscoped read of flows. - expect(vi.mocked(loadPackageLessSurfaces)).toHaveBeenCalledWith(expect.anything(), 'flow', expect.any(String)); - - fireEvent.click(entry); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/~org/automations')); - expect(screen.getByTestId('pillar-builder')).toBeInTheDocument(); - }); - - it('offers it beside writable packages too, and a package card still opens that package', async () => { - packages.list = [{ id: 'com.acme.app', name: 'Acme', writable: true, namespace: 'acme' }]; - renderLanding(); - - await screen.findByText('Acme'); - expect(await screen.findByTestId('studio-landing-org-scope')).toBeInTheDocument(); - - fireEvent.click(screen.getByText('Acme')); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.acme.app/data')); - }); - - it('draws no entry when no flow belongs to no package (objectstack#34715)', async () => { - packages.list = [{ id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }]; - packageLess.answer = 0; - renderLanding(); - - await screen.findByText('Showcase'); - await waitFor(() => expect(vi.mocked(loadPackageLessSurfaces)).toHaveBeenCalled()); - // CONTROL: the section the entry sits in is drawn, with its other entry. - expect(screen.getByTestId('studio-landing-env-catalog')).toBeInTheDocument(); - expect(screen.queryByTestId('studio-landing-org-scope')).not.toBeInTheDocument(); - expect(screen.queryByText('Flows in no app')).not.toBeInTheDocument(); - }); - - it('a failed count still draws the entry, with no number: unknown is not zero', async () => { - packages.list = []; - packageLess.answer = 'failed'; - renderLanding(); - - const entry = await screen.findByTestId('studio-landing-org-scope'); - expect(entry).toHaveTextContent('Flows in no app'); - expect(screen.queryByTestId('studio-landing-org-scope-count')).not.toBeInTheDocument(); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.packagesDoor-35196.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.packagesDoor-35196.test.tsx deleted file mode 100644 index e903ad37d45..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.packagesDoor-35196.test.tsx +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#35196 — the served Studio's door to package management. - * - * Ruling 甲 (objectstack#25098) puts the unfiltered package list in Studio - * only. The `@objectstack/studio` app whose Overview → Packages entry names it - * is not default-loaded, so on a default boot the Studio is the console's own, - * at `/studio`, and its landing is the door: each package card carries Manage, - * which opens the package's detail sheet (the one the top-bar switcher's - * "Package info & settings" opens), and the title row links to the unfiltered - * Packages page. - * - * Read off the real `BuilderLanding` and the real `PackageDetailSheet`. The - * sheet's Disable is the served `disableable` verdict and its Enable follows a - * disabled record, so the cases hold one package of each kind, with a - * read-only package the server does not let be disabled as the control. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; -import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config'; - -/** A code-loaded module of an installed app: the server serves `disableable: true`. */ -const MODULE = { id: 'com.example.multi.orders', name: 'Multi-Package Orders' }; -/** A code-loaded app: read-only, and the disable door refuses it. */ -const APP = { id: 'com.example.multi.core', name: 'Multi-Package Core' }; -/** A module already switched off. */ -const DISABLED = { id: 'com.example.multi.extras', name: 'Multi-Package Extras' }; -/** The author's own writable base. */ -const OWN = { id: 'com.acme.mine', name: 'My App' }; - -const entries = [ - { ...MODULE, writable: false, namespace: 'crm' }, - { ...APP, writable: false, namespace: 'crm' }, - { ...DISABLED, writable: false, namespace: 'crm' }, - { ...OWN, writable: true, namespace: 'mine' }, -]; - -/** `GET /api/v1/packages` as the wire serves it: the full rows the sheet opens on. */ -const servedRows = [ - { manifest: { ...MODULE, version: '1.0.0', type: 'module' }, source: 'code', writable: false, disableable: true, enabled: true, status: 'installed' }, - { manifest: { ...APP, version: '1.0.0', type: 'app' }, source: 'code', writable: false, disableable: false, enabled: true, status: 'installed' }, - { manifest: { ...DISABLED, version: '1.0.0', type: 'module' }, source: 'code', writable: false, disableable: true, enabled: false, status: 'disabled' }, - { manifest: { ...OWN, version: '0.1.0', type: 'app' }, source: 'authored', writable: true, disableable: true, enabled: true, status: 'installed' }, -]; - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => entries), - fetchListedPackageIds: vi.fn(async () => new Set(entries.map((e) => e.id))), - }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); - -import { BuilderLanding, STUDIO_ALL_PACKAGES_PATH } from './BuilderLanding'; - -const json = (body: unknown, status = 200) => - ({ ok: status < 400, status, json: async () => body, text: async () => JSON.stringify(body) }) as Response; - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); - resetRuntimeConfigForTesting(); -}); - -async function renderLanding() { - resetRuntimeConfigForTesting(); - vi.stubGlobal( - 'fetch', - vi.fn(async (input: RequestInfo | URL) => { - const url = String(input); - if (/\/api\/v1\/packages(\?|$)/.test(url)) return json({ success: true, data: { packages: servedRows } }); - if (url.includes('/api/v1/meta/_drafts')) return json({ drafts: [] }); - return json({ features: { installLocal: false, marketplace: false } }); - }), - ); - await initRuntimeConfig(); - render( - - - } /> - - , - ); - await screen.findByText(MODULE.name); -} - -/** The card for `id`, and its Manage button. */ -function manageOn(id: string): HTMLElement { - const card = document.querySelector(`[data-package-id="${id}"]`); - if (!card) throw new Error(`no card for ${id}`); - return within(card).getByTestId('studio-landing-manage'); -} - -/** Opens `id`'s sheet from its card and answers the sheet's action names. */ -async function openSheet(id: string, name: string): Promise { - fireEvent.click(manageOn(id)); - const sheet = await screen.findByRole('dialog'); - await within(sheet).findByText(name); - return within(sheet) - .getAllByRole('button') - .map((b) => (b.textContent ?? '').trim()) - .filter(Boolean); -} - -describe('the Studio landing is the served door to package management (objectstack#35196)', () => { - it('a code-loaded module the server lets be disabled opens a sheet with Disable', async () => { - await renderLanding(); - expect(await openSheet(MODULE.id, MODULE.name)).toContain('Disable'); - }); - - it('control: a read-only app the disable door refuses opens a sheet without Disable', async () => { - await renderLanding(); - const actions = await openSheet(APP.id, APP.name); - expect(actions).not.toContain('Disable'); - expect(actions).not.toContain('Enable'); - }); - - it('a disabled package opens a sheet with Enable, so switching it back on stays one click from the landing', async () => { - await renderLanding(); - const actions = await openSheet(DISABLED.id, DISABLED.name); - expect(actions).toContain('Enable'); - expect(actions).not.toContain('Disable'); - }); - - it("every card carries Manage, the author's own apps included", async () => { - await renderLanding(); - for (const { id } of entries) expect(manageOn(id)).toBeInTheDocument(); - expect(await openSheet(OWN.id, OWN.name)).toContain('Disable'); - }); - - it('the title row links to the unfiltered Packages page', async () => { - await renderLanding(); - const link = screen.getByTestId('studio-landing-all-packages'); - expect(link).toHaveAttribute('href', '/apps/setup/component/developer/packages'); - expect(STUDIO_ALL_PACKAGES_PATH).toBe('/apps/setup/component/developer/packages'); - // Unfiltered: no `source` query narrows it to the marketplace view. - expect(link.getAttribute('href')).not.toContain('source='); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.readonlyRoutes-11808.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.readonlyRoutes-11808.test.tsx deleted file mode 100644 index 6f8048e485f..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.readonlyRoutes-11808.test.tsx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#11808 — a read-only package's Studio landing card points at the - * routes that exist for it, and Duplicate stays on writable bases. - * - * ADR-0070 D4's Duplicate clones a writable base; a code or installed package - * is customized by org overlay where the item's metadata type declares - * `allowEnvironmentOverlay` (ADR-0005). Measured before this card: the read-only card - * was one button that opened the package for browsing, with no route forward. - * The overlay link this card added, into Setup's metadata directory, retired - * with that directory (objectstack ADR-0146 D1, N-28): an item is customized in - * Studio now. - * - * The routes are read off the real `BuilderLanding` under a real router: the - * card opens the package for browsing, and the marketplace link appears only - * when the runtime serves a marketplace — read through the - * REAL `initRuntimeConfig()` over a stubbed `GET /api/v1/runtime/config`, the - * way `HomePage.marketplaceDisabled.test.tsx` drives the same flag. - */ - -import '@testing-library/jest-dom/vitest'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; -import { t } from '../metadata-admin/i18n'; -import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config'; - -const packages = vi.hoisted(() => ({ list: [] as Array> })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, fetchPackages: vi.fn(async () => packages.list) }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); - -import { BuilderLanding } from './BuilderLanding'; - -const READ_ONLY = { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }; -const WRITABLE = { id: 'com.acme.app', name: 'Acme', writable: true, namespace: 'acme' }; - -afterEach(() => { - cleanup(); - packages.list = []; - vi.unstubAllGlobals(); - resetRuntimeConfigForTesting(); -}); - -/** Boot the REAL runtime-config module over a served `/runtime/config` body. */ -async function bootRuntime(features: Record) { - resetRuntimeConfigForTesting(); - vi.stubGlobal( - 'fetch', - vi.fn(async () => { - const body = { features: { installLocal: false, ...features } }; - return { ok: true, status: 200, json: async () => body, text: async () => JSON.stringify(body) } as Response; - }), - ); - await initRuntimeConfig(); -} - -function LocationProbe() { - const { pathname, search } = useLocation(); - return
{`${pathname}${search}`}
; -} - -function renderLanding() { - return render( - - - - } /> - } /> - } /> - - , - ); -} - -/** The card a package renders in: the element holding both its name and its links. */ -function cardOf(name: string): HTMLElement { - const card = screen.getByText(name).closest('.rounded-lg.border'); - if (!(card instanceof HTMLElement)) throw new Error(`no card found for ${name}`); - return card; -} - -describe('Studio landing: a read-only package points at the routes it has (objectui#11808)', () => { - it('the read-only card carries no link into Setup’s metadata directory (ADR-0146 D1)', async () => { - // objectui#11808 linked the card to `/apps/setup/metadata?package=…`, the - // overlay route. N-28 retired Setup's metadata directory into Studio's "All - // metadata" area, so the card opens the package itself (below) and links - // nowhere into Setup's metadata pages. - await bootRuntime({ marketplace: true }); - packages.list = [READ_ONLY]; - renderLanding(); - - await screen.findByText('Showcase'); - expect(screen.getByTestId('studio-landing-readonly-hint')).toBeInTheDocument(); - expect(within(cardOf('Showcase')).queryByTestId('studio-landing-overlay')).not.toBeInTheDocument(); - for (const link of within(cardOf('Showcase')).queryAllByRole('link')) { - expect(link.getAttribute('href') ?? '').not.toMatch(/^\/apps\/setup\/metadata/); - } - }); - - it('still opens the read-only package for browsing from the card itself', async () => { - await bootRuntime({ marketplace: true }); - packages.list = [READ_ONLY]; - renderLanding(); - - fireEvent.click(await screen.findByText('Showcase')); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.example.showcase/data')); - }); - - it('offers Duplicate on a writable base only, never on a read-only package (ADR-0070 D4)', async () => { - await bootRuntime({ marketplace: true }); - packages.list = [WRITABLE, READ_ONLY]; - renderLanding(); - - await screen.findByText('Showcase'); - const dupTitle = t('engine.studio.landing.dupTitle', 'en-US'); - expect(within(cardOf('Acme')).getByTitle(dupTitle)).toBeInTheDocument(); - expect(within(cardOf('Showcase')).queryByTitle(dupTitle)).not.toBeInTheDocument(); - }); - - it('links the marketplace when the runtime serves one', async () => { - await bootRuntime({ marketplace: true }); - packages.list = [READ_ONLY]; - renderLanding(); - - const marketplace = await screen.findByTestId('studio-landing-marketplace'); - expect(marketplace).toHaveAttribute('href', '/apps/setup/system/marketplace'); - fireEvent.click(marketplace); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/apps/setup/system/marketplace')); - expect(screen.getByTestId('marketplace')).toBeInTheDocument(); - }); - - it('offers no marketplace link on a runtime without one', async () => { - await bootRuntime({ marketplace: false }); - packages.list = [READ_ONLY]; - renderLanding(); - - await screen.findByText('Showcase'); - expect(screen.queryByTestId('studio-landing-marketplace')).not.toBeInTheDocument(); - expect(screen.getByTestId('studio-landing-readonly-hint')).toBeInTheDocument(); - }); - - it('renders no read-only section at all when every package is writable', async () => { - await bootRuntime({ marketplace: true }); - packages.list = [WRITABLE]; - renderLanding(); - - await screen.findByText('Acme'); - expect(screen.queryByTestId('studio-landing-readonly-hint')).not.toBeInTheDocument(); - expect(screen.queryByTestId('studio-landing-marketplace')).not.toBeInTheDocument(); - expect(screen.queryByTestId('studio-landing-overlay')).not.toBeInTheDocument(); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx deleted file mode 100644 index d73a85e4bf9..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.recentPackages-11863.test.tsx +++ /dev/null @@ -1,399 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#11863 (Q3) — the Studio landing lists the packages the author was - * last in, above its package cards. - * - * A recent `package` entry stores the package's identity and no label - * (objectui#11678's shape); the landing labels it from the package list it - * loads, on every render. So these cases pin what that buys and what it must - * not regress into: - * - * - the label is the package's CURRENT name: a rename between the visit and - * the render shows the new one, and no entry is drawn as its raw id while a - * live package is behind it; - * - a package the list no longer has is not listed at all (objectstack#32615: - * it used to draw its machine name and open an empty builder), while a - * package the list names but the cards hide — a kernel package — still is; - * - nothing is listed before the list answers, or when there are no recent - * packages, and the existing cards stay. - * - * The store is the REAL `RecentItemsProvider`, seeded through the localStorage - * copy it hydrates from (no signed-in user here, so the key is unscoped). - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, 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'; - -const packages = vi.hoisted(() => ({ - list: [] as Array>, - /** Ids the list names that the cards hide (kernel packages): `fetchListedPackageIds` only. */ - hidden: [] as string[], - /** When set, `fetchPackages` waits for it, so the loading window can be observed. */ - gate: null as Promise | null, -})); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => { - if (packages.gate) await packages.gate; - return packages.list; - }), - // The same answer's every id, the kernel packages the cards hide included. - fetchListedPackageIds: vi.fn(async () => { - if (packages.gate) await packages.gate; - return new Set([...packages.list.map((p) => String(p.id)), ...packages.hidden]); - }), - }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); -// A read-only base's customization read (ADR-0146 D3) is not under test here: -// it stays pending, so no request leaves the file. -vi.mock('./packageCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - fetchPackageCustomizations: vi.fn(() => new Promise(() => {})), -})); - -// The package-less flow count the landing draws (objectstack#34715) is not under -// test here: no flow belongs to no package, and no request leaves the file. -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, loadPackageLessSurfaces: vi.fn(async () => []) }; -}); - -import { BuilderLanding } from './BuilderLanding'; -import { RecentItemsProvider } from '../../context/RecentItemsProvider'; - -/** The key `RecentItemsProvider` hydrates from with no signed-in user. */ -const STORAGE_KEY = 'objectui-recent-items'; - -const at = '2026-10-08T09:00:00.000Z'; -const visit = (id: string) => ({ - id: `package:${id}`, - type: 'package', - name: id, - href: `/studio/${encodeURIComponent(id)}`, - visitedAt: at, -}); - -afterEach(() => { - cleanup(); - localStorage.clear(); - packages.list = []; - packages.hidden = []; - packages.gate = null; -}); - -function LocationProbe() { - const { pathname } = useLocation(); - return
{pathname}
; -} - -function renderLanding(stored: unknown[]) { - localStorage.setItem(STORAGE_KEY, JSON.stringify(stored)); - return render( - - - - - } /> - } /> - } /> - - - , - ); -} - -const recentSection = () => screen.getByTestId('studio-landing-recent'); -const recentLinks = () => within(recentSection()).getAllByRole('link'); - -describe('Studio landing → recent packages (objectui#11863)', () => { - it('with a recent visit, the installed apps still lead the page: the list follows the author’s own apps (objectstack#34715)', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }, - ]; - renderLanding([visit('com.example.showcase')]); - - await screen.findByText('Recently viewed'); - expect(screen.getAllByRole('heading', { level: 2 }).map((h) => h.textContent)).toEqual([ - 'Installed apps', - 'Customizations in this environment', - 'Your own apps', - 'Recently viewed', - 'Outside any app', - ]); - }); - - it('lists the most recent packages first, each by its current name, each opening its /studio/PKG route', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }, - ]; - renderLanding([visit('com.example.showcase'), visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - const links = recentLinks(); - expect(links.map((a) => a.querySelector('.font-medium')?.textContent)).toEqual(['Showcase', 'Acme CRM']); - expect(links.map((a) => a.getAttribute('href'))).toEqual(['/studio/com.example.showcase', '/studio/com.acme.crm']); - - fireEvent.click(links[1]); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.acme.crm')); - expect(screen.getByTestId('package-route')).toBeInTheDocument(); - }); - - it('a package renamed since the visit shows its new name: the label is read on the render, never stored', async () => { - // The visit happened while the package was called something else; the - // stored entry carries no text from that moment to go stale. - // A second app the row does not repeat keeps it drawn (objectstack#35018). - packages.list = [ - { id: 'com.acme.crm', name: 'Acme Sales', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - const [link] = recentLinks(); - expect(within(link).getByText('Acme Sales')).toBeInTheDocument(); - expect(within(link).queryByText('Acme CRM')).not.toBeInTheDocument(); - }); - - it('lists only package entries, and at most one row of three', async () => { - packages.list = ['a', 'b', 'c', 'd'].map((x) => ({ - id: `com.acme.${x}`, - name: `Pkg ${x.toUpperCase()}`, - writable: true, - namespace: `acme${x}`, - })); - renderLanding([ - visit('com.acme.a'), - { id: 'object:showcase_task', type: 'object', name: 'showcase_task', href: '/apps/showcase/showcase_task', visitedAt: at }, - visit('com.acme.b'), - visit('com.acme.c'), - visit('com.acme.d'), - ]); - - await screen.findByText('Recently viewed'); - expect(recentLinks().map((a) => a.querySelector('.font-medium')?.textContent)).toEqual([ - 'Pkg A', - 'Pkg B', - 'Pkg C', - ]); - }); - - it('nothing is listed while the package list loads, so no entry is drawn as its id', async () => { - let release!: () => void; - packages.gate = new Promise((resolve) => { - release = resolve; - }); - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.crm')]); - - expect(screen.getByText('Loading…')).toBeInTheDocument(); - expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); - expect(screen.queryByText('com.acme.crm')).not.toBeInTheDocument(); - - release(); - await screen.findByText('Recently viewed'); - expect(within(recentSection()).getByText('Acme CRM')).toBeInTheDocument(); - }); - - it('with no recent package there is no section, and the package cards are unchanged', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; - renderLanding([ - { id: 'object:showcase_task', type: 'object', name: 'showcase_task', href: '/apps/showcase/showcase_task', visitedAt: at }, - ]); - - await screen.findByText('Acme CRM'); - expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); - expect(screen.queryByText('Recently viewed')).not.toBeInTheDocument(); - expect(screen.getByText('Your own apps')).toBeInTheDocument(); - expect(screen.getByTestId('studio-landing-env-catalog')).toBeInTheDocument(); - }); - - it('the package cards stay beside the recent row', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - // Once in the recent row, once as its writable card. - expect(screen.getAllByText('Acme CRM')).toHaveLength(2); - expect(screen.getByText('Your own apps')).toBeInTheDocument(); - }); -}); - -describe('Studio landing → a deleted package leaves "Recently viewed" (objectstack#32615)', () => { - it('a package the list no longer has is not listed; CONTROL — a live one beside it is', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.gone'), visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - expect(recentLinks().map((a) => a.getAttribute('href'))).toEqual(['/studio/com.acme.crm']); - expect(screen.queryByText('com.acme.gone')).not.toBeInTheDocument(); - }); - - it('the gone entry does not take a slot of the row: the next live packages fill it', async () => { - // A fourth app, never visited, keeps the row from repeating the cards (objectstack#35018). - packages.list = ['a', 'b', 'c', 'd'].map((x) => ({ - id: `com.acme.${x}`, - name: `Pkg ${x.toUpperCase()}`, - writable: true, - namespace: `acme${x}`, - })); - renderLanding([visit('com.acme.gone'), visit('com.acme.a'), visit('com.acme.b'), visit('com.acme.c')]); - - await screen.findByText('Recently viewed'); - expect(recentLinks().map((a) => a.querySelector('.font-medium')?.textContent)).toEqual([ - 'Pkg A', - 'Pkg B', - 'Pkg C', - ]); - }); - - it('only gone packages: no section at all', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; - renderLanding([visit('com.acme.gone')]); - - await screen.findByText('Acme CRM'); - expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); - }); - - it('CONTROL — a kernel package the cards hide is installed, so its entry stays', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; - packages.hidden = ['com.objectstack.platform']; - renderLanding([visit('com.objectstack.platform'), visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - expect(recentLinks().map((a) => a.getAttribute('href'))).toEqual([ - '/studio/com.objectstack.platform', - '/studio/com.acme.crm', - ]); - }); - - it('the stored entry is kept: filtered on the render, never dropped from the store here', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.gone'), visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - const stored = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]') as Array<{ id: string }>; - expect(stored.map((e) => e.id)).toEqual(['package:com.acme.gone', 'package:com.acme.crm']); - }); -}); - -/** The own-app section's card for `id`. */ -const ownCard = (id: string) => { - const card = screen.getByTestId('studio-landing-own').querySelector(`[data-package-id="${id}"]`); - if (!(card instanceof HTMLElement)) throw new Error(`no own-app card for ${id}`); - return card; -}; - -describe('Studio landing → an own-app card shows the app, not its package (objectstack#35018)', () => { - it('names no package id and carries no Writable badge on its face', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }, - ]; - renderLanding([]); - - await screen.findByText('Acme CRM'); - const card = ownCard('com.acme.crm'); - expect(within(card).getByText('Acme CRM')).toBeInTheDocument(); - expect(card.textContent).not.toContain('com.acme.crm'); - expect(within(card).queryByText('Writable')).not.toBeInTheDocument(); - // Nowhere on the page: an installed app's card carries no such badge either. - expect(screen.queryByText('Writable')).not.toBeInTheDocument(); - }); - - it('keeps the package id reachable, as the card’s hover title', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; - renderLanding([]); - - await screen.findByText('Acme CRM'); - expect(within(ownCard('com.acme.crm')).getByTitle('com.acme.crm')).toBeInTheDocument(); - }); -}); - -describe('Studio landing → a "Recently viewed" entry shows the app, not its package (objectstack#35018)', () => { - it('shows the name and not the id; the id is the entry’s hover title', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - const [link] = recentLinks(); - expect(within(link).getByText('Acme CRM')).toBeInTheDocument(); - expect(link.textContent).not.toContain('com.acme.crm'); - expect(within(recentSection()).getByTitle('com.acme.crm')).toBe(link); - }); -}); - -describe('Studio landing → "Recently viewed" is left out when it only repeats the cards (objectstack#35018)', () => { - it('one recent visit to the only app: no row', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; - renderLanding([visit('com.acme.crm')]); - - await screen.findByText('Acme CRM'); - expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); - expect(screen.queryByText('Recently viewed')).not.toBeInTheDocument(); - expect(screen.getAllByText('Acme CRM')).toHaveLength(1); - }); - - it('every card visited, in any order, installed apps included: no row', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }, - ]; - renderLanding([visit('com.example.showcase'), visit('com.acme.crm')]); - - await screen.findByText('Acme CRM'); - expect(screen.queryByTestId('studio-landing-recent')).not.toBeInTheDocument(); - }); - - it('CONTROL — a recent app no card shows keeps the row', async () => { - packages.list = [{ id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }]; - packages.hidden = ['com.objectstack.platform']; - renderLanding([visit('com.acme.crm'), visit('com.objectstack.platform')]); - - await screen.findByText('Recently viewed'); - expect(recentLinks().map((a) => a.getAttribute('href'))).toEqual([ - '/studio/com.acme.crm', - '/studio/com.objectstack.platform', - ]); - }); - - it('CONTROL — a card the row does not repeat keeps the row', async () => { - packages.list = [ - { id: 'com.acme.crm', name: 'Acme CRM', writable: true, namespace: 'acme' }, - { id: 'com.acme.hr', name: 'Acme HR', writable: true, namespace: 'acmehr' }, - ]; - renderLanding([visit('com.acme.crm')]); - - await screen.findByText('Recently viewed'); - expect(recentLinks().map((a) => a.getAttribute('href'))).toEqual(['/studio/com.acme.crm']); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.setupExit-12513.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.setupExit-12513.test.tsx deleted file mode 100644 index e34deac531d..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.setupExit-12513.test.tsx +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectui#12513 gave the installed card's link into Setup an "Open in Setup" - * label and an outward arrow, so it said that it left Studio. objectstack - * ADR-0146 D1 (N-28) retired the page it opened: Setup's metadata directory - * redirects into Studio's "All metadata" area, so the link would have left - * Studio only to come straight back. The card now carries no Setup exit, and - * the Packaged automation route Studio built (`packagedAutomationPath`) went - * with that page (D11). - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, render, screen } from '@testing-library/react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; - -const packages = vi.hoisted(() => ({ list: [] as Array> })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => packages.list), - // The landing reads the list's ids beside its entries (the same request, - // objectstack#32615): both are answered by this double, never the network. - fetchListedPackageIds: vi.fn(async () => new Set(packages.list.map((p) => String(p.id)))), - }; -}); - -// The create dialog is closed throughout; its form stack is not under test. -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); -// A read-only base's customization read (ADR-0146 D3) is not under test here: -// it stays pending, so no request leaves the file. -vi.mock('./packageCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - fetchPackageCustomizations: vi.fn(() => new Promise(() => {})), -})); - -// The package-less flow count the landing draws (objectstack#34715) is not under -// test here: no flow belongs to no package, and no request leaves the file. -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { ...mod, loadPackageLessSurfaces: vi.fn(async () => []) }; -}); - -import * as landing from './BuilderLanding'; - -const { BuilderLanding } = landing; - -const READ_ONLY = { id: 'com.example.showcase', name: 'Showcase', writable: false, namespace: 'showcase' }; - -afterEach(() => { - cleanup(); - packages.list = []; -}); - -function renderLanding() { - return render( - - - } /> - - , - ); -} - -describe('Studio landing: the installed card has no Setup exit (objectui#12513, ADR-0146 D1)', () => { - it('a read-only package card links nowhere into Setup', async () => { - packages.list = [READ_ONLY]; - renderLanding(); - - await screen.findByText('Showcase'); - expect(screen.queryByTestId('studio-landing-overlay')).toBeNull(); - expect(screen.queryByText('Open in Setup')).toBeNull(); - for (const link of screen.queryAllByRole('link')) { - expect(link.getAttribute('href') ?? '').not.toMatch(/^\/apps\/setup\/metadata/); - } - }); - - it('no longer builds the overlay route into Setup’s metadata directory', () => { - expect('overlayPath' in landing).toBe(false); - }); - - it('no longer builds the Packaged automation route (ADR-0146 D11)', () => { - // Setup › Packaged automation retired: its flows half is Studio's, so - // Studio builds no route to it (`nav_packaged_automation` is tombstoned). - expect('packagedAutomationPath' in landing).toBe(false); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.taskOrder-34715.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.taskOrder-34715.test.tsx deleted file mode 100644 index e9df738cca6..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.taskOrder-34715.test.tsx +++ /dev/null @@ -1,221 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#34715 — the Studio landing is ordered by what the author came to - * do, and its copy names no package mechanism. - * - * The installed apps lead (changing one is the likeliest errand), the - * author's own apps and the create card follow, and the entries that belong - * to no app come last. An installed app's card carries a Customize button that - * opens it the way the card does, says "No changes yet" when nothing is - * changed, and shows no package id on its face. In Chinese the page body - * carries none of 「.custom」「基座」「只读」; in English none of ".custom", - * "read-only", "writable base". - * - * Read off the real `BuilderLanding` under a real router, in English and in - * Chinese; the package list, the customization read and the package-less flow - * count are answered by doubles, so no request leaves the file. - */ - -import '@testing-library/jest-dom/vitest'; -// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. -import '@objectstack/lint'; -import * as React from 'react'; -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; -import { I18nProvider, createI18n } from '@object-ui/i18n'; -import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; -await loadStudioCatalogue('zh'); - -const packages = vi.hoisted(() => ({ list: [] as Array> })); -const counts = vi.hoisted(() => ({ byId: {} as Record })); - -vi.mock('./packages-io', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - fetchPackages: vi.fn(async () => packages.list), - fetchListedPackageIds: vi.fn(async () => new Set(packages.list.map((p) => String(p.id)))), - }; -}); -vi.mock('../metadata-admin/PackageFormDialog', () => ({ PackageFormDialog: () => null })); -vi.mock('./packageCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - // A served answer whose lists are as long as the counts asked for: `customized` view overrides, `switchedOff` flows. - fetchPackageCustomizations: vi.fn(async (id: string) => { - const { customized, switchedOff } = counts.byId[id] ?? { customized: 0, switchedOff: 0 }; - return { - packageId: id, - overrides: Array.from({ length: customized }, (_, i) => ({ type: 'view', name: `view_${i}` })), - extensions: [], - switchedOff: Array.from({ length: switchedOff }, (_, i) => ({ type: 'flow', name: `flow_${i}` })), - arrangements: [], - contributions: [], - counts: { overrides: customized, extensions: 0, switchedOff, arrangements: 0, contributions: 0 }, - }; - }), -})); -// The panel's label read (objectstack#34714) is not under test here: rows keep their names. -vi.mock('./landingCustomizations-io', async (importOriginal) => ({ - ...(await importOriginal()), - loadCustomizationLabels: vi.fn(async () => ({})), -})); -vi.mock('./packageSurfaces', async (importOriginal) => { - const mod = await importOriginal(); - return { - ...mod, - loadPackageLessSurfaces: vi.fn(async () => [ - { type: 'flow', name: 'org_flow_a', label: 'Org flow A' }, - { type: 'flow', name: 'org_flow_b', label: 'Org flow B' }, - ]), - }; -}); - -import { BuilderLanding } from './BuilderLanding'; -import { parsePackages } from './packages-io'; - -const HOTCRM = { id: 'app.objectstack.hotcrm', name: 'HotCRM', writable: false, namespace: 'crm' }; -const SERVICE = { id: 'app.objectstack.service', name: 'HotCRM Service', writable: false, namespace: 'svc' }; -const OWN = { id: 'com.acme.app', name: 'Acme', writable: true, namespace: 'acme' }; - -afterEach(() => { - cleanup(); - packages.list = []; - counts.byId = {}; -}); - -function LocationProbe() { - const { pathname } = useLocation(); - return
{pathname}
; -} - -function renderLanding(lang: 'en' | 'zh' = 'en') { - const landing = ( - - - - } /> - } /> - - - ); - if (lang === 'en') return render(landing); - const zh = createI18n({ defaultLanguage: 'zh', detectBrowserLanguage: false, resources: { zh: {} } }); - return render({landing}); -} - -/** The landing's body: every rendered word, the location probe left out. */ -function bodyText(): string { - const probe = screen.getByTestId('location'); - return (document.body.textContent ?? '').replace(probe.textContent ?? '', ''); -} - -/** Section headings in page order. */ -const headings = () => screen.getAllByRole('heading', { level: 2 }).map((h) => h.textContent); - -describe('Studio landing: ordered by what the author came to do (objectstack#34715)', () => { - it('installed apps come first, then the author’s own apps, then the entries outside any app', async () => { - packages.list = [OWN, HOTCRM, SERVICE]; - renderLanding(); - - await screen.findByText('HotCRM'); - expect(headings()).toEqual(['Installed apps', 'Customizations in this environment', 'Your own apps', 'Outside any app']); - const installed = screen.getByTestId('studio-landing-installed'); - // DOM order: each installed card precedes the author's own card. - const own = screen.getByTestId('studio-landing-own'); - expect(installed.compareDocumentPosition(own) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); - expect(within(own).getByText('Acme')).toBeInTheDocument(); - expect(within(own).getByTestId('studio-landing-new-app')).toHaveTextContent('New app of your own'); - }); - - it('every installed card carries Customize, which opens the app the way the card does', async () => { - packages.list = [HOTCRM, SERVICE]; - renderLanding(); - - await screen.findByText('HotCRM'); - expect(screen.getAllByTestId('studio-landing-customize')).toHaveLength(2); - - fireEvent.click(screen.getByRole('button', { name: 'Customize HotCRM' })); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/app.objectstack.hotcrm/data')); - expect(screen.getByTestId('pillar-builder')).toBeInTheDocument(); - }); - - it('an installed card shows no package id on its face, and says "No changes yet" when nothing is changed', async () => { - packages.list = [HOTCRM, SERVICE]; - counts.byId = { 'app.objectstack.hotcrm': { customized: 6, switchedOff: 1 } }; - renderLanding(); - - const installed = await screen.findByTestId('studio-landing-installed'); - await waitFor(() => - expect(within(installed).getAllByTestId('studio-landing-customizations').map((l) => l.textContent)).toEqual([ - '6 customized, 1 switched off', - 'No changes yet', - ]), - ); - expect(installed.textContent).not.toContain('app.objectstack'); - // The id is still there to read, in the card's title. - expect(installed.querySelector('[data-package-id="app.objectstack.hotcrm"]')).toHaveAttribute( - 'title', - 'app.objectstack.hotcrm', - ); - }); - - it('a system package served flat with a kernel scope is no installed app: no card, no Customize (comment 6943119575)', async () => { - // The list as the registry half serves a hosted environment: a `sys.*` - // package whose kernel `scope` is flat, beside an installed app. - const parsed = parsePackages({ - data: [ - { id: 'sys.package-state', name: 'Package State', scope: 'system', writable: false }, - { id: 'sys.env-artifact-cache', name: 'Environment Artifact Cache', scope: 'cloud', writable: false }, - { manifest: { id: 'app.objectstack.hotcrm', name: 'HotCRM', namespace: 'crm' }, writable: false }, - ], - }); - // CONTROL: the parser keeps the flat kernel rows, tagged — the landing is what drops them. - expect(parsed.filter((p) => p.kernel).map((p) => p.id)).toEqual(['sys.package-state', 'sys.env-artifact-cache']); - packages.list = parsed.map((p) => ({ ...p })); - renderLanding(); - - const installed = await screen.findByTestId('studio-landing-installed'); - expect(within(installed).getByText('HotCRM')).toBeInTheDocument(); - expect(within(installed).getAllByTestId('studio-landing-customize')).toHaveLength(1); - expect(document.querySelector('[data-package-id^="sys."]')).toBeNull(); - expect(bodyText()).not.toMatch(/Package State|Environment Artifact Cache/u); - }); - - it('positions and permissions keep their Studio entry under the new name', async () => { - packages.list = [HOTCRM]; - renderLanding(); - - const entry = await screen.findByTestId('studio-landing-env-catalog'); - expect(entry).toHaveTextContent('Positions and permissions'); - fireEvent.click(entry); - await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent(/^\/studio\/[^/]+\/metadata$/)); - }); - - it('en-US: the body names no mechanism — no ".custom", "read-only" or "writable base"', async () => { - packages.list = [OWN, HOTCRM, SERVICE]; - renderLanding('en'); - - await screen.findByTestId('studio-landing-org-scope'); - const text = bodyText(); - // CONTROL: the body was read after the cards and both entries drew. - expect(text).toContain('HotCRM Service'); - expect(text).toContain('Flows in no app'); - expect(text).not.toMatch(/\.custom|read-only|writable base/iu); - }); - - it('zh-CN: the body carries none of 「.custom」「基座」「只读」, and installed apps lead', async () => { - packages.list = [OWN, HOTCRM, SERVICE]; - renderLanding('zh'); - - await screen.findByTestId('studio-landing-org-scope'); - expect(headings()[0]).toBe('已安装的应用'); - expect(screen.getAllByTestId('studio-landing-customize')[0]).toHaveTextContent('定制'); - expect(screen.getByTestId('studio-landing-org-scope')).toHaveTextContent('未归属的流程2'); - expect(screen.getByTestId('studio-landing-env-catalog')).toHaveTextContent('岗位与权限'); - const text = bodyText(); - expect(text).toContain('HotCRM Service'); - for (const word of ['.custom', '基座', '只读']) expect(text).not.toContain(word); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx deleted file mode 100644 index 0c635df5d9d..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ /dev/null @@ -1,846 +0,0 @@ -// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * BuilderLanding — the application builder's front door. - * - * The journey from login: Home → Studio app → the App Builder landing (this page, embedded - * in the app chrome via the `studio:builder` component ref) → pick an installed app to - * customize, or create or open an app of the author's own → the full-screen pillar - * builder (`/studio/:packageId/:tab`). Also served standalone at bare `/studio` so the - * builder is bookmarkable. - * - * The page is ordered by what the author came to do (objectstack#34715). - * Installed apps come first, because changing one is the likeliest - * errand: each card says what this deployment changed on it, "n customized, - * m switched off" (ADR-0146 D3), from the server's per-package customization - * read, and carries a Customize button that opens the app in Studio, where its - * items are customized (objectui#11808). The author's own writable bases, with - * the create card, follow. Last come the entries that belong to no app: the - * environment's positions and permissions (the "All metadata" area's - * cross-package leg, ADR-0146 D1 keeps it in Studio), and the organization's - * package-less flows (objectui#11553), shown only when there are any. - * Writability is the server's verdict read by packages-io (`PkgEntry.writable`, - * ADR-0070 D2), and the server's write gate stays the authority. The page's - * copy says what the author can do; it names no package mechanism. - * - * objectstack#35196 — this page is the served Studio's door to package - * management (the `@objectstack/studio` app whose Overview → Packages entry - * names the full list is not default-loaded; Setup → Packages opens the same - * list on its administration face only, objectstack#36834): every card - * carries Manage, which opens the same detail sheet as the top-bar - * switcher's "Package info & settings" (Disable / Enable, export, and the - * writable actions), and the title row links to the unfiltered Packages page. - */ - -import * as React from 'react'; -import { Link, useNavigate, useSearchParams } from 'react-router-dom'; -import { Boxes, Building2, Clock, Hammer, Library, List, Plus, Loader2, Copy, Settings, Store } from 'lucide-react'; -import { toast } from 'sonner'; -import { useRecentItems, type RecentNamedItem } from '../../context/RecentItemsProvider.js'; -import { useRecentItemLabel } from '../../hooks/useRecentItemLabel.js'; -import { t, tFormat, useMetadataLocale } from '../metadata-admin/i18n.js'; -import { PackageFormDialog } from '../metadata-admin/PackageFormDialog.js'; -import { PackageDetailSheet, type InstalledPackageRow } from '../metadata-admin/PackagesPage.js'; -import { packagesHref } from '../metadata-admin/packageSource.js'; -import { formatMetadataError } from '@object-ui/data-objectstack'; -import { fetchInstalledPackageRow } from './PackageSwitcher.js'; -import { isMarketplaceEnabled } from '../../runtime-config.js'; -import { fetchPackages, fetchListedPackageIds, duplicatePackage, isSpecPackageId, type PkgEntry } from './packages-io.js'; -import { - customizationCountsOf, - fetchPackageCustomizations, - type PackageCustomizationCounts, - type PackageCustomizations, -} from './packageCustomizations-io.js'; -import { LandingCustomizationsPanel, type AppCustomizationRead } from './LandingCustomizationsPanel.js'; -import { - readActionObjects, - switchedOffActionListPath, - switchedOffActionPath, - type ActionObjects, -} from './switchedOffActionTargets.js'; -import { customizationPackageId, isCustomizationPackage } from '@objectstack/spec/kernel'; -import { PackageIdInput } from './PackageIdInput.js'; -import { studioOrgScopePath } from './studioScope.js'; -import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaPath } from './metadataArea.js'; -import { STUDIO_NEW_PARAM, STUDIO_NEW_PACKAGE_VALUE } from './studioNewPackage.js'; -import { foldCustomizationPairs } from './StudioRailCustomizations.js'; -import { loadPackageLessSurfaces } from './packageSurfaces.js'; -import { useMetadataClient } from '../metadata-admin/useMetadata.js'; -import { newAppStep } from './newAppDoor.js'; -import { studioHomePath, studioPillarPath } from './studioAddress.js'; - -/** - * objectui#11808 — where a read-only package's card sends the author beyond - * the package itself: Home's "Start with a template" (the marketplace), when - * this runtime serves one. The card's own button opens the package in Studio, - * where Customize and the "All metadata" area are; Studio links into no Setup - * metadata page (objectstack ADR-0146 D1, Setup carries none). - */ -const MARKETPLACE_PATH = '/apps/setup/system/marketplace'; - -/** - * objectstack#35196 — the Packages page's development surface - * (`developer:packages` with no `face` and no `source`), the full list with - * every package's lifecycle and authoring actions; this landing's link is its - * menu door in the served Studio. Setup → Packages opens the same page with - * `?face=admin`, its administration face — enable / disable, delete and create - * only (objectstack#36834, amending ruling 甲 of objectstack#25098, which had - * given the list no Setup entry). The route is hosted under the Setup app's - * address, the one console app every boot loads. - */ -export const STUDIO_ALL_PACKAGES_PATH = packagesHref('/apps/setup'); - -/** objectui#11863 — how many recent packages the landing lists: one row of cards. */ -const RECENT_PACKAGES_SHOWN = 3; - -/** - * ADR-0146 D3 — one read-only base's customization line, by the state of its - * read. No entry means the read has not answered: the line shows no number. - */ -type CustomizationLine = - | { - kind: 'read'; - counts: PackageCustomizationCounts; - read: PackageCustomizations; - /** - * objectstack#34724 — which object holds each switched-off action, read - * only when the base has one (`readActionObjects`); empty when that read - * failed, so every action then links to its item page. - */ - actionObjects?: ActionObjects; - } - | { kind: 'failed'; message: string }; - -/** How many switched-off actions the landing line names before its "more" link (objectstack#34724). */ -const SWITCHED_OFF_ACTIONS_NAMED = 3; - - -export function BuilderLanding(): React.ReactElement { - const navigate = useNavigate(); - const locale = useMetadataLocale(); - const [pkgs, setPkgs] = React.useState(null); - // objectstack#32615 — every id the same list answer names, the kernel - // packages `pkgs` hides included: what "Recently viewed" is filtered by. - const [listedPackageIds, setListedPackageIds] = React.useState | null>(null); - const [error, setError] = React.useState(null); - // The new-package deep link (`studioNewPackage.ts`): Home's and the `/ai` - // screen's "New in Studio" land here with the create dialog open. Read once, - // on arrival, and dropped from the address with a replace, so a refresh or - // Back does not open the dialog a second time. The effect is keyed on the - // param's value, the primitive it reads (ui/AGENTS.md #10). - const [searchParams, setSearchParams] = useSearchParams(); - const newParam = searchParams.get(STUDIO_NEW_PARAM); - const [createOpen, setCreateOpen] = React.useState(() => newParam === STUDIO_NEW_PACKAGE_VALUE); - React.useEffect(() => { - if (newParam !== STUDIO_NEW_PACKAGE_VALUE) return; - setSearchParams( - (prev) => { - const next = new URLSearchParams(prev); - next.delete(STUDIO_NEW_PARAM); - return next; - }, - { replace: true }, - ); - }, [newParam, setSearchParams]); - - React.useEffect(() => { - let cancelled = false; - // Asked beside the entries read, so both share its one request - // (`GET /api/v1/packages`). A failure is reported once, by the entries read. - fetchListedPackageIds().then( - (ids) => { - if (!cancelled) setListedPackageIds(ids); - }, - () => {}, - ); - fetchPackages() - .then((list) => { - if (!cancelled) setPkgs(list); - }) - .catch((e) => { - if (!cancelled) setError(e instanceof Error ? e.message : String(e)); - }); - return () => { - cancelled = true; - }; - }, []); - - const open = (id: string) => navigate(studioHomePath(id)); - - // objectstack#35196 — Manage on a card: the switcher's detail sheet, opened - // on the package's full installed row (`fetchInstalledPackageRow`), so - // Disable and Enable are one click from the landing. The sheet offers - // Disable where the server's `disableable` says the door accepts it, and - // Enable on any disabled package. - const [manage, setManage] = React.useState(null); - const [manageOpen, setManageOpen] = React.useState(false); - const [manageBusy, setManageBusy] = React.useState(null); - const openManage = async (id: string) => { - setManageBusy(id); - try { - const full = await fetchInstalledPackageRow(id); - if (!full) { - // The list answered without it: removed since this page loaded. - toast.error(tFormat('engine.studio.pkg.manageMissing', locale, { id })); - return; - } - setManage(full); - setManageOpen(true); - } catch (e) { - toast.error(formatMetadataError(e)); - } finally { - setManageBusy(null); - } - }; - // A lifecycle action ran in the sheet: re-read the cards and the sheet's - // record, so a disable shows at once. A package the list no longer names - // (deleted) closes the sheet; its card goes with the refreshed list. - const onManageChanged = async () => { - const id = manage?.manifest.id; - fetchListedPackageIds().then(setListedPackageIds, () => {}); - fetchPackages().then( - (list) => setPkgs(list), - (e: unknown) => toast.error(formatMetadataError(e)), - ); - if (!id) return; - try { - const fresh = await fetchInstalledPackageRow(id); - if (fresh) setManage(fresh); - else setManageOpen(false); - } catch (e) { - // Never left open on the pre-action record: its button would offer the - // verb the author just used (the switcher's posture). - toast.error( - tFormat('engine.studio.pkg.manageRefreshFailed', locale, { id, error: formatMetadataError(e) }), - ); - setManageOpen(false); - } - }; - const manageButton = (p: PkgEntry) => ( - - ); - - // objectui#11863 — the packages the author was last in, newest first, as the - // console's route owner records them (`StudioRoute`). An entry stores the - // package's identity only, and is labelled here from the list this page just - // loaded, so a renamed package shows its new name (objectui#11678's shape). - // Listed only once that list has answered, so no entry is drawn as its id - // while it loads; nothing is listed when there are none. - // objectstack#32615 — and only a package that list still names: a package - // deleted since the visit is not listed (the delete in Studio also drops its - // entry from the store, `PackageSwitcher`). Filtered here, not dropped, for - // a package removed anywhere else: the list is the active organization's, - // and the store is the user's. - const { recentItems } = useRecentItems(); - const recentLabel = useRecentItemLabel({ packages: pkgs }); - const recentPackages = - pkgs === null || listedPackageIds === null - ? [] - : recentItems - .filter((item): item is RecentNamedItem => item.type === 'package' && listedPackageIds.has(item.name)) - .slice(0, RECENT_PACKAGES_SHOWN); - - // ADR-0146 D3 — a base's `.custom` pair has no card of its own: it is - // folded under its base, the way the package switcher folds it - // (`foldCustomizationPairs`). The base's card carries the pair through its - // customized line and link, and the pair's export and delete stay on the - // Packages page, which lists every package. A pair whose base is not listed - // keeps its card. - // - // objectstack#34715 — a kernel package (ADR-0016 §3.8: no one authors into - // it) is not an app the author installed, so it draws no card. The list - // leaves out a manifest-scoped one already; a flat-scoped one stays in it, - // tagged `kernel` (`parsePackages`), and is dropped here by the same tag the - // package switcher reads (objectstack#34593). - const cards = pkgs === null ? [] : foldCustomizationPairs(pkgs.filter((p) => !p.kernel)).rows; - const writable = cards.filter((p) => p.writable); - const readonly = cards.filter((p) => !p.writable); - - // objectstack#35018 — "Recently viewed" is drawn only when it adds something - // to the cards above it. When its entries are exactly the apps those cards - // already show (one recent visit to the only app, say), the row repeats the - // page and is left out; any entry the cards do not show, or any card it does - // not repeat, keeps the whole row. - const cardIds = new Set(cards.map((p) => p.id)); - const recentRepeatsCards = - recentPackages.length === cardIds.size && recentPackages.every((item) => cardIds.has(item.name)); - - // ADR-0146 D3 — each read-only BASE's card carries "n customized, m switched - // off", the server's counts (`GET /packages/:id/customizations`), one read - // per card drawn. A pair (`.custom`) draws no line and is never sent: - // the route refuses its id. The page does not wait for these reads. The - // effect is keyed on the joined ids, the primitive it reads (ui/AGENTS.md #10). - const customizationTargetKey = readonly - .filter((p) => !isCustomizationPackage(p.id)) - .map((p) => p.id) - .join('\n'); - const [customizationLines, setCustomizationLines] = React.useState>({}); - const metadataClient = useMetadataClient(); - // objectstack#36748 — the app half of the 「新建自己的应用」 door. - const appStep = React.useMemo(() => newAppStep(metadataClient, locale), [metadataClient, locale]); - React.useEffect(() => { - if (!customizationTargetKey) return; - let cancelled = false; - for (const id of customizationTargetKey.split('\n')) { - // objectstack#34714 — the whole answer is kept: the card draws its two - // numbers off it and the "Customizations in this environment" panel its - // rows, so one read serves both and the panel's total is the cards' sum. - fetchPackageCustomizations(id) - .then(async (read) => { - const counts = customizationCountsOf(read); - // objectstack#34724 — a switched-off action's link needs its object, - // which the ledger row does not name: read it before drawing the line. - if (!counts.switchedOffActions?.length) return { counts, read }; - const actionObjects = await readActionObjects(metadataClient, id).catch((): ActionObjects => ({})); - return { counts, read, actionObjects }; - }) - .then( - (line) => { - if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', ...line } })); - }, - (e: unknown) => { - const message = e instanceof Error ? e.message : String(e); - if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'failed', message } })); - }, - ); - } - return () => { - cancelled = true; - }; - // Keyed on the ids alone: the client only carries the reads, and a new - // client identity must not read every card again. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [customizationTargetKey]); - // objectstack#34714 — the panel's apps are the cards' bases, in card order; - // its reads are the same answers the cards draw. - const customizationApps = React.useMemo( - () => readonly.filter((p) => !isCustomizationPackage(p.id)).map((p) => ({ id: p.id, name: p.name })), - // eslint-disable-next-line react-hooks/exhaustive-deps - [customizationTargetKey, pkgs], - ); - const customizationReads = React.useMemo(() => { - const out: Record = {}; - for (const [id, line] of Object.entries(customizationLines)) { - out[id] = line.kind === 'read' ? { kind: 'read', read: line.read, actionObjects: line.actionObjects } : line; - } - return out; - }, [customizationLines]); - - // objectui#11553 — how many flows belong to no package: the same published - // and draft union the package-less scope lists (`loadPackageLessSurfaces`). - // The entry is drawn once the read says there is at least one; a failed read - // draws it with no number, so the scope stays reachable when the count is - // unknown. `null` = not answered yet. - const [packageLessFlows, setPackageLessFlows] = React.useState(null); - React.useEffect(() => { - let cancelled = false; - loadPackageLessSurfaces(metadataClient, 'flow', locale).then( - (flows) => { - if (!cancelled) setPackageLessFlows(flows.length); - }, - () => { - if (!cancelled) setPackageLessFlows('failed'); - }, - ); - return () => { - cancelled = true; - }; - // Read once per page visit: the count does not follow the display locale. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - // The pair is linked only when the package list holds it: a base with no - // pair has nothing to open, and the read never creates one. - const listedIds = new Set(pkgs?.map((p) => p.id) ?? []); - const listedPairOf = (baseId: string): string | null => { - const pair = customizationPackageId(baseId); - return pair.ok && listedIds.has(pair.value) ? pair.value : null; - }; - - const renderCustomizationLine = (baseId: string): React.ReactNode => { - if (isCustomizationPackage(baseId)) return null; - const line = customizationLines[baseId]; - const lineClass = 'text-[10px] leading-4 text-muted-foreground'; - if (!line) { - return ( -

- {t('engine.studio.landing.customizations.loading', locale)} -

- ); - } - if (line.kind === 'failed') { - // Never a "0": the read did not answer. The server's sentence is the title. - return ( -

- {t('engine.studio.landing.customizations.failed', locale)} -

- ); - } - if (line.counts.customized === 0 && line.counts.switchedOff === 0) { - // objectstack#34715 — a base this deployment has not changed says so in - // words; the Customize button beside it is the way in. - return ( -

- {t('engine.studio.landing.customizations.none', locale)} -

- ); - } - const pair = listedPairOf(baseId); - const customized = tFormat('engine.studio.landing.customizations.customized', locale, { - customized: line.counts.customized, - }); - const linkClass = 'hover:text-foreground hover:underline'; - // objectstack#34724 — the "switched off" count leads to the items: a flow's - // switch is in the Automations pillar, an action's where the action is - // drawn (`switchedOffActionPath`: its object's Actions view, or its own - // item page when no object holds it). When every switched-off item is an - // action, the count opens it (one) or the action list (several); when - // flows are among them, the count opens Automations. Whenever the count - // alone does not land on the action, the line names each switched-off - // action as a link to where it is switched (the action list marks none of - // them), up to SWITCHED_OFF_ACTIONS_NAMED, then a "more" link to the list. - const offActions = line.counts.switchedOffActions ?? []; - const actionPath = (name: string) => switchedOffActionPath(baseId, name, line.actionObjects?.[name]); - const offOnlyActions = offActions.length > 0 && offActions.length === line.counts.switchedOff; - const nameActions = offActions.length > 1 || (offActions.length > 0 && !offOnlyActions); - const namedActions = offActions.slice(0, SWITCHED_OFF_ACTIONS_NAMED); - const moreActions = offActions.length - namedActions.length; - return ( -

- {pair ? ( - - {customized} - - ) : ( - {customized} - )} - {t('engine.studio.landing.customizations.separator', locale)} - - {tFormat('engine.studio.landing.customizations.switchedOff', locale, { - switchedOff: line.counts.switchedOff, - })} - - {nameActions && ( - - {t('engine.studio.landing.customizations.separator', locale)} - {t('engine.studio.landing.customizations.switchedOffActionsLead', locale)} - {namedActions.map((name, i) => ( - - {i > 0 && t('engine.studio.landing.customizations.separator', locale)} - - {name} - - - ))} - {moreActions > 0 && ( - <> - {' '} - - {tFormat('engine.studio.landing.customizations.switchedOffActionsMore', locale, { count: moreActions })} - - - )} - - )} -

- ); - }; - - // Duplicate (ADR-0070 D4) clones a writable BASE into a new writable package, - // the "duplicate base" gesture, and drops the user straight into the copy's - // builder. It is offered on writable bases only. A read-only code or - // installed package is not a duplicate source: its items are customized in - // its paired `.custom` package through Customize or New similar (objectstack - // ADR-0146 D2, D3), never by a package-less overlay (D11), and the read-only - // section below says so. Home's "Start with a template" is not this gesture - // either: it opens the marketplace. - const [dupFor, setDupFor] = React.useState(null); - const [dupName, setDupName] = React.useState(''); - const [dupId, setDupId] = React.useState(''); - const [dupBusy, setDupBusy] = React.useState(false); - const [dupErr, setDupErr] = React.useState(null); - - const startDup = (p: PkgEntry) => { - setDupFor(p.id); - setDupName(tFormat('engine.studio.landing.dupDefaultName', locale, { name: p.name })); - setDupId(`${p.id}-copy`); - setDupErr(null); - }; - // objectui#11855 — the target id is judged by the spec's id rule, the one the - // duplicate route refuses by and the id input below shows its hint for. - const doDup = async () => { - if (!dupFor) return; - const id = dupId.trim(); - const name = dupName.trim(); - if (!isSpecPackageId(id) || !name) return; - setDupBusy(true); - setDupErr(null); - try { - await duplicatePackage(dupFor, id, name); - toast.success(tFormat('engine.studio.landing.dupCreated', locale, { name })); - open(id); - } catch (e) { - setDupErr(e instanceof Error ? e.message : String(e)); - } finally { - setDupBusy(false); - } - }; - - const headingClass = 'mb-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground'; - const entryCardClass = 'flex items-center gap-2.5 rounded-lg border bg-background px-3 py-2.5 text-left hover:bg-muted/40'; - const entryIconClass = 'flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary'; - - return ( -
-
- - - -

{t('engine.studio.landing.title', locale)}

- {/* objectstack#35196 — the unfiltered Packages page's menu door. */} - - {t('engine.studio.landing.allPackages', locale)} - -
-

- {t('engine.studio.landing.lead', locale)} -

- - {error && ( -
- {error} -
- )} - - {pkgs === null &&

{t('engine.studio.loading', locale)}

} - - {/* objectui#11808 — an installed (read-only) app is not a dead end, and - * it leads the page (objectstack#34715). ADR-0070 D2: code and - * installed packages take no new items, and D4's Duplicate clones a - * writable base, not them. The card's Customize button, like the card - * itself, opens the app in Studio, where its items are customized - * (ADR-0146 D2, D3: saved in its paired customization package); the - * card links into no Setup page (ADR-0146 D1). The app's id is not on - * the card's face, only in its title. The marketplace is offered only - * when this runtime serves one (`isMarketplaceEnabled`, objectui#5504): - * elsewhere that route does not exist. */} - {readonly.length > 0 && ( -
-
-

- {t('engine.studio.landing.appsHeading', locale)} -

- {isMarketplaceEnabled() && ( - - {t('engine.studio.landing.marketplaceInstall', locale)} - - )} -
-

- {t('engine.studio.landing.appsHint', locale)} -

-
- {readonly.map((p) => ( -
- - - -
- - {renderCustomizationLine(p.id)} -
- {/* objectstack#35196 — Customize and Manage stack in one column, - * so the card's name keeps the width it had with one button. */} -
- - {manageButton(p)} -
-
- ))} -
-
- )} - - {/* objectstack#34714 — every change this deployment made to its - * installed apps, in one list, under the apps themselves. */} - - -

{t('engine.studio.landing.ownHeading', locale)}

-
- {writable.map((p) => ( -
- {/* objectstack#35018 — the app's id is not on the card's face, only - * in its hover title, as on an installed app's card. Every app in - * this section is writable, so the card carries no badge saying so. */} -
- - {/* ADR-0070 D4 — Duplicate clones a writable base: the copy is a new - * writable package holding the base's sys_metadata rows. It is - * offered here, on writable bases only; a read-only package's card - * offers the routes that exist for it (its `.custom` pair, the - * marketplace). */} -
- - {manageButton(p)} -
-
- {dupFor === p.id && ( -
- setDupName(e.target.value)} - onKeyDown={(e) => { - if (e.key === 'Enter') void doDup(); - if (e.key === 'Escape') setDupFor(null); - }} - placeholder={t('engine.studio.landing.dupNamePlaceholder', locale)} - className="h-7 w-full rounded-md border bg-background px-2 text-[11px] outline-none focus:ring-1 focus:ring-primary" - /> - void doDup()} - onEscape={() => setDupFor(null)} - placeholder={t('engine.studio.landing.dupIdPlaceholder', locale)} - locale={locale} - testId="pkg-dup-id-input" - /> - {dupErr &&

{dupErr}

} -
- - -
-
- )} -
- ))} - - {/* 「新建自己的应用」 — opens the spec-driven create dialog - * (PackageFormDialog) as the new-app door (objectstack#36748): one - * confirm creates the package and its app, live at once. */} - -
- - open(r.id)} - /> - void onManageChanged()} - /> - - {/* objectui#11863 — the packages last opened here. objectstack#34715 - * orders the page by the errand: installed apps first, the author's own - * apps next, then the other entries, this one among them. - * objectstack#35018 — left out when it only repeats those cards. */} - {recentPackages.length > 0 && !recentRepeatsCards && ( - <> -

{t('engine.home.recent', locale)}

-
- {recentPackages.map((item) => ( - // objectstack#35018 — the app's id is only the entry's hover - // title, as on the cards above; its face shows the name. - - - - - - {recentLabel(item)} - - - ))} -
- - )} - -

{t('engine.studio.landing.outsideHeading', locale)}

-
- {/* objectstack#28561 — the "All metadata" area's cross-package leg - * (ADR-0146 D1): the environment's positions, permission sets and - * sharing rules, which have one name per deployment and may belong to - * no package (ADR-0131 D3). Named for what it holds (objectstack#34715). */} - - {/* objectui#11553 — the organization's own flows, which belong to no - * package (a clone of a packaged flow is one, by ADR-0126 §7.1). They - * match no package card above, so they get their own entry, shown - * whether or not any writable package exists, and only when there is - * at least one such flow (objectstack#34715). */} - {packageLessFlows !== null && packageLessFlows !== 0 && ( - - )} -
-
- ); -} diff --git a/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx deleted file mode 100644 index 1a26c7cc879..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * objectstack#34714 — "Customizations in this environment": the Studio - * landing's one list of every change this deployment made to its installed - * apps, so "what did we change here" is answered without opening each app. - * - * The rows are the per-app customization read the landing already makes for - * each installed app's card (ADR-0146 D3), handed in whole: one read per app - * serves both the card's numbers and these rows, so the panel's total is the - * sum of the cards' "customized" and "switched off" by construction - * (`customizationRowsOf`, `landingCustomizations-io.ts`). Other packages' - * contributions make no row. - * - * Each row names the item (its label where the app's list gives one), what - * kind of item it is, which app it belongs to and how it changed it, and opens - * the item in Studio. Tabs narrow by kind, a search narrows by text, and the - * rows can be grouped by app; the first rows show, the rest behind "Show all". - * With no change anywhere the panel is one line. An app whose read failed (a - * 403 included) is named as unreadable, never counted as 0. - */ - -import * as React from 'react'; -import { Link } from 'react-router-dom'; -import { Search } from 'lucide-react'; -import { t, tFormat } from '../metadata-admin/i18n.js'; -import { useMetadataClient } from '../metadata-admin/useMetadata.js'; -import type { PackageCustomizations } from './packageCustomizations-io.js'; -import type { ActionObjects } from './switchedOffActionTargets.js'; -import { - customizationRowsOf, - loadCustomizationLabels, - type CustomizationRow, -} from './landingCustomizations-io.js'; - -/** One app's read, as the landing holds it. */ -export type AppCustomizationRead = - | { - kind: 'read'; - read: Pick; - /** objectstack#34724 — the object holding each switched-off action (`readActionObjects`). */ - actionObjects?: ActionObjects; - } - | { kind: 'failed'; message: string }; - -/** How many rows the panel shows before "Show all". */ -export const LANDING_CUSTOMIZATION_ROWS_SHOWN = 6; - -type Tab = 'all' | 'fields' | 'views' | 'flows' | 'switchedOff'; -const TABS: readonly Tab[] = ['all', 'fields', 'views', 'flows', 'switchedOff']; - -const inTab = (row: CustomizationRow, tab: Tab): boolean => { - switch (tab) { - case 'all': - return true; - case 'fields': - return row.mode === 'added' && row.type === 'field'; - case 'views': - return row.type === 'view' || row.type === 'form'; - case 'flows': - return row.type === 'flow'; - case 'switchedOff': - return row.mode === 'switchedOff'; - } -}; - -/** The kinds the panel names in words; any other type shows as served. */ -const NAMED_TYPES = new Set(['object', 'field', 'validation', 'index', 'view', 'flow', 'page', 'dashboard', 'report', 'action']); -const K = 'engine.studio.landing.envCustomizations'; - -export function LandingCustomizationsPanel({ - apps, - reads, - locale, - headingClass, -}: { - /** The installed apps whose cards are drawn, in card order (pairs excluded). */ - apps: ReadonlyArray<{ id: string; name: string }>; - /** Each app's read, by id; an app not yet answered is absent. */ - reads: Readonly>; - locale: string; - headingClass: string; -}): React.ReactElement | null { - const rows = React.useMemo( - () => - apps.flatMap((app) => { - const r = reads[app.id]; - return r?.kind === 'read' ? customizationRowsOf(app, r.read, r.actionObjects) : []; - }), - [apps, reads], - ); - const unreadable = apps.filter((app) => reads[app.id]?.kind === 'failed'); - const pending = apps.some((app) => !reads[app.id]); - - // Labels: one read per app and type that has rows, keyed on the rows drawn - // (ui/AGENTS.md #10: the effect reads the joined keys, a primitive). - const client = useMetadataClient(); - const [labels, setLabels] = React.useState>>({}); - const labelTargetKey = [...new Set(rows.map((r) => r.appId))] - .map((id) => `${id}\u0001${rows.filter((r) => r.appId === id).map((r) => r.labelKey).join('\u0002')}`) - .join('\n'); - React.useEffect(() => { - if (!labelTargetKey) return; - let cancelled = false; - for (const id of new Set(rows.map((r) => r.appId))) { - loadCustomizationLabels(client, id, rows, locale).then( - (found) => { - if (!cancelled) setLabels((prev) => ({ ...prev, [id]: found })); - }, - () => {}, - ); - } - return () => { - cancelled = true; - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [labelTargetKey, locale]); - const labelOf = (row: CustomizationRow) => labels[row.appId]?.[row.labelKey] ?? row.name; - - const [tab, setTab] = React.useState('all'); - const [query, setQuery] = React.useState(''); - const [grouped, setGrouped] = React.useState(false); - const [expanded, setExpanded] = React.useState(false); - - if (apps.length === 0) return null; - - const typeText = (type: string) => (NAMED_TYPES.has(type) ? t(`${K}.type.${type}`, locale) : type); - const needle = query.trim().toLowerCase(); - const matches = (row: CustomizationRow) => - !needle || - [labelOf(row), row.name, row.type, typeText(row.type), row.appName, t(`${K}.mode.${row.mode}`, locale)].some((s) => - s.toLowerCase().includes(needle), - ); - const visible = rows.filter((r) => inTab(r, tab) && matches(r)); - const shown = grouped || expanded ? visible : visible.slice(0, LANDING_CUSTOMIZATION_ROWS_SHOWN); - - const renderRow = (row: CustomizationRow) => { - const label = labelOf(row); - return ( -
  • - - {label} - - - {`${t(`${K}.mode.${row.mode}`, locale)} · ${typeText(row.type)}${grouped ? '' : ` · ${row.appName}`}`} - -
  • - ); - }; - - const settled = !pending; - const nothing = settled && rows.length === 0 && unreadable.length === 0; - - return ( -
    -
    -

    {t(`${K}.heading`, locale)}

    - {rows.length > 0 && ( - - {rows.length} - - )} -
    - - {unreadable.map((app) => { - const r = reads[app.id]; - return ( -

    - {tFormat(`${K}.unreadable`, locale, { name: app.name })} -

    - ); - })} - - {pending && rows.length === 0 && ( -

    - {t(`${K}.loading`, locale)} -

    - )} - - {nothing && ( -

    - {t(`${K}.empty`, locale)} -

    - )} - - {rows.length > 0 && ( -
    -
    - {TABS.map((key) => { - const count = rows.filter((r) => inTab(r, key)).length; - return ( - - ); - })} - - -
    - - {visible.length === 0 ? ( -

    {t(`${K}.noMatch`, locale)}

    - ) : grouped ? ( - apps - .filter((app) => shown.some((r) => r.appId === app.id)) - .map((app) => ( -
    -

    {app.name}

    -
      {shown.filter((r) => r.appId === app.id).map(renderRow)}
    -
    - )) - ) : ( -
      {shown.map(renderRow)}
    - )} - - {!grouped && !expanded && visible.length > shown.length && ( - - )} -
    - )} -
    - ); -} diff --git a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx new file mode 100644 index 00000000000..acaa449d1ff --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx @@ -0,0 +1,287 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36908 — an installed app's "Customizations in this environment" + * in its Setup → Packages detail: the removed Studio home's panel + * (objectstack#34714) and its card line (ADR-0146 D3), one app at a time. + * objectstack#36833 — "customized" counts the pair's arrangements too: an app + * whose only change is a tab arrangement is customized. + * + * The real panel and the real customization reader (`packageCustomizations-io`) + * run under a real router; the wire of the customization route and the + * metadata client's list reads are stubbed. The stubbed answers are shaped by + * the route's declaration (`GetPackageCustomizationsResponseSchema`) inside + * the dispatcher envelope. + */ + +import '@testing-library/jest-dom/vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; +import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; +await loadStudioCatalogue('zh'); + +/** What the metadata client's `list(type, { packageId })` answers, by type. */ +const lists = vi.hoisted(() => ({ byType: {} as Record, asked: [] as string[] })); +vi.mock('../metadata-admin/useMetadata.js', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataClient: () => ({ + list: async (type: string, options?: { packageId?: string }) => { + lists.asked.push(`${type}@${options?.packageId}`); + return lists.byType[type] ?? []; + }, + }), +})); + +import { PACKAGE_CUSTOMIZATION_ROWS_SHOWN, PackageCustomizationsPanel } from './PackageCustomizationsPanel'; +import { customizationRowsOf, customizedCountOf, loadCustomizationLabels } from './packageCustomizationRows'; +import { t } from '../metadata-admin/i18n'; + +const APP = 'app.objectstack.hotcrm'; + +type Lists = { + overrides?: Array>; + extensions?: Array>; + arrangements?: Array>; + switchedOff?: Array>; + contributions?: Array>; +}; + +/** A served answer, its counts derived from its lists as the route derives them. */ +function served(l: Lists = {}) { + const data = { + packageId: APP, + overrides: l.overrides ?? [], + extensions: l.extensions ?? [], + arrangements: l.arrangements ?? [], + switchedOff: l.switchedOff ?? [], + contributions: l.contributions ?? [], + }; + return { + ...data, + counts: { + overrides: data.overrides.length, + extensions: data.extensions.length, + arrangements: data.arrangements.length, + switchedOff: data.switchedOff.length, + contributions: data.contributions.length, + }, + }; +} + +/** Answer the customization route with `status` and `data`; any other request is refused. */ +function stubWire(status: number, data: unknown) { + vi.stubGlobal( + 'fetch', + vi.fn(async (input: RequestInfo | URL) => { + const url = String(input); + if (url !== `/api/v1/packages/${APP}/customizations`) throw new Error(`unexpected request ${url}`); + const body = + status === 200 + ? { success: true, data } + : { success: false, error: { code: 'PERMISSION_DENIED', message: 'You may not read this package.' } }; + return { ok: status === 200, status, json: async () => body } as Response; + }), + ); +} + +function Where() { + const { pathname, search } = useLocation(); + return
    {`${pathname}${search}`}
    ; +} + +function renderPanel(locale = 'en') { + const onNavigate = vi.fn(); + render( + + + } + /> + } /> + + , + ); + return { onNavigate }; +} + +const summary = () => screen.getByTestId('pkg-detail-customizations-summary'); +const rows = () => screen.queryAllByTestId('pkg-detail-customization'); +const tab = (key: string) => screen.getByTestId(`pkg-detail-customizations-tab-${key}`); + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); + lists.byType = {}; + lists.asked = []; +}); + +describe('Setup → Packages: an installed app’s customizations (objectstack#36908)', () => { + it('lists one row per change, each saying how it changed the app, and counts them', async () => { + stubWire( + 200, + served({ + overrides: [{ type: 'view', name: 'account_list' }], + extensions: [{ object: 'account', kind: 'field', name: 'region' }], + arrangements: [{ object: 'account', key: 'relatedLists' }], + switchedOff: [{ type: 'flow', name: 'lead_nurture' }], + contributions: [{ kind: 'field', object: 'account', name: 'x', packageId: 'com.other' }], + }), + ); + lists.byType = { view: [{ name: 'account_list', label: 'All accounts' }], object: [{ name: 'account', label: 'Account' }] }; + renderPanel(); + + await waitFor(() => expect(summary()).toHaveAttribute('data-state', 'read')); + expect(summary()).toHaveTextContent('3 customized, 1 switched off'); + expect(rows().map((r) => r.getAttribute('data-mode'))).toEqual(['changed', 'added', 'arranged', 'switchedOff']); + await waitFor(() => expect(rows()[0]).toHaveTextContent('All accounts')); + expect(within(rows()[2]).getByTestId('pkg-detail-customization-meta')).toHaveTextContent('Rearranged · Tabs'); + // The label read asks the app's own lists, one per type with rows. + expect(lists.asked.sort()).toEqual([`flow@${APP}`, `object@${APP}`, `view@${APP}`]); + }); + + it('objectstack#36833: an app whose only change is a tab arrangement is customized, on its own tab', async () => { + stubWire(200, served({ arrangements: [{ object: 'account', key: 'relatedLists' }] })); + renderPanel(); + + await waitFor(() => expect(summary()).toHaveTextContent('1 customized, 0 switched off')); + expect(tab('arranged')).toHaveTextContent('1'); + expect(rows()).toHaveLength(1); + }); + + it('with no change the section says so in one line and draws no list', async () => { + stubWire(200, served()); + renderPanel(); + + await waitFor(() => expect(summary()).toHaveTextContent(t('engine.packages.customizations.none', 'en'))); + expect(rows()).toHaveLength(0); + expect(screen.queryByTestId('pkg-detail-customizations-tab-all')).toBeNull(); + }); + + it('a read that fails says so, never "0", with the server’s sentence as its title', async () => { + stubWire(403, null); + renderPanel(); + + await waitFor(() => expect(summary()).toHaveAttribute('data-state', 'failed')); + expect(summary()).toHaveTextContent(t('engine.packages.customizations.failed', 'en')); + expect(summary().getAttribute('title')).toContain('You may not read this package.'); + expect(summary()).not.toHaveTextContent('0'); + }); + + it('a row opens its item in Studio and closes the sheet; Customize in Studio opens the app', async () => { + stubWire(200, served({ extensions: [{ object: 'account', kind: 'field', name: 'region' }] })); + const { onNavigate } = renderPanel(); + + expect(screen.getByTestId('pkg-detail-customize')).toHaveAttribute('href', `/studio/${APP}/data`); + await waitFor(() => expect(rows()).toHaveLength(1)); + fireEvent.click(within(rows()[0]).getByRole('link')); + expect(await screen.findByTestId('where')).toHaveTextContent(`/studio/${APP}/metadata/object/account`); + expect(onNavigate).toHaveBeenCalled(); + }); + + it('a switched-off action opens where it is switched: its object’s Actions view (objectstack#34724)', async () => { + stubWire(200, served({ switchedOff: [{ type: 'action', name: 'clone_opportunity' }] })); + lists.byType = { object: [{ name: 'opportunity', actions: [{ name: 'clone_opportunity' }] }] }; + renderPanel(); + + await waitFor(() => expect(rows()).toHaveLength(1)); + expect(within(rows()[0]).getByRole('link')).toHaveAttribute( + 'href', + `/studio/${APP}/data?surface=object%3Aopportunity&action=clone_opportunity`, + ); + }); + + it('tabs narrow by kind and the search by text', async () => { + stubWire( + 200, + served({ + overrides: [{ type: 'view', name: 'account_list' }], + extensions: [{ object: 'account', kind: 'field', name: 'region' }], + switchedOff: [{ type: 'flow', name: 'lead_nurture' }], + }), + ); + renderPanel(); + await waitFor(() => expect(rows()).toHaveLength(3)); + + fireEvent.click(tab('fields')); + expect(rows().map((r) => r.getAttribute('data-mode'))).toEqual(['added']); + fireEvent.click(tab('all')); + fireEvent.change(screen.getByTestId('pkg-detail-customizations-search'), { target: { value: 'nurture' } }); + expect(rows().map((r) => r.getAttribute('data-mode'))).toEqual(['switchedOff']); + }); + + it(`shows the first ${PACKAGE_CUSTOMIZATION_ROWS_SHOWN} rows, the rest behind "Show all"`, async () => { + const overrides = Array.from({ length: PACKAGE_CUSTOMIZATION_ROWS_SHOWN + 2 }, (_, i) => ({ type: 'view', name: `v${i}` })); + stubWire(200, served({ overrides })); + renderPanel(); + await waitFor(() => expect(rows()).toHaveLength(PACKAGE_CUSTOMIZATION_ROWS_SHOWN)); + fireEvent.click(screen.getByTestId('pkg-detail-customizations-show-all')); + expect(rows()).toHaveLength(PACKAGE_CUSTOMIZATION_ROWS_SHOWN + 2); + }); + + it('zh-CN: the section speaks the card’s words', async () => { + stubWire(200, served({ arrangements: [{ object: 'account', key: 'relatedLists' }] })); + renderPanel('zh'); + await waitFor(() => expect(summary()).toHaveTextContent('已定制 1 项,已停用 0 项')); + expect(screen.getByText('本环境的定制')).toBeInTheDocument(); + expect(within(rows()[0]).getByTestId('pkg-detail-customization-meta')).toHaveTextContent('重新排列 · 页签'); + }); +}); + +describe('the section’s rows, count and labels (objectstack#36908)', () => { + const read = served({ + overrides: [{ type: 'view', name: 'account_list' }], + arrangements: [ + { object: 'account', key: 'fieldGroups' }, + { object: 'account', key: 'relatedLists' }, + ], + contributions: [{ kind: 'field', object: 'account', name: 'x', packageId: 'com.other' }], + }); + + it('one row per served override, extension, arrangement and switched-off item; contributions make none', () => { + expect(customizationRowsOf(APP, read).map((r) => `${r.mode}:${r.type}:${r.name}:${r.arrangement ?? ''}`)).toEqual([ + 'changed:view:account_list:', + 'arranged:object:account:fieldGroups', + 'arranged:object:account:relatedLists', + ]); + }); + + it('objectstack#36833: "customized" is overrides + extensions + arrangements', () => { + expect(customizedCountOf(read)).toBe(3); + }); + + it('a switched-off action with no object read opens its own page', () => { + const rowsOf = customizationRowsOf(APP, { ...served(), switchedOff: [{ type: 'action', name: 'export_all' }] }); + expect(rowsOf[0].href).toBe(`/studio/${APP}/metadata/action/export_all`); + }); + + it('labels come from the app’s own list of each type with rows, a field’s from its object; a failed list keeps the names', async () => { + const rowsOf = customizationRowsOf(APP, { + ...served(), + overrides: [{ type: 'view', name: 'ticket_list' }], + extensions: [{ object: 'ticket', kind: 'field', name: 'region' }], + switchedOff: [{ type: 'flow', name: 'escalate' }], + }); + const asked: string[] = []; + const client = { + list: vi.fn(async (type: string, options?: { packageId?: string }) => { + asked.push(`${type}@${options?.packageId}`); + if (type === 'flow') throw new Error('HTTP 500'); + if (type === 'view') return [{ name: 'ticket_list', label: { en: 'All tickets', zh: '全部工单' } }]; + if (type === 'object') return [{ name: 'ticket', label: 'Ticket', fields: { region: { label: 'Region' } } }]; + return []; + }), + }; + expect(await loadCustomizationLabels(client, APP, rowsOf, 'zh')).toEqual({ + 'view:ticket_list': '全部工单', + 'object:ticket': 'Ticket', + 'field:ticket.region': 'Region', + }); + expect(asked.sort()).toEqual([`flow@${APP}`, `object@${APP}`, `view@${APP}`]); + // No row, no request. + client.list.mockClear(); + expect(await loadCustomizationLabels(client, APP, [], 'en')).toEqual({}); + expect(client.list).not.toHaveBeenCalled(); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx new file mode 100644 index 00000000000..92e0b6b676d --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx @@ -0,0 +1,283 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * "Customizations in this environment" for one installed app, in its Setup → + * Packages detail (objectstack#36908, epic #36890 decision 9): what this + * deployment changed on the app, answered without opening it in Studio. + * + * It was the removed Studio home's panel over every installed app + * (objectstack#34714) and the "n customized, m switched off" line on each + * app's card (ADR-0146 D3). The home went; the package list in Setup is where + * an administrator now looks an installed app up, so the panel is drawn in + * that app's detail, one app at a time. + * + * The numbers and the rows are the server's per-package customization read + * (`GET /api/v1/packages/:id/customizations`): "customized" counts the pair's + * overrides, extensions and arrangements (objectstack#36833: an app whose only + * change is a tab arrangement is customized), "switched off" the ledger's + * switched-off items. Each row names the item (its label where the app's list + * gives one), what kind of item it is and how it changed, and opens the item + * in Studio. Tabs narrow by kind and a search by text; the first rows show, + * the rest behind "Show all". A read that fails says so, never "0". + * "Customize in Studio" opens the app there, the home card's Customize door. + */ + +import * as React from 'react'; +import { Link } from 'react-router-dom'; +import { Search, SlidersHorizontal } from 'lucide-react'; +import { t, tFormat } from '../metadata-admin/i18n.js'; +import { useMetadataClient } from '../metadata-admin/useMetadata.js'; +import { fetchPackageCustomizations } from './packageCustomizations-io.js'; +import { readActionObjects, type ActionObjects } from './switchedOffActionTargets.js'; +import { + customizationRowsOf, + customizedCountOf, + loadCustomizationLabels, + type CustomizationRow, +} from './packageCustomizationRows.js'; +import { studioHomePath } from './studioAddress.js'; + +/** How many rows the section shows before "Show all". */ +export const PACKAGE_CUSTOMIZATION_ROWS_SHOWN = 6; + +type Tab = 'all' | 'fields' | 'views' | 'flows' | 'arranged' | 'switchedOff'; +const TABS: readonly Tab[] = ['all', 'fields', 'views', 'flows', 'arranged', 'switchedOff']; + +const inTab = (row: CustomizationRow, tab: Tab): boolean => { + switch (tab) { + case 'all': + return true; + case 'fields': + return row.mode === 'added' && row.type === 'field'; + case 'views': + return row.type === 'view' || row.type === 'form'; + case 'flows': + return row.type === 'flow'; + case 'arranged': + return row.mode === 'arranged'; + case 'switchedOff': + return row.mode === 'switchedOff'; + } +}; + +/** The kinds the section names in words; any other type shows as served. */ +const NAMED_TYPES = new Set(['object', 'field', 'validation', 'index', 'view', 'flow', 'page', 'dashboard', 'report', 'action']); +const K = 'engine.packages.customizations'; + +type ReadState = + | { status: 'loading' } + | { status: 'failed'; message: string } + | { status: 'read'; rows: CustomizationRow[]; customized: number; switchedOff: number }; + +export function PackageCustomizationsPanel({ + packageId, + locale, + onNavigate, +}: { + /** The installed base whose changes are read; never a `.custom` pair. */ + packageId: string; + locale: string; + /** Called when a link leaves the page (the sheet closes on it). */ + onNavigate?: () => void; +}): React.ReactElement { + const client = useMetadataClient(); + const [state, setState] = React.useState({ status: 'loading' }); + React.useEffect(() => { + let cancelled = false; + setState({ status: 'loading' }); + fetchPackageCustomizations(packageId) + .then(async (read) => { + // objectstack#34724 — a switched-off action's link needs its object, + // which the ledger row does not name: read it before drawing the row. + const hasActions = read.switchedOff.some((s) => s.type === 'action'); + const actionObjects = hasActions + ? await readActionObjects(client, packageId).catch((): ActionObjects => ({})) + : undefined; + return { + status: 'read' as const, + rows: customizationRowsOf(packageId, read, actionObjects), + customized: customizedCountOf(read), + switchedOff: read.counts.switchedOff, + }; + }) + .then( + (next) => { + if (!cancelled) setState(next); + }, + (e: unknown) => { + if (!cancelled) setState({ status: 'failed', message: e instanceof Error ? e.message : String(e) }); + }, + ); + return () => { + cancelled = true; + }; + // Keyed on the package alone: the client only carries the reads, and a new + // client identity must not read again (ui/AGENTS.md #10). + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [packageId]); + + // Labels: one read per type that has rows, keyed on the rows drawn + // (ui/AGENTS.md #10: the effect reads the joined keys, a primitive). + const rows = state.status === 'read' ? state.rows : []; + const labelTargetKey = rows.map((r) => r.labelKey).join('\n'); + const [labels, setLabels] = React.useState>({}); + React.useEffect(() => { + if (!labelTargetKey) return; + let cancelled = false; + loadCustomizationLabels(client, packageId, rows, locale).then( + (found) => { + if (!cancelled) setLabels(found); + }, + () => {}, + ); + return () => { + cancelled = true; + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [labelTargetKey, packageId, locale]); + const labelOf = (row: CustomizationRow) => labels[row.labelKey] ?? row.name; + + const [tab, setTab] = React.useState('all'); + const [query, setQuery] = React.useState(''); + const [expanded, setExpanded] = React.useState(false); + + const typeText = (type: string) => (NAMED_TYPES.has(type) ? t(`${K}.type.${type}`, locale) : type); + const metaOf = (row: CustomizationRow) => + row.arrangement + ? `${t(`${K}.mode.${row.mode}`, locale)} · ${t(`${K}.arrangement.${row.arrangement}`, locale)}` + : `${t(`${K}.mode.${row.mode}`, locale)} · ${typeText(row.type)}`; + const needle = query.trim().toLowerCase(); + const matches = (row: CustomizationRow) => + !needle || [labelOf(row), row.name, metaOf(row)].some((s) => s.toLowerCase().includes(needle)); + const visible = rows.filter((r) => inTab(r, tab) && matches(r)); + const shown = expanded ? visible : visible.slice(0, PACKAGE_CUSTOMIZATION_ROWS_SHOWN); + + return ( +
    +
    +

    {t(`${K}.heading`, locale)}

    + + + {t(`${K}.customize`, locale)} + +
    + + {state.status === 'loading' && ( +

    + {t(`${K}.loading`, locale)} +

    + )} + {state.status === 'failed' && ( + // Never a "0": the read did not answer. The server's sentence is the title. +

    + {t(`${K}.failed`, locale)} +

    + )} + {state.status === 'read' && ( +

    + {state.customized === 0 && state.switchedOff === 0 + ? t(`${K}.none`, locale) + : `${tFormat(`${K}.customized`, locale, { count: state.customized })}${t(`${K}.separator`, locale)}${tFormat( + `${K}.switchedOff`, + locale, + { count: state.switchedOff }, + )}`} +

    + )} + + {rows.length > 0 && ( +
    +
    + {TABS.map((key) => { + const count = rows.filter((r) => inTab(r, key)).length; + return ( + + ); + })} + +
    + + {visible.length === 0 ? ( +

    {t(`${K}.noMatch`, locale)}

    + ) : ( +
      + {shown.map((row) => { + const label = labelOf(row); + return ( +
    • + + {label} + + + {metaOf(row)} + +
    • + ); + })} +
    + )} + + {!expanded && visible.length > shown.length && ( + + )} +
    + )} +
    + ); +} diff --git a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx index 121f91d2e79..1148ca267d4 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageSwitcher.tsx @@ -1,16 +1,15 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The package helpers Studio's surface shares: the package-list toast id and - * the installed-row read. The top-bar package switcher that lived here with - * them, since objectstack#29988's move-only split, was removed by - * objectstack#36501: the top bar's left end is 「‹ Back to app」 + * The package-list toast id Studio's surface shares. The top-bar package + * switcher that lived here with it, since objectstack#29988's move-only split, + * was removed by objectstack#36501: the top bar's left end is 「‹ Back to app」 * (`StudioBackToApp.tsx`), and a package is picked in the app or in Setup → - * Packages (objectstack#36834, objectstack#36908). + * Packages (objectstack#36834, objectstack#36908). The installed-row read that + * the Studio home's Manage opened the package sheet with went with that home + * (objectstack#36908). */ -import type { InstalledPackageRow } from '../metadata-admin/PackagesPage.js'; - /** * One sonner id for EVERY `fetchPackages()` failure on this surface * (objectui#7368). More than one effect calls that one endpoint on mount — the @@ -22,114 +21,3 @@ import type { InstalledPackageRow } from '../metadata-admin/PackagesPage.js'; * reporting it three times is noise that would get the report muted. */ export const PACKAGE_LIST_TOAST_ID = 'studio-package-list'; - -/** - * The record the standard detail/management sheet opens on: a package's full - * installed row (manifest + status), read from `GET /api/v1/packages`, since - * the Studio landing holds only the trimmed {id,name,writable} view. `null` = - * the list answered and does not name `id`; a failed read throws. Read by the - * landing cards' Manage (objectstack#35196). - */ -export async function fetchInstalledPackageRow(id: string): Promise { - const res = await fetch('/api/v1/packages', { - credentials: 'include', - headers: { Accept: 'application/json' }, - cache: 'no-store', - }); - /** - * ⛔ `res.ok` is not optional here (objectui#7881). The platform answers a - * failed read in the ADR-0112 envelope — `{ success: false, error: { code, - * message } }` — and that envelope PARSES CLEANLY through the reader - * below: `root` becomes the error object, which is neither an array nor - * carries `packages`, so `list` fell to `[]` and `.find()` to `null`. - * Nothing threw, `openManage`'s catch never ran, and the management sheet - * was opened on a null package. An empty list is a completely legitimate - * SUCCESS answer, so using it for a failure is representing failure with a - * legitimate success value — the same family as objectui#7368 and - * objectui#7821 (PR #7879), one seam over. - * - * Measured on this path, not assumed. `GET /api/v1/packages` is served by - * the direct-mount registrar (`@objectstack/rest` `package-routes.ts`, - * which mounts FIRST in the production stack), and `check:route-envelope` - * pins that module at zero hand-written bodies: every failure leaves - * through the shared `sendError` / `sendThrownError`. The reachable - * failures are `401 UNAUTHENTICATED` (anonymous deny), `403 FORBIDDEN` - * (the `studio.access` / `setup.access` capability gate), `503 - * SERVICE_UNAVAILABLE` (either half of the two-source merge refusing a - * read it could not perform) and `500 INTERNAL_ERROR` — one shape, - * `{ success: false, error: { code, message } }`, pinned wire-side by - * `package-envelope.conformance.test.ts`. - * - * So the envelope's own `success` is NOT a second bit to read here: `sendOk` - * writes `true` on every 2xx and the error writers write `false` on every - * non-2xx, which makes it `!res.ok` restated. `res.ok` is the DECISION; the - * envelope is read for the WORDS, which is the half that needs it — in the - * 5xx band the platform withholds the producer's prose and answers the - * generic `Internal server error`, leaving `error.code` as the only - * discriminating word, so the code travels with the message. - * - * The one other shape a browser can meet is a non-JSON error body (a - * proxy's HTML 502/504). `res.json()` rejects on it — which the caller - * already reported, as a JSON syntax error — so the tolerant read below - * names the status instead. - */ - if (!res.ok) { - const failure = (await res.json().catch(() => null)) as { - error?: { code?: unknown; message?: unknown; userMessage?: unknown }; - } | null; - /** - * ⭐ `userMessage` OUTRANKS `message`, and the order is the contract's, - * not a preference (objectui#7938). - * - * `error.userMessage` is the producer's channel (objectstack `79c46da90`), - * and the envelope writer's own words are the rule this line implements: - * "the text a producer marked, AT THROW TIME, as addressed to the END USER. - * Presence IS the marking — a consumer that sees the field renders it - * verbatim and keeps its generic substitution for everything unmarked" - * (`sendError`, `@objectstack/types` `response-envelope.ts`). This - * reader was that consumer and did not see the field: it read - * `error.message` and `error.code` and stopped, so a marked sentence - * arrived on the wire and had nowhere to appear. - * - * The 5xx band is where the loss became visible rather than merely - * theoretical. That door withholds the producer's PROSE and substitutes - * the generic `Internal server error` into `error.message` — but the - * withhold rewrites a local `message` const and `looksLikeInternalErrorLeak` - * is only ever handed `thrown.message`, so `userMessage` is never an - * input to it and rides through untouched (`sendThrownError`, - * `@objectstack/rest` `package-routes.ts`; pinned wire-side by - * `package-door-user-message.test.ts`). So on a marked 500/503 this - * reader showed the author the generic sentence and dropped the - * specific one written for them — nothing invalid displayed, which is - * exactly what made it quiet. - * - * ⛔ NOT scoped to 5xx, deliberately. The marked channel is - * status-agnostic by the producing door's own ruling — "a marked text is - * the producer's deliberate statement to the caller at any status" — so - * a consumer that honoured it only in one band would re-create, on the - * reading end, precisely the divergence that door refused to create on - * the writing end. A 4xx `message` is already caller-facing by design; - * when a producer ALSO marked a text there, the mark is the more - * specific answer to "what should this person read", and the diagnostic - * it displaces is not lost to diagnosis — `code` still travels below. - * - * ⛔ Not a tolerant alias ladder either: these are two DECLARED fields - * with different meanings, not two spellings of one. An unmarked refusal - * carries no `userMessage` at all (the producer's `declaredUserMessage` - * already applied its non-empty-string rule), so the overwhelmingly - * common case falls straight through to `message` with byte-identical - * output. - */ - const marked = typeof failure?.error?.userMessage === 'string' ? failure.error.userMessage : ''; - const diagnostic = typeof failure?.error?.message === 'string' ? failure.error.message : ''; - const message = marked || diagnostic; - const code = typeof failure?.error?.code === 'string' ? failure.error.code : ''; - throw new Error(message ? (code ? `${message} (${code})` : message) : `HTTP ${res.status}`); - } - const data = (await res.json()) as unknown; - const root = (data as { data?: unknown })?.data ?? data; - const list = (Array.isArray(root) ? root : ((root as { packages?: unknown[] })?.packages ?? [])) as Array< - InstalledPackageRow & { id?: string } - >; - return list.find((p) => (p?.manifest?.id ?? p?.id) === id) ?? null; -} 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 57f4938e078..e2150e1404c 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 @@ -204,7 +204,7 @@ function renderAt(url: string) { - } /> + } /> } /> , diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.metadataArea-28561.test.tsx index de051a782c0..e08a562145f 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 @@ -160,7 +160,7 @@ function renderAt(path: string) { - } /> + } /> } /> } /> 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 484243c5a11..cd7a1c6a232 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 @@ -201,7 +201,7 @@ async function renderSurfaceOnAccess() { } /> {/* objectstack#36899 — a menu type entry opens that type's area list. */} } /> - } /> + } /> } /> diff --git a/ui/packages/app-shell/src/views/studio-design/fetchInstalledPackageRow-7881.test.ts b/ui/packages/app-shell/src/views/studio-design/fetchInstalledPackageRow-7881.test.ts deleted file mode 100644 index 403a2ad28af..00000000000 --- a/ui/packages/app-shell/src/views/studio-design/fetchInstalledPackageRow-7881.test.ts +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * `fetchInstalledPackageRow` — the installed-row read behind the package - * management sheet, read today by the Studio landing cards' Manage - * (objectstack#35196). - * - * These pins moved here from the two surface files that drove the read - * through the Studio top bar's package switcher (objectui#7881's - * `packageLookupFailure` and objectui#7938's `packageUserMessage`): the - * switcher was removed by objectstack#36501, and the read it shared lives on. - * Each case is the same wire answer those files served, asserted at the - * helper itself. - * - * - objectui#7881: a failed read is not an empty result. The ADR-0112 - * failure envelope parses cleanly, so without `res.ok` a 503 read as "the - * list has no such package"; it THROWS now, with the code beside the words, - * and only a successful list that lacks the package answers `null`. - * - objectui#7938: a producer-marked `error.userMessage` outranks `message`, - * at every status; `code` composes with whichever sentence won, and a body - * with no prose names the status. - */ - -import { afterEach, describe, expect, it, vi } from 'vitest'; -import { fetchInstalledPackageRow } from './PackageSwitcher'; - -const PACKAGE_ID = 'app.b2r4'; -const GENERIC = 'Internal server error'; -const MARKED = 'Publishing is temporarily unavailable. Nothing was changed.'; - -function answer(response: { ok: boolean; status: number; json: () => Promise }): void { - vi.stubGlobal( - 'fetch', - vi.fn(async () => response), - ); -} -const listOk = (packages: unknown[]) => - answer({ ok: true, status: 200, json: async () => ({ success: true, data: { packages, total: packages.length } }) }); -const listFailure = (status: number, error: Record) => - answer({ ok: false, status, json: async () => ({ success: false, error }) }); - -/** The message the read throws with, for a failed answer. */ -async function thrownFor(status: number, error: Record): Promise { - listFailure(status, error); - const failure = await fetchInstalledPackageRow(PACKAGE_ID).then( - () => null, - (e: unknown) => e, - ); - expect(failure).toBeInstanceOf(Error); - return (failure as Error).message; -} - -afterEach(() => { - vi.unstubAllGlobals(); -}); - -describe('a failed read is not an empty result (objectui#7881)', () => { - it('a 503 envelope throws its message and code', async () => { - expect(await thrownFor(503, { code: 'SERVICE_UNAVAILABLE', message: GENERIC })).toBe( - 'Internal server error (SERVICE_UNAVAILABLE)', - ); - }); - - it('a 403 envelope carries the server’s own sentence', async () => { - expect( - await thrownFor(403, { - code: 'FORBIDDEN', - message: 'Reading packages requires the `studio.access` or `setup.access` capability.', - }), - ).toBe('Reading packages requires the `studio.access` or `setup.access` capability. (FORBIDDEN)'); - }); - - it('a 401 envelope throws too', async () => { - expect(await thrownFor(401, { code: 'UNAUTHENTICATED', message: 'Authentication required' })).toBe( - 'Authentication required (UNAUTHENTICATED)', - ); - }); - - it('a non-JSON error body names the status, not a JSON syntax error', async () => { - answer({ - ok: false, - status: 502, - json: async () => { - throw new SyntaxError("Unexpected token '<', \"\"... is not valid JSON"); - }, - }); - await expect(fetchInstalledPackageRow(PACKAGE_ID)).rejects.toThrow(/^HTTP 502$/); - }); - - it('a SUCCESSFUL list without the package answers null', async () => { - listOk([]); - await expect(fetchInstalledPackageRow(PACKAGE_ID)).resolves.toBeNull(); - }); - - it('CONTROL — a successful list with the package answers its row', async () => { - listOk([{ manifest: { id: PACKAGE_ID, name: PACKAGE_ID }, writable: true }]); - await expect(fetchInstalledPackageRow(PACKAGE_ID)).resolves.toMatchObject({ manifest: { id: PACKAGE_ID } }); - }); - - it('CONTROL — the bare-array body the endpoint also serves reads the same', async () => { - answer({ ok: true, status: 200, json: async () => [{ manifest: { id: PACKAGE_ID, name: PACKAGE_ID } }] }); - await expect(fetchInstalledPackageRow(PACKAGE_ID)).resolves.toMatchObject({ manifest: { id: PACKAGE_ID } }); - }); -}); - -describe('a producer-marked userMessage reaches the author (objectui#7938)', () => { - it('`message` only: the diagnostic prose with its code, unchanged', async () => { - expect(await thrownFor(409, { code: 'RESOURCE_CONFLICT', message: 'version 1.2.0 already published' })).toBe( - 'version 1.2.0 already published (RESOURCE_CONFLICT)', - ); - }); - - it('`userMessage` only: the marked text, never the bare status', async () => { - expect(await thrownFor(503, { code: 'SERVICE_UNAVAILABLE', userMessage: MARKED })).toBe( - `${MARKED} (SERVICE_UNAVAILABLE)`, - ); - }); - - it('both, in the 5xx band: the mark displaces the generic sentence', async () => { - const shown = await thrownFor(500, { code: 'INTERNAL_ERROR', message: GENERIC, userMessage: MARKED }); - expect(shown).toBe(`${MARKED} (INTERNAL_ERROR)`); - expect(shown).not.toContain(GENERIC); - }); - - it('both, in the 4xx band: the mark still wins', async () => { - expect( - await thrownFor(409, { - code: 'RESOURCE_CONFLICT', - message: 'version 1.2.0 already published for app.b2r4', - userMessage: 'That version is already published. Bump the version and retry.', - }), - ).toBe('That version is already published. Bump the version and retry. (RESOURCE_CONFLICT)'); - }); - - it('a marked body with no code: the bare sentence', async () => { - expect(await thrownFor(503, { message: GENERIC, userMessage: MARKED })).toBe(MARKED); - }); - - it('no prose, a code present: the status, and the code is not it', async () => { - expect(await thrownFor(503, { code: 'SERVICE_UNAVAILABLE' })).toBe('HTTP 503'); - }); - - it('a non-string or empty `userMessage` is not a mark', async () => { - expect(await thrownFor(500, { code: 'INTERNAL_ERROR', message: GENERIC, userMessage: 42 })).toBe( - `${GENERIC} (INTERNAL_ERROR)`, - ); - expect(await thrownFor(500, { code: 'INTERNAL_ERROR', message: GENERIC, userMessage: '' })).toBe( - `${GENERIC} (INTERNAL_ERROR)`, - ); - }); -}); diff --git a/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts b/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts index 942e648d0b5..24e82a5a5e3 100644 --- a/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts @@ -56,7 +56,7 @@ describe('Studio links into no retired Setup page (ADR-0146)', () => { const files = sourceFiles(here); // Control: the walk really reads the folder. expect(files.some((file) => file.endsWith('StudioDesignSurface.tsx'))).toBe(true); - expect(files.some((file) => file.endsWith('BuilderLanding.tsx'))).toBe(true); + expect(files.some((file) => file.endsWith('StudioEntryRedirect.tsx'))).toBe(true); const offenders = files.flatMap((file) => [...mask(readFileSync(file, 'utf8')).matchAll(RETIRED)].map((m) => `${path.basename(file)}: ${m[0]}`), diff --git a/ui/packages/app-shell/src/views/studio-design/noSetupMetadataLink-28578.test.ts b/ui/packages/app-shell/src/views/studio-design/noSetupMetadataLink-28578.test.ts index a2ee9e33169..0f7616d024e 100644 --- a/ui/packages/app-shell/src/views/studio-design/noSetupMetadataLink-28578.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/noSetupMetadataLink-28578.test.ts @@ -71,7 +71,7 @@ describe('Studio links into no Setup metadata page (ADR-0146 D1)', () => { const files = sourceFiles(here); // Control: the walk really reads the folder. expect(files.some((file) => file.endsWith('StudioDesignSurface.tsx'))).toBe(true); - expect(files.some((file) => file.endsWith('BuilderLanding.tsx'))).toBe(true); + expect(files.some((file) => file.endsWith('StudioEntryRedirect.tsx'))).toBe(true); const offenders = files.flatMap((file) => setupLinks(readFileSync(file, 'utf8')).map((link) => `${path.basename(file)}: ${link}`), diff --git a/ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts b/ui/packages/app-shell/src/views/studio-design/packageCustomizationRows.ts similarity index 61% rename from ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts rename to ui/packages/app-shell/src/views/studio-design/packageCustomizationRows.ts index f2e2e5aaccf..c581ca9d66e 100644 --- a/ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts +++ b/ui/packages/app-shell/src/views/studio-design/packageCustomizationRows.ts @@ -1,28 +1,31 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * objectstack#34714 — the rows of the Studio landing's "Customizations in this - * environment" panel: every change this deployment made to its installed apps, - * in one list. + * The rows of an installed app's "Customizations in this environment" section + * in Setup → Packages (objectstack#36908, which moved it from the removed + * Studio home, objectstack#34714): every change this deployment made to the + * app, in one list. * - * The rows are the server's per-app customization read - * (`GET /api/v1/packages/:id/customizations`, ADR-0146 D3, D8 item 4), the same - * answer each installed app's card counts, one row per served entry: + * The rows are the server's per-package customization read + * (`GET /api/v1/packages/:id/customizations`, ADR-0146 D3, D8 item 4), one row + * per served entry: * * - `overrides` → "changed" (an item of the app the pair overrides); * - `extensions` → "added" (a field, validation or index the pair adds to one * of the app's objects); + * - `arrangements` → "rearranged" (an object's field groups, tabs or action + * layout the pair declares whole, ADR-0146 D10); * - `switchedOff` → "switched off" (an item of the app this deployment turned * off). * * `contributions` (what OTHER packages bring to the app) are not this * deployment's changes and make no row. Nothing is folded or deduped, so the - * panel's total is the cards' "customized" plus "switched off" by - * construction: the served counts are each list's length. + * rows match the counts {@link customizedCountOf} reads: every served list's + * length. * * The answer carries names, not labels. A row's label is read from the app's - * own published list of that type (one list per app and type that has rows); - * a field's from its object. A label that cannot be read leaves the row on its + * own published list of that type (one list per type that has rows); a + * field's from its object. A label that cannot be read leaves the row on its * name: a failed label read never hides a row. * * ⛔ No diff against the app, no "based on" version and no clone lineage @@ -35,85 +38,102 @@ import { studioMetadataAreaPath } from './metadataArea.js'; import { switchedOffActionPath, type ActionObjects } from './switchedOffActionTargets.js'; /** How a row changed the app. */ -export type CustomizationMode = 'changed' | 'added' | 'switchedOff'; +export type CustomizationMode = 'changed' | 'added' | 'arranged' | 'switchedOff'; -/** One row of the panel. */ +/** Which arrangement an arranged row names. */ +export type ArrangementKey = PackageCustomizations['arrangements'][number]['key']; + +/** One row of the section. */ export interface CustomizationRow { - /** Stable key: app, mode and the entry's identity. */ + /** Stable key: mode and the entry's identity. */ key: string; - appId: string; - appName: string; mode: CustomizationMode; /** * The row's metadata type: the served `type` for a changed or switched-off - * item; for an added member its kind (`field`, `validation`, `index`). + * item; for an added member its kind (`field`, `validation`, `index`); for + * an arrangement `object`, the item it rearranges. */ type: string; - /** The entry's name; for an added member, `object.name`. */ + /** The entry's name; for an added member, `object.name`; for an arrangement, the object. */ name: string; - /** For an added member: the object it is added to. */ - object?: string; + /** For an arrangement: which one (`fieldGroups`, `relatedLists`, `actionLayout`). */ + arrangement?: ArrangementKey; /** The key {@link loadCustomizationLabels} answers a label under. */ labelKey: string; /** Where the row opens in Studio. */ href: string; } +/** + * objectstack#36833 — what "customized" counts: every change the pair makes, + * the served overrides, extensions AND arrangements. A package whose only + * change is a tab arrangement is customized; the Studio home's count left the + * arrangements out. + */ +export function customizedCountOf({ counts }: Pick): number { + return counts.overrides + counts.extensions + counts.arrangements; +} + /** The address of one item on an app's metadata area; a pillar type opens its pillar from there. */ const itemHref = (appId: string, type: string, name: string) => `${studioMetadataAreaPath(appId)}/${encodeURIComponent(type)}/${encodeURIComponent(name)}`; /** * The rows one app's served answer makes, in the served order: changed, added, - * switched off. `actionObjects` (objectstack#34724) names the object holding - * each switched-off action: such an action opens on its object's Actions view, - * since one declared inside its object has no item page; any other action - * opens its own page, as every other type does. + * rearranged, switched off. `actionObjects` (objectstack#34724) names the + * object holding each switched-off action: such an action opens on its + * object's Actions view, since one declared inside its object has no item + * page; any other action opens its own page, as every other type does. */ export function customizationRowsOf( - app: { id: string; name: string }, - read: Pick, + appId: string, + read: Pick, actionObjects?: ActionObjects, ): CustomizationRow[] { const rows: CustomizationRow[] = []; for (const o of read.overrides) { const name = o.member ? `${o.name} (${o.member})` : o.name; rows.push({ - key: `${app.id}\u0000changed\u0000${o.type}\u0000${o.name}\u0000${o.member ?? ''}`, - appId: app.id, - appName: app.name, + key: `changed\u0000${o.type}\u0000${o.name}\u0000${o.member ?? ''}`, mode: 'changed', type: o.type, name, labelKey: `${o.type}:${o.name}`, - href: itemHref(app.id, o.type, o.name), + href: itemHref(appId, o.type, o.name), }); } read.extensions.forEach((e, i) => { const member = e.name ?? (e.fields?.join(', ') || String(i + 1)); rows.push({ - key: `${app.id}\u0000added\u0000${e.object}\u0000${e.kind}\u0000${e.name ?? `#${i}`}`, - appId: app.id, - appName: app.name, + key: `added\u0000${e.object}\u0000${e.kind}\u0000${e.name ?? `#${i}`}`, mode: 'added', type: e.kind, name: `${e.object}.${member}`, - object: e.object, labelKey: e.kind === 'field' && e.name ? `field:${e.object}.${e.name}` : `${e.kind}:${e.object}.${member}`, // A member opens on its object: the Data pillar designs the object's fields and rules. - href: itemHref(app.id, 'object', e.object), + href: itemHref(appId, 'object', e.object), }); }); + for (const a of read.arrangements) { + rows.push({ + key: `arranged\u0000${a.object}\u0000${a.key}`, + mode: 'arranged', + type: 'object', + name: a.object, + arrangement: a.key, + labelKey: `object:${a.object}`, + // An arrangement is the object's record page: it opens on the object. + href: itemHref(appId, 'object', a.object), + }); + } for (const s of read.switchedOff) { rows.push({ - key: `${app.id}\u0000switchedOff\u0000${s.type}\u0000${s.name}`, - appId: app.id, - appName: app.name, + key: `switchedOff\u0000${s.type}\u0000${s.name}`, mode: 'switchedOff', type: s.type, name: s.name, labelKey: `${s.type}:${s.name}`, - href: s.type === 'action' ? switchedOffActionPath(app.id, s.name, actionObjects?.[s.name]) : itemHref(app.id, s.type, s.name), + href: s.type === 'action' ? switchedOffActionPath(appId, s.name, actionObjects?.[s.name]) : itemHref(appId, s.type, s.name), }); } return rows; @@ -149,10 +169,10 @@ function fieldsOf(object: Record): Array<[string, unknown]> { /** * Read the labels of one app's rows: one `list(type, { packageId })` per type - * its changed and switched-off rows name, and one `list('object', …)` when it - * has added fields. Answers `labelKey → label` for the labels it could read; a - * failed list leaves its rows out of the answer, so they keep their names. No - * row, no request. + * its changed, rearranged and switched-off rows name, and one + * `list('object', …)` when it has added fields. Answers `labelKey → label` for + * the labels it could read; a failed list leaves its rows out of the answer, + * so they keep their names. No row, no request. */ export async function loadCustomizationLabels( client: LabelClient, @@ -160,9 +180,8 @@ export async function loadCustomizationLabels( rows: readonly CustomizationRow[], locale?: string, ): Promise> { - const mine = rows.filter((r) => r.appId === appId); - const types = new Set(mine.filter((r) => r.mode !== 'added').map((r) => r.type)); - const wantsFields = mine.some((r) => r.mode === 'added' && r.type === 'field'); + const types = new Set(rows.filter((r) => r.mode !== 'added').map((r) => r.type)); + const wantsFields = rows.some((r) => r.mode === 'added' && r.type === 'field'); if (wantsFields) types.add('object'); const labels: Record = {}; await Promise.all( diff --git a/ui/packages/app-shell/src/views/studio-design/packages-io.envelopeUserMessage.test.ts b/ui/packages/app-shell/src/views/studio-design/packages-io.envelopeUserMessage.test.ts index 679705b0b7c..d6d0565cdbc 100644 --- a/ui/packages/app-shell/src/views/studio-design/packages-io.envelopeUserMessage.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/packages-io.envelopeUserMessage.test.ts @@ -210,8 +210,7 @@ describe('fetchPackages — how `code` composes, and what is not a mark', () => describe('fetchPackages — negative controls (GREEN with the fix reverted)', () => { /** * ⭐ §7. A proxy's HTML 502 has no envelope to read. The status is then the - * only honest thing to say, and it is what `fetchInstalledPackageRow-7881` - * pins for the sibling read. + * only honest thing to say. */ it('§7 an unparseable body still names the status', async () => { stubFetch({ diff --git a/ui/packages/app-shell/src/views/studio-design/packages-io.ts b/ui/packages/app-shell/src/views/studio-design/packages-io.ts index 79e97774988..d62349d9569 100644 --- a/ui/packages/app-shell/src/views/studio-design/packages-io.ts +++ b/ui/packages/app-shell/src/views/studio-design/packages-io.ts @@ -23,11 +23,10 @@ * why the client cannot compute this and a "missing scope means read-only" rule * would have flipped every Studio base read-only. * - * Kernel packages (scope `system` / `cloud`) are hidden from the Studio - * landing whatever their verdict says: that filter is about visibility, not + * Kernel packages (scope `system` / `cloud`) are not offered to an author + * whatever their verdict says: that filter is about visibility, not * writability. A manifest-scoped one is left out of this list; a flat-scoped - * one stays in it, tagged `kernel`, and the landing hides it (`BuilderLanding`, - * ADR-0016 §3.8). + * one stays in it, tagged `kernel`, for its readers to hide (ADR-0016 §3.8). */ import { EnsureCustomizationPackageResponseSchema } from '@objectstack/spec/api'; @@ -64,8 +63,7 @@ export interface PkgEntry { * flat with a kernel `scope` (`system` / `cloud`) at the top level. Such a * row stays in the list, because the app → Studio entries read this tag to * draw nothing for it (`useStudioEntryGate`), as for the manifest-scoped - * kernel packages this list leaves out. The Studio landing does not offer - * it (`BuilderLanding`, ADR-0016 §3.8). + * kernel packages this list leaves out (ADR-0016 §3.8). */ kernel?: true; } @@ -94,8 +92,7 @@ export interface PkgEntry { * * `scope` is read in both positions, for two different answers: a manifest * kernel scope drops the row here, while a flat one keeps the row and tags it - * `kernel` — the app → Studio entry gate reads that tag, and the Studio - * landing hides the tagged row (`BuilderLanding`). + * `kernel` — the app → Studio entry gate reads that tag. */ export function parsePackages(payload: unknown): PkgEntry[] { const root = (payload as { data?: unknown })?.data ?? payload; diff --git a/ui/packages/i18n/src/__tests__/makerEmptyState-v1-scope-8329.test.ts b/ui/packages/i18n/src/__tests__/makerEmptyState-v1-scope-8329.test.ts index b5b4e7eb842..c4419b8d31e 100644 --- a/ui/packages/i18n/src/__tests__/makerEmptyState-v1-scope-8329.test.ts +++ b/ui/packages/i18n/src/__tests__/makerEmptyState-v1-scope-8329.test.ts @@ -44,8 +44,7 @@ * ⚠️ Scope note — this suite guards the AI-AUTHORING promise, not the word * "automation". The platform's manual automation surfaces are real and are * deliberately NOT covered: `home.build.subtitle` (its card opens Studio, which - * genuinely authors flows), `engine.studio.landing.description`, - * `packagedAutomation.*`, the marketplace + * genuinely authors flows), `packagedAutomation.*`, the marketplace * `automation` category, and the approvals / flow-runner groups. * * REVERT the wording (and relax this suite) when ADR-0112 v2 re-adds flows and diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 79a71639192..67576d99e58 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -3120,8 +3120,7 @@ const en = { // // NOT the same thing as the platform's manual automation surfaces, which // are real and stay as they are: `home.build.subtitle` (that card opens - // Studio, which does author flows), `engine.studio.landing.description`, - // `packagedAutomation.*` and the + // Studio, which does author flows), `packagedAutomation.*` and the // marketplace `automation` category. The boundary is v1 AI AUTHORING, not // the word "automation". // diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 1d22255c166..8f20b269230 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -2013,6 +2013,46 @@ const STUDIO_EN: Record = { 'engine.packages.detail.description': 'Description', 'engine.packages.detail.browseMetadata': "Browse this package's metadata", 'engine.packages.detail.openInStudio': 'Open in Studio', + // objectstack#36908 — an installed app's "Customizations in this environment", + // in its Setup → Packages detail (moved from the removed Studio home). + // "Customized" counts the pair's overrides, extensions and arrangements + // (objectstack#36833). + 'engine.packages.customizations.heading': 'Customizations in this environment', + 'engine.packages.customizations.customize': 'Customize in Studio', + 'engine.packages.customizations.customizeTitle': 'Open this app in Studio, where its items are customized', + 'engine.packages.customizations.loading': 'Reading customizations…', + 'engine.packages.customizations.failed': 'Couldn’t read customizations', + 'engine.packages.customizations.none': 'No changes in this environment yet', + 'engine.packages.customizations.customized': '{count} customized', + 'engine.packages.customizations.separator': ', ', + 'engine.packages.customizations.switchedOff': '{count} switched off', + 'engine.packages.customizations.tab.all': 'All', + 'engine.packages.customizations.tab.fields': 'New fields', + 'engine.packages.customizations.tab.views': 'Forms and views', + 'engine.packages.customizations.tab.flows': 'Flows', + 'engine.packages.customizations.tab.arranged': 'Layouts', + 'engine.packages.customizations.tab.switchedOff': 'Switched off', + 'engine.packages.customizations.search': 'Search customizations', + 'engine.packages.customizations.showAll': 'Show all {count}', + 'engine.packages.customizations.noMatch': 'No customization matches.', + 'engine.packages.customizations.mode.changed': 'Changed', + 'engine.packages.customizations.mode.added': 'Added', + 'engine.packages.customizations.mode.arranged': 'Rearranged', + 'engine.packages.customizations.mode.switchedOff': 'Switched off', + 'engine.packages.customizations.arrangement.fieldGroups': 'Field groups', + 'engine.packages.customizations.arrangement.relatedLists': 'Tabs', + 'engine.packages.customizations.arrangement.actionLayout': 'Action layout', + 'engine.packages.customizations.type.object': 'Object', + 'engine.packages.customizations.type.field': 'Field', + 'engine.packages.customizations.type.validation': 'Validation rule', + 'engine.packages.customizations.type.index': 'Index', + 'engine.packages.customizations.type.view': 'View', + 'engine.packages.customizations.type.flow': 'Flow', + 'engine.packages.customizations.type.page': 'Page', + 'engine.packages.customizations.type.dashboard': 'Dashboard', + 'engine.packages.customizations.type.report': 'Report', + 'engine.packages.customizations.type.action': 'Action', + 'engine.packages.customizations.rowTitle': 'Open {name} in Studio', 'engine.packages.detail.pendingChanges': 'Pending changes', 'engine.packages.detail.pendingHint': 'Drafted, not yet published. Publish the whole app, or review each below.', 'engine.packages.detail.publishApp': 'Publish app ({count})', @@ -3585,63 +3625,21 @@ const STUDIO_EN: Record = { 'engine.studio.interfaces.create.descriptionInPair': 'Saved as a draft in this deployment’s customization of {baseName}, and opened on the canvas. The navigation of {baseName} stays as it was installed.', 'engine.studio.app.scaffoldNav': "Add this package's objects as menu items", - 'engine.studio.landing.title': 'App Builder', - 'engine.studio.landing.description': 'Design objects, forms, automations and interfaces inside a writable package; edits save as drafts and the whole package publishes in one release. Code and installed packages are read-only: browse them here, and change their items with Customize or New similar, which save into the package’s .custom customization package.', - 'engine.studio.landing.mineHeading': 'My packages (writable)', - 'engine.studio.landing.noneWritable': 'No writable packages yet — create one to start.', - 'engine.studio.landing.dup': 'Duplicate', - 'engine.studio.landing.dupTitle': 'Duplicate this package into a new writable copy (like “duplicate base”)', + // The Packages page's Duplicate form; the keys keep the name of the Studio + // home that first drew the form (removed by objectstack#36908). 'engine.studio.landing.dupDefaultName': '{name} copy', 'engine.studio.landing.dupNamePlaceholder': 'Copy name', 'engine.studio.landing.dupIdPlaceholder': 'Copy package ID', - 'engine.studio.landing.dupGo': 'Duplicate and open the builder', - 'engine.studio.landing.dupCreated': 'Duplicated into writable package “{name}”', - 'engine.studio.landing.installedHeading': 'Installed (read-only · browsable)', - // The routes a read-only package does have (objectstack ADR-0146 D2, D3, D11): - // Customize or New similar into its paired `.custom` package, and the - // marketplace where the runtime has one. A package-less overlay is not one. - 'engine.studio.landing.readonlyHint': 'Code and installed packages are read-only, so they are not edited or duplicated here. To change one, open an item and choose Customize or New similar: the change is saved in the package’s .custom customization package, and upgrades keep reaching the installed package.', - 'engine.studio.landing.marketplace': 'Or install a template app from the marketplace', - // ADR-0146 D3 — a read-only base's card says what this deployment changed on - // it, from the server's per-package customization read. - 'engine.studio.landing.customizations.customized': '{customized} customized', - 'engine.studio.landing.customizations.separator': ', ', - 'engine.studio.landing.customizations.switchedOff': '{switchedOff} switched off', - 'engine.studio.landing.customizations.loading': 'Reading customizations…', - 'engine.studio.landing.customizations.failed': 'Couldn’t read customizations', - 'engine.studio.landing.customizations.pairTitle': 'Open the customization package {pair} in Studio', - 'engine.studio.landing.customizations.switchedOffTitle': 'Open this package’s Automations, where its items are switched on and off', - 'engine.studio.landing.customizations.switchedOffActionsLead': 'Actions: ', - 'engine.studio.landing.customizations.switchedOffActionsMore': '+{count} more', - 'engine.studio.landing.customizations.switchedOffActionsTitle': 'Open the switched-off actions: each one is switched on again on the action', // objectui#11553 — the package-less scope: the organization's own flows. - 'engine.studio.landing.orgHeading': 'Not in a package', 'engine.studio.org.name': 'Organization flows', 'engine.studio.org.hint': 'Flows that belong to no package', 'engine.studio.org.description': 'The organization’s own flows that belong to no package, such as a clone of a packaged flow. They open editable.', // ADR-0146 D11 — no link out: no Setup page copies a flow into this scope any more. 'engine.studio.org.none': 'No flows outside a package. To change a packaged flow, open its package and use New similar.', - // objectstack#28561 — the "All metadata" area's cross-package leg: the - // environment catalog, entered from the landing. - 'engine.studio.landing.envCatalog.name': 'Environment catalog', - 'engine.studio.landing.envCatalog.description': 'Positions, capabilities, permission sets and sharing rules, across every package.', - // objectstack#34715 — the landing ordered by what the author came to do, in - // words that name no package mechanism. - 'engine.studio.landing.lead': 'Change an installed app, or build an app of your own. Changes take effect when you press Save.', - 'engine.studio.landing.appsHeading': 'Installed apps', - 'engine.studio.landing.appsHint': 'Each app is upgraded by its vendor. Your changes are kept separately, so an upgrade does not overwrite them.', - 'engine.studio.landing.marketplaceInstall': 'Install from the marketplace', - 'engine.studio.landing.customizeTitle': 'Customize {name}', - 'engine.studio.landing.manage': 'Manage', - 'engine.studio.landing.manageTitle': 'Manage {name}: details, disable or enable, export', - 'engine.studio.landing.allPackages': 'All packages', - 'engine.studio.landing.allPackagesTitle': 'Every package in this environment, with its disable, enable and export actions', - 'engine.studio.landing.customizations.none': 'No changes yet', - 'engine.studio.landing.ownHeading': 'Your own apps', - 'engine.studio.landing.newApp': 'New app of your own', - 'engine.studio.landing.newAppDescription': 'Start from a blank app.', - // objectstack#36748 — the Studio landing's new-app door: one dialog creates - // the package and its app, worded for an app throughout. + // objectstack#36748 — the new-app step of the package dialog (`newAppDoor.ts`): + // one dialog creates the package and its app, worded for an app throughout. + // The Studio home that opened it was removed (objectstack#36908); the step + // stays for the create-package dialog's create-app choice (objectstack#37134). 'engine.studio.newApp.title': 'New app', 'engine.studio.newApp.description': 'Give your app a name; everything else is filled in for you. It opens as soon as it is created.', 'engine.studio.newApp.advancedHint': 'App ID, namespace, version and type, filled in from the name.', @@ -3660,41 +3658,6 @@ const STUDIO_EN: Record = { 'engine.studio.newApp.failed': 'Could not create the app', 'engine.studio.newApp.nameTaken': 'The app “{label}” already uses the identifier “{name}”. Change the namespace under Advanced.', 'engine.studio.newApp.appFailed': '“{name}” was created, but its app could not go live: {reason}. Use Create app in the Studio top bar to try again.', - 'engine.studio.landing.outsideHeading': 'Outside any app', - 'engine.studio.landing.rolesPermissions.name': 'Positions and permissions', - 'engine.studio.landing.rolesPermissions.description': 'Positions, permission sets and sharing rules, shared by every app.', - 'engine.studio.landing.unassignedFlows.name': 'Flows in no app', - 'engine.studio.landing.unassignedFlows.description': 'Flows that belong to no app, such as a copy of an app’s flow. They open editable.', - // objectstack#34714 — the landing's "Customizations in this environment" panel. - 'engine.studio.landing.envCustomizations.heading': 'Customizations in this environment', - 'engine.studio.landing.envCustomizations.totalTitle': '{count} changes across the installed apps', - 'engine.studio.landing.envCustomizations.loading': 'Reading what this environment changed…', - 'engine.studio.landing.envCustomizations.empty': 'No installed app has been changed in this environment yet.', - 'engine.studio.landing.envCustomizations.unreadable': '{name}: this app’s customizations could not be read.', - 'engine.studio.landing.envCustomizations.tab.all': 'All', - 'engine.studio.landing.envCustomizations.tab.fields': 'New fields', - 'engine.studio.landing.envCustomizations.tab.views': 'Forms and views', - 'engine.studio.landing.envCustomizations.tab.flows': 'Flows', - 'engine.studio.landing.envCustomizations.tab.switchedOff': 'Switched off', - 'engine.studio.landing.envCustomizations.search': 'Search customizations', - 'engine.studio.landing.envCustomizations.groupByApp': 'Group by app', - 'engine.studio.landing.envCustomizations.ungroup': 'One list', - 'engine.studio.landing.envCustomizations.showAll': 'Show all {count}', - 'engine.studio.landing.envCustomizations.noMatch': 'No customization matches.', - 'engine.studio.landing.envCustomizations.mode.changed': 'Changed', - 'engine.studio.landing.envCustomizations.mode.added': 'Added', - 'engine.studio.landing.envCustomizations.mode.switchedOff': 'Switched off', - 'engine.studio.landing.envCustomizations.type.object': 'Object', - 'engine.studio.landing.envCustomizations.type.field': 'Field', - 'engine.studio.landing.envCustomizations.type.validation': 'Validation rule', - 'engine.studio.landing.envCustomizations.type.index': 'Index', - 'engine.studio.landing.envCustomizations.type.view': 'View', - 'engine.studio.landing.envCustomizations.type.flow': 'Flow', - 'engine.studio.landing.envCustomizations.type.page': 'Page', - 'engine.studio.landing.envCustomizations.type.dashboard': 'Dashboard', - 'engine.studio.landing.envCustomizations.type.report': 'Report', - 'engine.studio.landing.envCustomizations.type.action': 'Action', - 'engine.studio.landing.envCustomizations.rowTitle': 'Open {name} in {app}', // objectstack#28561 — assignments are Setup's (ADR-0146 D7): the area links // the Setup page in place of the section. 'engine.studio.area.assignments.position': 'The people who hold this position are assigned in Setup.', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index a8e42226df5..226c984f6a7 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -1816,6 +1816,42 @@ const STUDIO_ZH: Record = { 'engine.packages.detail.description': '描述', 'engine.packages.detail.browseMetadata': '浏览此软件包的元数据', 'engine.packages.detail.openInStudio': '在 Studio 中打开', + 'engine.packages.customizations.heading': '本环境的定制', + 'engine.packages.customizations.customize': '在 Studio 中定制', + 'engine.packages.customizations.customizeTitle': '在 Studio 中打开这个应用,在那里定制它的条目', + 'engine.packages.customizations.loading': '正在读取定制…', + 'engine.packages.customizations.failed': '无法读取定制', + 'engine.packages.customizations.none': '本环境还没有改动', + 'engine.packages.customizations.customized': '已定制 {count} 项', + 'engine.packages.customizations.separator': ',', + 'engine.packages.customizations.switchedOff': '已停用 {count} 项', + 'engine.packages.customizations.tab.all': '全部', + 'engine.packages.customizations.tab.fields': '新增字段', + 'engine.packages.customizations.tab.views': '表单与视图', + 'engine.packages.customizations.tab.flows': '流程', + 'engine.packages.customizations.tab.arranged': '布局', + 'engine.packages.customizations.tab.switchedOff': '已停用', + 'engine.packages.customizations.search': '搜索定制', + 'engine.packages.customizations.showAll': '显示全部 {count} 项', + 'engine.packages.customizations.noMatch': '没有匹配的定制。', + 'engine.packages.customizations.mode.changed': '改了原有的', + 'engine.packages.customizations.mode.added': '新增的', + 'engine.packages.customizations.mode.arranged': '重新排列', + 'engine.packages.customizations.mode.switchedOff': '已停用', + 'engine.packages.customizations.arrangement.fieldGroups': '字段分组', + 'engine.packages.customizations.arrangement.relatedLists': '页签', + 'engine.packages.customizations.arrangement.actionLayout': '动作布局', + 'engine.packages.customizations.type.object': '对象', + 'engine.packages.customizations.type.field': '字段', + 'engine.packages.customizations.type.validation': '校验规则', + 'engine.packages.customizations.type.index': '索引', + 'engine.packages.customizations.type.view': '视图', + 'engine.packages.customizations.type.flow': '流程', + 'engine.packages.customizations.type.page': '页面', + 'engine.packages.customizations.type.dashboard': '仪表盘', + 'engine.packages.customizations.type.report': '报表', + 'engine.packages.customizations.type.action': '动作', + 'engine.packages.customizations.rowTitle': '在 Studio 中打开 {name}', 'engine.packages.detail.pendingChanges': '待发布更改', 'engine.packages.detail.pendingHint': '草稿尚未发布。可以发布整个应用,也可以逐项查看。', 'engine.packages.detail.publishApp': '发布应用({count})', @@ -3166,54 +3202,16 @@ const STUDIO_ZH: Record = { 'engine.studio.if.addInPairTitle': '新建到 {baseName} 的定制', 'engine.studio.interfaces.create.descriptionInPair': '存为本部署对 {baseName} 定制的草稿,并在画布上打开。{baseName} 的导航保持安装时的样子。', 'engine.studio.app.scaffoldNav': '将本包的对象添加为菜单项', - 'engine.studio.landing.title': '应用构建', - 'engine.studio.landing.description': '在一个可写软件包里设计对象、表单、自动化与界面;编辑存为草稿,整包一次发布。源码与已安装的软件包为只读:可在此浏览,并用「定制」或「新建类似」修改其条目,修改保存在该软件包的 .custom 定制包中。', - 'engine.studio.landing.mineHeading': '我的软件包(可写)', - 'engine.studio.landing.noneWritable': '还没有可写软件包 — 新建一个开始。', - 'engine.studio.landing.dup': '复制', - 'engine.studio.landing.dupTitle': '复制这个软件包为新的可写副本(类似「复制基座」)', 'engine.studio.landing.dupDefaultName': '{name} 副本', 'engine.studio.landing.dupNamePlaceholder': '副本名称', 'engine.studio.landing.dupIdPlaceholder': '副本包 ID', - 'engine.studio.landing.dupGo': '复制并进入构建器', - 'engine.studio.landing.dupCreated': '已复制为可写软件包「{name}」', - 'engine.studio.landing.installedHeading': '已安装(只读 · 可浏览)', - // objectui#11808 — the routes a read-only package does have. - 'engine.studio.landing.readonlyHint': '源码与已安装的软件包为只读,不能在此编辑或复制。要修改其中一个,请打开条目并选择「定制」或「新建类似」:修改保存在该软件包的 .custom 定制包中,升级仍会到达已安装的软件包。', - 'engine.studio.landing.marketplace': '或从应用市场安装一个模板应用', - 'engine.studio.landing.customizations.customized': '已定制 {customized} 项', - 'engine.studio.landing.customizations.separator': ',', - 'engine.studio.landing.customizations.switchedOff': '已停用 {switchedOff} 项', - 'engine.studio.landing.customizations.loading': '正在读取定制…', - 'engine.studio.landing.customizations.failed': '无法读取定制', - 'engine.studio.landing.customizations.pairTitle': '在 Studio 中打开定制包 {pair}', - 'engine.studio.landing.customizations.switchedOffTitle': '打开该软件包的自动化,在那里启用或停用其中的项', - 'engine.studio.landing.customizations.switchedOffActionsLead': '动作:', - 'engine.studio.landing.customizations.switchedOffActionsMore': '另 {count} 项', - 'engine.studio.landing.customizations.switchedOffActionsTitle': '打开已停用的动作:在动作上即可重新启用', // objectui#11553 — the package-less scope: the organization's own flows. - 'engine.studio.landing.orgHeading': '不属于软件包', 'engine.studio.org.name': '组织流程', 'engine.studio.org.hint': '不属于任何软件包的流程', 'engine.studio.org.description': '本组织自有、不属于任何软件包的流程,例如软件包流程的克隆副本。可直接编辑。', 'engine.studio.org.none': '没有不属于软件包的流程。要修改软件包中的流程,请打开它所在的软件包,使用“新建类似”。', - 'engine.studio.landing.envCatalog.name': '环境目录', - 'engine.studio.landing.envCatalog.description': '岗位、能力、权限集与共享规则,覆盖所有软件包。', - // objectstack#34715 — the landing ordered by what the author came to do. - 'engine.studio.landing.lead': '改已安装的应用,或者新建自己的应用。改动点击「保存」后立即生效。', - 'engine.studio.landing.appsHeading': '已安装的应用', - 'engine.studio.landing.appsHint': '应用本身由厂商升级;你的改动单独保存,升级不会冲掉。', - 'engine.studio.landing.marketplaceInstall': '从应用市场安装', - 'engine.studio.landing.customizeTitle': '定制 {name}', - 'engine.studio.landing.manage': '管理', - 'engine.studio.landing.manageTitle': '管理 {name}:信息、停用或启用、导出', - 'engine.studio.landing.allPackages': '全部软件包', - 'engine.studio.landing.allPackagesTitle': '本环境的全部软件包,可停用、启用和导出', - 'engine.studio.landing.customizations.none': '还没有改动', - 'engine.studio.landing.ownHeading': '自己的应用', - 'engine.studio.landing.newApp': '新建自己的应用', - 'engine.studio.landing.newAppDescription': '从空白开始。', - // objectstack#36748 — Studio 首页的「新建应用」入口:一个对话框同时建包和应用,全程只说「应用」。 + // objectstack#36748 — the package dialog's new-app step: one dialog creates the package and its app. + // The Studio home that opened it was removed (objectstack#36908); it stays for objectstack#37134. 'engine.studio.newApp.title': '新建应用', 'engine.studio.newApp.description': '给应用起个名字,其余都会自动填好。创建后立即可以打开。', 'engine.studio.newApp.advancedHint': '应用 ID、命名空间、版本和类型,已根据名称自动填写。', @@ -3232,41 +3230,6 @@ const STUDIO_ZH: Record = { 'engine.studio.newApp.failed': '创建应用失败', 'engine.studio.newApp.nameTaken': '应用「{label}」已经在用标识「{name}」。请在“高级”中换一个命名空间。', 'engine.studio.newApp.appFailed': '「{name}」已创建,但应用没能上线:{reason}。可以在 Studio 顶栏点「创建应用」重试。', - 'engine.studio.landing.outsideHeading': '不属于某个应用', - 'engine.studio.landing.rolesPermissions.name': '岗位与权限', - 'engine.studio.landing.rolesPermissions.description': '岗位、权限集、共享规则,所有应用共用。', - 'engine.studio.landing.unassignedFlows.name': '未归属的流程', - 'engine.studio.landing.unassignedFlows.description': '不属于任何应用的流程,例如应用流程的副本。可直接编辑。', - // objectstack#34714 — the landing's "Customizations in this environment" panel. - 'engine.studio.landing.envCustomizations.heading': '本环境的定制', - 'engine.studio.landing.envCustomizations.totalTitle': '已安装的应用上共 {count} 处改动', - 'engine.studio.landing.envCustomizations.loading': '正在读取本环境的改动…', - 'engine.studio.landing.envCustomizations.empty': '本环境还没有改过任何已安装的应用。', - 'engine.studio.landing.envCustomizations.unreadable': '{name}:这个应用的定制读不到。', - 'engine.studio.landing.envCustomizations.tab.all': '全部', - 'engine.studio.landing.envCustomizations.tab.fields': '新增字段', - 'engine.studio.landing.envCustomizations.tab.views': '表单与视图', - 'engine.studio.landing.envCustomizations.tab.flows': '流程', - 'engine.studio.landing.envCustomizations.tab.switchedOff': '已停用', - 'engine.studio.landing.envCustomizations.search': '搜索定制', - 'engine.studio.landing.envCustomizations.groupByApp': '按应用分组', - 'engine.studio.landing.envCustomizations.ungroup': '合成一张清单', - 'engine.studio.landing.envCustomizations.showAll': '显示全部 {count} 项', - 'engine.studio.landing.envCustomizations.noMatch': '没有匹配的定制。', - 'engine.studio.landing.envCustomizations.mode.changed': '改了原有的', - 'engine.studio.landing.envCustomizations.mode.added': '新增的', - 'engine.studio.landing.envCustomizations.mode.switchedOff': '已停用', - 'engine.studio.landing.envCustomizations.type.object': '对象', - 'engine.studio.landing.envCustomizations.type.field': '字段', - 'engine.studio.landing.envCustomizations.type.validation': '校验规则', - 'engine.studio.landing.envCustomizations.type.index': '索引', - 'engine.studio.landing.envCustomizations.type.view': '视图', - 'engine.studio.landing.envCustomizations.type.flow': '流程', - 'engine.studio.landing.envCustomizations.type.page': '页面', - 'engine.studio.landing.envCustomizations.type.dashboard': '仪表盘', - 'engine.studio.landing.envCustomizations.type.report': '报表', - 'engine.studio.landing.envCustomizations.type.action': '动作', - 'engine.studio.landing.envCustomizations.rowTitle': '在 {app} 里打开 {name}', 'engine.studio.area.assignments.position': '此岗位的任职人员在设置中分配。', 'engine.studio.area.assignments.permission': '此权限集分配给哪些人,在设置中管理。', 'engine.studio.area.assignments.open': '在设置中打开', From 556a93729978d5a939fa0d6ee2acbb8f0296629f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 23:11:31 +0000 Subject: [PATCH 05/21] test(studio): leave the pillar-nav guard's route sink as main has it Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- .../studio-design/StudioDesignSurface.pillarNavGuard.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cd7a1c6a232..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 @@ -201,7 +201,7 @@ async function renderSurfaceOnAccess() { } /> {/* objectstack#36899 — a menu type entry opens that type's area list. */} } /> - } /> + } /> } /> From 7c31991b02174e28dd70ee0db0a57329eae9b37d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 23:22:10 +0000 Subject: [PATCH 06/21] chore(changeset): remove the Studio home Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- .changeset/36908-remove-studio-home.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .changeset/36908-remove-studio-home.md diff --git a/.changeset/36908-remove-studio-home.md b/.changeset/36908-remove-studio-home.md new file mode 100644 index 00000000000..3eae925a813 --- /dev/null +++ b/.changeset/36908-remove-studio-home.md @@ -0,0 +1,23 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/console': patch +'@object-ui/i18n': patch +'@objectstack/platform-objects': patch +--- + +feat(studio): remove the Studio home page; `/studio` opens the last package or the package list, and an installed app's customizations show in Setup → Packages + +Clause-②: no +Metadata-protocol: none + +The package-card page at bare `/studio` is gone. Studio is opened from an app or from Setup → Packages. Every entry that page carried now has another home: + +- **`/studio`** opens the package you were last in, provided the package list still has it. Otherwise it opens Setup → Packages (`/apps/setup/component/developer/packages?face=admin`). A user who may enter Studio but not that Setup page goes to Studio's "All metadata" area across packages (`/studio/~all/metadata`) instead. The 「应用构建」 (`studio:builder`) entry of the `@objectstack/studio` app goes to the same place. +- **New package.** Home's and the `/ai` screen's 「New in Studio」 and the 「Add app」 menu open Setup → Packages with New Package already open (`?new=package`). After the package is created you land in Studio on it. An old `/studio?new=package` bookmark goes there too. Creating the package and its app in one step is the subject of a separate card; for now this flow creates the package only. +- **What this environment changed on an installed app.** The home page showed "n customized, m switched off" and a "Customizations in this environment" panel. Both are now in the app's detail in Setup → Packages, together with a 「在 Studio 中定制」 / "Customize in Studio" link. The count now includes tab, field-group and action-layout arrangements, so an app whose only change is a tab arrangement shows as customized. +- **Organization flows and the environment catalog** are in Studio's left menu. +- **A package Studio cannot find**, and a retired Setup page whose URL names no package, now go to Setup → Packages. + +The Packages page's development view (import, publish, revert, adopt loose items) is still at its address. Its menu entry is added by a separate card. + +`@object-ui/app-shell` is private. It no longer exports `BuilderLanding`, and it now exports `StudioEntryRedirect` and `SETUP_PACKAGES_PATH`. The `engine.studio.landing.*` strings are removed from `@object-ui/i18n`, except the three duplicate-form strings the Packages page still uses. The `engine.packages.customizations.*` strings are added. `@objectstack/platform-objects` changes a code comment only. From 9657609f70faad343227082d3b329ddb55434e67 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 23:30:30 +0000 Subject: [PATCH 07/21] refactor(studio): key the customizations panel on its package Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- .../app-shell/src/views/metadata-admin/PackagesPage.tsx | 2 +- .../src/views/studio-design/PackageCustomizationsPanel.tsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 8a3b4c994d0..042efe2944d 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -1271,7 +1271,7 @@ export function PackageDetailSheet({ {!authoring && !writable && !isKernel && !isCustomizationPackage(id) && ( <> - onOpenChange(false)} /> + onOpenChange(false)} /> )} diff --git a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx index 92e0b6b676d..ec4bfa777bf 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.tsx @@ -83,8 +83,9 @@ export function PackageCustomizationsPanel({ const client = useMetadataClient(); const [state, setState] = React.useState({ status: 'loading' }); React.useEffect(() => { + // A new package is a new mount (the sheet keys the panel on the id), so + // the state starts at `loading` without a reset here. let cancelled = false; - setState({ status: 'loading' }); fetchPackageCustomizations(packageId) .then(async (read) => { // objectstack#34724 — a switched-off action's link needs its object, From fe2355034712ef39db34bdda345be6700c7bb10a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 00:41:08 +0000 Subject: [PATCH 08/21] test(studio): type the customizations fixture by the served read Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- .../PackageCustomizationsPanel.test.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx index acaa449d1ff..825ae45d4e9 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx @@ -36,19 +36,16 @@ vi.mock('../metadata-admin/useMetadata.js', async (importOriginal) => ({ import { PACKAGE_CUSTOMIZATION_ROWS_SHOWN, PackageCustomizationsPanel } from './PackageCustomizationsPanel'; import { customizationRowsOf, customizedCountOf, loadCustomizationLabels } from './packageCustomizationRows'; import { t } from '../metadata-admin/i18n'; +import type { PackageCustomizations } from './packageCustomizations-io'; const APP = 'app.objectstack.hotcrm'; -type Lists = { - overrides?: Array>; - extensions?: Array>; - arrangements?: Array>; - switchedOff?: Array>; - contributions?: Array>; -}; +type Lists = Partial< + Pick +>; /** A served answer, its counts derived from its lists as the route derives them. */ -function served(l: Lists = {}) { +function served(l: Lists = {}): PackageCustomizations { const data = { packageId: APP, overrides: l.overrides ?? [], From 4a67173ef03f7e4676cd7aae55487bdc633fda70 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 00:44:27 +0000 Subject: [PATCH 09/21] test(studio): pay the plugin-detail load at collection in the not-found pin check:test-source-alias: the pin reaches import('@object-ui/plugin-detail') through the command palette; the home-loop pin is left as main has it. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYkkwuF6UuFtu85Yd5H --- .../studio-design/StudioDesignSurface.homeLoop-12513.test.tsx | 2 +- .../studio-design/StudioDesignSurface.notFound-26708.test.tsx | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 e2150e1404c..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 @@ -204,7 +204,7 @@ function renderAt(url: string) { - } /> + } /> } /> , 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 f6c7c7c112f..cdc57a7f79b 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 @@ -24,6 +24,9 @@ import '@testing-library/jest-dom/vitest'; // The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. import '@objectstack/lint'; +// The source under test reaches `import('@object-ui/plugin-detail')` (the command palette's lazy +// detail surfaces): paid here, at collection, never inside a test's clock. +import '@object-ui/plugin-detail'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react'; import * as React from 'react'; From eb04eb9fdba0f100586d5490b389b32a4b2a8448 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 01:09:00 +0000 Subject: [PATCH 10/21] test(layout): drop the Studio home's deleted frame from the top-bar census The census listed StudioRoute.tsx as a literal copy of the bar; that frame went with the Studio home. Five frames remain, all token or AppShell. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYoTgerzGuKa8DDrMii --- .../consoleTopBar.height-12639.test.ts | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/ui/packages/app-shell/src/layout/__tests__/consoleTopBar.height-12639.test.ts b/ui/packages/app-shell/src/layout/__tests__/consoleTopBar.height-12639.test.ts index 5bb13a68b3d..59fe2837cc2 100644 --- a/ui/packages/app-shell/src/layout/__tests__/consoleTopBar.height-12639.test.ts +++ b/ui/packages/app-shell/src/layout/__tests__/consoleTopBar.height-12639.test.ts @@ -5,9 +5,11 @@ * * ## The defect this holds closed * - * The console's top bar is not one component: six frames each draw a sticky + * The console's top bar is not one component: five frames each draw a sticky * `header` around `AppHeader` (or, inside an app, `AppShell` draws it around * the `navbar` that `ConsoleLayout` hands it). They were all `h-14`, 56 px. + * (A sixth, the Studio home's console frame in `apps/console`'s + * `StudioRoute.tsx`, was deleted with that home by objectstack#36908.) * The approved artboards draw the bar at 48 px, and changing one frame alone * makes the bar jump on the way from Home into an app — which is why * objectui#12601 left Home at 56 px and carded this. So the height is held for @@ -17,12 +19,12 @@ * - what sits under the bar at the viewport's edge (the app sidebar) offsets * by that same height, derived from it rather than restated; * - every frame that mounts `AppHeader` draws its bar from that constant — - * by reading it, or, across a package boundary it cannot import over, as a - * literal equal to it; + * by reading it, or, through `@object-ui/layout`'s `AppShell`, which cannot + * import over the package boundary, as a literal equal to it; * - no other source copies the bar's class, and nothing offsets from a * 56 px bar any more. * - * A seventh frame that mounts `AppHeader`, a copy of the bar's class anywhere + * A sixth frame that mounts `AppHeader`, a copy of the bar's class anywhere * in the trees below, or a revert of any one frame to `h-14` turns this file * red. * @@ -69,24 +71,20 @@ const LAYOUT_APP_SHELL = 'packages/layout/src/AppShell.tsx'; * token reads `CONSOLE_TOP_BAR` (this package's frames) * app-shell hands `AppHeader` to `@object-ui/layout`'s `AppShell` as its * `navbar`; that header is a literal equal to the constant - * literal a frame outside this package; its header is a literal equal to - * the constant + * + * `apps/console/src/components/StudioRoute.tsx` was listed here as a literal + * copy until objectstack#36908 deleted the Studio home's console frame it drew. */ -const FRAMES: ReadonlyArray<{ file: string; bar: 'token' | 'app-shell' | 'literal' }> = [ +const FRAMES: ReadonlyArray<{ file: string; bar: 'token' | 'app-shell' }> = [ { file: 'packages/app-shell/src/console/home/HomeLayout.tsx', bar: 'token' }, { file: 'packages/app-shell/src/console/organizations/OrganizationsLayout.tsx', bar: 'token' }, { file: 'packages/app-shell/src/console/organizations/manage/OrganizationLayout.tsx', bar: 'token' }, { file: 'packages/app-shell/src/console/ai/AiChatPage.tsx', bar: 'token' }, { file: 'packages/app-shell/src/layout/ConsoleLayout.tsx', bar: 'app-shell' }, - { file: 'apps/console/src/components/StudioRoute.tsx', bar: 'literal' }, ]; -/** The sources allowed to spell the bar's class as a literal: the constant and its two copies. */ -const LITERAL_SITES = new Set([ - TOKEN_MODULE, - LAYOUT_APP_SHELL, - ...FRAMES.filter((f) => f.bar === 'literal').map((f) => f.file), -]); +/** The sources allowed to spell the bar's class as a literal: the constant and its one copy. */ +const LITERAL_SITES = new Set([TOKEN_MODULE, LAYOUT_APP_SHELL]); /** The workspace directories whose `package.json` names this package as a dependency, and this package. */ function packagesThatCanMountAppHeader(): string[] { @@ -177,7 +175,7 @@ describe('the console top bar is one 48 px bar in every frame (objectui#12639)', expect(SCANNED).toContain(LAYOUT_APP_SHELL); }); - it('every frame that mounts `AppHeader` is listed here, so a seventh frame cannot draw its own bar', () => { + it('every frame that mounts `AppHeader` is listed here, so a sixth frame cannot draw its own bar', () => { const mounting = SCANNED.filter((rel) => / { + it(`${file} draws the bar ${bar === 'token' ? 'from `CONSOLE_TOP_BAR`' : 'through `AppShell`, equal to `CONSOLE_TOP_BAR`'}`, () => { if (bar === 'token') { const tag = headerTagOf(file); expect(tag, `${file}'s top bar no longer reads CONSOLE_TOP_BAR`).toMatch( @@ -198,19 +196,15 @@ describe('the console top bar is one 48 px bar in every frame (objectui#12639)', expect(heightStepsOf(tag.replace(/CONSOLE_TOP_BAR/, '')), `${file} sets its own bar height`).toEqual([]); return; } - if (bar === 'app-shell') { - expect(code(file)).toMatch(/import\s*\{[^}]*\bAppShell\b[^}]*\}\s*from\s*'@object-ui\/layout'/); - // The same slot draws the design mode's bar while the mode is on - // (objectstack#36362), and so at the same height. - expect(code(file)).toMatch( - / Date: Wed, 25 Nov 2026 01:09:00 +0000 Subject: [PATCH 11/21] fix(i18n): keep the Studio home's released strings, unread 68 of the deleted engine.studio.landing keys and landingHome ship in @object-ui/i18n 18.6.0; removing a published key is a narrowing. They return to en and zh unread. The four never released stay removed. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYoTgerzGuKa8DDrMii --- .changeset/36908-remove-studio-home.md | 2 +- ui/packages/i18n/src/namespaces/studio/en.ts | 72 ++++++++++++++++++++ ui/packages/i18n/src/namespaces/studio/zh.ts | 72 ++++++++++++++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) diff --git a/.changeset/36908-remove-studio-home.md b/.changeset/36908-remove-studio-home.md index 3eae925a813..934249936ba 100644 --- a/.changeset/36908-remove-studio-home.md +++ b/.changeset/36908-remove-studio-home.md @@ -20,4 +20,4 @@ The package-card page at bare `/studio` is gone. Studio is opened from an app or The Packages page's development view (import, publish, revert, adopt loose items) is still at its address. Its menu entry is added by a separate card. -`@object-ui/app-shell` is private. It no longer exports `BuilderLanding`, and it now exports `StudioEntryRedirect` and `SETUP_PACKAGES_PATH`. The `engine.studio.landing.*` strings are removed from `@object-ui/i18n`, except the three duplicate-form strings the Packages page still uses. The `engine.packages.customizations.*` strings are added. `@objectstack/platform-objects` changes a code comment only. +`@object-ui/app-shell` is private. It no longer exports `BuilderLanding`, and it now exports `StudioEntryRedirect` and `SETUP_PACKAGES_PATH`. In `@object-ui/i18n`, the `engine.studio.landing.*` strings and `engine.studio.landingHome` that shipped in 18.6.0 stay in the studio namespace (`en`, `zh`), no longer read; no published key is removed. Four landing strings added after 18.6.0 and never released are removed. The `engine.packages.customizations.*` strings are added. `@objectstack/platform-objects` changes a code comment only. diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 8f20b269230..9387e5178af 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -4849,6 +4849,78 @@ const STUDIO_EN: Record = { 'engine.studio.itemTabs.history': 'History', 'engine.studio.itemTabs.source': 'Source', 'engine.studio.itemTabs.versions': 'Versions', + // objectstack#36908 removed the Studio home, the only reader of these keys. + // They ship in the released `@object-ui/i18n@18.6.0`, so they stay published, + // unread: removing a published key is a narrowing a separate change decides. + // (The home's four Manage / All packages keys never shipped and are gone.) + 'engine.studio.landingHome': 'Studio home', + 'engine.studio.landing.title': 'App Builder', + 'engine.studio.landing.description': 'Design objects, forms, automations and interfaces inside a writable package; edits save as drafts and the whole package publishes in one release. Code and installed packages are read-only: browse them here, and change their items with Customize or New similar, which save into the package’s .custom customization package.', + 'engine.studio.landing.mineHeading': 'My packages (writable)', + 'engine.studio.landing.noneWritable': 'No writable packages yet — create one to start.', + 'engine.studio.landing.dup': 'Duplicate', + 'engine.studio.landing.dupTitle': 'Duplicate this package into a new writable copy (like “duplicate base”)', + 'engine.studio.landing.dupGo': 'Duplicate and open the builder', + 'engine.studio.landing.dupCreated': 'Duplicated into writable package “{name}”', + 'engine.studio.landing.installedHeading': 'Installed (read-only · browsable)', + 'engine.studio.landing.readonlyHint': 'Code and installed packages are read-only, so they are not edited or duplicated here. To change one, open an item and choose Customize or New similar: the change is saved in the package’s .custom customization package, and upgrades keep reaching the installed package.', + 'engine.studio.landing.marketplace': 'Or install a template app from the marketplace', + 'engine.studio.landing.customizations.customized': '{customized} customized', + 'engine.studio.landing.customizations.separator': ', ', + 'engine.studio.landing.customizations.switchedOff': '{switchedOff} switched off', + 'engine.studio.landing.customizations.loading': 'Reading customizations…', + 'engine.studio.landing.customizations.failed': 'Couldn’t read customizations', + 'engine.studio.landing.customizations.pairTitle': 'Open the customization package {pair} in Studio', + 'engine.studio.landing.customizations.switchedOffTitle': 'Open this package’s Automations, where its items are switched on and off', + 'engine.studio.landing.customizations.switchedOffActionsLead': 'Actions: ', + 'engine.studio.landing.customizations.switchedOffActionsMore': '+{count} more', + 'engine.studio.landing.customizations.switchedOffActionsTitle': 'Open the switched-off actions: each one is switched on again on the action', + 'engine.studio.landing.orgHeading': 'Not in a package', + 'engine.studio.landing.envCatalog.name': 'Environment catalog', + 'engine.studio.landing.envCatalog.description': 'Positions, capabilities, permission sets and sharing rules, across every package.', + 'engine.studio.landing.lead': 'Change an installed app, or build an app of your own. Changes take effect when you press Save.', + 'engine.studio.landing.appsHeading': 'Installed apps', + 'engine.studio.landing.appsHint': 'Each app is upgraded by its vendor. Your changes are kept separately, so an upgrade does not overwrite them.', + 'engine.studio.landing.marketplaceInstall': 'Install from the marketplace', + 'engine.studio.landing.customizeTitle': 'Customize {name}', + 'engine.studio.landing.customizations.none': 'No changes yet', + 'engine.studio.landing.ownHeading': 'Your own apps', + 'engine.studio.landing.newApp': 'New app of your own', + 'engine.studio.landing.newAppDescription': 'Start from a blank app.', + 'engine.studio.landing.outsideHeading': 'Outside any app', + 'engine.studio.landing.rolesPermissions.name': 'Positions and permissions', + 'engine.studio.landing.rolesPermissions.description': 'Positions, permission sets and sharing rules, shared by every app.', + 'engine.studio.landing.unassignedFlows.name': 'Flows in no app', + 'engine.studio.landing.unassignedFlows.description': 'Flows that belong to no app, such as a copy of an app’s flow. They open editable.', + 'engine.studio.landing.envCustomizations.heading': 'Customizations in this environment', + 'engine.studio.landing.envCustomizations.totalTitle': '{count} changes across the installed apps', + 'engine.studio.landing.envCustomizations.loading': 'Reading what this environment changed…', + 'engine.studio.landing.envCustomizations.empty': 'No installed app has been changed in this environment yet.', + 'engine.studio.landing.envCustomizations.unreadable': '{name}: this app’s customizations could not be read.', + 'engine.studio.landing.envCustomizations.tab.all': 'All', + 'engine.studio.landing.envCustomizations.tab.fields': 'New fields', + 'engine.studio.landing.envCustomizations.tab.views': 'Forms and views', + 'engine.studio.landing.envCustomizations.tab.flows': 'Flows', + 'engine.studio.landing.envCustomizations.tab.switchedOff': 'Switched off', + 'engine.studio.landing.envCustomizations.search': 'Search customizations', + 'engine.studio.landing.envCustomizations.groupByApp': 'Group by app', + 'engine.studio.landing.envCustomizations.ungroup': 'One list', + 'engine.studio.landing.envCustomizations.showAll': 'Show all {count}', + 'engine.studio.landing.envCustomizations.noMatch': 'No customization matches.', + 'engine.studio.landing.envCustomizations.mode.changed': 'Changed', + 'engine.studio.landing.envCustomizations.mode.added': 'Added', + 'engine.studio.landing.envCustomizations.mode.switchedOff': 'Switched off', + 'engine.studio.landing.envCustomizations.type.object': 'Object', + 'engine.studio.landing.envCustomizations.type.field': 'Field', + 'engine.studio.landing.envCustomizations.type.validation': 'Validation rule', + 'engine.studio.landing.envCustomizations.type.index': 'Index', + 'engine.studio.landing.envCustomizations.type.view': 'View', + 'engine.studio.landing.envCustomizations.type.flow': 'Flow', + 'engine.studio.landing.envCustomizations.type.page': 'Page', + 'engine.studio.landing.envCustomizations.type.dashboard': 'Dashboard', + 'engine.studio.landing.envCustomizations.type.report': 'Report', + 'engine.studio.landing.envCustomizations.type.action': 'Action', + 'engine.studio.landing.envCustomizations.rowTitle': 'Open {name} in {app}', }; export default STUDIO_EN; diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 226c984f6a7..48be7a6db23 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -4363,6 +4363,78 @@ const STUDIO_ZH: Record = { 'engine.studio.itemTabs.history': '历史', 'engine.studio.itemTabs.source': '源码', 'engine.studio.itemTabs.versions': '版本', + // objectstack#36908 removed the Studio home, the only reader of these keys. + // They ship in the released `@object-ui/i18n@18.6.0`, so they stay published, + // unread: removing a published key is a narrowing a separate change decides. + // (The home's four Manage / All packages keys never shipped and are gone.) + 'engine.studio.landingHome': 'Studio 首页', + 'engine.studio.landing.title': '应用构建', + 'engine.studio.landing.description': '在一个可写软件包里设计对象、表单、自动化与界面;编辑存为草稿,整包一次发布。源码与已安装的软件包为只读:可在此浏览,并用「定制」或「新建类似」修改其条目,修改保存在该软件包的 .custom 定制包中。', + 'engine.studio.landing.mineHeading': '我的软件包(可写)', + 'engine.studio.landing.noneWritable': '还没有可写软件包 — 新建一个开始。', + 'engine.studio.landing.dup': '复制', + 'engine.studio.landing.dupTitle': '复制这个软件包为新的可写副本(类似「复制基座」)', + 'engine.studio.landing.dupGo': '复制并进入构建器', + 'engine.studio.landing.dupCreated': '已复制为可写软件包「{name}」', + 'engine.studio.landing.installedHeading': '已安装(只读 · 可浏览)', + 'engine.studio.landing.readonlyHint': '源码与已安装的软件包为只读,不能在此编辑或复制。要修改其中一个,请打开条目并选择「定制」或「新建类似」:修改保存在该软件包的 .custom 定制包中,升级仍会到达已安装的软件包。', + 'engine.studio.landing.marketplace': '或从应用市场安装一个模板应用', + 'engine.studio.landing.customizations.customized': '已定制 {customized} 项', + 'engine.studio.landing.customizations.separator': ',', + 'engine.studio.landing.customizations.switchedOff': '已停用 {switchedOff} 项', + 'engine.studio.landing.customizations.loading': '正在读取定制…', + 'engine.studio.landing.customizations.failed': '无法读取定制', + 'engine.studio.landing.customizations.pairTitle': '在 Studio 中打开定制包 {pair}', + 'engine.studio.landing.customizations.switchedOffTitle': '打开该软件包的自动化,在那里启用或停用其中的项', + 'engine.studio.landing.customizations.switchedOffActionsLead': '动作:', + 'engine.studio.landing.customizations.switchedOffActionsMore': '另 {count} 项', + 'engine.studio.landing.customizations.switchedOffActionsTitle': '打开已停用的动作:在动作上即可重新启用', + 'engine.studio.landing.orgHeading': '不属于软件包', + 'engine.studio.landing.envCatalog.name': '环境目录', + 'engine.studio.landing.envCatalog.description': '岗位、能力、权限集与共享规则,覆盖所有软件包。', + 'engine.studio.landing.lead': '改已安装的应用,或者新建自己的应用。改动点击「保存」后立即生效。', + 'engine.studio.landing.appsHeading': '已安装的应用', + 'engine.studio.landing.appsHint': '应用本身由厂商升级;你的改动单独保存,升级不会冲掉。', + 'engine.studio.landing.marketplaceInstall': '从应用市场安装', + 'engine.studio.landing.customizeTitle': '定制 {name}', + 'engine.studio.landing.customizations.none': '还没有改动', + 'engine.studio.landing.ownHeading': '自己的应用', + 'engine.studio.landing.newApp': '新建自己的应用', + 'engine.studio.landing.newAppDescription': '从空白开始。', + 'engine.studio.landing.outsideHeading': '不属于某个应用', + 'engine.studio.landing.rolesPermissions.name': '岗位与权限', + 'engine.studio.landing.rolesPermissions.description': '岗位、权限集、共享规则,所有应用共用。', + 'engine.studio.landing.unassignedFlows.name': '未归属的流程', + 'engine.studio.landing.unassignedFlows.description': '不属于任何应用的流程,例如应用流程的副本。可直接编辑。', + 'engine.studio.landing.envCustomizations.heading': '本环境的定制', + 'engine.studio.landing.envCustomizations.totalTitle': '已安装的应用上共 {count} 处改动', + 'engine.studio.landing.envCustomizations.loading': '正在读取本环境的改动…', + 'engine.studio.landing.envCustomizations.empty': '本环境还没有改过任何已安装的应用。', + 'engine.studio.landing.envCustomizations.unreadable': '{name}:这个应用的定制读不到。', + 'engine.studio.landing.envCustomizations.tab.all': '全部', + 'engine.studio.landing.envCustomizations.tab.fields': '新增字段', + 'engine.studio.landing.envCustomizations.tab.views': '表单与视图', + 'engine.studio.landing.envCustomizations.tab.flows': '流程', + 'engine.studio.landing.envCustomizations.tab.switchedOff': '已停用', + 'engine.studio.landing.envCustomizations.search': '搜索定制', + 'engine.studio.landing.envCustomizations.groupByApp': '按应用分组', + 'engine.studio.landing.envCustomizations.ungroup': '合成一张清单', + 'engine.studio.landing.envCustomizations.showAll': '显示全部 {count} 项', + 'engine.studio.landing.envCustomizations.noMatch': '没有匹配的定制。', + 'engine.studio.landing.envCustomizations.mode.changed': '改了原有的', + 'engine.studio.landing.envCustomizations.mode.added': '新增的', + 'engine.studio.landing.envCustomizations.mode.switchedOff': '已停用', + 'engine.studio.landing.envCustomizations.type.object': '对象', + 'engine.studio.landing.envCustomizations.type.field': '字段', + 'engine.studio.landing.envCustomizations.type.validation': '校验规则', + 'engine.studio.landing.envCustomizations.type.index': '索引', + 'engine.studio.landing.envCustomizations.type.view': '视图', + 'engine.studio.landing.envCustomizations.type.flow': '流程', + 'engine.studio.landing.envCustomizations.type.page': '页面', + 'engine.studio.landing.envCustomizations.type.dashboard': '仪表盘', + 'engine.studio.landing.envCustomizations.type.report': '报表', + 'engine.studio.landing.envCustomizations.type.action': '动作', + 'engine.studio.landing.envCustomizations.rowTitle': '在 {app} 里打开 {name}', }; export default STUDIO_ZH; From a21c7b6ff4c648c77d903f75713871acba2750b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 01:51:53 +0000 Subject: [PATCH 12/21] test(console): a packaged-actions bookmark naming no package opens Setup > Packages The retired page's no-package fallback opened the Studio home; with that home removed it opens the package list on the admin face. The pin still expected /studio. The named-package case is unchanged. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01QSeKYoTgerzGuKa8DDrMii --- ...Content.setupMetadataStudio-28578.test.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx b/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx index 336353ddd93..5079ab94d0c 100644 --- a/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx +++ b/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx @@ -30,7 +30,8 @@ * Automations pillar for the package its `?package=` names, or the area's * cross-package flow list when it names none. And objectstack#34724: a * bookmark of Setup › Packaged Actions (`component/automation/packaged-actions`) - * opens the named app's Data pillar, or the Studio landing. + * opens the named app's Data pillar, or, naming no package, Setup → Packages + * (objectstack#36908 removed the Studio home it opened before). * * The host's own aliases (`system/objects`, `system/metadata`, * `system/{roles,positions,permissions}`) are `apps/console`'s, pinned in @@ -48,7 +49,7 @@ import React from 'react'; // first load is paid here, at collection, never inside a case's clock // (`check:test-source-alias`). import '@objectstack/lint'; -import { render, screen } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import { MemoryRouter, Routes, Route, Navigate, useLocation, useParams } from 'react-router-dom'; vi.mock('../../views/metadata-admin', () => ({ @@ -235,15 +236,27 @@ describe('a bookmark of the retired Setup › Packaged automation page opens Stu describe('a bookmark of the retired Setup › Packaged Actions page opens Studio (objectstack#34724)', () => { it.each([ - ['/apps/setup/component/automation/packaged-actions', '/studio'], ['/apps/setup/component/automation/packaged-actions?package=crm', '/studio/crm/data?package=crm'], - ['/apps/crm/component/automation/packaged-actions?package=all', '/studio?package=all'], ])('%s → %s, in one hop', async (from, to) => { const chain = renderAt(from); expect(await screen.findByTestId('studio-probe')).toBeInTheDocument(); expect(chain).toEqual([from, to]); }); + + // Naming no package (or `all`), it opened the Studio home, which listed every + // installed app; objectstack#36908 removed that home, so the bookmark opens + // Setup → Packages on its admin face, the package list, and not Studio. + it.each([ + ['/apps/setup/component/automation/packaged-actions'], + ['/apps/crm/component/automation/packaged-actions?package=all'], + ])('%s → Setup → Packages, in one hop', async (from) => { + const chain = renderAt(from); + + await waitFor(() => expect(chain).toEqual([from, '/apps/setup/component/developer/packages?face=admin'])); + expect(await screen.findByTestId('console-layout')).toBeInTheDocument(); + expect(screen.queryByTestId('studio-probe')).not.toBeInTheDocument(); + }); }); describe('the datasource pages keep their own shape', () => { From 890cbfd5f26176b277192dd256a00d8a035b8ef3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 03:06:50 +0000 Subject: [PATCH 13/21] fix(studio): send Studio-only authors off the new-package bookmark and not-found exit to All metadata The retired /studio?new=package bookmark and the package-not-found state's way out both sent every principal to Setup > Packages. A principal who may enter Studio but not open that Setup page landed on its access-denied page. Both now read the capability set Studio's entry gate read, through a provider app-shell exports, and choose the same way bare /studio does. Also: the permission matrix's read-only hint copy pin moves off the deleted Studio-home test; the new-app step's three cases move onto PackageFormDialog; the Packages detail gate gets its kernel and .custom cases; the changeset is rewritten in user terms with the i18n note in its own changeset; stale names of the removed home are corrected. Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .changeset/36908-remove-studio-home.md | 17 +- .changeset/36908-studio-home-strings.md | 10 + .../areas/studio-authoring.json | 2 +- .../console/src/components/StudioRoute.tsx | 17 +- ui/packages/app-shell/src/index.ts | 7 + ...ackageFormDialog.newAppStep-36748.test.tsx | 278 ++++++++++++++++++ ...esPage.installedAppsUpdates-34722.test.tsx | 60 +++- ...atrixEditor.readOnlyHintCopy-12171.test.ts | 104 +++++++ ...tudioDesignSurface.notFound-26708.test.tsx | 53 +++- .../studio-design/StudioDesignSurface.tsx | 17 +- .../StudioEntryRedirect.test.tsx | 24 +- .../studio-design/StudioEntryRedirect.tsx | 25 +- .../studio-design/studioAddress.guard.test.ts | 2 +- .../studio-design/studioEntryPermissions.ts | 27 ++ ui/packages/i18n/src/namespaces/studio/en.ts | 3 + ui/packages/i18n/src/namespaces/studio/zh.ts | 1 + ui/scripts/check-eager-closure-budget.mjs | 8 +- 17 files changed, 609 insertions(+), 46 deletions(-) create mode 100644 .changeset/36908-studio-home-strings.md create mode 100644 ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx create mode 100644 ui/packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.readOnlyHintCopy-12171.test.ts create mode 100644 ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts diff --git a/.changeset/36908-remove-studio-home.md b/.changeset/36908-remove-studio-home.md index 934249936ba..b087702e000 100644 --- a/.changeset/36908-remove-studio-home.md +++ b/.changeset/36908-remove-studio-home.md @@ -1,23 +1,20 @@ --- '@object-ui/app-shell': patch '@object-ui/console': patch -'@object-ui/i18n': patch '@objectstack/platform-objects': patch --- -feat(studio): remove the Studio home page; `/studio` opens the last package or the package list, and an installed app's customizations show in Setup → Packages +feat(studio): Studio no longer has a home page; opening Studio takes you to the package you were last in, or to the package list Clause-②: no Metadata-protocol: none -The package-card page at bare `/studio` is gone. Studio is opened from an app or from Setup → Packages. Every entry that page carried now has another home: +The package-card page Studio used to open on is gone. Studio is opened from an app or from Setup → Packages, and everything that page offered has another place: -- **`/studio`** opens the package you were last in, provided the package list still has it. Otherwise it opens Setup → Packages (`/apps/setup/component/developer/packages?face=admin`). A user who may enter Studio but not that Setup page goes to Studio's "All metadata" area across packages (`/studio/~all/metadata`) instead. The 「应用构建」 (`studio:builder`) entry of the `@objectstack/studio` app goes to the same place. -- **New package.** Home's and the `/ai` screen's 「New in Studio」 and the 「Add app」 menu open Setup → Packages with New Package already open (`?new=package`). After the package is created you land in Studio on it. An old `/studio?new=package` bookmark goes there too. Creating the package and its app in one step is the subject of a separate card; for now this flow creates the package only. -- **What this environment changed on an installed app.** The home page showed "n customized, m switched off" and a "Customizations in this environment" panel. Both are now in the app's detail in Setup → Packages, together with a 「在 Studio 中定制」 / "Customize in Studio" link. The count now includes tab, field-group and action-layout arrangements, so an app whose only change is a tab arrangement shows as customized. +- **Opening Studio** takes you to the package you were last in, if it is still installed. Otherwise an administrator lands on Setup → Packages, and a developer who cannot open that Setup page lands on the All metadata area. The 应用构建 entry of the Studio app goes to the same place. +- **New package.** 「New in Studio」 on Home and on the AI-unavailable screen, and the 「Add app」 menu, open Setup → Packages with the New Package dialog already open. After the package is created you land in Studio on it. An old bookmark to Studio's new-package page goes there too, or to the All metadata area for a developer who cannot open Setup → Packages. Creating a package and its app in one step comes with a later change; for now this creates the package only. +- **What this environment changed on an installed app.** The "n customized, m switched off" line and the "Customizations in this environment" panel are now in the app's detail in Setup → Packages, with a 「Customize in Studio」 link. The count now includes tab, field-group and action-layout arrangements, so an app whose only change is a tab arrangement shows as customized. The list across all installed apps at once is now shown one app at a time. - **Organization flows and the environment catalog** are in Studio's left menu. -- **A package Studio cannot find**, and a retired Setup page whose URL names no package, now go to Setup → Packages. +- **A package Studio cannot find** offers a way to Setup → Packages, or to the All metadata area for a developer who cannot open that page. A retired Setup page whose address names no package opens Setup → Packages. -The Packages page's development view (import, publish, revert, adopt loose items) is still at its address. Its menu entry is added by a separate card. - -`@object-ui/app-shell` is private. It no longer exports `BuilderLanding`, and it now exports `StudioEntryRedirect` and `SETUP_PACKAGES_PATH`. In `@object-ui/i18n`, the `engine.studio.landing.*` strings and `engine.studio.landingHome` that shipped in 18.6.0 stay in the studio namespace (`en`, `zh`), no longer read; no published key is removed. Four landing strings added after 18.6.0 and never released are removed. The `engine.packages.customizations.*` strings are added. `@objectstack/platform-objects` changes a code comment only. +The Packages page's developer view (import, publish, revert, adopt loose items) still opens at its address; its menu entry comes with a later change. diff --git a/.changeset/36908-studio-home-strings.md b/.changeset/36908-studio-home-strings.md new file mode 100644 index 00000000000..8a5b8f1e0cb --- /dev/null +++ b/.changeset/36908-studio-home-strings.md @@ -0,0 +1,10 @@ +--- +'@object-ui/i18n': patch +--- + +feat(i18n): strings for the customizations section in Setup → Packages and for Studio's way out of a missing package + +Clause-②: no +Metadata-protocol: none + +Adds the strings for the customizations section of an app's detail in Setup → Packages, and for the way out of Studio's "package not found" state. The strings of Studio's removed home page that shipped in 18.6.0 stay in the studio namespace, no longer read, so no released string is removed. Four of that page's strings that were added after 18.6.0 and never released are removed. diff --git a/docs/qa/platform-checklist/areas/studio-authoring.json b/docs/qa/platform-checklist/areas/studio-authoring.json index cb3c7fe525f..d0cd17326be 100644 --- a/docs/qa/platform-checklist/areas/studio-authoring.json +++ b/docs/qa/platform-checklist/areas/studio-authoring.json @@ -5184,7 +5184,7 @@ { "revision": 4, "date": "2026-11-24", - "change": "the line moved from the removed Studio home to the read-only base's detail in Setup → Packages (#36908): title, steps[1], steps[4], acceptance[0] and [2], automated.ref and source re-pointed; acceptance[0] now counts counts.arrangements in n (#36833, closed into #36908). The All metadata half is unchanged", + "change": "the line moved from the removed Studio home to the read-only base's detail in Setup → Packages (#36908): title, steps[1], steps[4], acceptance[0] and [2], automated.ref and source re-pointed; acceptance[0] now counts counts.arrangements in n (#36833's requirement; that card was closed as not planned, and #36908 delivers it in the panel's new home). The All metadata half is unchanged", "ref": "#36908" } ] diff --git a/ui/apps/console/src/components/StudioRoute.tsx b/ui/apps/console/src/components/StudioRoute.tsx index 0e63e651f3b..6187a51ed2a 100644 --- a/ui/apps/console/src/components/StudioRoute.tsx +++ b/ui/apps/console/src/components/StudioRoute.tsx @@ -34,7 +34,7 @@ * Studio exists for. The gate belongs here, in this app's router. */ -import { createContext, lazy, Suspense, useContext, useEffect, type ReactNode } from 'react'; +import { lazy, Suspense, useEffect, type ReactNode } from 'react'; import { Link, Navigate, Outlet, Route, useParams } from 'react-router-dom'; import { Lock } from 'lucide-react'; import { Button, Empty, EmptyTitle } from '@object-ui/components'; @@ -46,10 +46,12 @@ import { STUDIO_METADATA_AREA, STUDIO_ORG_SCOPE_PILLAR, STUDIO_ORG_SCOPE_SEGMENT, + StudioEntryPermissionsProvider, studioMetadataAreaPath, studioPackagePath, useHomePath, useRecentItems, + useStudioEntryPermissions, } from '@object-ui/app-shell'; import { useObjectTranslation } from '@object-ui/i18n'; @@ -78,12 +80,6 @@ const StudioEntryRedirect = lazy(() => import('./studioBuilder').then((m) => ({ default: m.StudioEntryRedirect })), ); -/** - * The capability set the entry gate read, for the screens below it that choose - * by it (Studio's entry, objectstack#36908). Provided only around a holder. - */ -const StudioEntryPermissions = createContext(undefined); - /** * What a principal without `studio.access` sees, at the Studio URL they opened * (objectui#12035): one sentence saying Studio access is needed, and the way @@ -164,7 +160,10 @@ export function RequireStudioAccess({ } return ( - {children} + // The capability set this gate read, for the Studio screens below it that + // choose a destination by it: Studio's entry and the package-not-found + // state's way out (objectstack#36908). Provided only around a holder. + {children} ); } @@ -188,7 +187,7 @@ export function StudioRoute() { * entered from an app or from Setup → Packages. */ function StudioEntry() { - const systemPermissions = useContext(StudioEntryPermissions); + const systemPermissions = useStudioEntryPermissions(); return ( }> } /> diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index 2a95ad72253..4accce1760c 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -598,6 +598,13 @@ export { // author was last in, else the package list. A host that declares the // `/studio` routes mounts it as their index. export { StudioEntryRedirect } from './views/studio-design/StudioEntryRedirect.js'; +// The capability set that host's Studio entry gate read, provided around the +// `/studio` subtree so every Studio exit that names no package lands where the +// principal may go (Setup → Packages, else the "All metadata" area). +export { + StudioEntryPermissionsProvider, + useStudioEntryPermissions, +} from './views/studio-design/studioEntryPermissions.js'; // The one Studio scope that is not a package (objectui#11553): the // organization's own package-less flows, at `/studio/~org/automations`. A host // that declares the `/studio` routes reads the reserved segment from here. diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx new file mode 100644 index 00000000000..13f4b15cb12 --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx @@ -0,0 +1,278 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36748 — `PackageFormDialog` handed a `newApp` step + * (`newAppStep`, `studio-design/newAppDoor.ts`) ends with an app. + * + * 1. The dialog is titled 「新建应用」/"New app" and worded for an app: a + * no-code author reads 「应用」, never 「软件包」, on this door (the + * maintainer's ruling). + * 2. One confirm creates the package AND its app: the package `POST`, the + * app's draft under the first-write pin, then that one app's publish + * (objectstack#36511: a human-created item is live at once). The author + * lands in the new package's Studio, whose header names the app, and + * 「‹ Back to app」 opens it. + * 3. A taken app name refuses the whole confirm and writes nothing. + * + * The door's first host, the Studio home, was removed (objectstack#36908); + * the dialog's `newApp` branch and `newAppDoor.ts` stay for the one-step + * 「新建应用」 of the create-package dialog (objectstack#37134). These cases + * moved off the home onto the dialog itself, mounted as that home mounted it: + * create mode, `newApp={newAppStep(client, locale)}`, and Studio on the new + * package after save. + * + * The REAL `PackageFormDialog`, `newAppStep`, metadata client and + * `StudioDesignSurface` over a fetch stub that keeps the server's state: + * packages, published apps and app drafts. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +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, useNavigate } from 'react-router-dom'; +// The surface's reach loads `@objectstack/lint` lazily; pay that load during +// collection, not inside a case's clocked window (`check:test-source-alias`). +import '@objectstack/lint'; +import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; +await loadStudioCatalogue('zh'); + +let localeFixture: 'en-US' | 'zh-CN' = 'en-US'; +vi.mock('./i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataLocale: () => localeFixture, +})); +vi.mock('@object-ui/react', async (importOriginal) => { + const actual = await importOriginal>(); + return { ...actual, useAdapter: () => ({}) }; +}); +vi.mock('sonner', () => ({ + toast: { warning: vi.fn(), error: vi.fn(), success: vi.fn(), info: vi.fn(), message: vi.fn(), dismiss: vi.fn() }, + Toaster: () => null, +})); +vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPanel: () => null })); +vi.mock('./AccessExplainPanel', () => ({ AccessExplainPanel: () => null })); +vi.mock('../studio-design/StudioAiCopilot', () => ({ StudioChatDock: () => null })); +vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null })); + +import { toast } from 'sonner'; +import { PackageFormDialog } from './PackageFormDialog'; +import { useMetadataClient } from './useMetadata'; +import { t, useMetadataLocale } from './i18n'; +import { newAppStep } from '../studio-design/newAppDoor'; +import { studioPackagePath } from '../studio-design/studioAddress'; +import { StudioDesignSurface } from '../studio-design/StudioDesignSurface'; + +window.matchMedia = ((query: string) => ({ + matches: false, + media: query, + onchange: null, + addEventListener: () => {}, + removeEventListener: () => {}, + addListener: () => {}, + removeListener: () => {}, + dispatchEvent: () => false, +})) as unknown as typeof window.matchMedia; +(globalThis as unknown as { ResizeObserver: unknown }).ResizeObserver = + (globalThis as unknown as { ResizeObserver?: unknown }).ResizeObserver ?? + class { + observe() {} + unobserve() {} + disconnect() {} + }; + +function json(body: unknown, status = 200): Response { + return new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } }); +} + +interface Write { + method: string; + path: string; + search: URLSearchParams; + body: Record | null; +} + +const srv = { + packages: [] as Array>, + apps: [] as Array>, + appDrafts: [] as Array>, + writes: [] as Write[], +}; + +beforeEach(() => { + localeFixture = 'en-US'; + srv.packages = []; + srv.apps = []; + srv.appDrafts = []; + srv.writes = []; + vi.stubGlobal( + 'fetch', + vi.fn(async (input: unknown, init?: RequestInit) => { + const url = new URL(String(input), 'http://localhost'); + const path = url.pathname; + const method = init?.method ?? 'GET'; + if (method !== 'GET') { + const body = init?.body ? (JSON.parse(String(init.body)) as Record) : null; + srv.writes.push({ method, path, search: url.searchParams, body }); + if (method === 'POST' && path === '/api/v1/packages') { + const manifest = body?.manifest as Record; + srv.packages.push({ manifest, writable: true }); + return json({ success: true, data: { manifest } }, 201); + } + const draft = path.match(/^\/api\/v1\/meta\/app\/([^/]+)$/); + if (method === 'PUT' && draft) { + srv.appDrafts.push({ ...body, name: draft[1], type: 'app' }); + return json({ success: true, version: 'v1' }); + } + const publish = path.match(/^\/api\/v1\/meta\/app\/([^/]+)\/publish$/); + if (method === 'POST' && publish) { + const row = srv.appDrafts.find((d) => d.name === publish[1]); + srv.appDrafts = srv.appDrafts.filter((d) => d !== row); + if (row) srv.apps.push(row); + return json({ success: true, version: 'v2' }); + } + return json({ success: true }); + } + if (path === '/api/v1/packages') return json({ success: true, data: srv.packages }); + if (path === '/api/v1/meta/_drafts') { + return json({ drafts: url.searchParams.get('type') === 'app' ? srv.appDrafts : [] }); + } + if (path === '/api/v1/meta/app') return json(srv.apps); + if (path.endsWith('/layers')) return json({ code: null, overlay: null, overlayScope: null, effective: null }); + if (/^\/api\/v1\/meta\/[^/]+\/[^/]+$/.test(path)) return json({}, 404); + return json([]); + }) as unknown as typeof fetch, + ); +}); + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); + vi.mocked(toast.success).mockClear(); + vi.mocked(toast.error).mockClear(); +}); + +function RunningApp() { + const location = useLocation(); + return

    {location.pathname}

    ; +} + +/** The dialog as a host mounts the door: create mode, the app step, and Studio on the new package after save. */ +function NewAppHost() { + const navigate = useNavigate(); + const client = useMetadataClient(); + const locale = useMetadataLocale(); + const step = React.useMemo(() => newAppStep(client, locale), [client, locale]); + const [open, setOpen] = React.useState(false); + return ( + <> + + navigate(studioPackagePath(r.id))} + /> + + ); +} + +function renderDoor() { + return render( + + + } /> + } /> + } /> + + , + ); +} + +async function openNewAppDialog(): Promise { + fireEvent.click(await screen.findByTestId('open-new-app')); + return screen.findByRole('dialog'); +} + +const nameInput = (dialog: HTMLElement) => + within(dialog).getByLabelText(t('engine.packages.create.name', localeFixture), { exact: false }) as HTMLInputElement; + +const describeWrite = (w: Write) => `${w.method} ${w.path}`; + +describe('PackageFormDialog with a new-app step: one dialog worded for an app (objectstack#36748)', () => { + it('titled 「新建应用」, its submit 「创建应用」, and no 「软件包」 anywhere on its face', async () => { + localeFixture = 'zh-CN'; + renderDoor(); + const dialog = await openNewAppDialog(); + expect(within(dialog).getByRole('heading', { name: '新建应用' })).toBeInTheDocument(); + fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } }); + expect(within(dialog).getByTestId('package-form-submit')).toHaveTextContent('创建应用'); + // Advanced opened too: its rows say 「应用 ID」. + fireEvent.click(within(dialog).getByTestId('package-form-advanced-toggle')); + expect(within(dialog).getByText('应用 ID')).toBeInTheDocument(); + expect(dialog.textContent).not.toMatch(/软件包/); + }); +}); + +describe('PackageFormDialog with a new-app step: one confirm creates the package and its app, and the app opens (objectstack#36748)', () => { + it('package, app draft, app publish — then the header names the app and 「‹ Back to app」 opens it', async () => { + renderDoor(); + const dialog = await openNewAppDialog(); + fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } }); + await waitFor(() => expect(within(dialog).getByTestId('package-form-submit')).toBeEnabled()); + fireEvent.click(within(dialog).getByTestId('package-form-submit')); + + await waitFor(() => expect(srv.writes).toHaveLength(3), { timeout: 8000 }); + const [pkg, draft, publish] = srv.writes; + const manifest = pkg.body?.manifest as Record; + const packageId = String(manifest.id); + const namespace = String(manifest.namespace); + expect(srv.writes.map(describeWrite)).toEqual([ + 'POST /api/v1/packages', + `PUT /api/v1/meta/app/${namespace}`, + `POST /api/v1/meta/app/${namespace}/publish`, + ]); + // The app is the new package's, labelled with its name, written under the + // first-write pin, and that one item is published at its package. + expect(draft.search.get('package')).toBe(packageId); + expect(draft.search.get('mode')).toBe('draft'); + expect(draft.body?.label).toBe('Visits'); + expect(publish.search.get('package')).toBe(packageId); + expect(toast.success).toHaveBeenCalledWith(expect.stringMatching(/^Created app “Visits”/)); + expect(toast.error).not.toHaveBeenCalled(); + + // The author lands in the new package's Studio; the header names the app. + const header = await screen.findByTestId('studio-shell-header', undefined, { timeout: 8000 }); + await waitFor( + () => expect(within(header).getByTestId('studio-back-app-name')).toHaveAttribute('data-names', 'app'), + { timeout: 8000 }, + ); + expect(within(header).getByTestId('studio-back')).toHaveTextContent(/^Back to app·Visits·Studio$/); + // The app is live: no Create app is offered, and the back link opens it. + expect(within(header).queryByRole('button', { name: /Create app/ })).toBeNull(); + fireEvent.click(within(header).getByTestId('studio-back-to-app')); + expect(await screen.findByTestId('running-app')).toHaveTextContent(`/apps/${packageId}`); + }); + + it('an app name already taken refuses the confirm and writes nothing', async () => { + renderDoor(); + const dialog = await openNewAppDialog(); + fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } }); + await waitFor(() => expect(within(dialog).getByTestId('package-form-submit')).toBeEnabled()); + const namespace = (within(dialog).getByTestId('package-form-derived-summary').textContent ?? '').match( + /will start with (\w+?)_\./, + )?.[1]; + expect(namespace, 'the derived namespace is read off the dialog').toBeTruthy(); + // Both names the door would try are held by another package's apps. + srv.apps = [ + { name: namespace, label: 'Other visits' }, + { name: `${namespace}_app`, label: 'Other visits app' }, + ]; + fireEvent.click(within(dialog).getByTestId('package-form-submit')); + expect(await within(dialog).findByText(/already uses the identifier/)).toHaveTextContent('Other visits'); + expect(srv.writes).toEqual([]); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx index 088aeb0042f..e10f7d3ca1a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx @@ -81,7 +81,7 @@ vi.mock('./PackageFormDialog', () => ({ })); import { resolveHref } from '@object-ui/layout'; -import { PackagesPage, type InstalledPackageRow } from './PackagesPage'; +import { PackageDetailSheet, PackagesPage, type InstalledPackageRow } from './PackagesPage'; import { t } from './i18n'; import { SETUP_NEW_PACKAGE_PATH } from './packageSource'; // The page's package form reaches the CEL authoring helpers, which load these @@ -160,6 +160,8 @@ let catalogReads: string[] = []; let writes: string[] = []; /** How many times the list door was read. */ let packagesReads = 0; +/** The package ids whose customizations door was read (objectstack#36908). */ +let customizationReads: string[] = []; /** Boot the real runtime config, then serve the package, install and catalog doors. */ async function serve({ @@ -182,6 +184,7 @@ async function serve({ catalogReads = []; writes = []; packagesReads = 0; + customizationReads = []; vi.stubGlobal( 'fetch', vi.fn(async (input: unknown, init?: { method?: string }) => { @@ -205,6 +208,7 @@ async function serve({ // deployment changed on it: one tab arrangement, for every base. const customized = /^\/api\/v1\/packages\/([^/]+)\/customizations$/.exec(path); if (customized) { + customizationReads.push(decodeURIComponent(customized[1])); const arrangements = [{ object: 'acme_task', key: 'relatedLists' }]; return reply(200, { success: true, @@ -797,6 +801,31 @@ describe('Setup → Packages: the new-package deep link (objectstack#36908)', () // the panel itself). // --------------------------------------------------------------------------- +/** A code base's paired customization package, served read-only (`isCustomizationPackage`). */ +const CODE_PAIR: InstalledPackageRow = { + manifest: { id: 'com.acme.code.custom', name: 'Code App customizations', version: '1.0.0', type: 'app', scope: 'project' }, + enabled: true, + source: 'code', + writable: false, +}; + +/** The detail sheet alone, on the administration face. */ +function renderSheet(pkg: InstalledPackageRow) { + return render( + + + {}} onChanged={() => {}} /> + + , + ); +} + +/** The sheet's own reads have had a turn to start: its info block is drawn. */ +async function settledSheet(sheet: HTMLElement) { + await waitFor(() => expect(within(sheet).getAllByText(/1\.0\.0/).length).toBeGreaterThan(0)); + await new Promise((r) => setTimeout(r, 50)); +} + describe('Setup → Packages: a read-only base’s customizations in its detail (objectstack#36908)', () => { it('a code package’s detail draws what this deployment changed on it, arrangements counted (objectstack#36833)', async () => { await serve({ packages: [CODE] }); @@ -826,4 +855,33 @@ describe('Setup → Packages: a read-only base’s customizations in its detail const sheet = await screen.findByRole('dialog'); expect(within(sheet).queryByTestId('pkg-detail-customizations')).toBeNull(); }); + + it('a read-only `.custom` pair’s detail draws no section and reads no customizations: it is read through its base', async () => { + await serve({ packages: [CODE_PAIR] }); + renderAt(ADMIN_URL); + fireEvent.click(await screen.findByTestId(`pkg-row-${CODE_PAIR.manifest.id}`)); + const sheet = await screen.findByRole('dialog'); + await settledSheet(sheet); + expect(within(sheet).queryByTestId('pkg-detail-customizations')).toBeNull(); + expect(customizationReads).toEqual([]); + }); + + // The administration face lists no kernel package (pinned above), so its + // detail is opened directly: the sheet's own gate is what is measured. + it('a kernel package’s detail draws no section and reads no customizations: it takes no customization', async () => { + await serve({ packages: [PLATFORM] }); + renderSheet(PLATFORM); + const sheet = await screen.findByRole('dialog'); + await settledSheet(sheet); + expect(within(sheet).queryByTestId('pkg-detail-customizations')).toBeNull(); + expect(customizationReads).toEqual([]); + }); + + it('CONTROL: the same direct render of a code package’s detail draws the section and reads its customizations once', async () => { + await serve({ packages: [CODE] }); + renderSheet(CODE); + const sheet = await screen.findByRole('dialog'); + await waitFor(() => expect(within(sheet).getByTestId('pkg-detail-customizations')).toBeInTheDocument()); + await waitFor(() => expect(customizationReads).toEqual(['com.acme.code'])); + }); }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.readOnlyHintCopy-12171.test.ts b/ui/packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.readOnlyHintCopy-12171.test.ts new file mode 100644 index 00000000000..fe700fba132 --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/PermissionMatrixEditor.readOnlyHintCopy-12171.test.ts @@ -0,0 +1,104 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectui#12171 — the permission matrix's read-only hint names the overlay + * axis that exists. + * + * `PermissionMatrixEditor` titles its read-only badge on a set a code package + * ships with `perm.readOnly.artifact.hint`. ADR-0131 D6 (objectstack) retired + * ADR-0005's per-organization overlay axis, and the hint's parenthetical said + * "per-org overlay" (zh 「按组织覆盖」). It names the environment overlay — the + * registry flag `allowEnvironmentOverlay` — because it says that overlay is + * refused on a packaged item (objectstack ADR-0146 D11). + * + * This pin lived in the Studio home's copy test, beside the home's own two + * strings, until the home was removed (objectstack#36908); the hint is still + * drawn, so its half moved here. + * + * ## The population + * + * Every designer string table, read through their shared extractor + * (`readDesignerPairs` in `ui/scripts/check-i18n-dead-keys.mjs`), narrowed to + * the tables that carry the key. No list of locales is kept here: a table + * added for another language joins the population by itself. + * + * ## The pins + * + * 1. No table's value names the organization axis. + * 2. Lit control on the matchers: the hint names the environment overlay in + * every table. A table in a language neither pattern speaks fails here, so + * pin 1 cannot pass on it by matching nothing. + * 3. Lit control on the reader: for every locale the module's own + * `SupportedLocale` union declares, the value `t()` serves is the one the + * extractor read, so an extractor that read some other table cannot pass. + */ + +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { describe, it, expect } from 'vitest'; +// @ts-expect-error — plain-JS gate script, intentionally untyped (`allowJs: false`) +import { readDesignerPairs } from '../../../../../scripts/check-i18n-dead-keys.mjs'; +import { t, type SupportedLocale } from './i18n'; +// The designer's `perm.*` rows live in `@object-ui/i18n`'s `studio` namespace, +// whose `zh` catalogue is fetched on demand (objectstack#25922). Resident +// before any case, so the zh rows below read synchronously. +import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; +await loadStudioCatalogue('zh'); + +/** Local annotation, since the import above is untyped — the call site stays checked. */ +const readTables: (root: string) => Map> = readDesignerPairs; + +const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..'); + +/** The hint `PermissionMatrixEditor` shows on a set a code package ships: it names the overlay it refuses. */ +const PERMISSION_HINT = 'perm.readOnly.artifact.hint'; + +/** The retired axis, in the languages the tables speak: "org", "per-org", "organization", 组织. */ +const ORGANIZATION_AXIS = /\borg(?:ani[sz]ation)?s?\b|组织/iu; + +/** The overlay axis, in the same languages: refused on a packaged item since objectstack ADR-0146 D11. */ +const ENVIRONMENT_OVERLAY = /\benvironment overlay\b|环境覆盖/iu; + +/** + * Every locale the module declares. `satisfies` makes the record complete over + * `SupportedLocale`, so a locale added to that union fails the type-check here + * until it is listed. + */ +const DECLARED_LOCALES = { 'en-US': true, 'zh-CN': true, 'zh-Hant': true } satisfies Record; + +function tablesCarryingHint(): Array<[string, Map]> { + return [...readTables(REPO_ROOT)].filter(([, table]) => table.has(PERMISSION_HINT)); +} + +describe("the permission matrix's read-only hint names no organization axis (objectui#12171)", () => { + it('lit control: reads the tables t() serves', () => { + const read = tablesCarryingHint(); + expect(read.length).toBeGreaterThan(0); + for (const locale of Object.keys(DECLARED_LOCALES)) { + const served = t(PERMISSION_HINT, locale); + expect(served, `${locale} ${PERMISSION_HINT} is missing from the table t() reads`).not.toBe(PERMISSION_HINT); + expect( + read.some(([, table]) => table.get(PERMISSION_HINT) === served), + `${locale} ${PERMISSION_HINT}: the value t() serves is not among the values the extractor read`, + ).toBe(true); + } + }); + + it('no table names the organization axis', () => { + const offenders: string[] = []; + for (const [name, table] of tablesCarryingHint()) { + const value = table.get(PERMISSION_HINT) ?? ''; + if (ORGANIZATION_AXIS.test(value)) offenders.push(`${name}: ${value}`); + } + expect(offenders).toEqual([]); + }); + + it('lit control: the hint names the environment overlay in every table', () => { + const silent: string[] = []; + for (const [name, table] of tablesCarryingHint()) { + const value = table.get(PERMISSION_HINT) ?? ''; + if (!ENVIRONMENT_OVERLAY.test(value)) silent.push(`${name}: ${value}`); + } + expect(silent).toEqual([]); + }); +}); 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 cdc57a7f79b..6cc078270aa 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 @@ -7,8 +7,9 @@ * 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 menu and no package actions, and a way out - * to Setup → Packages, the package list (objectstack#36908: the Studio home - * it used to walk back to was removed). And `/studio//` for a segment no pillar + * to Setup → Packages, the package list, or to the "All metadata" area for a + * principal who may not open that Setup page (objectstack#36908: the Studio + * home it used to walk back to was removed). 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 left menu (objectstack#36899, which replaced * the pillars above it) still beside it, nothing in it current. (The @@ -80,6 +81,7 @@ vi.mock('./StudioAiCopilot', () => ({ StudioChatDock: () =>
    {search}
    ; } -function renderAt(path: string, surface: React.ReactElement = ) { +/** The "All metadata" area across packages. */ +function AllMetadata() { + return
    ; +} + +/** Holds the two capabilities Setup → Packages is shown under. */ +const ADMIN = ['studio.access', 'setup.access', 'manage_platform_settings', 'manage_metadata']; +/** May enter Studio and author metadata; holds neither capability Setup → Packages is shown under. */ +const STUDIO_ONLY = ['studio.access', 'manage_metadata']; + +/** + * The surface under the capability set Studio's entry gate read, as the + * console's `RequireStudioAccess` provides it. + */ +function renderAt( + path: string, + surface: React.ReactElement = , + systemPermissions: readonly string[] = ADMIN, +) { render( - - - } /> - - - , + + + + } /> + } /> + + + + , ); } @@ -174,7 +197,7 @@ describe('Studio: a package id no package has renders "package not found" (objec expect(packageListReads(fetchMock)).toBe(1); }); - it('its one action opens Setup → Packages, on its administration face', async () => { + it('CONTROL — for an administrator, its one action opens Setup → Packages, on its administration face', async () => { servePackages(); renderAt(`/studio/${PHANTOM}/data`); const notFound = await screen.findByTestId('studio-package-not-found'); @@ -182,6 +205,16 @@ describe('Studio: a package id no package has renders "package not found" (objec expect(await screen.findByTestId('setup-packages')).toHaveTextContent('?face=admin'); }); + it('for a principal who may enter Studio but not Setup → Packages, it opens the "All metadata" area, never Setup (objectstack#36908)', async () => { + servePackages(); + renderAt(`/studio/${PHANTOM}/data`, , STUDIO_ONLY); + const notFound = await screen.findByTestId('studio-package-not-found'); + expect(within(notFound).queryByRole('button', { name: t('engine.studio.notFound.packageList', 'en') })).toBeNull(); + within(notFound).getByRole('button', { name: t('engine.studio.notFound.allMetadata', 'en') }).click(); + expect(await screen.findByTestId('all-metadata')).toBeInTheDocument(); + expect(screen.queryByTestId('setup-packages')).toBeNull(); + }); + it('CONTROL — a listed package renders its builder', async () => { const fetchMock = servePackages(); renderAt(`/studio/${PACKAGE_ID}/data`); 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 d4aef4394a5..fca2ee9ee37 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -63,6 +63,8 @@ import { } from './flowGrouping.js'; import { StudioRefusalStrip } from './StudioRefusalStrip.js'; import { PACKAGE_LIST_TOAST_ID } from './PackageSwitcher.js'; +import { studioEntryFallbackPath } from './StudioEntryRedirect.js'; +import { useStudioEntryPermissions } from './studioEntryPermissions.js'; import { SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; import { StudioBackToApp, type StudioAppTarget } from './StudioBackToApp.js'; import { @@ -909,6 +911,10 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re // is 「‹ Back to app」 at the left (`StudioBackToApp`, objectstack#36501), in // the same tab, mirroring the app bar's Edit app. const shellNavigate = useNavigate(); + // objectstack#36908 — where the package-not-found state's way out leads: + // Setup → Packages for a principal who may open it, the "All metadata" area + // for a Studio-only author (the same choice as Studio's entry). + const notFoundExit = studioEntryFallbackPath(useStudioEntryPermissions()); React.useEffect(() => { openAccessRef.current = () => { if (confirmLeavePillar()) shellNavigate(studioPillarPath(scopeSegment, 'access', { segmentEncoding: 'verbatim' })); @@ -1511,10 +1517,13 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re testId="studio-package-not-found" sentence={tFormat('engine.studio.notFound.package', locale, { id: packageId })} action={ - // objectstack#36908 — Setup → Packages: Studio's home, its - // old way out, was removed. - } /> diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx index a21bf9117cc..fdaf7dacff5 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx @@ -6,7 +6,7 @@ * list; otherwise the package list: Setup → Packages for a principal who may * open it, the "All metadata" area across packages for one who may only enter * Studio. The retired `/studio?new=package` bookmark lands on Setup's New - * Package. + * Package for the first, and on that same "All metadata" area for the second. * * The recent store and the list read are stubbed at their modules: what is * measured is where the entry SENDS the author, read off the router's @@ -28,11 +28,13 @@ vi.mock('./packages-io.js', () => ({ fetchListedPackageIds: () => listed.read(), })); -import { StudioEntryRedirect, studioEntryFallbackPath } from './StudioEntryRedirect'; +import { StudioEntryRedirect, studioEntryFallbackPath, studioNewPackageEntryPath } from './StudioEntryRedirect'; const SETUP_PACKAGES = '/apps/setup/component/developer/packages?face=admin'; const ALL_METADATA = '/studio/~all/metadata'; const ADMIN = ['studio.access', 'setup.access', 'manage_platform_settings']; +/** May enter Studio and author metadata; holds neither capability Setup → Packages is shown under. */ +const STUDIO_ONLY = ['studio.access', 'manage_metadata']; function Where() { const { pathname, search } = useLocation(); @@ -126,10 +128,26 @@ describe("Studio's entry: the package list (objectstack#36908)", () => { }); describe('the retired `/studio?new=package` bookmark (objectstack#36908)', () => { - it("lands on Setup's New Package, whatever is remembered", async () => { + it("CONTROL — an administrator lands on Setup's New Package, whatever is remembered", async () => { recent.items = [pkg('com.acme.crm')]; listed.read = async () => new Set(['com.acme.crm']); renderEntry('/studio?new=package'); expect(await screen.findByTestId('where')).toHaveTextContent(`${SETUP_PACKAGES}&new=package`); }); + + it('a principal who may enter Studio but not Setup → Packages is never sent to Setup: the "All metadata" area', async () => { + recent.items = [pkg('com.acme.crm')]; + listed.read = async () => new Set(['com.acme.crm']); + renderEntry('/studio?new=package', STUDIO_ONLY); + const where = await screen.findByTestId('where'); + expect(where).toHaveTextContent(new RegExp(`^${ALL_METADATA}$`)); + expect(where.textContent).not.toContain('/apps/setup'); + }); + + it('the forward reads the same two capabilities as the fallback, and holds nothing for no answer', () => { + expect(studioNewPackageEntryPath(ADMIN)).toBe(`${SETUP_PACKAGES}&new=package`); + expect(studioNewPackageEntryPath(['studio.access', 'manage_platform_settings'])).toBe(ALL_METADATA); + expect(studioNewPackageEntryPath(['studio.access', 'setup.access'])).toBe(ALL_METADATA); + expect(studioNewPackageEntryPath(undefined)).toBe(ALL_METADATA); + }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx index 1628279bdf7..e27b4548785 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx @@ -18,7 +18,10 @@ * Setup page ({@link studioEntryFallbackPath}). * * The retired `/studio?new=package` bookmark is forwarded to Setup's New - * Package (`studioNewPackage.ts`). + * Package (`studioNewPackage.ts`) for a principal who may open Setup → + * Packages, and to the same fallback as (2) for anyone else + * ({@link studioNewPackageEntryPath}): a Studio-only author is never sent to a + * Setup page that refuses them. * * A package deleted since the visit is passed over: the recent store is the * user's, the list the active organization's, so an entry the list no longer @@ -42,6 +45,12 @@ import { STUDIO_NEW_PACKAGE_VALUE, STUDIO_NEW_PARAM } from './studioNewPackage.j */ const SETUP_PACKAGES_CAPABILITIES = ['setup.access', 'manage_platform_settings'] as const; +/** `undefined` (no answer reported) holds nothing. */ +function holdsSetupPackages(systemPermissions: readonly string[] | undefined): boolean { + const held = new Set(systemPermissions ?? []); + return SETUP_PACKAGES_CAPABILITIES.every((c) => held.has(c)); +} + /** * Where Studio's entry goes when no remembered package opens: Setup → Packages * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else the "All metadata" @@ -49,12 +58,20 @@ const SETUP_PACKAGES_CAPABILITIES = ['setup.access', 'manage_platform_settings'] * `undefined` (no answer reported) holds nothing. */ export function studioEntryFallbackPath(systemPermissions: readonly string[] | undefined): string { - const held = new Set(systemPermissions ?? []); - return SETUP_PACKAGES_CAPABILITIES.every((c) => held.has(c)) + return holdsSetupPackages(systemPermissions) ? SETUP_PACKAGES_PATH : studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT); } +/** + * Where the retired `/studio?new=package` bookmark goes: Setup's New Package + * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else + * {@link studioEntryFallbackPath}'s answer for that principal. + */ +export function studioNewPackageEntryPath(systemPermissions: readonly string[] | undefined): string { + return holdsSetupPackages(systemPermissions) ? SETUP_NEW_PACKAGE_PATH : studioEntryFallbackPath(systemPermissions); +} + export function StudioEntryRedirect({ systemPermissions, pending = null, @@ -94,7 +111,7 @@ export function StudioEntryRedirect({ // Keyed on the primitives it reads (ui/AGENTS.md #10). }, [forwardNew, rememberedKey, fallback]); - if (forwardNew) return ; + if (forwardNew) return ; if (!rememberedKey) return ; if (target === null) return <>{pending}; return ; diff --git a/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts b/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts index d84e78d41a6..29f08ca1c48 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts @@ -52,7 +52,7 @@ const ALLOWED = new Set([ ]); /** The root's names, as a composed path would start from them. */ -const ROOT_NAMES = new Set(['STUDIO_ROOT_PATH', 'STUDIO_LANDING_PATH']); +const ROOT_NAMES = new Set(['STUDIO_ROOT_PATH']); const SKIP_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage', '.turbo', '__tests__', '__mocks__']); diff --git a/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts b/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts new file mode 100644 index 00000000000..6ec97905093 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts @@ -0,0 +1,27 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The capability set Studio's entry gate read, for the Studio screens that + * choose a destination by it (objectstack#36908). + * + * Every exit from Studio that names no package — bare `/studio` with nothing + * remembered, the retired `/studio?new=package` bookmark, the package-not-found + * state's way out — lands on Setup → Packages for a principal who may open + * that page, and on the "All metadata" area across packages for one who may + * enter Studio and not that Setup page (`studioEntryFallbackPath`). The host + * that gates `/studio` (the console's `RequireStudioAccess`) provides the set + * it read; a screen outside that provider reads `undefined`, which holds + * nothing, so it never sends anyone to a page they may not open. + */ + +import * as React from 'react'; + +const StudioEntryPermissionsContext = React.createContext(undefined); + +/** Provided by the host around a principal its Studio entry gate let in. */ +export const StudioEntryPermissionsProvider = StudioEntryPermissionsContext.Provider; + +/** The capability set the Studio entry gate read; `undefined` outside its provider. */ +export function useStudioEntryPermissions(): readonly string[] | undefined { + return React.useContext(StudioEntryPermissionsContext); +} diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 9387e5178af..af3d992ec73 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3509,6 +3509,9 @@ const STUDIO_EN: Record = { // objectstack#36908 — the package-not-found state's way out: Setup → Packages, // where Studio's entries that name no package land since the Studio home went. 'engine.studio.notFound.packageList': 'Open the package list', + // The same way out for a principal who may enter Studio but not open + // Setup → Packages: the "All metadata" area across packages. + 'engine.studio.notFound.allMetadata': 'Open All metadata', 'engine.studio.notFound.pillar': 'This page does not exist. Studio has no "{pillar}" section; pick Data, Automations, Interfaces, Access or All metadata above.', 'engine.studio.aiCopilot': 'AI Assistant', // objectui#12725 — the Studio right slot: properties OR the copilot. diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 48be7a6db23..c9e161932a7 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3097,6 +3097,7 @@ const STUDIO_ZH: Record = { 'engine.studio.desktopHint': 'Studio 专为桌面屏幕设计。', 'engine.studio.notFound.package': '未找到包。本部署没有安装 ID 为“{id}”的包,因此无处可构建。', 'engine.studio.notFound.packageList': '打开软件包列表', + 'engine.studio.notFound.allMetadata': '打开「全部元数据」', 'engine.studio.notFound.pillar': '页面不存在。Studio 没有“{pillar}”这一栏,请在上方选择数据、自动化、界面、权限或全部元数据。', 'engine.studio.aiCopilot': 'AI 助手', // objectui#12725 — Studio 右栏:属性或 AI 助手二选一。 diff --git a/ui/scripts/check-eager-closure-budget.mjs b/ui/scripts/check-eager-closure-budget.mjs index 02527ed011b..4394c73a2a6 100644 --- a/ui/scripts/check-eager-closure-budget.mjs +++ b/ui/scripts/check-eager-closure-budget.mjs @@ -916,9 +916,11 @@ import { isEntrypoint } from './invoked-as.mjs'; * claims the shim (the comment on that group in `apps/console/vite.config.ts` * says why the flag that would also have stopped the capture was refused); * the shim's bytes are the `vendor-react` row. - * - THE STUDIO BUILDER (-33,928 alone). `StudioDesignSurface` and - * `BuilderLanding` load through the console-local `import()` in - * `apps/console/src/components/studioBuilder.ts`. Most of what `index` lost + * - THE STUDIO BUILDER (-33,928 alone). `StudioDesignSurface` and the + * Studio home of that day load through the console-local `import()` in + * `apps/console/src/components/studioBuilder.ts` (the home was removed + * with objectstack#36908; Studio's entry, `StudioEntryRedirect`, rides in + * that chunk now). Most of what `index` lost * is the builder; the `studioScope` row is NOT new payload but 49 modules * `index` held on `455c6466` (the app header and the AI chat page among * them), which the bundler split out because the lazy builder imports From f3f2be86d47907e66c2eacffccbc60117fa34ab6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 03:12:49 +0000 Subject: [PATCH 14/21] test(studio): pay the plugin-detail load at collection in the moved new-app pin Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .../metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx index 13f4b15cb12..a8dbb68cfd4 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx @@ -34,6 +34,9 @@ import { MemoryRouter, Route, Routes, useLocation, useNavigate } from 'react-rou // The surface's reach loads `@objectstack/lint` lazily; pay that load during // collection, not inside a case's clocked window (`check:test-source-alias`). import '@objectstack/lint'; +// It also reaches `import('@object-ui/plugin-detail')` (the command palette's lazy +// detail surfaces): paid here, at collection, never inside a test's clock. +import '@object-ui/plugin-detail'; import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; await loadStudioCatalogue('zh'); From 4121473e39e05e486c2dd78b6a441a94c26e1684 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 04:08:51 +0000 Subject: [PATCH 15/21] test(studio): land the moved new-app pin on the package's Studio home, as the removed home did Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .../PackageFormDialog.newAppStep-36748.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx index a8dbb68cfd4..23020f847c6 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx @@ -63,7 +63,7 @@ import { PackageFormDialog } from './PackageFormDialog'; import { useMetadataClient } from './useMetadata'; import { t, useMetadataLocale } from './i18n'; import { newAppStep } from '../studio-design/newAppDoor'; -import { studioPackagePath } from '../studio-design/studioAddress'; +import { studioHomePath } from '../studio-design/studioAddress'; import { StudioDesignSurface } from '../studio-design/StudioDesignSurface'; window.matchMedia = ((query: string) => ({ @@ -177,7 +177,7 @@ function NewAppHost() { open={open} onOpenChange={setOpen} newApp={step} - onSaved={(r) => navigate(studioPackagePath(r.id))} + onSaved={(r) => navigate(studioHomePath(r.id))} /> ); From 329ddefce7730a6cd7b747a40e5f7461219e97f5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 04:21:44 +0000 Subject: [PATCH 16/21] test(studio): drop the address guard's fixtures for the removed landing-path name main's pre-filter added two fixtures spelling STUDIO_LANDING_PATH, a name the Studio home's removal deleted; the guard's root names no longer hold it. Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .../src/views/studio-design/studioAddress.guard.test.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts b/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts index e7bc8c48b40..f6df001668c 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioAddress.guard.test.ts @@ -132,14 +132,13 @@ function handBuiltStudioAddresses(fileName: string, text: string): string[] { * all but a few files hold none, so only the files that pass are parsed. * * It is a superset of the matcher by construction. The matcher flags three - * node shapes, and each one needs a token whose COOKED text is one of three + * node shapes, and each one needs a token whose COOKED text is one of two * words: * * - a string or template literal (or a template head) whose text starts with * `/studio`; - * - a template whose first span is the identifier `STUDIO_ROOT_PATH` or - * `STUDIO_LANDING_PATH`; - * - `+` with one of those identifiers on its left. + * - a template whose first span is the identifier `STUDIO_ROOT_PATH`; + * - `+` with that identifier on its left. * * A JSX attribute string is not cooked (`/` stays `/`), so its raw text * is its text. A JS string or template is cooked, and its raw text can spell @@ -200,9 +199,7 @@ const FLAGGED_SPELLINGS = [ "const a4 = '\\57\\163tudio';", "const a5 = '/stu\\\ndio';", 'const b1 = `\\x2fstudio/${pkg}`;', - 'const e1 = `${STUDIO_LANDING_PATH}/${pkg}`;', 'const e2 = `${STUDIO\\u005FROOT_PATH}/${pkg}`;', - "const f1 = STUDIO_LANDING_PATH + '/' + pkg;", "const f2 = STUDIO_\\u{52}OOT_PATH + '/' + pkg;", ]; From 1ab7e75973e708e6725c995bf2f896aa243e9621 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 05:38:00 +0000 Subject: [PATCH 17/21] feat(app-shell): Add app drops Build with AI and always offers New blank app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The maintainer ruled Build with AI off the Add app menu and the blank-app entry always shown, whether or not the build agent is served. The entry is relabelled New blank app (zh 新建空白应用) under its existing key; a menu with no entries draws no Add app and no separator for it. Also: the customizations panel's Response stub carries empty headers. Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .changeset/36908-remove-studio-home.md | 3 +- .changeset/36908-studio-home-strings.md | 2 +- .../src/console/ai/AiUnavailable.tsx | 2 +- .../HomePage.desktopNoApps-36732.test.tsx | 19 +++- .../app-shell/src/hooks/useAddAppEntries.ts | 32 +++--- .../app-shell/src/layout/SidebarAppMenu.tsx | 13 ++- .../__tests__/SidebarAppMenu-36112.test.tsx | 104 +++++++++++++----- .../PackageCustomizationsPanel.test.tsx | 3 +- ui/packages/i18n/src/locales/en.ts | 2 +- ui/packages/i18n/src/locales/zh-Hans.ts | 2 +- ui/packages/i18n/src/locales/zh-Hant.ts | 2 +- 11 files changed, 126 insertions(+), 58 deletions(-) diff --git a/.changeset/36908-remove-studio-home.md b/.changeset/36908-remove-studio-home.md index b087702e000..97b30a4818a 100644 --- a/.changeset/36908-remove-studio-home.md +++ b/.changeset/36908-remove-studio-home.md @@ -12,8 +12,9 @@ Metadata-protocol: none The package-card page Studio used to open on is gone. Studio is opened from an app or from Setup → Packages, and everything that page offered has another place: - **Opening Studio** takes you to the package you were last in, if it is still installed. Otherwise an administrator lands on Setup → Packages, and a developer who cannot open that Setup page lands on the All metadata area. The 应用构建 entry of the Studio app goes to the same place. -- **New package.** 「New in Studio」 on Home and on the AI-unavailable screen, and the 「Add app」 menu, open Setup → Packages with the New Package dialog already open. After the package is created you land in Studio on it. An old bookmark to Studio's new-package page goes there too, or to the All metadata area for a developer who cannot open Setup → Packages. Creating a package and its app in one step comes with a later change; for now this creates the package only. +- **New package.** 「New blank app」 (formerly 「New in Studio」) on Home, on the AI-unavailable screen and in the 「Add app」 menu opens Setup → Packages with the New Package dialog already open. After the package is created you land in Studio on it. An old bookmark to Studio's new-package page goes there too, or to the All metadata area for a developer who cannot open Setup → Packages. Creating a package and its app in one step comes with a later change; for now this creates the package only. - **What this environment changed on an installed app.** The "n customized, m switched off" line and the "Customizations in this environment" panel are now in the app's detail in Setup → Packages, with a 「Customize in Studio」 link. The count now includes tab, field-group and action-layout arrangements, so an app whose only change is a tab arrangement shows as customized. The list across all installed apps at once is now shown one app at a time. +- **The 「Add app」 menu** no longer offers 「Build with AI」, and neither do the buttons on the "No applications yet" screen. 「New blank app」 is now always offered wherever apps can be built, whether or not the AI build assistant is available, so the menu is never empty for someone who may add an app; a menu with nothing to offer is not shown. Home's own 「Build with AI」 button is unchanged. - **Organization flows and the environment catalog** are in Studio's left menu. - **A package Studio cannot find** offers a way to Setup → Packages, or to the All metadata area for a developer who cannot open that page. A retired Setup page whose address names no package opens Setup → Packages. diff --git a/.changeset/36908-studio-home-strings.md b/.changeset/36908-studio-home-strings.md index 8a5b8f1e0cb..51b7371f3ef 100644 --- a/.changeset/36908-studio-home-strings.md +++ b/.changeset/36908-studio-home-strings.md @@ -7,4 +7,4 @@ feat(i18n): strings for the customizations section in Setup → Packages and for Clause-②: no Metadata-protocol: none -Adds the strings for the customizations section of an app's detail in Setup → Packages, and for the way out of Studio's "package not found" state. The strings of Studio's removed home page that shipped in 18.6.0 stay in the studio namespace, no longer read, so no released string is removed. Four of that page's strings that were added after 18.6.0 and never released are removed. +Adds the strings for the customizations section of an app's detail in Setup → Packages, and for the way out of Studio's "package not found" state. The strings of Studio's removed home page that shipped in 18.6.0 stay in the studio namespace, no longer read, so no released string is removed. Four of that page's strings that were added after 18.6.0 and never released are removed. The "New in Studio" label now reads "New blank app" in English and 「新建空白应用」 in Chinese (Simplified and Traditional); its other translations are unchanged. diff --git a/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx b/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx index f68ba0b37ff..3e7958c4b44 100644 --- a/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx +++ b/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx @@ -69,7 +69,7 @@ export function AiUnavailable({ {offerStudio && ( )} diff --git a/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx b/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx index 43f3771d188..057ce34e43d 100644 --- a/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx +++ b/ui/packages/app-shell/src/console/home/__tests__/HomePage.desktopNoApps-36732.test.tsx @@ -4,8 +4,10 @@ * objectstack#36732 — the desktop's no-apps empty state, what is left of the * retired platform home page. From 768 px up a viewer with no product app (no * app but Setup and the platform's own) is drawn 「No applications yet」, and a - * viewer who may add an app is offered the sidebar's 「Add app」 doors (build - * with AI, start from a template, the marketplace) as buttons. An administrator + * viewer who may add an app is offered the sidebar's 「Add app」 doors (a new + * blank app, start from a template, the marketplace) as buttons; 「Build with + * AI」 is no longer one of them, and the blank app is offered whether or not the + * build agent is served (objectstack#36908). An administrator * without `manage_metadata` is told why there are none (objectstack#8270); * anyone else is told their administrator shares apps with them. * @@ -116,13 +118,20 @@ afterEach(() => { }); describe('HomePage — the desktop no-apps empty state (objectstack#36732)', () => { - it('offers an admin who may author the 「Add app」 doors, building with AI first', () => { + it('offers an admin who may author the 「Add app」 doors, a new blank app first — with the build agent served too (objectstack#36908)', () => { render(); const empty = screen.getByTestId('home-no-apps'); expect(empty).toHaveTextContent('«home.noAppsTitle»'); expect(empty).toHaveTextContent('«home.noAppsAddDescription»'); - const ai = screen.getByTestId('home-no-apps-build-with-ai'); - expect(ai).toHaveAttribute('href', '/studio'); + expect(screen.queryByTestId('home-no-apps-build-with-ai')).not.toBeInTheDocument(); + expect(empty.querySelector('a[href="/studio"]')).toBeNull(); + const doors = Array.from(empty.querySelectorAll('a[data-testid^="home-no-apps-"]')); + expect(doors.map((a) => a.getAttribute('data-testid'))).toEqual([ + 'home-no-apps-new-in-studio', + 'home-no-apps-template', + 'home-no-apps-marketplace', + ]); + expect(screen.getByTestId('home-no-apps-new-in-studio')).toHaveAttribute('href', '/apps/setup/component/developer/packages?face=admin&new=package'); expect(screen.getByTestId('home-no-apps-template')).toHaveAttribute('href', '/apps/setup/system/marketplace'); expect(screen.getByTestId('home-no-apps-marketplace')).toHaveAttribute('href', '/apps/setup/system/marketplace'); // The app tiles the retired page drew are gone: Setup and Studio are no app of the viewer's. diff --git a/ui/packages/app-shell/src/hooks/useAddAppEntries.ts b/ui/packages/app-shell/src/hooks/useAddAppEntries.ts index 402e09e9955..89dbb3b291f 100644 --- a/ui/packages/app-shell/src/hooks/useAddAppEntries.ts +++ b/ui/packages/app-shell/src/hooks/useAddAppEntries.ts @@ -14,10 +14,8 @@ import { Hammer, LayoutGrid, Store } from 'lucide-react'; import { useObjectTranslation } from '@object-ui/i18n'; import { useWorkspaceAdminStatus } from '@object-ui/auth'; import { useCanAuthorMetadata } from './useCanAuthorMetadata.js'; -import { useAiSurfaceEnabled } from './useAiSurface.js'; import { isAiStudioEnabled, isMarketplaceEnabled } from '../runtime-config.js'; import { SETUP_NEW_PACKAGE_PATH } from '../views/metadata-admin/packageSource.js'; -import { studioLandingPath } from '../views/studio-design/studioAddress.js'; /** The marketplace, where templates and packages are installed from. */ const MARKETPLACE_PATH = '/apps/setup/system/marketplace'; @@ -42,23 +40,29 @@ export function useMayAddApp(): boolean { } /** - * The 「Add app」 choices: building with AI where the deployment offers AI - * authoring and its agent catalog serves the build agent (objectstack#36969: - * not merely any agent: where in-app building is closed the catalog keeps - * `ask` and drops `build`), else a new package in Studio; templates and - * the marketplace where a marketplace is mounted. Read only for a viewer - * {@link useMayAddApp} lets in, so no one else pays the agent-catalog read. + * The 「Add app」 choices: 「新建空白应用」 / "New blank app" (a new package, + * opened in Studio once created) wherever the deployment offers metadata + * authoring, whether or not its agent catalog serves the build agent; templates + * and the marketplace where a marketplace is mounted. + * + * objectstack#36908 — the maintainer ruled 「Build with AI」 off this menu + * (ruling record 7153161067) and the blank-app entry always shown, agent or no + * agent (ruling record 7153400210). It stays inside the authoring gate: where + * `features.aiStudio` is `false` the runtime offers no metadata authoring at + * all, and a viewer {@link useMayAddApp} admits there is offered the + * marketplace's two entries instead, so the list is never empty for an + * admitted viewer. A host still draws no 「Add app」 for an empty list. */ export function useAddAppEntries(): AddAppEntry[] { const { t } = useObjectTranslation(); - const { buildServed } = useAiSurfaceEnabled(); const entries: AddAppEntry[] = []; if (isAiStudioEnabled()) { - entries.push( - buildServed - ? { key: 'build-with-ai', to: studioLandingPath(), label: t('home.buildWithAI', { defaultValue: 'Build with AI' }), icon: Hammer } - : { key: 'new-in-studio', to: SETUP_NEW_PACKAGE_PATH, label: t('home.build.inStudio', { defaultValue: 'New in Studio' }), icon: Hammer }, - ); + entries.push({ + key: 'new-in-studio', + to: SETUP_NEW_PACKAGE_PATH, + label: t('home.build.inStudio', { defaultValue: 'New blank app' }), + icon: Hammer, + }); } if (isMarketplaceEnabled()) { entries.push( diff --git a/ui/packages/app-shell/src/layout/SidebarAppMenu.tsx b/ui/packages/app-shell/src/layout/SidebarAppMenu.tsx index ab346d49f42..7f7f250675b 100644 --- a/ui/packages/app-shell/src/layout/SidebarAppMenu.tsx +++ b/ui/packages/app-shell/src/layout/SidebarAppMenu.tsx @@ -52,7 +52,7 @@ import { appAddressSegment, appStudioDesignPath } from '../utils/appRoute.js'; import { useServedAppLabel } from '../hooks/useServedAppLabel.js'; import { useLauncherApps } from '../hooks/useLauncherApps.js'; import { useStudioEntryGate } from '../hooks/useStudioDesignGate.js'; -import { useAddAppEntries, useMayAddApp } from '../hooks/useAddAppEntries.js'; +import { useAddAppEntries, useMayAddApp, type AddAppEntry } from '../hooks/useAddAppEntries.js'; import { AppMark } from './AppMark.js'; import { useDesignMode } from './designMode.js'; import { useAppStudioEntry } from './ShellPageActions.js'; @@ -129,9 +129,8 @@ function StudioAppItem({ entry }: { entry: StudioEntry }) { } /** 「Add app」 and its choices. */ -function AddAppSubmenu() { +function AddAppSubmenu({ entries }: { entries: readonly AddAppEntry[] }) { const { t } = useObjectTranslation(); - const entries = useAddAppEntries(); return ( <> @@ -169,6 +168,10 @@ export function SidebarAppMenu({ activeAppName, onAppChange }: SidebarAppMenuPro const apps = metadataApps || []; const { apps: launcherApps } = useLauncherApps(apps); const mayAddApp = useMayAddApp(); + // objectstack#36908 — a menu with nothing to offer is not drawn: 「Add app」 + // (and the separator above it) only when the list has an entry. + const addAppEntries = useAddAppEntries(); + const offerAddApp = mayAddApp && addAppEntries.length > 0; const enterDesignMode = useEnterDesignMode(apps, activeAppName); const studioEntry = useAppStudioEntry(true, activeAppName).entry; const [query, setQuery] = React.useState(''); @@ -239,10 +242,10 @@ export function SidebarAppMenu({ activeAppName, onAppChange }: SidebarAppMenuPro
    )}
    - {(enterDesignMode || studioEntry || mayAddApp) && } + {(enterDesignMode || studioEntry || offerAddApp) && } {enterDesignMode && } {studioEntry && } - {mayAddApp && } + {offerAddApp && } ); diff --git a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx index 3021823a5c8..62fe2a3da8f 100644 --- a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx @@ -108,11 +108,26 @@ vi.mock('@object-ui/plugin-chatbot/core', async (importOriginal) => ({ ...(await importOriginal>()), useAgents: () => ({ agents: catalog, isLoading: false, error: undefined, refetch: () => {} }), })); +/** The deployment's posture: metadata authoring offered, a marketplace mounted. */ +let aiStudio = true; +let marketplace = true; vi.mock('../../runtime-config', async (importOriginal) => ({ ...(await importOriginal>()), - isAiStudioEnabled: () => true, - isMarketplaceEnabled: () => true, + isAiStudioEnabled: () => aiStudio, + isMarketplaceEnabled: () => marketplace, })); +/** When set, what the 「Add app」 list answers instead of the real hook (the empty-list guard). */ +let entriesOverride: unknown[] | null = null; +vi.mock('../../hooks/useAddAppEntries', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + useAddAppEntries: () => { + const real = actual.useAddAppEntries(); + return entriesOverride ?? real; + }, + }; +}); import { builtInLocales } from '@object-ui/i18n/locales'; import { SidebarAppMenu, APP_MENU_SEARCH_FROM } from '../SidebarAppMenu'; @@ -162,6 +177,9 @@ afterEach(() => { admin = false; canAuthor = true; catalog = [{ name: 'build' }, { name: 'ask' }]; + aiStudio = true; + marketplace = true; + entriesOverride = null; authOverride = {}; toastError.mockReset(); vi.unstubAllGlobals(); @@ -216,13 +234,13 @@ describe('the sidebar app menu only switches apps (objectstack#36112)', () => { expect(menu().getByTestId('sidebar-app-menu-empty')).toBeInTheDocument(); }); - it('「Add app」 is offered to a workspace admin who may author: AI, a template, the marketplace', () => { + it('「Add app」 is offered to a workspace admin who may author: a blank app, a template, the marketplace', () => { apps = [CRM]; admin = true; renderMenu('crm'); expect(menu().getByTestId('sidebar-app-menu-add')).toHaveTextContent('Add app'); const choices = within(screen.getByTestId('add-app-choices')); - expect(choices.getByTestId('sidebar-app-menu-add-build-with-ai')).toHaveAttribute('href', '/studio'); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute('href', '/apps/setup/component/developer/packages?face=admin&new=package'); expect(choices.getByTestId('sidebar-app-menu-add-template')).toHaveAttribute('href', '/apps/setup/system/marketplace'); expect(choices.getByTestId('sidebar-app-menu-add-marketplace')).toHaveAttribute('href', '/apps/setup/system/marketplace'); }); @@ -239,42 +257,74 @@ describe('the sidebar app menu only switches apps (objectstack#36112)', () => { }); }); -describe('「Add app」 offers building with AI only where the catalog serves build (objectstack#36969)', () => { +describe('「Add app」 offers 「New blank app」 whatever the catalog serves, and no 「Build with AI」 (objectstack#36908)', () => { + // objectstack#36969 drew a build-with-AI door where the catalog served the + // build agent and the Studio door elsewhere. The maintainer ruled 「Build with + // AI」 off this menu and 「New blank app」 always shown (ruling records + // 7153161067, 7153400210): the catalog no longer decides either. function addChoices() { apps = [CRM]; admin = true; renderMenu('crm'); return within(screen.getByTestId('add-app-choices')); } + const choiceIds = () => + Array.from(screen.getByTestId('add-app-choices').querySelectorAll('a')).map((a) => a.getAttribute('data-testid')); - it('in-app building closed (`ask` served, `build` not): no build-with-AI door; Studio, a template, the marketplace', () => { - catalog = [{ name: 'ask' }]; + it.each([ + ['build and ask served', [{ name: 'build' }, { name: 'ask' }]], + ['the legacy build id served', [{ name: 'metadata_assistant' }, { name: 'data_chat' }]], + ['in-app building closed (`ask` only)', [{ name: 'ask' }]], + ['other agents only', [{ name: 'custom_helper' }]], + ['no agent at all', []], + ])('%s: 「New blank app」 to New Package, a template, the marketplace — never 「Build with AI」', (_case, served) => { + catalog = served; const choices = addChoices(); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute( + 'href', + '/apps/setup/component/developer/packages?face=admin&new=package', + ); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveTextContent('New blank app'); expect(choices.queryByTestId('sidebar-app-menu-add-build-with-ai')).toBeNull(); - expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute('href', '/apps/setup/component/developer/packages?face=admin&new=package'); - expect(choices.getByTestId('sidebar-app-menu-add-template')).toHaveAttribute('href', '/apps/setup/system/marketplace'); - expect(choices.getByTestId('sidebar-app-menu-add-marketplace')).toHaveAttribute('href', '/apps/setup/system/marketplace'); + expect(choices.queryByText('Build with AI')).toBeNull(); + expect(choiceIds()).toEqual([ + 'sidebar-app-menu-add-new-in-studio', + 'sidebar-app-menu-add-template', + 'sidebar-app-menu-add-marketplace', + ]); }); - it('a catalog of other agents only offers no build-with-AI door either', () => { - catalog = [{ name: 'custom_helper' }]; - const choices = addChoices(); - expect(choices.queryByTestId('sidebar-app-menu-add-build-with-ai')).toBeNull(); - expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toBeInTheDocument(); + it.each([ + ['metadata authoring offered, no marketplace', true, false, ['sidebar-app-menu-add-new-in-studio']], + ['a marketplace, no metadata authoring', false, true, ['sidebar-app-menu-add-template', 'sidebar-app-menu-add-marketplace']], + ])('never empty for an admitted viewer — %s', (_case, ai, market, expected) => { + aiStudio = ai; + marketplace = market; + addChoices(); + expect(menu().getByTestId('sidebar-app-menu-add')).toBeInTheDocument(); + expect(choiceIds()).toEqual(expected); }); - it.each([ - ['build', [{ name: 'build' }, { name: 'ask' }]], - ['its legacy id', [{ name: 'metadata_assistant' }, { name: 'data_chat' }]], - ])('regression: with %s served the door is unchanged, to Studio', (_served, served) => { - catalog = served; - const choices = addChoices(); - expect(choices.getByTestId('sidebar-app-menu-add-build-with-ai')).toHaveAttribute('href', '/studio'); - expect(choices.getByTestId('sidebar-app-menu-add-build-with-ai')).toHaveTextContent('Build with AI'); - expect(choices.queryByTestId('sidebar-app-menu-add-new-in-studio')).toBeNull(); - expect( - Array.from(screen.getByTestId('add-app-choices').querySelectorAll('a')).map((a) => a.getAttribute('data-testid')), - ).toEqual(['sidebar-app-menu-add-build-with-ai', 'sidebar-app-menu-add-template', 'sidebar-app-menu-add-marketplace']); + it('control: with neither offered, the viewer is not admitted, and the menu draws no 「Add app」', () => { + aiStudio = false; + marketplace = false; + apps = [CRM]; + admin = true; + renderMenu('crm'); + expect(menu().queryByTestId('sidebar-app-menu-add')).toBeNull(); + }); + + it('guard: an admitted viewer handed no entries gets no 「Add app」 and no separator for it', () => { + entriesOverride = []; + apps = [CRM]; + admin = true; + renderMenu('crm'); + expect(menu().queryByTestId('sidebar-app-menu-add')).toBeNull(); + expect(screen.queryByTestId('add-app-choices')).toBeNull(); + // 「Design layout」 and 「Edit app」 read the package list, which has not + // answered on this first frame, so nothing else asks for the separator. + expect(menu().queryByRole('separator')).toBeNull(); + expect(screen.getByTestId('sidebar-app-menu').querySelector('hr')).toBeNull(); }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx index 825ae45d4e9..8601253d12b 100644 --- a/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/PackageCustomizationsPanel.test.tsx @@ -77,7 +77,8 @@ function stubWire(status: number, data: unknown) { status === 200 ? { success: true, data } : { success: false, error: { code: 'PERMISSION_DENIED', message: 'You may not read this package.' } }; - return { ok: status === 200, status, json: async () => body } as Response; + // `headers`: a transport that reads them finds an empty set, not a throw. + return { ok: status === 200, status, headers: new Headers(), json: async () => body } as Response; }), ); } diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index d90ef129907..1a96e0a6610 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -4526,7 +4526,7 @@ const en = { build: { title: 'Build an app', noCapability: 'Building apps isn\'t available in this system — it requires the “Manage Metadata” permission, which your account doesn\'t have.', - inStudio: 'New in Studio', + inStudio: 'New blank app', }, template: { title: 'Start with a template', diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index 97ea9b36f2c..26c95e18dba 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -3902,7 +3902,7 @@ const zh = { build: { title: '构建应用', noCapability: '本系统不提供构建应用功能 — 它需要「管理元数据」权限,而你的账号没有该权限。', - inStudio: '在 Studio 中新建', + inStudio: '新建空白应用', }, template: { title: '从模板开始', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index c16ecda97c7..a06a3fea9e2 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -3902,7 +3902,7 @@ const zhHant = { build: { title: '構建應用', noCapability: '本系統不提供構建應用功能 — 它需要「管理中繼資料」權限,而你的賬號沒有該權限。', - inStudio: '在 Studio 中新建', + inStudio: '新建空白應用', }, template: { title: '從模板開始', From 64e7071b87227ae2be87e38cbd05e85ad27531d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 08:03:48 +0000 Subject: [PATCH 18/21] fix(i18n): carry New blank app to Home's chip default and every language pack check:i18n-keys holds a call site's inline default to the en value, and check:i18n-drift holds every pack to an en change in the same PR. Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .changeset/36908-studio-home-strings.md | 2 +- ui/packages/app-shell/src/console/home/HomePage.tsx | 2 +- ui/packages/i18n/src/locales/ar.ts | 2 +- ui/packages/i18n/src/locales/de.ts | 2 +- ui/packages/i18n/src/locales/es.ts | 2 +- ui/packages/i18n/src/locales/fr.ts | 2 +- ui/packages/i18n/src/locales/ja.ts | 2 +- ui/packages/i18n/src/locales/ko.ts | 2 +- ui/packages/i18n/src/locales/pt-BR.ts | 2 +- ui/packages/i18n/src/locales/ru.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.changeset/36908-studio-home-strings.md b/.changeset/36908-studio-home-strings.md index 51b7371f3ef..258ae7b4157 100644 --- a/.changeset/36908-studio-home-strings.md +++ b/.changeset/36908-studio-home-strings.md @@ -7,4 +7,4 @@ feat(i18n): strings for the customizations section in Setup → Packages and for Clause-②: no Metadata-protocol: none -Adds the strings for the customizations section of an app's detail in Setup → Packages, and for the way out of Studio's "package not found" state. The strings of Studio's removed home page that shipped in 18.6.0 stay in the studio namespace, no longer read, so no released string is removed. Four of that page's strings that were added after 18.6.0 and never released are removed. The "New in Studio" label now reads "New blank app" in English and 「新建空白应用」 in Chinese (Simplified and Traditional); its other translations are unchanged. +Adds the strings for the customizations section of an app's detail in Setup → Packages, and for the way out of Studio's "package not found" state. The strings of Studio's removed home page that shipped in 18.6.0 stay in the studio namespace, no longer read, so no released string is removed. Four of that page's strings that were added after 18.6.0 and never released are removed. The "New in Studio" label now reads "New blank app" in English and 「新建空白应用」 in Chinese, and is translated anew in every other language pack. diff --git a/ui/packages/app-shell/src/console/home/HomePage.tsx b/ui/packages/app-shell/src/console/home/HomePage.tsx index 94f596c962f..aec812db1e8 100644 --- a/ui/packages/app-shell/src/console/home/HomePage.tsx +++ b/ui/packages/app-shell/src/console/home/HomePage.tsx @@ -987,7 +987,7 @@ export function HomePage({ checklist }: HomePageProps = {}) { {aiStudioEnabled && aiResolved && !buildServed && canAuthorMetadata && ( navigate(SETUP_NEW_PACKAGE_PATH)} disabledReason={undefined} diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 98b7563b35f..b970374e644 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -4049,7 +4049,7 @@ const ar = { build: { title: "إنشاء تطبيق", noCapability: "إنشاء التطبيقات غير متاح في هذا النظام — فهو يتطلب إذن «إدارة البيانات الوصفية» الذي لا يملكه حسابك.", - inStudio: "إنشاء جديد في Studio", + inStudio: "تطبيق فارغ جديد", }, template: { title: "ابدأ من قالب", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 526d637a43f..6cbd3976d67 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -3726,7 +3726,7 @@ const de = { build: { title: "App erstellen", noCapability: "Das Erstellen von Apps ist in diesem System nicht verfügbar — es erfordert die Berechtigung „Metadaten verwalten“, die Ihr Konto nicht besitzt.", - inStudio: "Neu in Studio", + inStudio: "Neue leere App", }, template: { title: "Mit einer Vorlage starten", diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index b4b7f69770b..8920319eb81 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -3808,7 +3808,7 @@ const es = { build: { title: "Crear una aplicación", noCapability: "La creación de aplicaciones no está disponible en este sistema: requiere el permiso «Gestionar metadatos», que su cuenta no tiene.", - inStudio: "Nuevo en Studio", + inStudio: "Nueva aplicación en blanco", }, template: { title: "Empezar con una plantilla", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 8db238ee123..af6a861eff9 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -3804,7 +3804,7 @@ const fr = { build: { title: "Créer une application", noCapability: "La création d'applications n'est pas disponible dans ce système : elle requiert l'autorisation « Gérer les métadonnées », que votre compte ne possède pas.", - inStudio: "Nouveau dans Studio", + inStudio: "Nouvelle application vierge", }, template: { title: "Partir d'un modèle", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 7900bf77b44..9e83f79854f 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -3728,7 +3728,7 @@ const ja = { build: { title: "アプリを作る", noCapability: "このシステムではアプリの作成はできません — 「メタデータ管理」権限が必要ですが、お使いのアカウントにはありません。", - inStudio: "Studio で新規作成", + inStudio: "空のアプリを新規作成", }, template: { title: "テンプレートから始める", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index 854f6c1bbdb..c348a8ac2f6 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -3726,7 +3726,7 @@ const ko = { build: { title: "앱 만들기", noCapability: "이 시스템에서는 앱 만들기를 사용할 수 없습니다 — ‘메타데이터 관리’ 권한이 필요하지만 계정에 해당 권한이 없습니다.", - inStudio: "Studio에서 새로 만들기", + inStudio: "새 빈 앱 만들기", }, template: { title: "템플릿으로 시작", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 2237161b73f..dc65281f587 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -3803,7 +3803,7 @@ const pt = { build: { title: "Criar um aplicativo", noCapability: "A criação de aplicativos não está disponível neste sistema — ela exige a permissão “Gerenciar metadados”, que sua conta não possui.", - inStudio: "Novo no Studio", + inStudio: "Novo aplicativo em branco", }, template: { title: "Comece com um modelo", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 973cd7afb5a..2f51a316731 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -3895,7 +3895,7 @@ const ru = { build: { title: "Создать приложение", noCapability: "Создание приложений недоступно в этой системе — для этого нужно разрешение «Управление метаданными», которого нет у вашей учётной записи.", - inStudio: "Создать в Studio", + inStudio: "Новое пустое приложение", }, template: { title: "Начать с шаблона", From 816cca43600faefe07bb2cfe4798ef9fdd802a61 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 08:40:40 +0000 Subject: [PATCH 19/21] fix(app-shell): the new-package doors outside Studio send a Studio-only author to All metadata Home's no-agent chip, the /ai screen's door and Add app's New blank app now make the same choice as Studio's entry: Setup's New Package for a holder of setup.access + manage_platform_settings, the All metadata area otherwise. They sit outside the entry gate's provider, so they read the session's own capability answer. The pure helpers move into studioEntryPermissions.ts so Home's eager code does not reach the Studio entry component. Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .../src/console/ai/AiUnavailable.tsx | 7 ++- .../app-shell/src/console/home/HomePage.tsx | 7 ++- .../HomePage.noAgentsBuildChip-26614.test.tsx | 28 +++++++++++ .../app-shell/src/hooks/useAddAppEntries.ts | 8 +-- .../src/hooks/useNewPackageDoorPath.ts | 21 ++++++++ .../__tests__/SidebarAppMenu-36112.test.tsx | 25 ++++++++++ .../studio-design/StudioDesignSurface.tsx | 3 +- .../StudioEntryRedirect.test.tsx | 8 ++- .../studio-design/StudioEntryRedirect.tsx | 41 ++------------- .../studio-design/studioEntryPermissions.ts | 50 +++++++++++++++++++ 10 files changed, 150 insertions(+), 48 deletions(-) create mode 100644 ui/packages/app-shell/src/hooks/useNewPackageDoorPath.ts diff --git a/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx b/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx index a6135471d9f..375af18e34d 100644 --- a/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx +++ b/ui/packages/app-shell/src/console/ai/AiUnavailable.tsx @@ -27,7 +27,7 @@ import { Button, Empty, EmptyDescription, EmptyTitle } from '@object-ui/componen import { useCanAuthorMetadata } from '../../hooks/useCanAuthorMetadata.js'; import { usePhoneViewport } from '../../hooks/usePhoneViewport.js'; import { isAiStudioEnabled } from '../../runtime-config.js'; -import { SETUP_NEW_PACKAGE_PATH } from '../../views/metadata-admin/packageSource.js'; +import { useNewPackageDoorPath } from '../../hooks/useNewPackageDoorPath.js'; export function AiUnavailable({ hasError, @@ -43,6 +43,9 @@ export function AiUnavailable({ }) { const { isAdmin } = useWorkspaceAdminStatus(); const canAuthorMetadata = useCanAuthorMetadata(); + // objectstack#36908 — New Package in Setup, or the "All metadata" area for an + // author who may not open Setup → Packages. + const newPackagePath = useNewPackageDoorPath(); const offerStudio = !hasError && isAdmin && isAiStudioEnabled() && canAuthorMetadata; // The way home names where it goes: a phone's Home is its app list; from // 768 px up the home page is retired (objectstack#36732) and `onHome` opens @@ -73,7 +76,7 @@ export function AiUnavailable({ )} {offerStudio && ( diff --git a/ui/packages/app-shell/src/console/home/HomePage.tsx b/ui/packages/app-shell/src/console/home/HomePage.tsx index aec812db1e8..8c2f0873669 100644 --- a/ui/packages/app-shell/src/console/home/HomePage.tsx +++ b/ui/packages/app-shell/src/console/home/HomePage.tsx @@ -89,7 +89,7 @@ import { usePublishAllDrafts } from '../../preview/usePublishAllDrafts.js'; import { fetchPackages } from '../../views/studio-design/packages-io.js'; import { resolveAiApiBase } from '../../hooks/useAiSurface.js'; import { isAiStudioEnabled, isMarketplaceEnabled } from '../../runtime-config.js'; -import { SETUP_NEW_PACKAGE_PATH } from '../../views/metadata-admin/packageSource.js'; +import { useNewPackageDoorPath } from '../../hooks/useNewPackageDoorPath.js'; import { useOpenAssistant } from '../../layout/chatDockControl.js'; import { isProductApp } from '../../utils/homePath.js'; import { useAddAppEntries, useMayAddApp } from '../../hooks/useAddAppEntries.js'; @@ -525,6 +525,9 @@ export function HomePage({ checklist }: HomePageProps = {}) { // `org_owner` is an admin (`isAdmin === true`) yet deliberately holds no // `manage_metadata`, so role alone offered a front door the backend refuses. const canAuthorMetadata = useCanAuthorMetadata(); + // objectstack#36908 — New Package in Setup, or the "All metadata" area for an + // author who may not open Setup → Packages. + const newPackagePath = useNewPackageDoorPath(); // objectui#5504 — a runtime deployed with `OS_CLOUD_URL=off` (the EE // deploy template's shipped default) mounts no marketplace at all. Home // used to recommend it first and error afterwards; that ORDERING was the @@ -989,7 +992,7 @@ export function HomePage({ checklist }: HomePageProps = {}) { icon={Hammer} label={t('home.build.inStudio', { defaultValue: 'New blank app' })} tone="soft" - onClick={() => navigate(SETUP_NEW_PACKAGE_PATH)} + onClick={() => navigate(newPackagePath)} disabledReason={undefined} reasonId={undefined} testId="home-build-in-studio" diff --git a/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx b/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx index 307e738221c..9f1ebb8c64f 100644 --- a/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx +++ b/ui/packages/app-shell/src/console/home/__tests__/HomePage.noAgentsBuildChip-26614.test.tsx @@ -44,6 +44,8 @@ const state = vi.hoisted(() => ({ agents: [] as Array<{ name: string }>, /** Holds the catalog in flight. */ catalogPending: false, + /** Whether the session holds the Setup → Packages pair (`setup.access` + `manage_platform_settings`). */ + setupPair: true, })); vi.mock('react-router-dom', async () => { @@ -109,6 +111,22 @@ vi.mock('../../../providers/MetadataProvider', () => ({ vi.mock('../../../context/NavigationContext', () => ({ useNavigationContext: () => ({ currentAppName: undefined }), })); +vi.mock('@object-ui/permissions', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + usePermissions: () => { + const real = actual.usePermissions(); + return { + ...real, + hasCapabilities: (required: string[]) => + required.includes('setup.access') || required.includes('manage_platform_settings') + ? state.setupPair + : real.hasCapabilities(required), + }; + }, + }; +}); vi.mock('../../../hooks/useCanAuthorMetadata', () => ({ useCanAuthorMetadata: () => state.canAuthorMetadata, useCanReadPendingDrafts: () => true, @@ -162,6 +180,7 @@ beforeEach(() => { state.canAuthorMetadata = true; state.agents = []; state.catalogPending = false; + state.setupPair = true; }); afterEach(() => { @@ -206,6 +225,15 @@ describe('with no agent in the catalog (objectstack#26614)', () => { expect(SETUP_NEW_PACKAGE_PATH).toBe('/apps/setup/component/developer/packages?face=admin&new=package'); }); + it('an author who may enter Studio but not Setup → Packages is sent to the "All metadata" area, never Setup (objectstack#36908)', async () => { + state.setupPair = false; + const user = userEvent.setup(); + render(); + await user.click(await screen.findByTestId('home-build-in-studio')); + expect(navigateMock).toHaveBeenCalledWith('/studio/~all/metadata'); + expect(navigateMock).not.toHaveBeenCalledWith(SETUP_NEW_PACKAGE_PATH); + }); + it('a session that may not author gets no build chip; the template chip keeps the reason', async () => { state.canAuthorMetadata = false; render(); diff --git a/ui/packages/app-shell/src/hooks/useAddAppEntries.ts b/ui/packages/app-shell/src/hooks/useAddAppEntries.ts index 89dbb3b291f..d1c2d4d1f1a 100644 --- a/ui/packages/app-shell/src/hooks/useAddAppEntries.ts +++ b/ui/packages/app-shell/src/hooks/useAddAppEntries.ts @@ -15,7 +15,7 @@ import { useObjectTranslation } from '@object-ui/i18n'; import { useWorkspaceAdminStatus } from '@object-ui/auth'; import { useCanAuthorMetadata } from './useCanAuthorMetadata.js'; import { isAiStudioEnabled, isMarketplaceEnabled } from '../runtime-config.js'; -import { SETUP_NEW_PACKAGE_PATH } from '../views/metadata-admin/packageSource.js'; +import { useNewPackageDoorPath } from './useNewPackageDoorPath.js'; /** The marketplace, where templates and packages are installed from. */ const MARKETPLACE_PATH = '/apps/setup/system/marketplace'; @@ -41,7 +41,8 @@ export function useMayAddApp(): boolean { /** * The 「Add app」 choices: 「新建空白应用」 / "New blank app" (a new package, - * opened in Studio once created) wherever the deployment offers metadata + * opened in Studio once created; `useNewPackageDoorPath` sends an author who + * may not open Setup → Packages to the "All metadata" area) wherever the deployment offers metadata * authoring, whether or not its agent catalog serves the build agent; templates * and the marketplace where a marketplace is mounted. * @@ -55,11 +56,12 @@ export function useMayAddApp(): boolean { */ export function useAddAppEntries(): AddAppEntry[] { const { t } = useObjectTranslation(); + const newPackagePath = useNewPackageDoorPath(); const entries: AddAppEntry[] = []; if (isAiStudioEnabled()) { entries.push({ key: 'new-in-studio', - to: SETUP_NEW_PACKAGE_PATH, + to: newPackagePath, label: t('home.build.inStudio', { defaultValue: 'New blank app' }), icon: Hammer, }); diff --git a/ui/packages/app-shell/src/hooks/useNewPackageDoorPath.ts b/ui/packages/app-shell/src/hooks/useNewPackageDoorPath.ts new file mode 100644 index 00000000000..aea6ee73073 --- /dev/null +++ b/ui/packages/app-shell/src/hooks/useNewPackageDoorPath.ts @@ -0,0 +1,21 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * Where a console door that creates a package leads: Setup → Packages with New + * Package open for a holder of `setup.access` + `manage_platform_settings`, and + * Studio's "All metadata" area for an author who may enter Studio but not open + * that Setup page (objectstack#36908). The doors are Home's no-agent chip, the + * `/ai` screen's 「New blank app」 and 「Add app」's 「New blank app」; they sit + * outside Studio's entry gate, so they read the session's own capability + * answer. See `newPackageDoorPath`. + * + * @module + */ + +import { usePermissions } from '@object-ui/permissions'; +import { newPackageDoorPath, SETUP_PACKAGES_CAPABILITIES } from '../views/studio-design/studioEntryPermissions.js'; + +export function useNewPackageDoorPath(): string { + const { hasCapabilities } = usePermissions(); + return newPackageDoorPath(hasCapabilities([...SETUP_PACKAGES_CAPABILITIES])); +} diff --git a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx index 76717bd3880..5a228d76893 100644 --- a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx @@ -116,6 +116,24 @@ vi.mock('../../runtime-config', async (importOriginal) => ({ isAiStudioEnabled: () => aiStudio, isMarketplaceEnabled: () => marketplace, })); +/** Whether the session holds the Setup → Packages pair (`setup.access` + `manage_platform_settings`). */ +let setupPair = true; +vi.mock('@object-ui/permissions', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + usePermissions: () => { + const real = actual.usePermissions(); + return { + ...real, + hasCapabilities: (required: string[]) => + required.includes('setup.access') || required.includes('manage_platform_settings') + ? setupPair + : real.hasCapabilities(required), + }; + }, + }; +}); /** When set, what the 「Add app」 list answers instead of the real hook (the empty-list guard). */ let entriesOverride: unknown[] | null = null; vi.mock('../../hooks/useAddAppEntries', async (importOriginal) => { @@ -180,6 +198,7 @@ afterEach(() => { aiStudio = true; marketplace = true; entriesOverride = null; + setupPair = true; authOverride = {}; toastError.mockReset(); vi.unstubAllGlobals(); @@ -294,6 +313,12 @@ describe('「Add app」 offers 「New blank app」 whatever the catalog serves, ]); }); + it('an author who may enter Studio but not Setup → Packages is sent to the "All metadata" area, never Setup (objectstack#36908)', () => { + setupPair = false; + const choices = addChoices(); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute('href', '/studio/~all/metadata'); + }); + it.each([ ['metadata authoring offered, no marketplace', true, false, ['sidebar-app-menu-add-new-in-studio']], ['a marketplace, no metadata authoring', false, true, ['sidebar-app-menu-add-template', 'sidebar-app-menu-add-marketplace']], 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 caee40d1389..0f52705aa09 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -63,8 +63,7 @@ import { } from './flowGrouping.js'; import { StudioRefusalStrip } from './StudioRefusalStrip.js'; import { PACKAGE_LIST_TOAST_ID } from './PackageSwitcher.js'; -import { studioEntryFallbackPath } from './StudioEntryRedirect.js'; -import { useStudioEntryPermissions } from './studioEntryPermissions.js'; +import { studioEntryFallbackPath, useStudioEntryPermissions } from './studioEntryPermissions.js'; import { SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; import { StudioBackToApp, type StudioAppTarget } from './StudioBackToApp.js'; import { diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx index fdaf7dacff5..841e91831ac 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.test.tsx @@ -28,7 +28,8 @@ vi.mock('./packages-io.js', () => ({ fetchListedPackageIds: () => listed.read(), })); -import { StudioEntryRedirect, studioEntryFallbackPath, studioNewPackageEntryPath } from './StudioEntryRedirect'; +import { StudioEntryRedirect } from './StudioEntryRedirect'; +import { newPackageDoorPath, studioEntryFallbackPath, studioNewPackageEntryPath } from './studioEntryPermissions'; const SETUP_PACKAGES = '/apps/setup/component/developer/packages?face=admin'; const ALL_METADATA = '/studio/~all/metadata'; @@ -150,4 +151,9 @@ describe('the retired `/studio?new=package` bookmark (objectstack#36908)', () => expect(studioNewPackageEntryPath(['studio.access', 'setup.access'])).toBe(ALL_METADATA); expect(studioNewPackageEntryPath(undefined)).toBe(ALL_METADATA); }); + + it('the console doors outside Studio (Home, /ai, 「Add app」) make the same choice from the session\'s own answer', () => { + expect(newPackageDoorPath(true)).toBe(`${SETUP_PACKAGES}&new=package`); + expect(newPackageDoorPath(false)).toBe(ALL_METADATA); + }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx index e27b4548785..409ab0f6b5e 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioEntryRedirect.tsx @@ -15,12 +15,12 @@ * 2. otherwise the package list: Setup → Packages for a principal who may * open it, and Studio's "All metadata" area across packages * (`/studio/~all/metadata`) for one who may enter Studio and not that - * Setup page ({@link studioEntryFallbackPath}). + * Setup page (`studioEntryFallbackPath`). * * The retired `/studio?new=package` bookmark is forwarded to Setup's New * Package (`studioNewPackage.ts`) for a principal who may open Setup → * Packages, and to the same fallback as (2) for anyone else - * ({@link studioNewPackageEntryPath}): a Studio-only author is never sent to a + * (`studioNewPackageEntryPath`): a Studio-only author is never sent to a * Setup page that refuses them. * * A package deleted since the visit is passed over: the recent store is the @@ -32,46 +32,11 @@ import * as React from 'react'; import { Navigate, useSearchParams } from 'react-router-dom'; import { useRecentItems, type RecentNamedItem } from '../../context/RecentItemsProvider.js'; -import { SETUP_NEW_PACKAGE_PATH, SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; -import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaPath } from './metadataArea.js'; import { fetchListedPackageIds } from './packages-io.js'; import { studioPackagePath } from './studioAddress.js'; +import { studioEntryFallbackPath, studioNewPackageEntryPath } from './studioEntryPermissions.js'; import { STUDIO_NEW_PACKAGE_VALUE, STUDIO_NEW_PARAM } from './studioNewPackage.js'; -/** - * The capabilities Setup → Packages is shown under: the Setup app's entry - * (`setup.access`) and the menu item's gate (`manage_platform_settings`, - * `nav_packages` in `setup-nav.contributions.ts`). - */ -const SETUP_PACKAGES_CAPABILITIES = ['setup.access', 'manage_platform_settings'] as const; - -/** `undefined` (no answer reported) holds nothing. */ -function holdsSetupPackages(systemPermissions: readonly string[] | undefined): boolean { - const held = new Set(systemPermissions ?? []); - return SETUP_PACKAGES_CAPABILITIES.every((c) => held.has(c)); -} - -/** - * Where Studio's entry goes when no remembered package opens: Setup → Packages - * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else the "All metadata" - * area across packages, which every principal who may enter Studio may open. - * `undefined` (no answer reported) holds nothing. - */ -export function studioEntryFallbackPath(systemPermissions: readonly string[] | undefined): string { - return holdsSetupPackages(systemPermissions) - ? SETUP_PACKAGES_PATH - : studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT); -} - -/** - * Where the retired `/studio?new=package` bookmark goes: Setup's New Package - * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else - * {@link studioEntryFallbackPath}'s answer for that principal. - */ -export function studioNewPackageEntryPath(systemPermissions: readonly string[] | undefined): string { - return holdsSetupPackages(systemPermissions) ? SETUP_NEW_PACKAGE_PATH : studioEntryFallbackPath(systemPermissions); -} - export function StudioEntryRedirect({ systemPermissions, pending = null, diff --git a/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts b/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts index 6ec97905093..8cb36f40938 100644 --- a/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts +++ b/ui/packages/app-shell/src/views/studio-design/studioEntryPermissions.ts @@ -15,6 +15,8 @@ */ import * as React from 'react'; +import { SETUP_NEW_PACKAGE_PATH, SETUP_PACKAGES_PATH } from '../metadata-admin/packageSource.js'; +import { STUDIO_ALL_PACKAGES_SEGMENT, studioMetadataAreaPath } from './metadataArea.js'; const StudioEntryPermissionsContext = React.createContext(undefined); @@ -25,3 +27,51 @@ export const StudioEntryPermissionsProvider = StudioEntryPermissionsContext.Prov export function useStudioEntryPermissions(): readonly string[] | undefined { return React.useContext(StudioEntryPermissionsContext); } + +/** + * The capabilities Setup → Packages is shown under: the Setup app's entry + * (`setup.access`) and the menu item's gate (`manage_platform_settings`, + * `nav_packages` in `setup-nav.contributions.ts`). + */ +export const SETUP_PACKAGES_CAPABILITIES = ['setup.access', 'manage_platform_settings'] as const; + +/** `undefined` (no answer reported) holds nothing. */ +export function holdsSetupPackages(systemPermissions: readonly string[] | undefined): boolean { + const held = new Set(systemPermissions ?? []); + return SETUP_PACKAGES_CAPABILITIES.every((c) => held.has(c)); +} + +/** + * Where Studio's entry goes when no remembered package opens: Setup → Packages + * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else the "All metadata" + * area across packages, which every principal who may enter Studio may open. + * `undefined` (no answer reported) holds nothing. + */ +export function studioEntryFallbackPath(systemPermissions: readonly string[] | undefined): string { + return holdsSetupPackages(systemPermissions) + ? SETUP_PACKAGES_PATH + : studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT); +} + +/** + * Where the retired `/studio?new=package` bookmark goes: Setup's New Package + * for a holder of {@link SETUP_PACKAGES_CAPABILITIES}, else + * {@link studioEntryFallbackPath}'s answer for that principal. + */ +export function studioNewPackageEntryPath(systemPermissions: readonly string[] | undefined): string { + return holdsSetupPackages(systemPermissions) ? SETUP_NEW_PACKAGE_PATH : studioEntryFallbackPath(systemPermissions); +} + +/** + * Where a door that creates a package goes, outside Studio's entry gate + * (Home's no-agent chip, the `/ai` screen, 「Add app」's 「New blank app」): + * the same choice as {@link studioNewPackageEntryPath}, decided by whether + * the caller holds {@link SETUP_PACKAGES_CAPABILITIES}. Those doors have no + * entry-gate set to read; they ask the session's own capability answer + * (`usePermissions().hasCapabilities`), which fails open on an unreported set + * as the doors' own authoring gate does — the server still refuses Setup to a + * non-holder (objectstack#36908). + */ +export function newPackageDoorPath(holdsSetupPackagesPair: boolean): string { + return holdsSetupPackagesPair ? SETUP_NEW_PACKAGE_PATH : studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT); +} From 0e05792701ee91132acd1c5694bd0af639dbc269 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 09:19:00 +0000 Subject: [PATCH 20/21] docs(changeset): the new-package doors send a developer without Setup access to All metadata Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .changeset/36908-remove-studio-home.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/36908-remove-studio-home.md b/.changeset/36908-remove-studio-home.md index 97b30a4818a..6fbdbf118c3 100644 --- a/.changeset/36908-remove-studio-home.md +++ b/.changeset/36908-remove-studio-home.md @@ -12,7 +12,7 @@ Metadata-protocol: none The package-card page Studio used to open on is gone. Studio is opened from an app or from Setup → Packages, and everything that page offered has another place: - **Opening Studio** takes you to the package you were last in, if it is still installed. Otherwise an administrator lands on Setup → Packages, and a developer who cannot open that Setup page lands on the All metadata area. The 应用构建 entry of the Studio app goes to the same place. -- **New package.** 「New blank app」 (formerly 「New in Studio」) on Home, on the AI-unavailable screen and in the 「Add app」 menu opens Setup → Packages with the New Package dialog already open. After the package is created you land in Studio on it. An old bookmark to Studio's new-package page goes there too, or to the All metadata area for a developer who cannot open Setup → Packages. Creating a package and its app in one step comes with a later change; for now this creates the package only. +- **New package.** 「New blank app」 (formerly 「New in Studio」) on Home, on the AI-unavailable screen and in the 「Add app」 menu opens Setup → Packages with the New Package dialog already open; a developer who cannot open Setup → Packages is taken to the All metadata area instead. After the package is created you land in Studio on it. An old bookmark to Studio's new-package page makes the same choice. Creating a package and its app in one step comes with a later change; for now this creates the package only. - **What this environment changed on an installed app.** The "n customized, m switched off" line and the "Customizations in this environment" panel are now in the app's detail in Setup → Packages, with a 「Customize in Studio」 link. The count now includes tab, field-group and action-layout arrangements, so an app whose only change is a tab arrangement shows as customized. The list across all installed apps at once is now shown one app at a time. - **The 「Add app」 menu** no longer offers 「Build with AI」, and neither do the buttons on the "No applications yet" screen. 「New blank app」 is now always offered wherever apps can be built, whether or not the AI build assistant is available, so the menu is never empty for someone who may add an app; a menu with nothing to offer is not shown. Home's own 「Build with AI」 button is unchanged. - **Organization flows and the environment catalog** are in Studio's left menu. From 1c7f29cc53c31ba99c6488176314c229305de049 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 09:21:25 +0000 Subject: [PATCH 21/21] test(app-shell): the docs portal's Add app follows the app menu's rule Claude-Session: https://claude.ai/code/session_01QSeKYkEULEjF814KSPBLVC Co-authored-by: Claude --- .../__tests__/SidebarAppMenu-36112.test.tsx | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx index f792fa3cee9..a043d0c4253 100644 --- a/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx +++ b/ui/packages/app-shell/src/layout/__tests__/SidebarAppMenu-36112.test.tsx @@ -668,4 +668,39 @@ describe('the docs portal\'s head names no app and only switches apps (objectsta expect(portalMenu().getByTestId('sidebar-app-menu-row-crm')).toBeInTheDocument(); expect(portalMenu().queryByTestId('sidebar-app-menu-add')).toBeNull(); }); + + // objectstack#36908 — the portal's 「Add app」 is the app menu's list, under + // the same rule (ruling records 7153161067, 7153400210). + it('its 「Add app」 offers 「New blank app」 and no 「Build with AI」, with the build agent served', () => { + apps = [CRM]; + admin = true; + renderPortalMenu(); + const choices = within(screen.getByTestId('add-app-choices')); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveTextContent('New blank app'); + expect(choices.getByTestId('sidebar-app-menu-add-new-in-studio')).toHaveAttribute( + 'href', + '/apps/setup/component/developer/packages?face=admin&new=package', + ); + expect(choices.queryByTestId('sidebar-app-menu-add-build-with-ai')).toBeNull(); + expect(choices.queryByText('Build with AI')).toBeNull(); + }); + + it('an author who may not open Setup → Packages gets 「New blank app」 to the "All metadata" area', () => { + setupPair = false; + apps = [CRM]; + admin = true; + renderPortalMenu(); + expect( + within(screen.getByTestId('add-app-choices')).getByTestId('sidebar-app-menu-add-new-in-studio'), + ).toHaveAttribute('href', '/studio/~all/metadata'); + }); + + it('guard: handed no entries, it draws no 「Add app」 and no separator for it', () => { + entriesOverride = []; + apps = [CRM]; + admin = true; + renderPortalMenu(); + expect(portalMenu().queryByTestId('sidebar-app-menu-add')).toBeNull(); + expect(screen.getByTestId('sidebar-docs-portal-menu').querySelector('hr')).toBeNull(); + }); });