diff --git a/.changeset/36150-authored-record-page-desktop-only.md b/.changeset/36150-authored-record-page-desktop-only.md new file mode 100644 index 00000000000..8630b860036 --- /dev/null +++ b/.changeset/36150-authored-record-page-desktop-only.md @@ -0,0 +1,17 @@ +--- +'@object-ui/app-shell': minor +--- + +feat(app-shell): an authored record page is drawn on the desktop full page only; a phone and the side drawer draw the standard page + +Clause-②: no +Metadata-protocol: semantic +Skills-docs: follow-up #36179 — skills/objectstack-ui/rules/record-page.md rules 4 and 5 (the `record_more` advice); skills edits ride a domain:skills PR + +What a `kind: 'full'` record page means changes: it is drawn on the desktop full page only. On a phone, and in every embedded record view (the side drawer a list opens, the split pane, an interface page's preview), the record draws the platform's standard page for its object, whether or not the object has an authored page. **Open full page** from the drawer still lands on the authored page. + +The standard page keeps what the object declares: field groups and order, field permissions and visibility, the `record_header` / `record_more` actions, one tab per child table, the stage and the approval state. The authored page's layout does not apply there, nor anything that lives only on it: its tabs and sections, page-only related lists and blocks, banners, and `record_section` actions, which the standard page does not draw. To keep such an action reachable on a phone and in the drawer, add `record_more` to its `locations` (and leave it out of the authored header's `actions` list, so the full page still draws it once). There is no setting that keeps an authored page on the phone or in the drawer. + +Unchanged: a slotted page (the standard page with slots filled) applies everywhere; a page named in the URL (`…/record/:id/page/:pageName`, print pages included) is drawn wherever that route renders; the platform's approval request (`sys_approval_request`) and user (`sys_user`) pages keep their own page on every surface. + +Nothing to migrate: no metadata key changes, and the desktop full page draws exactly as before. diff --git a/content/docs/ui/pages.mdx b/content/docs/ui/pages.mdx index 6036db13b74..0ebf271eb8b 100644 --- a/content/docs/ui/pages.mdx +++ b/content/docs/ui/pages.mdx @@ -258,6 +258,28 @@ const accountDetailPage = { Use a slotted page to change one or two parts of an otherwise standard record page, and a `full` page for a record page that looks nothing like the default. +### Where an authored page applies + +A `kind: 'full'` record page is drawn on the **desktop full page** only. On a phone (any window +narrower than 768 px, a narrowed desktop window included), and in every embedded record view (the +side drawer or split pane a list opens a record in, and an interface page's preview), the record +takes the platform's standard page for its object, whether or not the object has an authored page; **Open full page** from the +drawer lands on the authored one. There is no setting that keeps an authored page on the phone +or in the drawer. + +What carries over is what the object declares: its field groups and their order, field +permissions and visibility, the actions placed at `record_header` and `record_more`, one tab per +child table, the stage and the approval state. What does not is the page's own layout and +anything that lives only on it: its tabs and sections, a related list or block placed only on +the page, a banner, and `record_section` actions, which the standard page does not draw. To keep +such an action reachable off the full page, add `record_more` to its `locations`, and leave it +out of the page header's `actions` list so the full page still draws it once. + +A slotted page is the standard page with its slots filled, so its slots apply on every surface. +A page named in the URL (`…/record/:id/page/:pageName`, print pages and other named routes) is +drawn wherever that route renders. The platform's approval request and user pages keep their +own page on every surface. + ### The discussion panel is composed, never appended A record page shows a discussion panel if and only if the page composes a diff --git a/examples/app-showcase/src/ui/actions/index.ts b/examples/app-showcase/src/ui/actions/index.ts index 93616549da8..60343794403 100644 --- a/examples/app-showcase/src/ui/actions/index.ts +++ b/examples/app-showcase/src/ui/actions/index.ts @@ -189,11 +189,15 @@ export const RecalcEstimateAction = defineAction({ execution: 'perRecord', // Names the task (see MarkDoneAction's note on the hole and its fallback). successMessage: "Estimate recalculated for {{ record.title | default:'the task' }}.", - // `record_section` only: the Task Detail page's `record:quick_actions` bar - // names it, and the engine location-filters even explicitly-named actions. - // Not `record_more` too, so the page draws it once, in that bar, and not - // again under the header's ⋯ overflow. - locations: ['record_section'], + // `record_section`: the Task Detail page's `record:quick_actions` bar names + // it, and the engine location-filters even explicitly-named actions. And + // `record_more` (objectstack#36150): the authored page is drawn on the + // desktop full page only, and on a phone or in the side drawer the task + // takes the standard page, which draws no `record_section` action — the + // ⋯ overflow is where the action is found there. The authored header lists + // its action ids and leaves this one out, so the full page still draws it + // once, in the bar. + locations: ['record_section', 'record_more'], // The endpoint is record-scoped and rejects a body without an id. On a // record surface the page supplies it; invoked from a LIST ROW (see the // `legacy_row_actions` view) nothing else can, so name the body key the diff --git a/examples/app-showcase/src/ui/pages/task-detail.page.ts b/examples/app-showcase/src/ui/pages/task-detail.page.ts index d5a78c16663..6745057b7f5 100644 --- a/examples/app-showcase/src/ui/pages/task-detail.page.ts +++ b/examples/app-showcase/src/ui/pages/task-detail.page.ts @@ -19,7 +19,9 @@ import { definePage } from '@objectstack/spec/ui'; * • `record:highlights` + `record:details` — the standard compact + section * layout. * `kind: 'full'` — this page fully owns the record layout, as the Project - * page does for its own tab strip. + * page does for its own tab strip. It is drawn on the desktop full page only + * (objectstack#36150): on a phone and in the side drawer a task opens on the + * standard page, without the review banner or the section bar. */ export const TaskDetailPage = definePage({ name: 'showcase_task_detail', @@ -47,8 +49,11 @@ export const TaskDetailPage = definePage({ // `record_header` actions render as inline buttons, and an action // declaring `record_more` without `record_header` always goes under // the ⋯ overflow. The list is the object's whole `record_header` / - // `record_more` set, which is what the synthesized header would carry; - // `test/record-action-location-hosts.test.ts` holds the two equal. + // `record_more` set, which is what the synthesized header would carry, + // less the actions the section bar below draws (they declare + // `record_more` only for the standard page a phone or the side drawer + // shows, objectstack#36150); `test/record-action-location-hosts.test.ts` + // holds the two equal. // The host still appends its own Edit / Share / Delete after these. // No `title`: the header derives it from the record. { diff --git a/examples/app-showcase/test/record-action-location-hosts.test.ts b/examples/app-showcase/test/record-action-location-hosts.test.ts index 0afd9999938..3c27e000983 100644 --- a/examples/app-showcase/test/record-action-location-hosts.test.ts +++ b/examples/app-showcase/test/record-action-location-hosts.test.ts @@ -102,11 +102,16 @@ describe('showcase_task record action locations have a stock host (#22030)', () expect(result.data?.actions).toEqual(ids); }); - it('lists the task\'s whole record_header / record_more set — what the synthesized header carries', () => { + it('lists the task\'s whole record_header / record_more set — what the synthesized header carries — less the actions its section bar draws', () => { expect(ids.every((id) => typeof id === 'string')).toBe(true); expect(new Set(ids).size, 'no id is listed twice').toBe(ids.length); + // An action placed at record_section AND record_more is drawn on this + // page by the quick-actions bar; `record_more` is its place on the + // standard page a phone or the drawer draws (objectstack#36150), so the + // authored header leaves it out (see the record_section block below). const headerSet = taskActions .filter((a) => declares('record_header')(a) || declares('record_more')(a)) + .filter((a) => !declares('record_section')(a)) .map((a) => a.name as string); expect([...ids].sort()).toEqual([...headerSet].sort()); }); @@ -183,13 +188,22 @@ describe('showcase_task record action locations have a stock host (#22030)', () expect(names.length).toBeGreaterThan(0); expect(headerIds.length).toBeGreaterThan(0); expect(names.filter((n) => headerIds.includes(n))).toEqual([]); - // And by declaration: no task action is placed both in the header's - // locations and in the bar's, so a synthesized page cannot double it either. - const doubled = taskActions + // By declaration: no task action is placed both in the bar's location and + // INLINE in a header, so neither page draws one twice in view. + const inlineToo = taskActions .filter(declares('record_section')) - .filter((a) => declares('record_header')(a) || declares('record_more')(a)) + .filter(declares('record_header')) .map((a) => a.name); - expect(doubled).toEqual([]); + expect(inlineToo).toEqual([]); + }); + + it('reaches every record_section action on the standard page too, under the ⋯ overflow (objectstack#36150)', () => { + // A phone and the side drawer draw the standard page, which has no + // section bar: an action the bar hosts is found there through its + // `record_more` location, which the synthesized header reads. + const sectionSet = taskActions.filter(declares('record_section')); + expect(sectionSet.length).toBeGreaterThan(0); + expect(sectionSet.filter((a) => !declares('record_more')(a)).map((a) => a.name)).toEqual([]); }); }); diff --git a/ui/packages/app-shell/src/console/AppContent.tsx b/ui/packages/app-shell/src/console/AppContent.tsx index f8b4f11560a..22765994fb6 100644 --- a/ui/packages/app-shell/src/console/AppContent.tsx +++ b/ui/packages/app-shell/src/console/AppContent.tsx @@ -486,7 +486,11 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps = // app whose served item carries its package; the whole registry everywhere // else, as before (that module says why). A page route reads the objects // its page binds (objectui#12980), resolved as `PageView` resolves the page, - // and a record route those of its declared record page (objectui#13046). + // and a record route those of its declared record page (objectui#13046), + // on the desktop only: on a phone the view draws the standard page, whose + // related lists read every object that points at the record's + // (objectstack#36150), so the scope follows the width as the view does. + const phoneViewport = usePhoneViewport(); const { candidate: scopeCandidate, scope: objectScope, @@ -546,6 +550,7 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps = const appName = typeof activeApp?.name === 'string' ? activeApp.name : undefined; return bundledReads && appName ? bundledReads.objectsReferencing(appName, objectName) : BUNDLE_MISS; }, + phoneViewport, ); // Until the app list has loaded, a scope candidate does not know its package // yet, and reads nothing (the splash is up). diff --git a/ui/packages/app-shell/src/console/__tests__/AppContent.authoredPagePhoneScope-36150.test.tsx b/ui/packages/app-shell/src/console/__tests__/AppContent.authoredPagePhoneScope-36150.test.tsx new file mode 100644 index 00000000000..51f439ef565 --- /dev/null +++ b/ui/packages/app-shell/src/console/__tests__/AppContent.authoredPagePhoneScope-36150.test.tsx @@ -0,0 +1,310 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36150 — the record ROUTE's object scope follows the page the + * record view draws. An authored full record page is drawn on the desktop + * full page only; on a phone the view draws the standard page, whose child + * tabs are derived from every object that points at the record's object. So + * on a phone the route must not read only the objects the authored page binds + * (L2 M1 on #36174): it takes the synthesized page's arm, as the view does. + * + * Through the real `AppContent` and `MetadataProvider` (the harness of + * `AppContent.emptyPackageScope-13046.test.tsx`), the view a double that + * prints the object list it is handed: + * + * - desktop: the authored page's objects, as before (CONTROL); a child the + * page does not bind is not in the list. + * - phone: the whole registry, the unbound child included. + * - the width crossing 768 on an open record moves the scope with it. + * - a media-query change that leaves the window wide (what printing fires) + * keeps the authored page's scope (N4). + * - the host's exceptions on a phone: a page named in the URL, and the + * platform user page, still read their page's objects. + */ + +import '@testing-library/jest-dom/vitest'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import React from 'react'; +import { act, cleanup, render, screen, waitFor } from '@testing-library/react'; +import { MemoryRouter, Routes, Route } from 'react-router-dom'; +import { AuthProvider, ActiveOrganizationStorage } from '@object-ui/auth'; +import type { AuthClient, AuthOrganization } from '@object-ui/auth'; + +vi.mock('@object-ui/plugin-designer', async (importOriginal) => ({ + ...(await importOriginal()), + CreateAppPage: () => null, + EditAppPage: () => null, + DashboardDesignPage: () => null, +})); +// The chrome: what the sidebar's capability gate asks, as `ConsoleLayout` does. +vi.mock('../../layout/ConsoleLayout', async () => { + const { useNavMemberGates } = await import('../../hooks/useNavMemberGates'); + return { + ConsoleLayout: ({ children }: { children?: React.ReactNode }) => { + const gates = useNavMemberGates(); + return ( +
+ {String(gates.checkCapability('object', 'sys_member'))} + {children} +
+ ); + }, + }; +}); +vi.mock('../../chrome/CommandPalette', () => ({ CommandPalette: () => null })); +vi.mock('../../chrome/KeyboardShortcutsDialog', () => ({ KeyboardShortcutsDialog: () => null })); +vi.mock('../../chrome/OnboardingWalkthrough', () => ({ OnboardingWalkthrough: () => null })); +vi.mock('../../views/ObjectView', () => ({ + ObjectView: ({ objects }: { objects: Array<{ name: string }> }) => ( +
{objects.map((o) => o.name).join(',')}
+ ), +})); +vi.mock('../../views/RecordDetailView', () => ({ + RecordDetailView: ({ objects }: { objects: Array<{ name: string }> }) => ( +
{objects.map((o) => o.name).join(',')}
+ ), +})); +vi.mock('@object-ui/i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useObjectTranslation: () => ({ + t: (key: string, options?: Record) => String(options?.defaultValue ?? key), + }), + useObjectLabel: () => ({ objectLabel: ({ label }: { label?: string }) => label, objectPluralLabel: () => '' }), +})); + +const dataSourceStub = { + onConnectionStateChange: () => () => {}, + getConnectionState: () => 'connected', +}; +vi.mock('../../providers/AdapterProvider', async (importOriginal) => ({ + ...(await importOriginal>()), + useAdapter: () => dataSourceStub, +})); + +const actionRunnerStub = { registerHandler: vi.fn(), getContext: () => ({}) }; +vi.mock('@object-ui/react', async (importOriginal) => ({ + ...(await importOriginal>()), + useActionRunner: () => ({ execute: vi.fn(), runner: actionRunnerStub }), + useGlobalUndo: () => {}, + useMutationInvalidationBridge: () => {}, +})); + +// `AppContent` reaches a dynamic `import('@objectstack/lint')` (through +// `ConsoleLayout` → `DraftPreviewBar`, statically): pay its load at collection, +// never inside a case's clocked window (`check:test-source-alias`). +import '@objectstack/lint'; +import { AppContent } from '../AppContent'; +import { MetadataProvider } from '../../providers/MetadataProvider'; + +const CLOUD = 'com.example.cloud'; +const CRM = 'app.crm'; +const OBJECTS = [ + { name: 'sys_member', _packageId: 'plugin.auth', fields: { user: { type: 'lookup', reference: 'sys_user' } } }, + { name: 'sys_user', _packageId: 'plugin.auth', fields: {} }, + { name: 'crm_account', _packageId: CRM, fields: {} }, + { name: 'crm_opportunity', _packageId: CRM, fields: { account: { type: 'lookup', reference: 'crm_account' } } }, + { name: 'crm_quote', _packageId: 'app.sales', fields: { opportunity: { type: 'master_detail', reference: 'crm_opportunity' } } }, + // A child of the opportunity the authored page does not bind. + { name: 'crm_task', _packageId: 'app.service', fields: { opportunity: { type: 'lookup', reference: 'crm_opportunity' } } }, +]; +const CLOUD_NAVIGATION = [{ id: 'n1', type: 'object', label: 'Members', objectName: 'sys_member' }]; +const CRM_NAVIGATION = [{ id: 'c1', type: 'object', label: 'Accounts', objectName: 'crm_account' }]; +const OPPORTUNITY_PAGE = { + name: 'opportunity_detail', + type: 'record', + object: 'crm_opportunity', + kind: 'full', + isDefault: true, + regions: [{ name: 'main', components: [{ type: 'record:related_list', properties: { objectName: 'crm_quote' } }] }], +}; +const USER_PAGE = { + name: 'user_detail', + type: 'record', + object: 'sys_user', + kind: 'full', + isDefault: true, + regions: [{ name: 'main', components: [{ type: 'record:related_list', properties: { objectName: 'sys_member' } }] }], +}; + +const server = { calls: [] as string[], apps: [] as unknown[], pages: [] as unknown[] }; + +function makeAdapter() { + return { + clearCache: vi.fn(), + invalidateCache: vi.fn(), + // objectui#13044 — the provider's by-name OBJECT read goes through the + // adapter's `getObjectSchema`; this double answers it from the same door. + getObjectSchema(this: { getClient(): any }, name: string) { + return this.getClient() + .meta.getItem('object', name) + .then((res: any) => (res && typeof res === 'object' && 'item' in res ? res.item : res)); + }, + getClient: () => ({ + meta: { + getItems: (type: string, options?: { packageId?: string; names?: readonly string[] }) => { + // objectstack#34244 — the `?names=` presence read answers the asked names it holds and leaves an absent one out, as the list door does. + if (options?.names) { + server.calls.push(`${type}?names=${options.names.join(',')}`); + const named: any[] = type === 'object' ? (OBJECTS as any[]).filter((o: any) => options.names!.includes(o.name)) : []; + return Promise.resolve({ type, items: structuredClone(named) }); + } + server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type); + const all = type === 'object' ? OBJECTS : type === 'app' ? server.apps : type === 'page' ? server.pages : []; + const items = options?.packageId ? all.filter((o: any) => o._packageId === options.packageId) : all; + return Promise.resolve({ type, items: structuredClone(items) }); + }, + getItem: (type: string, name: string) => { + server.calls.push(`${type}/${name}`); + const item = (type === 'object' ? OBJECTS : []).find((o) => o.name === name); + return item + ? Promise.resolve({ type, name, item: structuredClone(item) }) + : Promise.reject(Object.assign(new Error('not found'), { httpStatus: 404, code: 'RESOURCE_NOT_FOUND' })); + }, + }, + }), + } as unknown as Parameters[0]['adapter']; +} + +const USER = 'u_36150'; +const ORG: AuthOrganization = { id: 'org_a', name: 'Org A', slug: 'a' }; + +function authClient(): AuthClient { + return { + getSession: vi.fn(async () => ({ + user: { id: USER, name: 'Ada', email: 'ada@test.com', role: 'admin', positions: ['admin'] }, + session: { token: 'tok-36150', activeOrganizationId: ORG.id }, + })), + signOut: vi.fn(async () => undefined), + getConfig: vi.fn(async () => ({ features: {} })), + listOrganizations: vi.fn(async () => [ORG]), + getActiveOrganization: vi.fn(async () => ORG), + setActiveOrganization: vi.fn(async () => ORG), + getActiveMember: vi.fn(async () => ({ id: 'm1', organizationId: ORG.id, userId: USER, role: 'owner' })), + } as unknown as AuthClient; +} + +function boot(url: string) { + render( + + + + + } /> + + + + , + ); +} + +const objectCalls = () => server.calls.filter((c) => c === 'object' || c.startsWith('object?') || c.startsWith('object/')); +const settle = () => new Promise((resolve) => setTimeout(resolve, 50)); +const listed = () => (screen.getByTestId('record-view').textContent ?? '').split(','); + +// The viewport: `usePhoneViewport` reads `innerWidth` and listens to the +// media query; this double lets a case move the width and fire the query. +const mediaListeners = new Set<() => void>(); +function setWidth(width: number) { + Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true }); +} +function fireMediaChange() { + act(() => { + for (const listener of [...mediaListeners]) listener(); + }); +} +const originalWidth = window.innerWidth; +const originalMatchMedia = window.matchMedia; + +beforeEach(() => { + server.calls = []; + server.pages = [OPPORTUNITY_PAGE, USER_PAGE]; + server.apps = [ + { name: 'cloud', label: 'Cloud', _packageId: CLOUD, navigation: CLOUD_NAVIGATION }, + { name: 'crm', label: 'CRM', _packageId: CRM, navigation: CRM_NAVIGATION }, + ]; + localStorage.clear(); + sessionStorage.clear(); + ActiveOrganizationStorage.clear(); + mediaListeners.clear(); + setWidth(1280); + window.matchMedia = ((query: string) => { + const max = Number(/max-width:\s*(\d+)px/.exec(query)?.[1] ?? Infinity); + return { + media: query, + get matches() { + return window.innerWidth <= max; + }, + onchange: null, + addEventListener: (_type: string, listener: () => void) => mediaListeners.add(listener), + removeEventListener: (_type: string, listener: () => void) => mediaListeners.delete(listener), + addListener: (listener: () => void) => mediaListeners.add(listener), + removeListener: (listener: () => void) => mediaListeners.delete(listener), + dispatchEvent: () => false, + }; + }) as unknown as typeof window.matchMedia; +}); + +afterEach(() => { + cleanup(); + ActiveOrganizationStorage.clear(); + setWidth(originalWidth); + window.matchMedia = originalMatchMedia; +}); + +describe('the record route reads the objects of the page the view draws (objectstack#36150)', () => { + it('CONTROL — desktop: the authored page\'s objects, by name; the child it does not bind is not read', async () => { + boot('/apps/crm/crm_opportunity/record/r1'); + await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('crm_quote')); + await settle(); + expect(objectCalls()).not.toContain('object'); + expect(listed()).not.toContain('crm_task'); + }); + + it('phone: the standard page\'s scope, every object pointing at the record\'s, the unbound child included', async () => { + setWidth(375); + boot('/apps/crm/crm_opportunity/record/r1'); + await waitFor(() => expect(listed()).toContain('crm_task')); + expect(listed()).toContain('crm_quote'); + expect(objectCalls()).toContain('object'); + }); + + it('the width crossing 768 on an open record moves the scope with it', async () => { + boot('/apps/crm/crm_opportunity/record/r1'); + await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('crm_quote')); + await settle(); + expect(listed()).not.toContain('crm_task'); + setWidth(600); + fireMediaChange(); + await waitFor(() => expect(listed()).toContain('crm_task')); + }); + + it('N4 — a media-query change that leaves the window wide (printing fires one) keeps the authored page\'s scope', async () => { + boot('/apps/crm/crm_opportunity/record/r1'); + await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('crm_quote')); + await settle(); + act(() => { + window.dispatchEvent(new Event('beforeprint')); + }); + fireMediaChange(); + await settle(); + expect(objectCalls()).not.toContain('object'); + expect(listed()).not.toContain('crm_task'); + }); + + it('phone: a page named in the URL still reads its own objects, never the whole registry', async () => { + setWidth(375); + boot('/apps/crm/crm_opportunity/record/r1/page/opportunity_detail'); + await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('crm_quote')); + await settle(); + expect(objectCalls()).not.toContain('object'); + expect(listed()).not.toContain('crm_task'); + }); + + it('phone: the platform user page keeps its own page, so its route reads that page\'s objects', async () => { + setWidth(375); + boot('/apps/cloud/sys_user/record/u1'); + await waitFor(() => expect(screen.getByTestId('record-view')).toHaveTextContent('sys_member')); + await settle(); + expect(objectCalls()).not.toContain('object'); + }); +}); diff --git a/ui/packages/app-shell/src/console/appObjectScope.ts b/ui/packages/app-shell/src/console/appObjectScope.ts index beb89395b68..68aefa57dbb 100644 --- a/ui/packages/app-shell/src/console/appObjectScope.ts +++ b/ui/packages/app-shell/src/console/appObjectScope.ts @@ -40,8 +40,13 @@ * whose record page is declared as a full page reads the objects that page * binds, by name, the way a page route does (objectui#13046), once the page * list has answered; the page it picks is the page `RecordDetailView` renders - * (`usePageAssignment`'s choice). A record route with no declared record page, - * or a slotted one, reads the whole registry: its synthesized page derives + * (`usePageAssignment`'s choice). objectstack#36150 — that page is drawn on + * the desktop full page only: on a phone (below `PHONE_BELOW_WIDTH`, read as + * the view reads it) the route takes the synthesized page's arm below, as the + * view does, through the same `authoredRecordPageApplies` (a page named in the + * URL, and the platform pages that keep their own, still read their page's + * objects). A record route with no declared record page, + * or a slotted one, or an authored page off the desktop, reads the whole registry: its synthesized page derives * the related lists from every object that points at the record's object, in * any package. objectstack#29552 — except for an object the app's navigation * reaches: the app bundle holds every object that points at it @@ -92,6 +97,8 @@ import { matchAppBySegment } from '../utils/appRoute.js'; import { COMMAND_PALETTE_PARAM, RECORD_FORM_OBJECT_PARAM, RECORD_FORM_PARAM } from '../urlParams.js'; import type { ReadNamesWithoutViews } from '../hooks/useObjectPresence.js'; import { BUNDLE_MISS, useBundledReads, type BundledRead } from '../providers/bundledReads.js'; +import { authoredRecordPageApplies } from '../views/recordPageSurface.js'; +import { usePhoneViewport } from '../hooks/usePhoneViewport.js'; type ReadObjectScope = NonNullable; export type AppObjectScope = ReturnType; @@ -454,14 +461,20 @@ export interface PagesRead { * segment), else the object's default record page (`defaultRecordPageObject`), * else its first record page. Only a full page is returned. A slotted page, or * none, returns `null`: the view synthesizes that page, and derives its related - * lists from every object that points at the record's object. + * lists from every object that points at the record's object. So does a full + * page where it does not apply (objectstack#36150): on a phone, unless the URL + * names it or the object keeps its own page (`authoredRecordPageApplies`). */ function declaredRecordPage( pages: readonly unknown[], objectName: string, pageName: string | undefined, appName: string | undefined, + phone: boolean, ): unknown { + // objectstack#36150 — the record route is the full page, never embedded: + // the drawer reads the registry beside the route's scope. + if (!authoredRecordPageApplies({ embedded: false, phone, objectName, requestedPageName: pageName })) return null; const page = pageName ? pages.find((p) => isRecord(p) && p.name === pageName && isRecordPageOf(p, objectName)) : (() => { @@ -690,6 +703,8 @@ export function readAppObjectScope( readPages?: () => PagesRead, readDashboard?: (dashboardName: string) => DashboardRead, readObjectsReferencing?: (objectName: string) => BundledRead, + /** objectstack#36150 — the viewport is a phone's (`usePhoneViewport`), as the record view reads it. */ + phone = false, ): AppObjectScopeRead { const route = matchObjectScopeRoute(subPath, hostPaths); const candidate = !!route && !!readObjectScope && !hasRecordFormOverlay(search); @@ -735,7 +750,7 @@ export function readAppObjectScope( } return { candidate, scope: PENDING_OBJECT_SCOPE, ready: false, ...NOT_READ }; } - const page = declaredRecordPage(pagesRead.pages, route.objectName, route.pageName, typeof app.name === 'string' ? app.name : undefined); + const page = declaredRecordPage(pagesRead.pages, route.objectName, route.pageName, typeof app.name === 'string' ? app.name : undefined, phone); if (!page) { // objectstack#29552 — the synthesized page: its related lists are // derived from every object that points at the record's object, which @@ -959,6 +974,8 @@ export function useAppObjectScopePrefetch(): void { const bundledReads = useBundledReads(); const dataSource = useAdapter() as BundleHost | null; const { pathname, search } = useLocation(); + // objectstack#36150 — the same surface `AppContent` reads the scope for. + const phone = usePhoneViewport(); const segments = pathname.split('/').filter(Boolean); const app = segments[0] === 'apps' && segments[1] ? matchAppBySegment(apps, segments[1]) : undefined; const bundleAppName = typeof app?.name === 'string' && app.name ? app.name : undefined; @@ -1003,5 +1020,6 @@ export function useAppObjectScopePrefetch(): void { }, undefined, (objectName) => (bundledReads && bundleAppName ? bundledReads.objectsReferencing(bundleAppName, objectName) : BUNDLE_MISS), + phone, ); } diff --git a/ui/packages/app-shell/src/views/RecordDetailView.appendInset-27520.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.appendInset-27520.test.tsx index 2a73c4268dc..5db797672da 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.appendInset-27520.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.appendInset-27520.test.tsx @@ -123,7 +123,7 @@ function renderRecordPage(pages: any[]): HTMLElement { onEdit={() => {}} objectNameOverride={OBJECT} recordIdOverride={REC} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.authoredActivityThreading-12249.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.authoredActivityThreading-12249.test.tsx index 0e0c6b4c524..ad3ae02c6ef 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.authoredActivityThreading-12249.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.authoredActivityThreading-12249.test.tsx @@ -218,7 +218,7 @@ async function mount(comments: Record[], options: MountOptions) onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> diff --git a/ui/packages/app-shell/src/views/RecordDetailView.authoredPageDesktopOnly-36150.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.authoredPageDesktopOnly-36150.test.tsx new file mode 100644 index 00000000000..3a7477d2a1b --- /dev/null +++ b/ui/packages/app-shell/src/views/RecordDetailView.authoredPageDesktopOnly-36150.test.tsx @@ -0,0 +1,315 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#36150 — an authored record page is drawn on the desktop full + * page only. On a phone and in the side drawer (an embedded view) the record + * draws the platform's standard page, built from the object's metadata. + * + * Read through the real `RecordDetailView`, as the Console mounts it: the full + * page by its route (at desktop and phone widths), and the drawer as + * `ObjectView` mounts it (`embedded`, the object and record handed in). + * + * - The card's pin: an authored `kind: 'full'` page draws on the desktop full + * page; on a phone and in the drawer its page-only block is gone, the + * standard page's tab strip is drawn, and the object's `record_more` + * action is still in the header's ⋯ menu. Red before the change (the + * authored page drew on all three). + * - CONTROL: an object with no authored page draws the standard page on all + * three, as before. + * - A media-query change that leaves the window wide (printing fires one) + * keeps the authored page on the desktop full page. + * - The host's exceptions, each on the drawer and the phone: a slotted + * page's slot is kept (it IS the standard page); the approval request and + * user pages keep their own page; a page named in the URL is drawn on the + * phone. + */ + +import * as React from 'react'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import type { MockInstance } from 'vitest'; +import { act, render, screen, waitFor, fireEvent, cleanup } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { MemoryRouter, Routes, Route } from 'react-router-dom'; + +vi.mock('@object-ui/auth', async (importOriginal) => ({ + ...(await importOriginal>()), + useAuth: () => ({ user: null, activeOrganization: null }), + createAuthenticatedFetch: () => vi.fn(), +})); +vi.mock('@object-ui/collaboration', async (importOriginal) => ({ + ...(await importOriginal>()), + useRecordPresence: () => [], + PresenceAvatars: () => null, +})); +vi.mock('sonner', () => ({ + toast: Object.assign(vi.fn(), { + success: vi.fn(), error: vi.fn(), info: vi.fn(), warning: vi.fn(), loading: vi.fn(), dismiss: vi.fn(), + }), +})); +vi.mock('./ActionParamDialog', () => ({ ActionParamDialog: () => null })); +vi.mock('./ActionResultDialog', () => ({ ActionResultDialog: () => null })); +vi.mock('./FlowRunner', () => ({ FlowRunner: () => null })); +vi.mock('./MetadataInspector', () => ({ + MetadataPanel: () => null, + useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }), +})); + +import { I18nProvider } from '@object-ui/i18n'; +import { MetadataCtx } from '@object-ui/react'; +import { RecordDetailView } from './RecordDetailView'; +import { FavoritesProvider } from '../context/FavoritesProvider'; +import { authoredRecordPageApplies, OBJECTS_KEEPING_AUTHORED_PAGE } from './recordPageSurface'; + +// The console's named record page route (`RECORD_NAMED_PAGE_ROUTE` in +// `console/AppContent.tsx`), spelled here: importing it would load the whole +// console shell into this file. +const RECORD_NAMED_PAGE_ROUTE = ':objectName/record/:recordId/page/:pageName'; +const RECORD_ID = 'rec-1'; +const AUTHORED_MARK = 'Authored page block'; +const SLOT_MARK = 'Slotted alert'; + +const MORE_ACTION = { name: 'qa_recalc', label: 'Recalculate', type: 'api', target: '/api/v1/x', locations: ['record_section', 'record_more'] }; + +function objectDef(name: string) { + return { + name, + label: name, + fields: { id: { type: 'text', label: 'Id' }, name: { type: 'text', label: 'Name' } }, + actions: [MORE_ACTION], + }; +} + +function fullPage(object: string, name = `${object}_detail`, isDefault = true) { + return { + name, + label: 'Detail', + type: 'record', + object, + kind: 'full', + ...(isDefault ? { isDefault: true } : {}), + regions: [{ + name: 'main', + width: 'full', + components: [ + { type: 'page:header', properties: { actions: [] } }, + { type: 'element:text', properties: { content: AUTHORED_MARK } }, + { type: 'record:details', properties: {} }, + ], + }], + }; +} + +function slottedPage(object: string) { + return { + name: `${object}_detail`, + label: 'Detail', + type: 'record', + object, + kind: 'slotted', + isDefault: true, + regions: [], + slots: { alerts: [{ type: 'record:alert', id: 'qa_alert', properties: { severity: 'info', title: SLOT_MARK } }] }, + }; +} + +type Face = 'desktop' | 'phone' | 'drawer'; + +function setWidth(width: number) { + Object.defineProperty(window, 'innerWidth', { value: width, configurable: true, writable: true }); +} + +function mount(objectName: string, pages: unknown[], face: Face, url?: string) { + setWidth(face === 'phone' ? 375 : 1280); + const objects = [objectDef(objectName)]; + const metadata = { + objects, + pages, + apps: [], + loading: false, + error: null, + refresh: async () => {}, + invalidate: () => {}, + ensureType: async () => [], + getItem: async (type: string, name: string) => (type === 'object' ? objects.find((o) => o.name === name) ?? null : null), + getItemsByType: () => [], + } as any; + const dataSource = { + find: vi.fn(async () => ({ data: [] })), + findOne: vi.fn(async () => ({ id: RECORD_ID, name: 'Ada' })), + create: vi.fn(async () => ({})), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => ({})), + } as any; + const page = ; + const view = + face === 'drawer' ? ( + + + + ) : ( + + + + + + + + + ); + render( + + + {view} + + , + ); +} + +/** Wait for the record to draw (its name in the details). */ +async function recordDrawn() { + await waitFor(() => expect(screen.getAllByText('Ada').length).toBeGreaterThan(0)); +} + +/** Whether the page draws the standard page's tab strip. */ +function standardTabs(): boolean { + return document.querySelector('[data-record-tab-row]') !== null || screen.queryAllByRole('tab').length > 0; +} + +let consoleError: MockInstance; +const originalWidth = window.innerWidth; + +beforeEach(() => { + cleanup(); + localStorage.clear(); + consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}); + vi.stubGlobal( + 'fetch', + vi.fn(async () => new Response(JSON.stringify({ data: [] }), { status: 200, headers: { 'content-type': 'application/json' } })), + ); +}); + +afterEach(() => { + consoleError.mockRestore(); + vi.unstubAllGlobals(); + vi.clearAllMocks(); + setWidth(originalWidth); +}); + +describe('authoredRecordPageApplies (objectstack#36150)', () => { + it('applies on the desktop full page only', () => { + expect(authoredRecordPageApplies({ embedded: false, phone: false, objectName: 'qa_project', requestedPageName: undefined })).toBe(true); + expect(authoredRecordPageApplies({ embedded: true, phone: false, objectName: 'qa_project', requestedPageName: undefined })).toBe(false); + expect(authoredRecordPageApplies({ embedded: false, phone: true, objectName: 'qa_project', requestedPageName: undefined })).toBe(false); + expect(authoredRecordPageApplies({ embedded: true, phone: true, objectName: 'qa_project', requestedPageName: undefined })).toBe(false); + }); + + it('a page named in the URL applies wherever its route renders', () => { + expect(authoredRecordPageApplies({ embedded: false, phone: true, objectName: 'qa_project', requestedPageName: 'qa_print' })).toBe(true); + }); + + it('the approval request and user pages apply on every surface, and no other object does', () => { + expect([...OBJECTS_KEEPING_AUTHORED_PAGE].sort()).toEqual(['sys_approval_request', 'sys_user']); + for (const objectName of OBJECTS_KEEPING_AUTHORED_PAGE) { + expect(authoredRecordPageApplies({ embedded: true, phone: false, objectName, requestedPageName: undefined })).toBe(true); + expect(authoredRecordPageApplies({ embedded: false, phone: true, objectName, requestedPageName: undefined })).toBe(true); + } + }); +}); + +describe('#36150 an authored full page', () => { + it('draws as authored on the desktop full page', async () => { + mount('qa_project', [fullPage('qa_project')], 'desktop'); + await recordDrawn(); + await waitFor(() => expect(screen.getByText(AUTHORED_MARK)).toBeInTheDocument()); + expect(standardTabs()).toBe(false); + }); + + it('a media-query change that leaves the window wide (printing fires one) keeps the authored page (N4)', async () => { + const listeners = new Set<() => void>(); + const original = window.matchMedia; + window.matchMedia = ((query: string) => ({ + media: query, + matches: false, + onchange: null, + addEventListener: (_t: string, l: () => void) => listeners.add(l), + removeEventListener: (_t: string, l: () => void) => listeners.delete(l), + addListener: (l: () => void) => listeners.add(l), + removeListener: (l: () => void) => listeners.delete(l), + dispatchEvent: () => false, + })) as unknown as typeof window.matchMedia; + try { + mount('qa_project', [fullPage('qa_project')], 'desktop'); + await recordDrawn(); + await waitFor(() => expect(screen.getByText(AUTHORED_MARK)).toBeInTheDocument()); + expect(listeners.size).toBeGreaterThan(0); + act(() => { + window.dispatchEvent(new Event('beforeprint')); + for (const l of [...listeners]) l(); + }); + expect(screen.getByText(AUTHORED_MARK)).toBeInTheDocument(); + expect(standardTabs()).toBe(false); + } finally { + window.matchMedia = original; + } + }); + + it.each(['phone', 'drawer'])('draws the standard page on the %s', async (face) => { + mount('qa_project', [fullPage('qa_project')], face); + await recordDrawn(); + await waitFor(() => expect(standardTabs()).toBe(true)); + expect(screen.queryByText(AUTHORED_MARK)).toBeNull(); + }); + + it('on the drawer the object\'s record_more action is in the standard header\'s ⋯ menu', async () => { + mount('qa_project', [fullPage('qa_project')], 'drawer'); + await recordDrawn(); + const trigger = await screen.findByRole('button', { name: 'More actions' }); + fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: 'mouse' }); + await waitFor(() => expect(screen.getByRole('menu')).toBeInTheDocument()); + const rows = Array.from(screen.getByRole('menu').querySelectorAll('[role="menuitem"]')).map((e) => (e.textContent ?? '').trim()); + expect(rows).toContain('Recalculate'); + }); +}); + +describe('#36150 CONTROL — no authored page', () => { + it.each(['desktop', 'phone', 'drawer'])('the standard page on the %s, as before', async (face) => { + mount('qa_plain', [], face); + await recordDrawn(); + await waitFor(() => expect(standardTabs()).toBe(true)); + }); +}); + +describe('#36150 the host\'s exceptions', () => { + it.each(['desktop', 'phone', 'drawer'])('a slotted page keeps its slot on the %s', async (face) => { + mount('qa_slotted', [slottedPage('qa_slotted')], face); + await recordDrawn(); + await waitFor(() => expect(screen.getByText(SLOT_MARK)).toBeInTheDocument()); + }); + + it.each<[string, Face]>([ + ['sys_approval_request', 'phone'], + ['sys_approval_request', 'drawer'], + ['sys_user', 'phone'], + ['sys_user', 'drawer'], + ])('%s keeps its own page on the %s', async (objectName, face) => { + mount(objectName, [fullPage(objectName)], face); + await waitFor(() => expect(screen.getByText(AUTHORED_MARK)).toBeInTheDocument()); + }); + + it('a page named in the URL is drawn on the phone', async () => { + mount( + 'qa_project', + [fullPage('qa_project'), fullPage('qa_project', 'qa_named', false)], + 'phone', + `/apps/a/qa_project/record/${RECORD_ID}/page/qa_named`, + ); + await waitFor(() => expect(screen.getByText(AUTHORED_MARK)).toBeInTheDocument()); + }); +}); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.commentWriteFailure-10899.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.commentWriteFailure-10899.test.tsx index 62efdafd974..532fdf99684 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.commentWriteFailure-10899.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.commentWriteFailure-10899.test.tsx @@ -133,7 +133,7 @@ function mount(dataSource: any) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx index a04559d1318..707d80fd5e1 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.commentsPanel-36075.test.tsx @@ -16,7 +16,9 @@ * - The comments are the panel's: the page's 动态 stream no longer draws them. * - No icon where the panel is not offered: an object with feeds off, and a * page authored by hand (option C, seat 13:24Z): that page keeps its own - * discussion block as it was. + * discussion block as it was. It is drawn on the desktop full page only + * (objectstack#36150): the same object's drawer draws the standard page, + * which offers the icon. */ import * as React from 'react'; @@ -284,9 +286,18 @@ describe('the record comment panel (objectstack#36075)', () => { }); it('no icon on a hand-written page, which keeps its own discussion block', async () => { - const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true }); + // objectstack#36150 — the full page: an authored page is drawn there only. + const { container } = await mount({ pages: [AUTHORED_PAGE] }); expect(await within(container).findByText(ADA_BODY)).toBeInTheDocument(); expect(button(container)).toBeNull(); expect(panel(container)).toBeNull(); }); + + it('the drawer of an object with a hand-written page draws the standard page, so it offers the icon (objectstack#36150)', async () => { + const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true }); + await waitFor(() => expect(button(container)).not.toBeNull()); + expect(panel(container)).toBeNull(); + fireEvent.click(button(container)!); + expect(await within(panel(container)!).findByText(ADA_BODY)).toBeInTheDocument(); + }); }); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.discussionExplicitComposition-7298.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.discussionExplicitComposition-7298.test.tsx index 2646c08d9c5..f3c04d9cb64 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.discussionExplicitComposition-7298.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.discussionExplicitComposition-7298.test.tsx @@ -195,7 +195,7 @@ function renderDetail(opts: { objects: any[]; pages: any[]; comments?: Array {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.discussionFallbackPipeline-8983.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.discussionFallbackPipeline-8983.test.tsx index 1563e9d8573..56d277d32bc 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.discussionFallbackPipeline-8983.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.discussionFallbackPipeline-8983.test.tsx @@ -259,7 +259,7 @@ function renderDetail(fixture: Fixture, pages: any[]) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.feedCommentEditDelete-12268.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.feedCommentEditDelete-12268.test.tsx index 7a85af9e9fe..dc2f750f2bc 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.feedCommentEditDelete-12268.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.feedCommentEditDelete-12268.test.tsx @@ -287,7 +287,7 @@ async function mount(block: Block, perms: MePermissionsResponse = answer(), opti onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> diff --git a/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx index 126ae4c9511..8cb449d90b2 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.feedGrant-12082.test.tsx @@ -216,7 +216,7 @@ async function mount( onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> @@ -480,7 +480,7 @@ describe('the reaction store is asked of the registry only by a caller who may r onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> diff --git a/ui/packages/app-shell/src/views/RecordDetailView.feedLoading.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.feedLoading.test.tsx index 1d3c31b2dcb..e0b150cc6bf 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.feedLoading.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.feedLoading.test.tsx @@ -196,7 +196,7 @@ function renderDetail(dataSource: any, pages: any[] = []) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx index 55d02634abe..f43d9327f29 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.feedRecordScope.test.tsx @@ -225,7 +225,9 @@ function tree(dataSource: any, recordId: string, pages: any[] = []) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={recordId} - embedded + // objectstack#36150 — an authored page draws on the full page only, + // so its cases mount the full page; the synthesized page's, the drawer. + embedded={pages.length === 0} /> diff --git a/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx index 1c6a162683d..5f4196ca864 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx @@ -2635,7 +2635,8 @@ describe('RecordDetailView.recordTabRowUrl-27524', () => { * - the premise, re-read live: the spec refuses each such page at `regions`; * - a `full` page whose region places nothing, and one with no `regions`, * draw the explanation naming the page, and no page body at all; - * - the record drawer draws the same explanation; + * - the record drawer draws the standard page, with no explanation: an + * authored page applies on the desktop full page only (objectstack#36150); * - CONTROLS: the same page placing a component draws that page; a `slotted` * page with no slots, and no assigned page, draw the default record page. */ @@ -2768,10 +2769,11 @@ describe('RecordDetailView.recordPagePlacesNoComponent-32478', () => { expect(panel.textContent).not.toContain('"{{name}}"'); }); - it('the record drawer explains it the same way', async () => { + it('the record drawer draws the standard page and no explanation: the authored page does not apply there (objectstack#36150)', async () => { const { container } = await mount([PLACES_NOTHING], true); - expect((await screen.findByTestId('record-page-places-no-component')).textContent).toContain(PAGE); - expect(container.querySelector('[data-page-type]')).toBeNull(); + await waitFor(() => expect(container.querySelector('[data-page-type="record"]')).not.toBeNull()); + expect(container.querySelector(`[aria-label="${PAGE}"]`)).toBeNull(); + expect(screen.queryByTestId('record-page-places-no-component')).toBeNull(); }); it('CONTROL: the same page placing a component draws that page, and no explanation', async () => { diff --git a/ui/packages/app-shell/src/views/RecordDetailView.oneProvenanceFooter-12307.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.oneProvenanceFooter-12307.test.tsx index 664a104a26f..24d6b832864 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.oneProvenanceFooter-12307.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.oneProvenanceFooter-12307.test.tsx @@ -139,7 +139,7 @@ async function renderRecordPage(pages: any[]): Promise { onEdit={() => {}} objectNameOverride={OBJECT} recordIdOverride={REC} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.reactionKeepIds-11019.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.reactionKeepIds-11019.test.tsx index f5d18333220..8dc6ed1349c 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.reactionKeepIds-11019.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.reactionKeepIds-11019.test.tsx @@ -154,7 +154,7 @@ async function mountAs(userId: string, dataSource: any) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.reactionRecords-12078.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.reactionRecords-12078.test.tsx index 5d59f067cf1..400ba639b3d 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.reactionRecords-12078.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.reactionRecords-12078.test.tsx @@ -254,7 +254,7 @@ function tree(member: string, dataSource: any, metadata: any) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> diff --git a/ui/packages/app-shell/src/views/RecordDetailView.reactionWriteFailure-10899.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.reactionWriteFailure-10899.test.tsx index 6306cb666ee..ce14304735c 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.reactionWriteFailure-10899.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.reactionWriteFailure-10899.test.tsx @@ -170,7 +170,7 @@ function mount(dataSource: any, wrap: (tree: React.ReactElement) => React.ReactE onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.reactionsCommentRowsOnly-11035.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.reactionsCommentRowsOnly-11035.test.tsx index f5febb8e06e..ea6617de138 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.reactionsCommentRowsOnly-11035.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.reactionsCommentRowsOnly-11035.test.tsx @@ -187,7 +187,7 @@ async function mount(dataSource: any, { withProbe = false } = {}) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.replyCountOnRead-12144.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.replyCountOnRead-12144.test.tsx index 55df9f37278..6e68311b507 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.replyCountOnRead-12144.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.replyCountOnRead-12144.test.tsx @@ -189,7 +189,7 @@ async function mount(comments: Record[], options: MountOptions onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> diff --git a/ui/packages/app-shell/src/views/RecordDetailView.topInset-35745.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.topInset-35745.test.tsx index aa70b9010fd..a4d8e79b3dc 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.topInset-35745.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.topInset-35745.test.tsx @@ -126,7 +126,7 @@ function renderRecordPage(pages: any[]): HTMLElement { onEdit={() => {}} objectNameOverride={OBJECT} recordIdOverride={REC} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> , diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index 0affb374150..69b6fcc9398 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -56,6 +56,7 @@ import { type RecordPageStreamsAsk, } from './recordPagePayload.js'; import { applySavedRecordEcho } from './recordSaveEcho.js'; +import { authoredRecordPageApplies } from './recordPageSurface.js'; import { withPageTabsUrlSync } from '../utils/pageTabsUrlSync.js'; import { RECORD_DETAIL_TAB_PARAM, RECORD_DRAWER_PARAM, RECORD_RELATED_ENLARGE_PARAM, RECORD_RELATED_ENLARGE_PUSHED_STATE as RELATED_ENLARGE_PUSHED, RECORD_TRAIL_PARAM, decodeRecordTrail, buildRecordTrailHref } from '../urlParams.js'; import { resolveActionParams } from '@object-ui/fields'; @@ -1230,9 +1231,17 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri () => new Set(objects.map((o: any) => o?.name).filter(Boolean)), [objects], ); + // objectstack#36150 — an authored full record page is drawn on the desktop + // full page only; on a phone and in an embedded host (drawer, split pane) + // the record takes the standard page (`authoredRecordPageApplies`, which + // names the two exceptions: a page named in the URL, and the platform + // pages listed in `OBJECTS_KEEPING_AUTHORED_PAGE`). Slotted pages are the + // standard page already and keep their slots everywhere. + const phone = usePhoneViewport(); + const authoredPageHere = authoredRecordPageApplies({ embedded, phone, objectName, requestedPageName }); const assignedPage = useMemo( - () => (namedPageBlocked ? null : pruneUnregisteredRecordPageObjects(resolvedPage, registeredObjectNames)), - [namedPageBlocked, resolvedPage, registeredObjectNames], + () => (namedPageBlocked || !authoredPageHere ? null : pruneUnregisteredRecordPageObjects(resolvedPage, registeredObjectNames)), + [namedPageBlocked, authoredPageHere, resolvedPage, registeredObjectNames], ); const assignedSlots = useMemo( () => (namedPageBlocked ? null : pruneUnregisteredRecordPageObjects(resolvedSlots, registeredObjectNames)), @@ -4525,8 +4534,8 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // in a bar at the bottom of the page (the header draws them there, through // `PageHeaderPhoneContext`), its top bar is one way back, a page pushed from // a related row has a path row, and going back to a page restores where it - // was scrolled. A record drawn in a pane is never on a phone. - const phone = usePhoneViewport(); + // was scrolled. A record drawn in a pane is never on a phone. (`phone` is + // read where the page is assigned, above.) const phonePage = phone && !embedded; const [phoneActionBarEl, setPhoneActionBarEl] = useState(null); const [pageScrollerEl, setPageScrollerEl] = useState(null); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.withheldMentions-28218.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.withheldMentions-28218.test.tsx index 39d5d381d19..94239a1cea0 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.withheldMentions-28218.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.withheldMentions-28218.test.tsx @@ -179,7 +179,7 @@ async function mount(dataSource: ReturnType) { onEdit={() => {}} objectNameOverride={OBJECT_NAME} recordIdOverride={RECORD_ID} - embedded + /* objectstack#36150 — not `embedded`: an authored page draws on the full page only. */ /> diff --git a/ui/packages/app-shell/src/views/recordPageSurface.ts b/ui/packages/app-shell/src/views/recordPageSurface.ts new file mode 100644 index 00000000000..b08fdbdc7c0 --- /dev/null +++ b/ui/packages/app-shell/src/views/recordPageSurface.ts @@ -0,0 +1,82 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack#36150 — where an authored record page applies. + * + * An object's authored full record page (`PageSchema` with `type: 'record'`, + * `kind: 'full'`, picked by `usePageAssignment`) is drawn on the DESKTOP FULL + * PAGE only. On a phone (the record page below `PHONE_BELOW_WIDTH`) and in + * every embedded host (the right-side drawer a list opens, the split pane, + * an interface page's preview) the record draws the platform's standard page, + * built from the object's own metadata: its field groups and order, field + * permissions and visibility, its `record_header` / `record_more` actions, + * one tab per child table, the stage and the approval state. "Open full + * page" from the drawer lands on the full page, so on the authored page. + * + * What does NOT apply off the full page is the layout and whatever lives only + * on it: page-only blocks and related lists, page-declared tabs and sections, + * and `record_section` actions, which the standard page does not draw (an + * author who wants an action there too adds `record_more`). + * + * There is no switch an author can set to keep a page on the phone or in the + * drawer. Two exceptions are the host's, named here and nowhere else: + * + * - The page NAMED in the URL (`/record/:id/page/:pageName`, print pages and + * other named routes) is not the object's assigned page: it is drawn + * wherever that route renders, or nothing is (objectui#12715). The drawer + * never reads a page name, so only the full-page route is concerned. + * - {@link OBJECTS_KEEPING_AUTHORED_PAGE}, the platform pages that carry what + * has no place on the standard page yet. + */ + +/** + * Platform objects whose own record page is kept on the phone and in the + * drawer (maintainer ruling 7066490078 on objectstack#36150). The key is the + * object's name, as the ruling words it ("the user page"): ANY assigned full + * page of these objects is kept everywhere, an app-scoped one included. + * + * - `sys_approval_request` — the page IS the decision (maintainer 2026-11-17, + * #34588: the request shows the submitted record whole): its approve, + * reject and reply actions are `record_section` ones, drawn only by + * `record:approval_decision`, and a request whose step requires a comment + * can be decided only there. + * - `sys_user` — the Security tab (two-factor, backup codes, account deletion), + * effective access and the AI assistants tab have no object-level place, and + * the standard page would open one tab per lookup to `sys_user`. Held until + * an object can name its record page's tabs (objectstack#35897). + */ +export const OBJECTS_KEEPING_AUTHORED_PAGE: ReadonlySet = new Set([ + 'sys_approval_request', + 'sys_user', +]); + +export interface RecordPageSurface { + /** The view is embedded (drawer, split pane, interface preview). */ + embedded: boolean | undefined; + /** The viewport is a phone's (`usePhoneViewport`). */ + phone: boolean; + /** The object the record belongs to. */ + objectName: string | undefined | null; + /** The page name the full-page route carries, if any. */ + requestedPageName: string | undefined | null; +} + +/** + * True when the object's assigned (authored, `kind: 'full'`) record page is + * drawn on this surface; false when the standard page is drawn instead. + * Slotted pages are not concerned: they already are the standard page with + * their slots filled, on every surface. The record view and the record + * route's object scope (`console/appObjectScope.ts`) both read it, so the + * route reads the objects of the page the view draws. + */ +export function authoredRecordPageApplies(surface: RecordPageSurface): boolean { + if (surface.requestedPageName) return true; + if (surface.objectName && OBJECTS_KEEPING_AUTHORED_PAGE.has(surface.objectName)) return true; + return !surface.embedded && !surface.phone; +}