Skip to content

Commit 180845d

Browse files
committed
fix(record-page): one date format, appends aligned with the page cards, comment text in the foreground colour
A record:details section row writes the year on a current-year date, as the highlights strip already does, so a record page draws every date one way. The approvals and attachments fallbacks and the provenance footer appended after an authored page take the page body's horizontal inset. A feed entry's body reads in the foreground colour; the meta line stays muted. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvWX6aMbbnnsKtDC5k
1 parent 9b4d193 commit 180845d

6 files changed

Lines changed: 355 additions & 3 deletions

File tree

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack#27520 row 14 — what the record page appends after an authored
11+
* page lines up with that page's cards.
12+
*
13+
* Measured on the showcase project page: the Attachments card the host appends
14+
* (the object declares `enable.files`, the page places no `record:attachments`)
15+
* drew 24 px wider on each side than the page's own cards, and the provenance
16+
* footer with it. The page renderer insets its body (`p-3 md:p-4 lg:p-6`) and
17+
* the appends sit beside the page, not inside it. They now take the same
18+
* horizontal inset.
19+
*
20+
* Mounted through `RecordDetailView` itself on an ASSIGNED record page, so the
21+
* inset is read off the page root the real page renderer draws, not copied.
22+
*/
23+
import * as React from 'react';
24+
import { describe, it, expect, vi, beforeEach, afterEach, beforeAll } from 'vitest';
25+
import { render, waitFor, cleanup } from '@testing-library/react';
26+
import { MemoryRouter } from 'react-router-dom';
27+
import { MetadataCtx } from '@object-ui/react';
28+
29+
vi.mock('@object-ui/auth', async (importOriginal) => ({
30+
...(await importOriginal<Record<string, unknown>>()),
31+
useAuth: () => ({ user: { id: 'u1', name: 'Ada', image: null }, activeOrganization: null }),
32+
createAuthenticatedFetch: () => vi.fn(),
33+
}));
34+
vi.mock('@object-ui/collaboration', async (importOriginal) => ({
35+
...(await importOriginal<Record<string, unknown>>()),
36+
useRecordPresence: () => [],
37+
PresenceAvatars: () => null,
38+
}));
39+
vi.mock('sonner', () => ({
40+
toast: Object.assign(vi.fn(), {
41+
success: vi.fn(), error: vi.fn(), info: vi.fn(),
42+
warning: vi.fn(), loading: vi.fn(), dismiss: vi.fn(),
43+
}),
44+
}));
45+
// Orthogonal chrome, stubbed.
46+
vi.mock('./ActionConfirmDialog', () => ({ ActionConfirmDialog: () => null }));
47+
vi.mock('./ActionParamDialog', () => ({ ActionParamDialog: () => null }));
48+
vi.mock('./ActionResultDialog', () => ({ ActionResultDialog: () => null }));
49+
vi.mock('./FlowRunner', () => ({ FlowRunner: () => null }));
50+
vi.mock('./MetadataInspector', () => ({
51+
MetadataPanel: () => null,
52+
useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }),
53+
}));
54+
55+
import { RecordDetailView } from './RecordDetailView';
56+
57+
const OBJECT = 'os_27520_project';
58+
const REC = 'prj-1';
59+
60+
const objectDef = {
61+
name: OBJECT,
62+
label: 'Project',
63+
enable: { files: true },
64+
highlightFields: ['name'],
65+
fields: {
66+
id: { label: 'Id', type: 'text' },
67+
name: { label: 'Name', type: 'text' },
68+
owner_email: { label: 'Owner Email', type: 'text' },
69+
},
70+
};
71+
72+
const RECORD = {
73+
id: REC,
74+
name: 'Website Relaunch',
75+
owner_email: 'auditor@example.com',
76+
created_at: '2026-01-02T03:04:05.000Z',
77+
updated_at: '2026-02-03T04:05:06.000Z',
78+
};
79+
80+
/** An authored page that places no `record:attachments`, so the host appends the panel. */
81+
const ASSIGNED_PAGE = {
82+
name: 'os_27520_project_detail',
83+
label: 'Project',
84+
type: 'record',
85+
object: OBJECT,
86+
regions: [
87+
{
88+
name: 'main',
89+
components: [
90+
{ type: 'record:details', id: 'overview', properties: { sections: [{ label: 'Overview', fields: ['owner_email'] }] } },
91+
],
92+
},
93+
],
94+
};
95+
96+
function makeDataSource() {
97+
return {
98+
find: vi.fn(async () => ({ data: [], total: 0, hasMore: false, pageSize: 50 })),
99+
findOne: vi.fn(async (name: string, id: string) => (name === OBJECT ? { ...RECORD, id } : null)),
100+
create: vi.fn(async (_o: string, row: any) => row),
101+
update: vi.fn(async () => ({})),
102+
delete: vi.fn(async () => ({})),
103+
getObjectSchema: async (name: string) => ({ name, fields: objectDef.fields }),
104+
} as any;
105+
}
106+
107+
function makeMetadata(pages: any[]) {
108+
return {
109+
objects: [], pages, loading: false, error: null,
110+
refresh: async () => {}, invalidate: () => {},
111+
ensureType: async () => pages, getItem: async () => null,
112+
getItemsByType: () => pages,
113+
} as any;
114+
}
115+
116+
function renderRecordPage(pages: any[]): HTMLElement {
117+
const { container } = render(
118+
<MemoryRouter initialEntries={[`/app/demo/${OBJECT}/${REC}`]}>
119+
<MetadataCtx.Provider value={makeMetadata(pages)}>
120+
<RecordDetailView
121+
dataSource={makeDataSource()}
122+
objects={[objectDef]}
123+
onEdit={() => {}}
124+
objectNameOverride={OBJECT}
125+
recordIdOverride={REC}
126+
embedded
127+
/>
128+
</MetadataCtx.Provider>
129+
</MemoryRouter>,
130+
);
131+
return container;
132+
}
133+
134+
/** The page root's padding utilities, each as the horizontal inset an append must carry. */
135+
function pageInsetOf(root: ParentNode): string[] {
136+
const page = root.querySelector('[data-page-type="record"]');
137+
expect(page, 'the page renderer must draw the record page root').toBeTruthy();
138+
const padding = Array.from(page!.classList).filter((c) => /^(?:[a-z]+:)?p-\d+$/.test(c));
139+
// Control: the page does inset its body; an inset-free page would make
140+
// every assertion below vacuous.
141+
expect(padding.length).toBeGreaterThan(0);
142+
return padding.map((c) => c.replace(/p-(\d+)$/, 'px-$1'));
143+
}
144+
145+
beforeAll(() => {
146+
Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1280 });
147+
});
148+
149+
beforeEach(() => {
150+
cleanup();
151+
vi.stubGlobal('fetch', vi.fn(async () =>
152+
new Response(JSON.stringify({ data: [] }), {
153+
status: 200, headers: { 'content-type': 'application/json' },
154+
})));
155+
});
156+
157+
afterEach(() => { vi.unstubAllGlobals(); vi.clearAllMocks(); });
158+
159+
describe('record page appends line up with the page cards (objectstack#27520 row 14)', () => {
160+
it('the appended Attachments panel takes the page body inset', async () => {
161+
const container = renderRecordPage([ASSIGNED_PAGE]);
162+
await waitFor(() => expect(container.textContent).toContain('auditor@example.com'));
163+
const fallback = await waitFor(() => {
164+
const el = container.querySelector('[data-record-attachments-fallback]');
165+
expect(el, 'the host appends the Attachments panel for an authored page that omits it').toBeTruthy();
166+
return el as HTMLElement;
167+
});
168+
const inset = pageInsetOf(container);
169+
for (const cls of inset) expect(fallback.classList).toContain(cls);
170+
// It is an append, not part of the page tree.
171+
expect(container.querySelector('[data-page-type="record"]')!.contains(fallback)).toBe(false);
172+
});
173+
174+
it('the provenance footer takes the same inset', async () => {
175+
const container = renderRecordPage([ASSIGNED_PAGE]);
176+
const footer = await waitFor(() => {
177+
const el = container.querySelector('[data-testid="record-meta-footer"]');
178+
expect(el).toBeTruthy();
179+
return el as HTMLElement;
180+
});
181+
for (const cls of pageInsetOf(container)) expect(footer.classList).toContain(cls);
182+
});
183+
});

‎ui/packages/app-shell/src/views/RecordDetailView.tsx‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ interface RecordDetailViewProps {
113113

114114
const FALLBACK_USER = { id: 'current-user', name: 'Demo User' };
115115

116+
/**
117+
* The horizontal inset the `page` renderer gives a page's body
118+
* (`p-3 md:p-4 lg:p-6` in `@object-ui/components` `renderers/layout/page.tsx`).
119+
* The appends this host draws after a page it renders whole (the approvals and
120+
* attachments fallbacks and the provenance footer) sit beside that page, not
121+
* inside it, so they take the same inset; without it they drew wider than the
122+
* page's own cards (objectstack#27520 row 14).
123+
*/
124+
const RECORD_PAGE_APPEND_INSET = 'px-3 md:px-4 lg:px-6';
125+
116126
/**
117127
* `⌘⇧,` / `Ctrl+Shift+,` — show or hide the record page's right column, the
118128
* reader's ⊟ (objectstack#27052; objectstack#27524, Target 4). The record
@@ -4776,7 +4786,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
47764786
nothing when the record has no requests. */}
47774787
{pureRecordId && !hasApprovalsNode && (
47784788
<RecordApprovalsPanel
4779-
className="mt-6"
4789+
className={cn('mt-6', !pageColumns && RECORD_PAGE_APPEND_INSET)}
47804790
approvals={approvals}
47814791
currentUserId={user?.id}
47824792
/>
@@ -4789,7 +4799,11 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
47894799
(objectstack#4358), so this bottom append fires only for
47904800
authored pages that omit the panel. */}
47914801
{filesEnabled && !hasAttachments && pureRecordId && (
4792-
<div className="mt-6" ref={setAttachmentsFallbackEl} data-record-attachments-fallback="">
4802+
<div
4803+
className={cn('mt-6', !pageColumns && RECORD_PAGE_APPEND_INSET)}
4804+
ref={setAttachmentsFallbackEl}
4805+
data-record-attachments-fallback=""
4806+
>
47934807
<RecordAttachmentsPanel
47944808
objectName={objectName!}
47954809
recordId={pureRecordId}
@@ -4814,6 +4828,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
48144828
{!pageColumns && (
48154829
<DefaultRecordPageContext.Provider value={!assignedPage && !namedPageBlocked}>
48164830
<RecordMetaFooter
4831+
className={RECORD_PAGE_APPEND_INSET}
48174832
data={readablePageRecord}
48184833
objectSchema={objectDef}
48194834
objectName={objectName}

‎ui/packages/plugin-detail/src/DetailSection.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,12 @@ export const DetailSection: React.FC<DetailSectionProps> = ({
654654
value={value}
655655
field={enrichedField as unknown as FieldMetadata}
656656
deadlineSettled={isDeadlineSettled(enrichedField, data, { scope: predicateScope, fields: objectSchema?.fields })}
657+
// A record page writes every date one way. The highlights strip
658+
// above writes the year on a current-year date (objectui#13331),
659+
// so a section row does too: "Dec 31, 2026" in the strip beside
660+
// "Oct 2" in a section was two formats on one page. Grid cells
661+
// keep the shared face that drops it.
662+
alwaysShowYear
657663
/>
658664
);
659665
}

‎ui/packages/plugin-detail/src/RecordActivityTimeline.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ export const RecordActivityTimeline: React.FC<RecordActivityTimelineProps> = ({
621621
item={item}
622622
onEditComment={onEditComment}
623623
onDeleteComment={onDeleteComment}
624-
bodyClassName="text-sm whitespace-pre-wrap break-words text-muted-foreground"
624+
// The body is what the author wrote, so it reads in the
625+
// foreground colour, as a reply's body does; the muted grey
626+
// belongs to the meta line above it (objectstack#27520 row 14).
627+
bodyClassName="text-sm whitespace-pre-wrap break-words text-foreground"
625628
/>
626629

627630
{/* Drill to source rich entity (ADR-0052 ActivityPointer) */}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* A record page writes every date one way (objectstack#27520 row 14).
11+
*
12+
* The sighting was a project record whose highlights strip read
13+
* "End Date Dec 31, 2026" while a section below read "Start Date Oct 2": the
14+
* strip writes the year on every date (objectui#13331) and the section row
15+
* used the shared face that drops the current year. A section row now passes
16+
* the same `alwaysShowYear`, so both read with the year. A grid cell keeps the
17+
* face that drops it.
18+
*
19+
* The clock is pinned, so "the current year" is 2026 and every date is
20+
* outside the relative window.
21+
*/
22+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
23+
import { render, screen, cleanup } from '@testing-library/react';
24+
import * as React from 'react';
25+
import type { DateFieldMetadata, DetailViewSection, HighlightField } from '@object-ui/types';
26+
import { getCellRenderer } from '@object-ui/fields';
27+
import { DetailSection } from '../DetailSection';
28+
import { HeaderHighlight } from '../HeaderHighlight';
29+
30+
const CLOCK = '2026-11-01T12:00:00.000Z';
31+
32+
beforeEach(() => {
33+
vi.useFakeTimers({ toFake: ['Date'] });
34+
vi.setSystemTime(new Date(CLOCK));
35+
});
36+
37+
afterEach(() => {
38+
cleanup();
39+
vi.useRealTimers();
40+
});
41+
42+
const objectSchema = {
43+
fields: {
44+
start_date: { name: 'start_date', type: 'date', label: 'Start Date' },
45+
end_date: { name: 'end_date', type: 'date', label: 'End Date' },
46+
kickoff_at: { name: 'kickoff_at', type: 'datetime', label: 'Kickoff', format: 'relative' },
47+
},
48+
};
49+
50+
const data = { start_date: '2026-10-02', end_date: '2026-12-31', kickoff_at: '2026-09-29T12:00:00.000Z' };
51+
52+
const section = {
53+
title: 'Timeline',
54+
fields: [
55+
{ name: 'start_date', label: 'Start Date', type: 'date' },
56+
{ name: 'kickoff_at', label: 'Kickoff', type: 'datetime', format: 'relative' },
57+
],
58+
} as unknown as DetailViewSection;
59+
60+
describe('one date format on a record page (objectstack#27520 row 14)', () => {
61+
it('a section row writes the year on a current-year date', () => {
62+
render(<DetailSection section={section} data={data} objectSchema={objectSchema} />);
63+
expect(screen.getByText('Oct 2, 2026')).toBeTruthy();
64+
expect(screen.queryByText('Oct 2')).toBeNull();
65+
// A `relative` datetime past the relative window falls back to the same face.
66+
expect(screen.getByText('Sep 29, 2026')).toBeTruthy();
67+
});
68+
69+
it('the section and the highlights strip draw a current-year date alike', () => {
70+
render(
71+
<>
72+
<HeaderHighlight
73+
fields={[{ name: 'end_date', label: 'End Date' }] satisfies HighlightField[]}
74+
data={data}
75+
objectSchema={objectSchema}
76+
/>
77+
<DetailSection
78+
section={{ title: 'Timeline', fields: [{ name: 'end_date', label: 'End Date', type: 'date' }] } as unknown as DetailViewSection}
79+
data={data}
80+
objectSchema={objectSchema}
81+
/>
82+
</>,
83+
);
84+
expect(screen.getAllByText('Dec 31, 2026')).toHaveLength(2);
85+
});
86+
87+
it('CONTROL: a grid cell keeps the face that drops the current year', () => {
88+
const DateCell = getCellRenderer('date');
89+
const field: DateFieldMetadata = { name: 'start_date', label: 'Start Date', type: 'date' };
90+
render(<DateCell value="2026-10-02" field={field} />);
91+
expect(screen.getByText('Oct 2')).toBeTruthy();
92+
});
93+
});

0 commit comments

Comments
 (0)