Skip to content

Commit a9e7bb7

Browse files
committed
fix(studio): rework round on the object designer's address
The L1 review's M1 and S2-S8 with the nits: - the unsaved-edit guard (saveBar.dirty) is pinned on the designer's x and next, on the real surface; - a Changes-sheet object request opens in the package holding the draft (draftScope); - the history address and ?tab= open their tabs, the partly refused discard keeps its message, and the copilot reads the item off the designer's address, each pinned; - the zone's designer-page helper (AREA_DESIGNER_PAGE_TYPES, areaItemOpensDesignerPage, areaDesignerItemOf) replaces the object-only helpers; - an address naming no object says it was not found (found on the browser walk); - README, changeset and stale comments in user terms; two dropped controls carried over. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSeKYoFqGdRM9Qmg7M2o2B
1 parent efd179c commit a9e7bb7

20 files changed

Lines changed: 435 additions & 82 deletions

‎.changeset/36904-object-designer-fullscreen.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
'@object-ui/app-shell': patch
33
---
44

5-
feat(studio): the object designer opens full-screen on the object's metadata address
5+
feat(studio): an object opens its designer full-screen, on its own address
66

77
Clause-②: no
88
Metadata-protocol: none
99

1010
Studio redesign (epic #36890), the object designer's card (#36904); it also delivers #36513's tab order.
1111

12-
- **One object, one address.** An object opens its designer full-screen at `/studio/<package>/metadata/object/<name>`, under the item header every Studio item page uses: × back to the object list (its filter and sort kept), ‹ › through the list, Esc to close. The designer has no object list of its own and no 「新建」: the object list is the area's, and its 「新建」 creates an object (organization-wide default, the app-menu join, a read-only base's `.custom` pair).
13-
- **Tabs in #36513's order.** Records, Field layout, Validations, Actions, Settings, Hooks, API; on a narrower column Hooks and API fold into "Advanced" first, then the other three. The item tools are tabs after them (References, History with the audit log, Source with the layered comparison), in place of the header's five icons. The open tab is in the address (`?tab=`), so a refresh, a shared link and ‹ › keep it.
14-
- **The old addresses redirect.** `/studio/<package>/data?surface=object:<name>` opens that object's designer (`?action=` kept, `?view=` and `?nav=` dropped); `/studio/<package>/data` with no object, Studio's old home, opens the package's object list, `?changes=review` kept. The app's 「对象设置」, the record page's 「配置页面」, ⌘K, the AI artifact link and the switched-off action link open the new address; a switched-off action is `?action=<name>` on it.
15-
- **Fixed on the way:** an AI-drafts discard that the server partly refused now keeps its message on the page; the object re-read the discard triggers used to clear it at once.
12+
- **One object, one page.** Opening an object in Studio opens its designer full-screen beside the left menu, with its own address you can bookmark or share. × goes back to the object list with its filter and sort as you left them, ‹ › open the previous and next object in that list, and Esc closes. The designer no longer has its own column of objects or its own 「新建」 button: you pick another object from the list, and you create one with the object list's 「新建」, which keeps the organization-wide default sharing choice, the option to add the object to the app's menu, and, on a read-only package, the save into its customization package.
13+
- **Tabs in a fixed order.** Records, Field layout, Validations, Actions, Settings, Hooks, API; when the page is narrow, Hooks and API fold into "Advanced" first, then Validations, Actions and Settings. References, History (with the audit log) and Source (with the layer comparison) are now tabs after them, in place of the five header icons. The tab you are on is part of the page's address, so refreshing, sharing the link or moving to the next object keeps it.
14+
- **Old links still work.** A bookmark or link to an object in Studio's old Data screen opens that object's designer; a link to the Data screen itself opens the package's object list, and the review link for unpublished changes still opens that review. The app's 「对象设置」, the record page's 「配置页面」, the command palette, links in AI replies and the link to a switched-off action all open the new page.
15+
- **Fixed on the way:** when discarding the AI's unpublished changes partly fails, the message saying which items could not be discarded now stays on the page instead of disappearing at once. A link to an object that does not exist (a deleted object's bookmark, a mistyped link) now says the object was not found, instead of offering it as a new object to design.

‎ui/packages/app-shell/README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,12 @@ dashboard, page, or report — it opens that item's page in Studio's "All
635635
metadata" area (`/studio/:packageId/metadata/<type>/<name>`), where it is read
636636
and edited as metadata; interfaces themselves are designed in the running app,
637637
since objectstack#36502 retired Studio's Interfaces pillar. On an object route
638-
it opens that object in the Data pillar
639-
(`/studio/:packageId/data?surface=object:<name>`), and at the app root the
640-
package's Data tab (`/studio/:packageId/data`). An old
641-
`/studio/:packageId/interfaces` link lands on the Data tab with a one-line
638+
it opens that object's designer full-screen on its own address
639+
(`/studio/:packageId/metadata/object/<name>`, objectstack#36904), and at the
640+
app root the package's Studio home, which lands on the package's object list
641+
(`/studio/:packageId/metadata/object`; the retired Data pillar's
642+
`/studio/:packageId/data` redirects there). An old
643+
`/studio/:packageId/interfaces` link lands on the object list with a one-line
642644
notice that interface editing moved into the app.
643645
The route-type → surface-type decision lives in `appStudioRoutePath`. It is the
644646
reverse of the builder's "Open app" bridge (ADR-0080): the entry only renders

‎ui/packages/app-shell/src/layout/SidebarItemMenu.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ import { confirmUnsavedLeave } from '../chrome/unsavedEdits.js';
5555

5656
/**
5757
* Where Object settings takes an object of `app` (objectstack#36487): the
58-
* object in Studio's Data surface (`surface=object:NAME`), through the
58+
* object's designer in Studio, full-screen on its own address
59+
* (`/studio/PKG/metadata/object/NAME`, objectstack#36904), through the
5960
* derivation the app bar's Studio entry reads on the object's list,
6061
* `appStudioObjectPath` (objectui#12520). `null` when the app has no owning
6162
* package Studio can open, or names no object, so the entry hides as the app

‎ui/packages/app-shell/src/views/metadata-admin/MetadataListCreateDialog.pairCreate-36897.test.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ vi.mock('../studio-design/packages-io.js', async (importOriginal) => ({
4444
fetchPackages: async () => [
4545
{ id: 'com.vendor.hr', namespace: 'hr' },
4646
{ id: 'com.example.crm', namespace: 'crm' },
47+
{ id: 'com.example.bare', namespace: null },
4748
],
4849
}));
4950
const publish = vi.fn(async () => ({ ok: true }));
@@ -164,6 +165,17 @@ describe('list 「新建」 for an object: the create the object designer no lon
164165
expect(save.mock.calls[0]?.[1]).toBe('crm_repair_ticket');
165166
});
166167

168+
// CONTROL: a package that declares no namespace previews, and saves, the bare identifier.
169+
it('previews the bare identifier when the package has no namespace, and saves exactly that', async () => {
170+
const onCreated = open('object', 'com.example.bare', false);
171+
fireEvent.change(screen.getByLabelText(t('engine.studio.data.nameLabel', L)), { target: { value: 'Repair Ticket' } });
172+
await waitFor(() => expect(screen.getByTestId('create-item-stored-name')).toHaveTextContent('repair_ticket'));
173+
expect(screen.getByTestId('create-item-stored-name').textContent).not.toMatch(/_repair_ticket/);
174+
fireEvent.click(screen.getByRole('button', { name: t('engine.studio.createLive', L) }));
175+
await waitFor(() => expect(onCreated).toHaveBeenCalledWith({ name: 'repair_ticket', packageId: 'com.example.bare' }));
176+
expect(save.mock.calls[0]?.[1]).toBe('repair_ticket');
177+
});
178+
167179
it('a taken identifier is refused and nothing is written (objectstack#26917)', async () => {
168180
taken.mockResolvedValueOnce({ name: 'crm_visit', label: 'Visit' });
169181
const onCreated = open('object', 'com.example.crm', false);

‎ui/packages/app-shell/src/views/studio-design/DataPillar.copilotChangesLine-34725.test.tsx‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import '@testing-library/jest-dom/vitest';
2222
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
23-
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
23+
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
2424
import { MemoryRouter } from 'react-router-dom';
2525

2626
const objectDef = {
@@ -172,8 +172,17 @@ describe('the AI assistant’s drafts on the Data canvas (objectstack#34725)', (
172172
const original = window.confirm;
173173
window.confirm = vi.fn(() => true);
174174
renderPillar();
175-
fireEvent.click(await screen.findByTestId('studio-copilot-changes-discard'));
176-
const message = await screen.findByTestId('studio-refusal-message');
175+
const discard = await screen.findByTestId('studio-copilot-changes-discard');
176+
const reads = mockClient.getDraft.mock.calls.length;
177+
fireEvent.click(discard);
178+
// objectstack#36904 — the discard re-reads the object, and a load clears the
179+
// pillar's error as it starts: the refusal must outlive that read, not
180+
// flash for one render before it.
181+
await waitFor(() => expect(mockClient.getDraft.mock.calls.length).toBeGreaterThan(reads));
182+
await act(async () => {
183+
await new Promise((r) => setTimeout(r, 200));
184+
});
185+
const message = screen.getByTestId('studio-refusal-message');
177186
expect(message).toHaveTextContent(
178187
tFormat('engine.studio.copilotChanges.discardFailed', 'en-US', {
179188
items: ['Task', 'showcase_task_grid'].join(L('engine.studio.copilotChanges.itemSeparator')),

‎ui/packages/app-shell/src/views/studio-design/DataPillar.draftOnlyNoLayers-12508.test.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import '@object-ui/plugin-detail';
101101
import { DataPillar } from './StudioDesignSurface';
102102
import { createEmptyDataSource } from './__tests__/emptyDataSource';
103103
import { registerBuiltinInspectors } from '../metadata-admin/inspectors';
104+
import { t } from '../metadata-admin/i18n';
104105

105106
const dataSource = createEmptyDataSource();
106107
registerBuiltinInspectors();
@@ -144,10 +145,24 @@ describe('DataPillar — a draft-only object logs no failed read (objectui#12508
144145
expect(server.requests.filter((r) => r.status >= 400)).toEqual([]);
145146
// objectstack#36904 — the header reads the label the draft declares, not the name.
146147
expect((await screen.findAllByTestId('studio-detail-title'))[0]).toHaveTextContent('Ticket');
148+
expect(screen.queryByTestId('data-object-not-found')).toBeNull();
147149
fireEvent.click(await screen.findByRole('button', { name: 'Field layout' }));
148150
expect(await screen.findByText('Subject')).toBeInTheDocument();
149151
});
150152

153+
// CONTROL (objectui#11843): a draft-only object that declares no label is titled by its name.
154+
it('CONTROL: a draft-only object with no label is titled by its name', async () => {
155+
const { label: _label, ...unlabelled } = ticket;
156+
server.drafts.set('st_ticket', unlabelled);
157+
server.draftHeaders = ['st_ticket'];
158+
await openPillar('st_ticket');
159+
160+
expect(reads('st_ticket', '')).toEqual([200]);
161+
const title = (await screen.findAllByTestId('studio-detail-title'))[0];
162+
expect(title).toHaveTextContent('st_ticket');
163+
expect(title).not.toHaveTextContent('Ticket');
164+
});
165+
151166
it('CONTROL: a name the drafts list holds but whose draft is no longer served still reads its /layers', async () => {
152167
server.draftHeaders = ['st_ticket'];
153168
await openPillar('st_ticket');
@@ -156,6 +171,17 @@ describe('DataPillar — a draft-only object logs no failed read (objectui#12508
156171
expect(reads('st_ticket', '/layers')).toEqual([404]);
157172
});
158173

174+
// objectstack#36904 — the address can name an object that is not there.
175+
it('an address naming no object, published or drafted, says it was not found', async () => {
176+
server.published = [kase];
177+
await openPillar('st_gone');
178+
179+
expect(reads('st_gone', '/layers')).toEqual([404]);
180+
expect(await screen.findByTestId('data-object-not-found')).toHaveTextContent('st_gone');
181+
// Not offered as a new object to design.
182+
expect(screen.queryByText(t('engine.studio.data.draftObjectTitle', 'en'))).toBeNull();
183+
});
184+
159185
it('CONTROL: a published object still reads its layers', async () => {
160186
server.published = [kase];
161187
await openPillar('st_case');

‎ui/packages/app-shell/src/views/studio-design/DataPillar.flatTabs-12450.test.tsx‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ vi.mock('@object-ui/plugin-view', async (importOriginal) => {
6464

6565
vi.mock('./ObjectValidationsPanel', () => ({ ObjectValidationsPanel: () => <div data-testid="rules-panel" /> }));
6666
vi.mock('./ObjectSettingsPanel', () => ({ ObjectSettingsPanel: () => <div data-testid="settings-panel" /> }));
67+
vi.mock('./ObjectHooksPanel', () => ({ ObjectHooksPanel: () => <div data-testid="hooks-panel" /> }));
6768

6869
import { DataPillar } from './StudioDesignSurface';
6970
import { SurfaceDeepLinkProvider } from './surfaceDeepLinkChannel';
@@ -98,16 +99,17 @@ function Where() {
9899
}
99100
const tabInAddress = () => new URLSearchParams(screen.getByTestId('where').textContent ?? '').get('tab');
100101

101-
async function renderPillar(props: { readOnly?: boolean } = {}) {
102+
async function renderPillar(props: { readOnly?: boolean; query?: string } = {}) {
102103
render(
103-
<MemoryRouter initialEntries={['/studio/com.example.showcase/metadata/object/showcase_account']}>
104+
<MemoryRouter initialEntries={[`/studio/com.example.showcase/metadata/object/showcase_account${props.query ?? ''}`]}>
104105
<SurfaceDeepLinkProvider>
105106
<DataPillar packageId="com.example.showcase" objectName="showcase_account" readOnly={props.readOnly} />
106107
<Where />
107108
</SurfaceDeepLinkProvider>
108109
</MemoryRouter>,
109110
);
110-
await waitFor(() => expect(screen.getByTestId('records-panel')).toBeInTheDocument(), { timeout: 8000 });
111+
if (props.query) await waitFor(() => expect(screen.getByTestId('data-object-header')).toBeInTheDocument(), { timeout: 8000 });
112+
else await waitFor(() => expect(screen.getByTestId('records-panel')).toBeInTheDocument(), { timeout: 8000 });
111113
}
112114

113115
/** The header's tab row: the `nav` the item header draws its tabs into. */
@@ -201,3 +203,33 @@ describe('the object designer’s tab row (objectui#12450, objectstack#36904)',
201203
await waitFor(() => expect(tabInAddress()).toBe('settings'));
202204
});
203205
});
206+
207+
/*
208+
* objectstack#36904 — the address opens the tab it names: a link to the
209+
* designer (and ‹ ›, which carries it) lands on that tab, not on Records.
210+
*/
211+
describe('the object designer opens on the tab its address names (objectstack#36904)', () => {
212+
it('`?tab=hooks` opens Hooks, its flat tab and the folded trigger pressed', async () => {
213+
await renderPillar({ query: '?tab=hooks' });
214+
await waitFor(() => expect(screen.getByTestId('hooks-panel')).toBeInTheDocument(), { timeout: 8000 });
215+
expect(screen.queryByTestId('records-panel')).toBeNull();
216+
expect(screen.getByTestId('data-tab-flat-hooks')).toHaveAttribute('aria-pressed', 'true');
217+
expect(screen.getByTestId('data-tabs-advanced-first')).toHaveAttribute('aria-pressed', 'true');
218+
expect(tabInAddress()).toBe('hooks');
219+
});
220+
221+
it('`?tab=history` opens the History tool tab', async () => {
222+
await renderPillar({ query: '?tab=history' });
223+
await waitFor(() => expect(screen.getByTestId('item-tab-panel-history')).toBeInTheDocument(), { timeout: 8000 });
224+
expect(screen.queryByTestId('records-panel')).toBeNull();
225+
expect(within(tabRow()).getByTestId('item-tab-history')).toHaveAttribute('aria-pressed', 'true');
226+
expect(tabInAddress()).toBe('history');
227+
});
228+
229+
// CONTROL: a value that names no tab opens Records.
230+
it('`?tab=nonsense` opens Records', async () => {
231+
await renderPillar({ query: '?tab=nonsense' });
232+
await waitFor(() => expect(screen.getByTestId('records-panel')).toBeInTheDocument(), { timeout: 8000 });
233+
expect(screen.queryByTestId('hooks-panel')).toBeNull();
234+
});
235+
});

‎ui/packages/app-shell/src/views/studio-design/DataPillar.tsx‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ export function DataPillar({
327327
return idx;
328328
}, [metaTypes]);
329329
// objectstack#36904 — the object is the address's: its label, icon and
330-
// colour are the loaded object's (the label the app shows, a draft-only
331-
// object's own), its machine name until it has loaded.
330+
// colour are the loaded object's as it is being edited (its draft when it
331+
// has one, a draft-only object's included, else as served; set where the
332+
// object loads), its machine name until it has loaded.
332333
const [served, setServed] = React.useState<{ label?: string; icon?: string; color?: string }>({});
333334
const current = React.useMemo<Surface>(
334335
() => ({ type: 'object', name: objectName, label: served.label || objectName, icon: served.icon, color: served.color }),
@@ -836,8 +837,9 @@ export function DataPillar({
836837
setObjVerdict(editedItemDiagnostics({ hasDraft: !!draftBody, draftDiagnostics: draftVerdict, layered: lay }));
837838
setObjVerdictBody(draftBody && draftVerdict ? draftBody : lay.effective);
838839
setObjDraftFor(`object:${current.name}`);
839-
// objectstack#36904 — the header's label, icon and colour: the object
840-
// as served, a draft-only object's draft (its own label, objectui#11843).
840+
// objectstack#36904 — the header's label, icon and colour: the draft
841+
// when there is one (a draft-only object's own label, objectui#11843),
842+
// else the object as served.
841843
const shown = (draftBody ?? baseline) as { label?: I18nLabel; icon?: unknown; color?: unknown };
842844
const next = {
843845
label: resolveI18nLabel(shown.label, locale)?.trim() || undefined,
@@ -1263,6 +1265,11 @@ export function DataPillar({
12631265

12641266
// objectui#11272 — the buffer is the open object's own once its load installed it.
12651267
const objLoaded = current !== null && objDraftFor === `object:${current.name}`;
1268+
// objectstack#36904 — the address names the object, so it can name one that
1269+
// is not there (a deleted object's bookmark, a mistyped link): loaded with
1270+
// neither a stored object nor a draft, it says so rather than offering an
1271+
// "unpublished new object" to design. A draft-only object has its draft.
1272+
const objMissing = objLoaded && !hasBaseline && !hasDraft;
12661273

12671274
// objectstack#28575 — the ensure door's answer for this base's extension
12681275
// writes: asked by the first add (no prompt), once per base, and again only
@@ -2208,6 +2215,15 @@ export function DataPillar({
22082215
<Loader2 className="h-4 w-4 animate-spin" /> {t('engine.studio.loading', locale)}
22092216
</div>
22102217
)
2218+
) : objMissing ? (
2219+
<div
2220+
role="status"
2221+
data-testid="data-object-not-found"
2222+
className={cn('flex flex-col items-center justify-center gap-1 py-16 text-sm text-muted-foreground', bodyFlush && 'mx-6')}
2223+
>
2224+
<span className="font-medium text-foreground">{t('engine.form.objectNotFound', locale)}</span>
2225+
<span className="font-mono text-xs">{current.name}</span>
2226+
</div>
22112227
) : viewMode === 'rules' ? (
22122228
<DraftVerdictContext.Provider value={objVerdict}>
22132229
<DraftVerdictBodyContext.Provider value={objVerdictBody}>

0 commit comments

Comments
 (0)