From 65e526e52bb70339e260d8be7221c176faf25c1b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 17:37:57 +0000 Subject: [PATCH 1/5] test(app-shell): pin the record page for a pending approver with no object read (red) Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L9qibvMXrDPhCt3pGziYWE --- .../views/RecordDetailView.harness.test.tsx | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) 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 88dde3f12a2..f7e527b46d0 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx @@ -4220,3 +4220,188 @@ describe('RecordDetailView.closedLock-37773', () => { expect(await overflowItems()).toContain('Delete'); }); }); + +// ── RecordDetailView.approverServedRow-39709 ──────────────────────────────── + +/** + * objectstack#39709 — a pending approver with no object read opens the record + * the request is about, and the record page draws the row the server served. + * + * The server admits that one read while the approver's step waits (the rulings + * on objectstack#26180 and objectstack#39485): the data API answers the record, + * stripped by the reader's own field rules. `/auth/me/permissions` describes + * the data API's standing rule, so it names no read on the object, and the + * page's two read mirrors (`check(object, 'read')`, `checkField(object, field, + * 'read')`) failed closed: no title, no field, a blank page for a record the + * server had just served. + * + * What is pinned, through the real record page and the real + * `MePermissionsProvider`: + * + * - the served row's title and fields are drawn when the answer grants no + * read on the object and the row was served; + * - writes stay gated: no Edit in the header for that reader; + * - a field the server did not serve is not drawn with a value; + * - CONTROLS: a reader whose answer names the object keeps today's field + * mirror (a field it denies stays off the page, even when served), and a + * record the server did not serve keeps the not-found state. + * + * Direction, written before the run: on `main` the approver case is RED (no + * title, no field) and every control is GREEN. + */ + +describe('RecordDetailView.approverServedRow-39709', () => { + restoreAfterBlock(); + + const OBJECT = 'os_39709_contract'; + const REC = 'CT-1'; + const objectDef = { + name: OBJECT, + label: 'Contract', + managedBy: 'platform', + fields: { + id: { label: 'Id', type: 'text' }, + name: { label: 'Name', type: 'text' }, + terms: { label: 'Terms', type: 'text' }, + secret_note: { label: 'Secret note', type: 'text' }, + }, + }; + /** What the server serves the approver: its masker took `secret_note` out. */ + const SERVED = { id: REC, name: 'Supply contract', terms: 'Net 30 days' }; + + /** A `/me/permissions` answer naming `objects` and `fields`, as the server resolves it. */ + function answer( + objects: MePermissionsAuthenticatedResponse['objects'], + fields: MePermissionsAuthenticatedResponse['fields'] = {}, + ): MePermissionsAuthenticatedResponse { + return { + authenticated: true, + userId: 'u1', + tenantId: null, + positions: [], + hasAnyQueue: false, + objectsUsingQueues: [], + permissionSets: [], + objects, + fields, + }; + } + /** The approver: the answer names another object and grants nothing on this one. */ + const APPROVER = answer({ os_39709_other: { allowRead: true } }); + const FULL = { allowRead: true, allowCreate: true, allowEdit: true, allowDelete: true }; + + function makeMetadata() { + const pages: unknown[] = []; + return { + objects: [], pages, loading: false, error: null, + refresh: async () => {}, invalidate: () => {}, + ensureType: async () => pages, getItem: async () => null, + getItemsByType: () => pages, + } as never; + } + + function headerEdit(): HTMLButtonElement | null { + const bar = document.querySelector('[role="toolbar"]'); + if (!bar) return null; + return (Array.from(bar.querySelectorAll('button')) + .find((b) => (b.textContent ?? '').trim().toLowerCase() === 'edit') as HTMLButtonElement | undefined) ?? null; + } + + async function mountRecord(perms: MePermissionsResponse, served: Record | null) { + const ds = { + find: vi.fn(async () => ({ data: [], total: 0, hasMore: false, pageSize: 50 })), + findOne: vi.fn(async () => (served ? { ...served } : null)), + create: vi.fn(async (_o: string, row: Record) => row), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => ({})), + getObjectSchema: async () => objectDef, + }; + render( + + + + + + {}} /> + } + /> + + + + + , + ); + await waitFor(() => expect(ds.findOne).toHaveBeenCalled()); + return ds; + } + + /** Let the page settle after the read, so an absence is read on a page that finished drawing. */ + async function settle() { + await act(async () => { + for (let i = 0; i < 10; i++) await new Promise((r) => setTimeout(r, 0)); + }); + } + + beforeAll(() => { + Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1280 }); + }); + + beforeEach(() => { + // Unrelated chrome (approvals, row-level verdicts) reaches for the platform + // API; happy-dom would resolve those relative URLs to a real socket, which + // the repo's network-escape guard fails the file for (objectui#6640). + vi.stubGlobal('fetch', vi.fn(async () => ({ + ok: true, + status: 200, + json: async () => ({ allowed: true, data: [] }), + text: async () => '{}', + })) as never); + }); + + afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); + }); + + it('draws the served title and fields for a reader the answer grants no read on the object', async () => { + await mountRecord(APPROVER, SERVED); + await waitFor(() => expect(document.querySelector('h1')?.textContent).toContain('Supply contract')); + await waitFor(() => expect(document.body.textContent).toContain('Net 30 days')); + }); + + it('keeps writes gated for that reader: no Edit in the header', async () => { + await mountRecord(APPROVER, SERVED); + await waitFor(() => expect(document.body.textContent).toContain('Net 30 days')); + await settle(); + expect(headerEdit()).toBeNull(); + }); + + it('draws no value for a field the server did not serve', async () => { + await mountRecord(APPROVER, SERVED); + await waitFor(() => expect(document.body.textContent).toContain('Net 30 days')); + await settle(); + expect(document.body.textContent).not.toContain('Merger planned'); + }); + + it('CONTROL: a reader whose answer names the object keeps the field mirror, even for a served field', async () => { + // A backend that does not strip: the denied field rides the row, and the + // client mirror is what keeps it off the page for this reader. + await mountRecord( + answer({ [OBJECT]: FULL }, { [`${OBJECT}.secret_note`]: { readable: false, editable: false } }), + { ...SERVED, secret_note: 'Merger planned' }, + ); + await waitFor(() => expect(document.body.textContent).toContain('Net 30 days')); + await waitFor(() => expect(headerEdit()).not.toBeNull()); + await settle(); + expect(document.body.textContent).not.toContain('Merger planned'); + }); + + it('CONTROL: a record the server did not serve keeps the not-found state', async () => { + await mountRecord(APPROVER, null); + await waitFor(() => expect(screen.getByTestId('record-not-found')).toBeTruthy()); + expect(document.body.textContent).not.toContain('Supply contract'); + }); +}); From e5347710eec38dfe8d712a209514a9849096fa40 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 17:46:12 +0000 Subject: [PATCH 2/5] fix(app-shell): the record page draws the row the server served to a reader the answer grants no read on Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L9qibvMXrDPhCt3pGziYWE --- .../views/RecordDetailView.harness.test.tsx | 10 +---- .../app-shell/src/views/RecordDetailView.tsx | 39 +++++++++++++++++-- 2 files changed, 37 insertions(+), 12 deletions(-) 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 f7e527b46d0..fe4b6842a2b 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.harness.test.tsx @@ -4241,7 +4241,6 @@ describe('RecordDetailView.closedLock-37773', () => { * - the served row's title and fields are drawn when the answer grants no * read on the object and the row was served; * - writes stay gated: no Edit in the header for that reader; - * - a field the server did not serve is not drawn with a value; * - CONTROLS: a reader whose answer names the object keeps today's field * mirror (a field it denies stays off the page, even when served), and a * record the server did not serve keeps the not-found state. @@ -4266,7 +4265,7 @@ describe('RecordDetailView.approverServedRow-39709', () => { secret_note: { label: 'Secret note', type: 'text' }, }, }; - /** What the server serves the approver: its masker took `secret_note` out. */ + /** What the server serves the approver: its masker took `secret_note` out (that strip is the server's to pin). */ const SERVED = { id: REC, name: 'Supply contract', terms: 'Net 30 days' }; /** A `/me/permissions` answer naming `objects` and `fields`, as the server resolves it. */ @@ -4379,13 +4378,6 @@ describe('RecordDetailView.approverServedRow-39709', () => { expect(headerEdit()).toBeNull(); }); - it('draws no value for a field the server did not serve', async () => { - await mountRecord(APPROVER, SERVED); - await waitFor(() => expect(document.body.textContent).toContain('Net 30 days')); - await settle(); - expect(document.body.textContent).not.toContain('Merger planned'); - }); - it('CONTROL: a reader whose answer names the object keeps the field mirror, even for a served field', async () => { // A backend that does not strip: the denied field rides the row, and the // client mirror is what keeps it off the page for this reader. diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index 6070a8a50ee..016fcac98f2 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -16,7 +16,7 @@ import { unresolvedThreadCount } from '@object-ui/plugin-detail'; import { Empty, EmptyTitle, EmptyDescription, Button, PageHeaderActions, PageHeaderPhoneContext, PageHeaderTrailingContext, PanelToggles, ObjectIconTile, RecordHeaderBarContext, RecordHeaderStateContext, RecordTopBar, RecordTopBarButton, cn, useRecordStepKeys, type PanelToggleItem, type RecordHeaderBar, type RecordHeaderGroupParts, type RecordHeaderState, type RecordTopBarStepper } from '@object-ui/components'; import { isActingApprover } from '../utils/approvalDecisionFold.js'; import { useAuth, createAuthenticatedFetch } from '@object-ui/auth'; -import { usePermissions } from '@object-ui/permissions'; +import { ServerReadScope, usePermissions } from '@object-ui/permissions'; import { useDisplayLocale, useLocalization, pickLocalized } from '@object-ui/i18n'; import { ActionProvider, useObjectTranslation, useObjectLabel, useActionTextLocalizer, usePageAssignment, isRecordPageOf, useMetadata, RecordContextProvider, SchemaRenderer, DiscussionContextProvider, HighlightFieldsProvider, InlineEditProvider, resolveApprovalLock, useGlobalUndo, useDataInvalidation, notifyDataChanged, subscribeDataChanges, dataChangeMatches, useRowPredicate, usePredicateScope, classifyLoadError, answeredLoadFailure, extractWriteErrorMessage, isExternalWriteRefusal } from '@object-ui/react'; import type { AnsweredLoadFailure } from '@object-ui/react'; @@ -455,6 +455,9 @@ export function resolveRecordHeaderActionGates( }; } +/** `ServerReadScope`'s object list on a record page the server reads no record for (objectstack#39709): one identity, so the scope's value is cached once. */ +const NO_SERVER_READ_OBJECTS: readonly string[] = Object.freeze([]); + /** Gated copies of served rows, keyed on the served row object itself. */ const READABLE_ROWS = new WeakMap(); @@ -1347,7 +1350,27 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // comes back. When something is, the gated copy is cached outside React on // the served row (`readableRow`), NOT on a `useMemo` (AGENTS.md #10), so a // re-render never republishes an equal row as a new object to the page. - const readablePageRecord = readableRow(pageRecord, perms, objectName); + // + // objectstack#39709 — except where the server read the record through a door + // the permissions answer does not describe: a pending approver with no object + // read reads the one record the request is about while their step waits (the + // rulings on objectstack#26180 and objectstack#39485). The data API served + // the row, stripped by the reader's own field rules; the answer, which + // describes the data API's standing rule, grants no read on the object, so + // both read mirrors fail closed and the page drew nothing it was served. + // There the page draws the row as served, and its body reads under + // `ServerReadScope` for this object (`pageTree` below). Keyed on the server's + // answer alone (the row is held for this route, and the loaded answer grants + // no read), never on the client's reading of who approves what. A reader + // whose answer grants the read keeps the mirror above unchanged. + const serverReadsRecord = + !!objectName + && perms.isLoaded + && pageRecordFor === routeRecordKey + && !!pageRecord + && typeof pageRecord === 'object' + && !perms.check(objectName, 'read').allowed; + const readablePageRecord = serverReadsRecord ? pageRecord : readableRow(pageRecord, perms, objectName); // objectstack#35415 — on an approval request's page, what the page's own // reads of a record learned (`recordReadReport.ts`): the title links to the @@ -5046,7 +5069,16 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri attachments: !!(filesEnabled && !hasAttachments && pureRecordId), }); const pageTree = ( - // objectstack#35892 — a related tab draws the list page's condition row. + // objectstack#39709 — the record's own object, while the server reads this + // record for a reader the answer grants no read on (`serverReadsRecord`): + // the page's blocks draw the row and its fields as served. Only the two + // READ verdicts move, for this object only; writes, export, actions, + // related lists of other objects and every other page keep the enclosing + // answer. Mounted on every record page with no object named otherwise, so + // the tree keeps its shape and the page's blocks are not remounted when + // the read lands or is read again. + + {/* objectstack#35892 — a related tab draws the list page's condition row. */} @@ -5613,6 +5645,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri + ); // A drawer draws this view embedded and is its own host. A page is the host // of the drawer its related rows and lookups open over it From a128c012003cf1d5f61c1eea90ccb4f44425b2e4 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 17:47:43 +0000 Subject: [PATCH 3/5] chore(changeset): record page draws the served row for a pending approver Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L9qibvMXrDPhCt3pGziYWE --- .changeset/39709-record-page-approver-served-row.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/39709-record-page-approver-served-row.md diff --git a/.changeset/39709-record-page-approver-served-row.md b/.changeset/39709-record-page-approver-served-row.md new file mode 100644 index 00000000000..ee99c300e94 --- /dev/null +++ b/.changeset/39709-record-page-approver-served-row.md @@ -0,0 +1,12 @@ +--- +"@object-ui/app-shell": patch +--- + +fix(app-shell): the record page draws the record the server served to a pending approver with no object read + +Clause-②: no +Metadata-protocol: none + +A pending approver may read the one record an approval request is about while their step waits, even without read on its object. The server served that record, but the record page showed only its id: the console's permissions answer grants no read on the object, so the page hid the title and every field the server had already filtered for this reader. + +The record page now draws the served record when two things hold: the server answered the read of this record, and the loaded permissions answer grants no read on its object. Only that page's reads of that object are left to the server. Edit, delete, inline editing, export and actions stay gated as before, related lists of other objects and every other page are unchanged, and a reader whose answer grants the read keeps today's field-level hiding (objectstack#39709). From 0432673e84d2d8320b30f85051bd714333342ea5 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 18:53:31 +0000 Subject: [PATCH 4/5] test(console): the served-page control pins what only ApprovalRecordReads opens The control mounted the request page without ApprovalRecordReads and pinned the request's own row stripped to its id. Since the record page leaves the reads of its own object to the server once the row is served and the answer grants no read on it (the rulings on objectstack#26180 and #39485, applied by reading 7419067633), that premise is superseded: the page draws the request's own fields there too. The control now pins both halves: the page's own served row is drawn (title and step), and the Timeline, a related list of the other approval object, draws no row without ApprovalRecordReads. Measured as a real control: with ApprovalRecordReads mounted over the same routes it goes red (the Timeline draws 'Budget checked'). The old wire assertion (no GET of the actions route) is replaced by the drawn-rows assertion: on main the tab's count badge reads that route too, so the wire assertion only held by timing. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L9qibvMXrDPhCt3pGziYWE --- ...servedPageMemberPermissions-13324.test.tsx | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx b/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx index 5cc0c44beb1..085b658c045 100644 --- a/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx +++ b/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx @@ -19,12 +19,17 @@ * (objectstack-ai/objectstack#25228). * * The control mounts the same page through the routed adapter WITHOUT - * `ApprovalRecordReads`, under the same answer, and pins that blank page: it is - * what proves the member answer here is one that strips, so the first test can - * only pass because `ApprovalRecordReads` scopes the field-read gate. + * `ApprovalRecordReads`, under the same answer. Since objectstack#39709 the + * record page itself leaves the reads of its OWN object to the server once the + * server served the row and the answer grants no read on it, so the request's + * own fields are drawn there too. What the control pins is what only + * `ApprovalRecordReads` opens: the Timeline, a related list of the other + * approval object (`sys_approval_action`), draws no row without it. That is + * what proves the member answer here is one that strips, so the Timeline test + * can only pass because `ApprovalRecordReads` scopes the read gate. */ import { describe, it, expect, vi, afterEach } from 'vitest'; -import { render, screen, cleanup, fireEvent, within, waitFor } from '@testing-library/react'; +import { render, screen, cleanup, fireEvent, within, waitFor, act } from '@testing-library/react'; import { MemoryRouter, Routes, Route } from 'react-router-dom'; import type { ReactNode } from 'react'; @@ -330,26 +335,28 @@ describe('the served request page for a non-admin approver, under the real MePer expect(screen.getByText('Please review the laptop order')).toBeTruthy(); }); - it('control: the same answer strips the served row to its id when the routed reads are mounted without ApprovalRecordReads', async () => { + it("control: without ApprovalRecordReads the page draws its own served row (objectstack#39709), and the Timeline's other approval object stays dark", async () => { openAsMember(routedReadsOnly); - // The page is up and the approvals get answered: the tab strip is drawn - // and the heading names the request by its object label and id, the - // title's last rung, as the blank page the report describes does. await screen.findByRole('tab', { name: /Details/ }, { timeout: 8000 }); await waitFor(() => expect(requestGets().length).toBeGreaterThan(0), { timeout: 8000 }); - await screen.findByRole('heading', { level: 1, name: /^Approval Request req_/ }, { timeout: 8000 }); - expect(screen.queryByTestId('declared-action-approval_approve')).toBeNull(); - expect(screen.queryByTestId('declared-action-approval_reject')).toBeNull(); - expect(pageText()).not.toContain('Invoice Approval'); - expect(pageText()).not.toContain('Manager Review'); + // The record page leaves the reads of ITS OWN object to the server once + // the server served the row and the answer grants no read on it + // (objectstack#39709, rulings on objectstack#26180 and #39485): the + // request's own fields are drawn without the console's scope. + await screen.findByRole('heading', { level: 1, name: 'Invoice Approval' }, { timeout: 8000 }); + expect(pageText()).toContain('Manager Review'); + // ...but nothing else: `sys_approval_action` is another object, which the + // member may not read by the data API's answer, so the Timeline draws no + // row. Only `ApprovalRecordReads` opens it (the Timeline test above). const tab = screen.getByRole('tab', { name: /Timeline/ }); fireEvent.mouseDown(tab); fireEvent.click(tab); await waitFor(() => expect(tab.getAttribute('aria-selected')).toBe('true'), { timeout: 8000 }); - // The member may not read `sys_approval_action` by the data API's answer, - // so the Timeline's related list is not drawn and never reads the route. - expect(timelineGets()).toEqual([]); + await act(async () => { + for (let i = 0; i < 20; i++) await new Promise((r) => setTimeout(r, 0)); + }); expect(pageText()).not.toContain('Budget checked'); + expect(pageText()).not.toContain('Please review the laptop order'); }); }); From 077a514d260e581680b7a5e1ee950b845dc3c4ef Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 19:02:50 +0000 Subject: [PATCH 5/5] test(console): the served-page control also pins no edit control; the Timeline test reads its route The control without ApprovalRecordReads now also asserts the page offers no edit control for the request (reads only). The Timeline test asserts its rows came from the actions route, which uses the wire helper the rewritten control no longer read (TS6133 in Type Check UI). Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L9qibvMXrDPhCt3pGziYWE --- ...tsDataSource.servedPageMemberPermissions-13324.test.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx b/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx index 085b658c045..86e5e9f750b 100644 --- a/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx +++ b/ui/apps/console/src/services/approvalRequestsDataSource.servedPageMemberPermissions-13324.test.tsx @@ -333,6 +333,8 @@ describe('the served request page for a non-admin approver, under the real MePer fireEvent.click(tab); expect(await screen.findByText('Budget checked', undefined, { timeout: 8000 })).toBeTruthy(); expect(screen.getByText('Please review the laptop order')).toBeTruthy(); + // The rows came from the actions route, not the data API. + expect(timelineGets().length).toBeGreaterThan(0); }); it("control: without ApprovalRecordReads the page draws its own served row (objectstack#39709), and the Timeline's other approval object stays dark", async () => { @@ -345,6 +347,11 @@ describe('the served request page for a non-admin approver, under the real MePer // request's own fields are drawn without the console's scope. await screen.findByRole('heading', { level: 1, name: 'Invoice Approval' }, { timeout: 8000 }); expect(pageText()).toContain('Manager Review'); + // Reads only: the scope moves no write verdict, so the page offers no + // edit control for the request (header Edit, nor an inline-edit pencil). + expect(screen.queryByRole('button', { name: /^Edit$/ })).toBeNull(); + expect(screen.queryByRole('menuitem', { name: /^Edit$/ })).toBeNull(); + expect(document.querySelector('[data-record-page-root] svg.lucide-pencil')).toBeNull(); // ...but nothing else: `sys_approval_action` is another object, which the // member may not read by the data API's answer, so the Timeline draws no // row. Only `ApprovalRecordReads` opens it (the Timeline test above).