Skip to content
Merged
15 changes: 15 additions & 0 deletions .changeset/37455-studio-top-bar-tenants-rehome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/app-shell': patch
---

feat(studio): Save and Cancel sit in the page's item header, the AI assistant ends every title row, and all of Studio draws graphite

Clause-②: no
Metadata-protocol: none

The Studio top bar's page controls move to the open page's own title row, as the first step of removing the bar. They work exactly as before; only their place changes.

- **Cancel and Save** end the item header's actions (an object, a flow, a permission set, any item page), after the page's own buttons. A page that saves with no item header ends its own title row with them. They are drawn only while the page holds unsaved edits, as before.
- **The AI assistant** (or, with no assistant served, the right panel's show / hide button) ends every page's title row, the list page's and the item header's, behind a hairline, as the app's page header ends with its button group. `⌘.` still switches the right panel.
- Only the page's own title row draws them, so a page never shows two Saves. Outside Studio (Setup's metadata pages) nothing changes.
- **Studio draws in its own graphite everywhere**, never the app's theme colour: buttons, links, hovers and focus rings on every Studio page, and also the dialogs, menus, popovers, sheets, tooltips, toasts and command palette that Studio opens. Leaving Studio gives the app's pages their own colour back.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
import { useMetadataAreaHost } from './metadataAreaHost.js';
import { t, tFormat, translateMetadataType, useMetadataLocale } from './i18n.js';
import { diagnosticsHeaderTone, type DiagnosticsHeaderTone } from './diagnostics-tone.js';
import { StudioTitleRowEnd } from '../studio-design/studioTitleRow.js';

type Severity = 'error' | 'warning';

Expand Down Expand Up @@ -173,6 +174,8 @@ export function MetadataDiagnosticsPage() {
<RefreshCw className="h-3.5 w-3.5 mr-1" />
{t('engine.diagnostics.refresh', locale)}
</Button>
{/* objectstack#37455 — under Studio, the page's Save and the AI assistant end the title row. */}
<StudioTitleRowEnd />
</div>
<p className="text-sm text-muted-foreground mt-2 max-w-3xl">
{t('engine.diagnostics.description', locale)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { ENVIRONMENT_SCOPE_QUERY } from './catalog-scope.js';
import { usePackageCustomizations } from '../studio-design/CustomizationMark.js';
import { customizationCountsByType, customizationTotal } from '../studio-design/customizationMarks.js';
import { STUDIO_MENU_GROUPS } from '../studio-design/studioMenuModel.js';
import { StudioTitleRowEnd } from '../studio-design/studioTitleRow.js';

/**
* objectstack#37360 — on a package under Studio's area, the types this page
Expand Down Expand Up @@ -280,7 +281,13 @@ export function MetadataDirectoryPage() {
<div className="flex flex-col h-full overflow-hidden">
{/* Header */}
<div className="px-6 pt-5 pb-4 border-b bg-background">
<h1 className="text-xl font-semibold">{t('engine.directory.title', locale)}</h1>
{/* objectstack#37455 — under Studio, the page's Save and the AI assistant end the title row. */}
<div className="flex items-center gap-2">
<h1 className="text-xl font-semibold">{t('engine.directory.title', locale)}</h1>
<span className="ml-auto flex items-center gap-2">
<StudioTitleRowEnd divider={false} />
</span>
</div>
<p className="text-sm text-muted-foreground mt-1 max-w-3xl" data-testid="directory-description">
{t('engine.directory.description', locale)}
</p>
Expand Down
7 changes: 7 additions & 0 deletions ui/packages/app-shell/src/views/metadata-admin/PageShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { environmentScopeSuffix } from './catalog-scope.js';
import { useMetadataAreaHost } from './metadataAreaHost.js';
import { isStudioCustomizeType } from '../studio-design/StudioCustomizeControls.js';
import { AREA_CUSTOMIZE_EDITOR_TYPES, AREA_FORM_EDITOR_TYPES } from '../studio-design/metadataArea.js';
import { StudioTitleRowEnd } from '../studio-design/studioTitleRow.js';

export interface PageShellProps {
/** The type entry from `/meta/types` (or a synthesized stub). */
Expand Down Expand Up @@ -321,6 +322,10 @@ export function PageShell({
</div>
))}
{actions}
{/* objectstack#37455 — under Studio, the page's Save and the AI
assistant end the title row (nothing elsewhere, nor embedded
in another page). */}
{!embedded && <StudioTitleRowEnd />}
</div>
</div>
</div>
Expand Down Expand Up @@ -376,6 +381,8 @@ export function PageShell({
</div>
))}
{actions}
{/* objectstack#37455 — under Studio, the page's Save and the AI assistant end the title row. */}
{!embedded && <StudioTitleRowEnd />}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#37455 (decision 4 of epic objectstack#37424) — under a
* non-default app theme, nothing Studio draws takes the app's colour:
*
* - the surface's root carries Studio's accent (`STUDIO_ACCENT`), so every
* button, link and hover inside it reads graphite;
* - a surface Studio draws in a portal on `body` (here the command palette's
* dialog) sits under the same accent, which `body` carries while Studio is
* mounted;
* - the accent comes off `body` when Studio unmounts, and the app's own
* branding on the page root is left as the app wrote it.
*
* The app's theme is written by the app shell's own hook
* (`useAppShellBranding`, a rose primary and an amber accent), not by hand.
* jsdom computes no Tailwind, so the pins read the class scope a node sits in,
* as the menu's own graphite pin (`StudioMenu.test.tsx`) does.
*/

import '@testing-library/jest-dom/vitest';
import * as React from 'react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { useAppShellBranding } from '@object-ui/layout';

const PACKAGE_ID = 'com.acme.app';

vi.mock('sonner', () => ({
toast: { error: vi.fn(), success: vi.fn(), info: vi.fn(), warning: vi.fn(), dismiss: vi.fn() },
Toaster: () => null,
}));

const mockClient = {
save: vi.fn(async () => ({})),
list: vi.fn(async () => []),
listDrafts: vi.fn(async () => []),
listTypes: vi.fn(async () => ({ entries: [] })),
layered: vi.fn(async (_type: string, name: string) => ({ effective: { name } })),
getDraft: vi.fn(async () => null),
get: vi.fn(async () => undefined),
references: vi.fn(async () => []),
withPreviewDrafts() {
return this;
},
};

vi.mock('../metadata-admin/useMetadata', async (importOriginal) => {
const actual = await importOriginal<Record<string, unknown>>();
return {
...actual,
useMetadataClient: () => mockClient,
useMetadataTypes: () => ({ loading: false, error: null, entries: [] }),
};
});
vi.mock('@object-ui/react', async (importOriginal) => {
const actual = await importOriginal<Record<string, unknown>>();
return { ...actual, useAdapter: () => ({}) };
});
vi.mock('../../components/SuggestedBindingsPanel', () => ({ SuggestedBindingsPanel: () => null }));
vi.mock('../metadata-admin/AccessExplainPanel', () => ({ AccessExplainPanel: () => null }));
vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null }));
vi.mock('./StudioAiCopilot', () => ({
StudioChatDock: ({ onStatusChange }: { onStatusChange?: (s: { available: boolean; planPendingCount: number }) => void }) => {
React.useEffect(() => {
onStatusChange?.({ available: true, planPendingCount: 0 });
}, [onStatusChange]);
return <div data-testid="copilot-body">conversation</div>;
},
}));

// The source loads `@objectstack/lint` lazily; paid here, at collection, not
// inside a case's clock (check:test-source-alias).
import '@objectstack/lint';
// The surface mounts the command palette, which reaches the record preview's
// `lazy()` detail entry: its first load is paid at collection too.
import '@object-ui/plugin-detail';
import { StudioDesignSurface } from './StudioDesignSurface';
import { STUDIO_ACCENT, STUDIO_ACCENT_HSL } from './studio-tokens';
import { COMMAND_PALETTE_TESTID } from '../../context/CommandPaletteProvider';

const answer = (body: unknown) => ({ ok: true, status: 200, json: async () => body });
const ACCENT_CLASSES = STUDIO_ACCENT.split(/\s+/).filter(Boolean);
/** One of the accent's classes, as a selector for the scope a node sits in. */
const ACCENT_SCOPE = `[class~="${ACCENT_CLASSES[0]}"]`;
const BRAND_TOKENS = [
'--primary',
'--primary-foreground',
'--ring',
'--sidebar-primary',
'--sidebar-ring',
'--accent',
'--accent-foreground',
'--brand-primary',
'--brand-primary-hsl',
'--brand-accent',
'--brand-accent-hsl',
];

beforeEach(() => {
window.sessionStorage.clear();
vi.stubGlobal(
'fetch',
vi.fn(async (input: unknown) =>
String(input) === '/api/v1/packages'
? answer({ success: true, data: { packages: [{ manifest: { id: PACKAGE_ID, name: 'Acme' }, writable: true }] } })
: answer([]),
),
);
vi.stubGlobal('matchMedia', (query: string) => ({
matches: false,
media: query,
onchange: null,
addEventListener: () => {},
removeEventListener: () => {},
addListener: () => {},
removeListener: () => {},
dispatchEvent: () => false,
}));
});

afterEach(() => {
cleanup();
vi.unstubAllGlobals();
for (const token of BRAND_TOKENS) document.documentElement.style.removeProperty(token);
});

/** An app with a non-default theme, written on the page root by the app shell's own hook. */
function BrandedApp({ studio }: { studio: boolean }): React.ReactElement {
useAppShellBranding({ primaryColor: '#e11d48', accentColor: '#f59e0b' });
return (
<MemoryRouter initialEntries={[`/studio/${PACKAGE_ID}/owd?palette=1`]}>
<Routes>
<Route path="/studio/:packageId/:tab" element={studio ? <StudioDesignSurface /> : <p data-testid="app-page">app</p>} />
</Routes>
</MemoryRouter>
);
}

/** The accent scope's every class is on `el`. */
function carriesAccent(el: Element): boolean {
return ACCENT_CLASSES.every((cls) => el.classList.contains(cls));
}

describe('a non-default app theme does not tint Studio (objectstack#37455)', () => {
it('CONTROL: the app\'s colour is on the page root, and it is not graphite', async () => {
render(<BrandedApp studio />);
await screen.findByTestId('studio-shell-header');
const root = document.documentElement.style;
expect(root.getPropertyValue('--primary').trim()).not.toBe('');
expect(root.getPropertyValue('--accent').trim()).not.toBe('');
expect(root.getPropertyValue('--primary').trim()).not.toBe(STUDIO_ACCENT_HSL.light);
});

it('the surface\'s root carries Studio\'s accent: its header, the page and its buttons sit under it', async () => {
render(<BrandedApp studio />);
const header = await screen.findByTestId('studio-shell-header');
const scope = header.closest(ACCENT_SCOPE);
expect(scope).not.toBeNull();
expect(scope).not.toBe(document.body);
expect(carriesAccent(scope as Element)).toBe(true);
expect(scope).toContainElement(screen.getByTestId('studio-pillars-host'));
expect(scope).toContainElement(await screen.findByTestId('topbar-ai-assistant'));
});

it('a portalled surface (the command palette) is outside the root and still under the accent, on body', async () => {
render(<BrandedApp studio />);
const header = await screen.findByTestId('studio-shell-header');
const palette = await waitFor(() => {
const el = document.querySelector(`[data-testid="${COMMAND_PALETTE_TESTID}"]`);
expect(el).not.toBeNull();
return el as HTMLElement;
});
const studioRoot = header.closest(ACCENT_SCOPE) as Element;
expect(studioRoot.contains(palette)).toBe(false);
expect(palette.closest(ACCENT_SCOPE)).toBe(document.body);
expect(carriesAccent(document.body)).toBe(true);
});

it('Studio unmounted: the accent leaves body, and the app\'s branding on the page root is as the app wrote it', async () => {
const { rerender } = render(<BrandedApp studio />);
await screen.findByTestId('studio-shell-header');
const primary = document.documentElement.style.getPropertyValue('--primary');
expect(carriesAccent(document.body)).toBe(true);

rerender(<BrandedApp studio={false} />);
await screen.findByTestId('app-page');
for (const cls of ACCENT_CLASSES) expect(document.body).not.toHaveClass(cls);
expect(document.body).not.toHaveAttribute('data-studio-accent');
expect(document.documentElement.style.getPropertyValue('--primary')).toBe(primary);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* - Selecting a canvas element switches it to that element's properties, the
* copilot folded to a strip at the slot's foot; Esc, or a click on empty
* canvas, returns to the item's own properties.
* - `⌘.` / `Ctrl+.` switches the two; the top bar's right-most icon hides the
* slot, remembered under the Studio key, never the console's.
* - `⌘.` / `Ctrl+.` switches the two; the right-most icon of the page's title
* row (the top bar's, before objectstack#37455) hides the slot, remembered
* under the Studio key, never the console's.
* - The canvas has no 画布 / 源码 / 属性 tabs: one status line, and the item's
* definition opens from its ⋯ menu.
* - The pillar names are visible from 1024 px (`lg`), icons below.
Expand Down Expand Up @@ -194,6 +195,42 @@ describe('Studio right slot — controls (objectui#12725)', () => {

});

// objectstack#37455 — the slot's control left the top bar for the end of the
// open page's title row: the item header's, and the list page's.
describe('Studio right slot — its control ends the page\'s title row (objectstack#37455)', () => {
it('the sharing overview: the AI assistant ends its item header behind a hairline, not the top bar, and hides and shows the slot', async () => {
renderAt('owd');
await waitFor(() => expect(slot()).toHaveAttribute('data-mode', 'copilot'));
const itemHeader = screen.getByTestId('owd-item-header');
const ai = await within(itemHeader).findByTestId('topbar-ai-assistant');
expect(within(screen.getByTestId('studio-shell-header')).queryByTestId('topbar-ai-assistant')).toBeNull();
expect(screen.getAllByTestId('topbar-ai-assistant')).toHaveLength(1);
// The last control of the header's action slot, the hairline right before it.
const actionSlot = ai.parentElement as HTMLElement;
expect(actionSlot.lastElementChild).toBe(ai);
expect(ai.previousElementSibling).toHaveAttribute('data-testid', 'studio-title-row-divider');
expect(within(actionSlot).getByTestId('access-explain')).toBeInTheDocument();

expect(slot()).toBeVisible();
expect(ai).toHaveAttribute('aria-pressed', 'true');
fireEvent.click(ai);
expect(slot()).not.toBeVisible();
expect(within(itemHeader).getByTestId('topbar-ai-assistant')).toHaveAttribute('aria-pressed', 'false');
fireEvent.click(within(itemHeader).getByTestId('topbar-ai-assistant'));
expect(slot()).toBeVisible();
expect(slot()).toHaveAttribute('data-mode', 'copilot');
});

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 });
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();
expect(screen.getAllByTestId('topbar-ai-assistant')).toHaveLength(1);
});
});

// objectstack#35061 item 1 — the pillars' host is what every rail's narrow form
// measures, and it says whether the slot squeezes it.
describe('Studio right slot — the rails read whether it squeezes the pillars (objectstack#35061)', () => {
Expand Down
Loading
Loading