diff --git a/.changeset/37456-studio-top-left-rows.md b/.changeset/37456-studio-top-left-rows.md new file mode 100644 index 00000000000..7c16c0ceda2 --- /dev/null +++ b/.changeset/37456-studio-top-left-rows.md @@ -0,0 +1,9 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(studio): Studio's left column opens with two rows — App Studio with its collapse control, then the way back and a package switcher that ends with New package; a read-only package shows a lock; collapsed, the column is a rail that keeps the app's logo and the way back + +Clause-②: no +Metadata-protocol: none diff --git a/ui/e2e/studio-left-menu-36899.spec.ts b/ui/e2e/studio-left-menu-36899.spec.ts index f8084cadb9d..aabfa96b913 100644 --- a/ui/e2e/studio-left-menu-36899.spec.ts +++ b/ui/e2e/studio-left-menu-36899.spec.ts @@ -14,8 +14,8 @@ import { uiRoot } from '../scripts/ui-root.mjs'; * jsdom has no layout engine. The unit tests (`StudioMenu.test.tsx`) pin what * the menu lists, its current entry, its search and its cookie; this page * proves where it is drawn: docked at the left of a wide window with the - * content beside it, off the canvas once collapsed with the content taking the - * full width, still collapsed after a reload (Studio's own cookie, on a real + * content beside it, a rail of icons once collapsed with the content beside it + * (objectstack#37456), still collapsed after a reload (Studio's own cookie, on a real * http origin), and a drawer over the page at phone width. * * objectstack#37201 — the 「高级」 fold laid out: closed by default with its @@ -239,12 +239,21 @@ test.describe('Studio left menu (objectstack#36899)', () => { await expect(page.getByTestId('studio-menu-advanced-toggle')).toHaveAttribute('aria-expanded', 'true'); }); - test('collapsed: off the canvas, the content takes the full width, and a reload keeps it', async ({ page }, testInfo) => { + // objectstack#37456 (ADR-0084, amended 2026-11-26, `#amendment-2026-11-26-frame`): collapsed, the + // column is a rail of icons (the sidebar's 3rem icon width), no longer off the canvas; the content + // starts where the rail ends. + test('collapsed: a rail of icons, the content beside it, and a reload keeps it', async ({ page }, testInfo) => { await open(page, 1280); await page.getByTestId('studio-menu-toggle').click(); await expect(page.locator('[data-side="left"][data-state="collapsed"]')).toHaveCount(1); - await expect.poll(async () => (await rect(page, PANEL)).right).toBeLessThanOrEqual(0); - await expect.poll(async () => (await rect(page, '#content')).left).toBe(0); + // Read once the width transition has finished. + await expect.poll(async () => (await rect(page, PANEL)).right).toBeLessThanOrEqual(49); + const rail = await rect(page, PANEL); + expect(rail.left).toBe(0); + expect(rail.right).toBeGreaterThan(40); + await expect(page.getByTestId('studio-menu-toggle')).toBeVisible(); + await expect.poll(async () => (await rect(page, '#content')).left).toBeGreaterThanOrEqual(rail.right - 1); + expect((await rect(page, '#content')).left).toBeLessThanOrEqual(rail.right + 1); const cookies = await page.context().cookies(ORIGIN); expect(cookies.find((c) => c.name === 'studio_menu_state')?.value).toBe('false'); expect(cookies.find((c) => c.name === 'sidebar_state')).toBeUndefined(); 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 38b1a637eaf..a73c21cbfd3 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 @@ -466,9 +466,13 @@ function mounts(component: string): string[] { } describe('every create-package door offers 「同时创建应用」 (objectstack#37134)', () => { - it('Setup → Packages (its button and the `?new=package` door) and the resource list mount CreatePackageDialog', () => { + it('Setup → Packages (its button and the `?new=package` door), the resource list and Studio’s package switcher (objectstack#37456) mount CreatePackageDialog', () => { const doors = mounts('CreatePackageDialog').map((m) => m.split(':')[0]); - expect(doors.sort()).toEqual(['views/metadata-admin/PackagesPage.tsx', 'views/metadata-admin/ResourceListPage.tsx']); + expect(doors.sort()).toEqual([ + 'views/metadata-admin/PackagesPage.tsx', + 'views/metadata-admin/ResourceListPage.tsx', + 'views/studio-design/StudioPackageSwitcher.tsx', + ]); }); it('no create-mode PackageFormDialog is mounted outside CreatePackageDialog, and that one passes the step', () => { diff --git a/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx b/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx index 1996fe5648a..dab224c4e1a 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx @@ -81,6 +81,56 @@ export function studioBackTarget({ return { path: `/apps/${segment}`, appLabel: labelOf(first) }; } +/** + * The way back as one control (objectstack#37456; ADR-0084, amended + * 2026-11-26, `#amendment-2026-11-26-frame`): the first control of the top + * left's package row, and of the collapsed rail. It leads where + * {@link studioBackTarget} says, the same place {@link StudioBackToApp} goes; + * the name beside it is the package switcher's, so the button carries the + * name only in its accessible name and tooltip. + */ +export function StudioBackButton({ + packageId, + apps, + locale, + beforeNavigate, + navigate, + className, +}: { + packageId: string | null; + apps: readonly StudioAppTarget[]; + locale: string; + beforeNavigate: () => boolean; + navigate: (path: string) => void; + className?: string; +}): React.ReactElement { + const [remembered] = React.useState(readAppReturnPage); + const homePath = useHomePath(); + const target = studioBackTarget({ remembered, packageId, apps, locale, landingPath: homePath }); + const title = target.appLabel + ? tFormat('engine.studio.backToAppTitle', locale, { app: target.appLabel }) + : t('engine.studio.backToAppTitleNoApp', locale); + return ( + + ); +} + export function StudioBackToApp({ packageId, packageLabel, 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 ba2228d7158..41d975adbd5 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 @@ -217,22 +217,21 @@ function renderAt(url: string) { } describe('Studio home loop (objectui#12513)', () => { - it('the header’s first way out is 「‹ Back to app」 now, not Studio home (objectstack#36501)', async () => { + it('the first way out is the way back, first in the package row, not Studio home (objectstack#36501, objectstack#37456)', async () => { // The Studio-home button and the switcher's Studio-home row were removed - // with the switcher: the landing is reached from the app. objectstack#36899 - // — the left menu's show / hide control leads the bar, so the way out is - // the button right after it. + // with the old switcher: the landing is reached from the app. + // objectstack#37456 — the top left's two rows: Studio's row holds the + // menu's show / hide control, and the package row starts with the way back. // objectstack#36903, objectstack#36904, objectstack#36905 — on the sharing // overview's page: the Automations, Data and Access pillars' addresses // redirect to the area now. renderAt(`/studio/${SHOWCASE}/owd`); - const back = await screen.findByTestId('studio-back-to-app'); - const header = screen.getByTestId('studio-shell-header'); - const buttons = within(header).getAllByRole('button'); - expect(buttons[0]).toBe(within(header).getByTestId('studio-menu-toggle')); - expect(buttons[1]).toBe(back); - expect(within(header).queryByRole('button', { name: 'Studio home' })).toBeNull(); + const back = await screen.findByTestId('studio-package-back'); + const row = screen.getByTestId('studio-package-row'); + expect(within(row).getAllByRole('button')[0]).toBe(back); + expect(within(screen.getByTestId('studio-brand-row')).getByTestId('studio-menu-toggle')).toBeTruthy(); + expect(screen.queryByRole('button', { name: 'Studio home' })).toBeNull(); }); // objectstack#36903 — the Automations rail's empty blocks went with the rail: // the package-less scope's list offers no create (StudioDesignSurface.packageLessFlows-11553). diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.rightSlot-12725.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.rightSlot-12725.test.tsx index 91c14c7d9b6..7519793cd6d 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.rightSlot-12725.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.rightSlot-12725.test.tsx @@ -223,7 +223,14 @@ describe('Studio right slot — its control ends the page\'s title row (objectst it('a list page: the AI assistant ends the list\'s title row, inside the page, not the top bar', async () => { renderAt('data'); - const ai = await screen.findByTestId('topbar-ai-assistant', undefined, { timeout: 4000 }); + // objectstack#37456 — while the list loads it has no title row, and the + // pane's fallback holds the control (`StudioTitleRowFallback`); once the + // list's title row is drawn the control is there, and only there. + await waitFor( + () => expect(screen.getByTestId('topbar-ai-assistant').closest('[data-slot="studio-title-row-end"]')).not.toBeNull(), + { timeout: 4000 }, + ); + const ai = screen.getByTestId('topbar-ai-assistant'); expect(within(screen.getByTestId('studio-shell-header')).queryByTestId('topbar-ai-assistant')).toBeNull(); expect(screen.getByTestId('studio-pillars-host')).toContainElement(ai); expect(ai.closest('[data-slot="studio-title-row-end"]')).not.toBeNull(); 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 99c7f9a62eb..b72a7e2c633 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -125,7 +125,7 @@ import { studioOrgScopePath, } from './studioScope.js'; import { STUDIO_METADATA_AREA, isStudioAllPackagesScope, settledAreaAddress } from './metadataArea.js'; -import { StudioMenu, StudioMenuDataProvider, StudioMenuProvider, StudioMenuTrigger } from './StudioMenu.js'; +import { StudioMenu, StudioMenuDataProvider, StudioMenuProvider } from './StudioMenu.js'; import { StudioMetadataArea } from './StudioMetadataArea.js'; import { StudioOwdOverviewPage } from './StudioOwdOverviewPage.js'; import { useMetadataRefreshNonce } from './useMetadataRefreshNonce.js'; @@ -167,7 +167,9 @@ import { type DraftPublishOptions, } from '../../preview/DraftChangesPanel.js'; import { toast } from 'sonner'; -import { STUDIO_OWD_SECTION, studioItemPath, studioMetadataTypePath, studioPillarPath } from './studioAddress.js'; +import { STUDIO_OWD_SECTION, studioItemPath, studioMetadataTypePath, studioPackagePath, studioPillarPath } from './studioAddress.js'; +import { StudioTopLeft } from './StudioTopLeft.js'; +import { StudioTitleRowFallback } from './StudioTitleRowFallback.js'; /** The batch door's `backfillApplied` receipt, by reference to what the client returns (objectui#12929). */ type PublishBackfillReceipt = NonNullable< @@ -1368,7 +1370,7 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re and Publish stay at the right end; objectstack#37455 — Cancel and Save moved to the page's item header. */}
- {showMenu && } + {/* objectstack#37456 — the menu's show / hide control moved to Studio's row (`StudioTopLeft`). */} {/* objectstack#36501 — 「‹ Back to app」, the app's name and the Studio mark: Studio's one way out. objectstack#36899 (decision 5) — it names the CURRENT package's app; with none, @@ -1529,7 +1531,29 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re {/* objectstack#36899 — the left menu and the page beside it. The menu docks in this row, below the header (a drawer under 768 px). */}
- {showMenu && } + {showMenu && ( + + } + /> + )}
+ {/* objectstack#37456 — the page controls of a page with no title row. */} +
diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx index e16b7cc4e34..ed6856710f3 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx @@ -130,6 +130,9 @@ import { type StudioMenuTier, } from './studioMenuModel.js'; +/** What the collapsed rail does not draw: the search and the fold's toggle. */ +const RAIL_HIDDEN = 'group-data-[state=collapsed]:group-data-[collapsible=icon]:hidden'; + /** The fold's cookie lives as long as the menu's own collapse cookie (the sidebar primitive's 7 days). */ const ADVANCED_COOKIE_MAX_AGE = 60 * 60 * 24 * 7; @@ -296,6 +299,11 @@ export interface StudioMenuProps { * `?` included); `false` keeps the author where they are. */ onReenterPillar?: (search: string) => boolean; + /** + * objectstack#37456 — what the column draws above its search: the top + * left's two rows (`StudioTopLeft`), or the rail's head while collapsed. + */ + head?: React.ReactNode; } /** @@ -320,6 +328,7 @@ function StudioMenuBody({ segment, locale, onReenterPillar, + head, data, }: StudioMenuProps & { data: StudioMenuData }): React.ReactElement { const scope = studioMenuScope(segment); @@ -367,7 +376,8 @@ function StudioMenuBody({ const Icon = studioMenuEntryIcon(entry, group); return ( - + {/* objectstack#37456 — on the collapsed rail an entry is its icon, named by its tooltip. */} + - + + {head} @@ -441,6 +454,7 @@ function StudioMenuBody({ id={searchId} type="search" data-testid="studio-menu-search" + className={RAIL_HIDDEN} placeholder={t('engine.studio.menu.search', locale)} value={query} onChange={(e) => setQuery(e.target.value)} @@ -459,7 +473,7 @@ function StudioMenuBody({ {folded && (tiers.advanced.length > 0 || allTypes) && ( <>