Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/37456-studio-top-left-rows.md
Original file line number Diff line number Diff line change
@@ -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
19 changes: 14 additions & 5 deletions ui/e2e/studio-left-menu-36899.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
50 changes: 50 additions & 0 deletions ui/packages/app-shell/src/views/studio-design/StudioBackToApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<button
type="button"
data-testid="studio-package-back"
data-target={target.path}
onClick={() => {
if (!beforeNavigate()) return;
navigate(target.path);
}}
aria-label={title}
title={title}
className={
className ??
'inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-sidebar-ring'
}
>
<ChevronLeft className="h-4 w-4" aria-hidden="true" />
</button>
);
}

export function StudioBackToApp({
packageId,
packageLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<
Expand Down Expand Up @@ -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. */}
<div className={cn('flex min-w-0 items-center gap-1', STUDIO_HEADER_PACKAGE_COLUMN)}>
{showMenu && <StudioMenuTrigger locale={locale} />}
{/* 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,
Expand Down Expand Up @@ -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). */}
<div className="relative flex min-h-0 flex-1 overflow-hidden">
{showMenu && <StudioMenu segment={scopeSegment} locale={locale} onReenterPillar={reenterPillar} />}
{showMenu && (
<StudioMenu
segment={scopeSegment}
locale={locale}
onReenterPillar={reenterPillar}
// objectstack#37456 — the top left's two rows: Studio's, then the
// way back and the package switcher (`StudioTopLeft.tsx`).
head={
<StudioTopLeft
packageId={packageId}
scope={allScope ? 'all' : packageId === null ? 'org' : undefined}
openEntry={pkgEntry}
readOnly={readOnly}
canCreate={canAuthorPackage}
apps={publishedApps}
locale={locale}
beforeNavigate={confirmLeavePillar}
navigate={shellNavigate}
packagePath={studioPackagePath}
/>
}
/>
)}
<div
className={cn('min-h-0 min-w-0 flex-1', STUDIO_PILLARS_HOST)}
data-testid="studio-pillars-host"
Expand Down Expand Up @@ -1627,6 +1651,8 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re
)}
</StudioPendingDraftsContext.Provider>
</div>
{/* objectstack#37456 — the page controls of a page with no title row. */}
<StudioTitleRowFallback />
</div>
</div>

Expand Down
22 changes: 18 additions & 4 deletions ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -320,6 +328,7 @@ function StudioMenuBody({
segment,
locale,
onReenterPillar,
head,
data,
}: StudioMenuProps & { data: StudioMenuData }): React.ReactElement {
const scope = studioMenuScope(segment);
Expand Down Expand Up @@ -367,7 +376,8 @@ function StudioMenuBody({
const Icon = studioMenuEntryIcon(entry, group);
return (
<SidebarMenuItem key={entry.key}>
<SidebarMenuButton asChild isActive={isCurrent}>
{/* objectstack#37456 — on the collapsed rail an entry is its icon, named by its tooltip. */}
<SidebarMenuButton asChild isActive={isCurrent} tooltip={label}>
<Link
to={entry.to}
aria-current={isCurrent ? 'page' : undefined}
Expand Down Expand Up @@ -425,22 +435,26 @@ function StudioMenuBody({

return (
<Sidebar
collapsible="offcanvas"
// objectstack#37456 — collapsed, the column is a rail of icons that
// keeps the app's logo and the way back (ADR-0084, amended 2026-11-26).
collapsible="icon"
// Docked below the surface's header, inside the body row, rather than
// fixed to the window's full height as the app sidebar is.
className="!absolute !h-full"
>
{/* Studio's accent over everything the menu draws, docked or in the
phone drawer (the primitive puts its own class on the docked frame only). */}
<div data-studio-accent="" data-testid="studio-menu-accent" className={cn('flex min-h-0 flex-1 flex-col', STUDIO_ACCENT)}>
<SidebarHeader className="border-b p-2">
<SidebarHeader className="gap-2 border-b p-2">
{head}
<label htmlFor={searchId} className="sr-only">
{t('engine.studio.menu.search', locale)}
</label>
<SidebarInput
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)}
Expand All @@ -459,7 +473,7 @@ function StudioMenuBody({
{folded && (tiers.advanced.length > 0 || allTypes) && (
<>
<div aria-hidden="true" data-testid="studio-menu-advanced-divider" className="mx-2 my-1 h-px bg-sidebar-border" />
<div className="px-2 py-1">
<div className={cn('px-2 py-1', RAIL_HIDDEN)}>
<button
type="button"
data-testid="studio-menu-advanced-toggle"
Expand Down
Loading
Loading