Skip to content

Commit 7f73108

Browse files
committed
Merge origin/main into claude/project-thread-th73j6
Claude-Session: https://claude.ai/code/session_01ADHkmR92m7ZN6cUVQTj1VE Co-authored-by: Claude <noreply@anthropic.com>
2 parents cdcb553 + e8cba8f commit 7f73108

11 files changed

Lines changed: 364 additions & 16 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
---
4+
5+
fix(plugin-detail): a `record:activity` whose `types` leaves out `comment` no longer offers a comment composer whose posts it then hides
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`types` is the list of feed item kinds the block shows, and `comment` is one of them. A block authored with a list that leaves it out, such as `types: ['task']`, filters every comment out of its feed, including a comment posted on that same block. It still drew the "Leave a comment" composer and the "Comments only" filter, so a member's comment was saved and then never appeared.
11+
12+
Such a block now draws no composer and no "Comments only" option. In development it logs one warning per block that names the block, its `types` and the two fixes:
13+
14+
- to take comments on the block, add `'comment'` to `types`;
15+
- to keep the block activity-only, set `showCommentInput: false`.
16+
17+
A block with no `types`, or with a `types` that includes `'comment'`, is unchanged.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/console': patch
3+
---
4+
5+
fix(console): the public form prints a form entry's own label as served, not the app bundle's object-field translation
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A form entry that declares its own `label` is the form's visitor-facing copy, and the form endpoint already serves it localized (from `_sections.SECTION.fields.FIELD.label` in the app's translations). The public form page then looked the field up in the app bundle as `fields.OBJECT.FIELD` first and printed that whenever the browser held the bundle, which translates the object field's label, the one agents see. So a visitor who was signed in to the same console, or any visit with the bundle loaded, read the agent-side label (for example "Submitter name" where the form says "Your name"), while a cold anonymous visit read the form's own label.
11+
12+
Each row now records where its label came from. A row whose entry declared a `label` prints it as served; only a row whose label came from the object field takes the bundle translation, as before. The required-field and `visibleWhen` refusal messages name each field by the same rule, so they use the label the visitor sees.

‎ui/apps/console/src/components/FormPage.omitBlanksRebind.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function row(name: string, defaultValue?: unknown): Row {
5959
return {
6060
name,
6161
label: name,
62+
labelSource: 'object',
6263
type: 'text',
6364
required: false,
6465
readonly: false,

‎ui/apps/console/src/components/FormPage.optionDefault-13049.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ describe('objectui#13049 — `readPrefill` keeps the stored record first', () =>
205205
const field = {
206206
name: 'priority',
207207
label: 'Priority',
208+
labelSource: 'object' as const,
208209
type: 'select',
209210
required: true,
210211
readonly: false,

‎ui/apps/console/src/components/FormPage.sectionLabelI18n.test.tsx‎

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
8181
import { render, screen, waitFor, cleanup } from '@testing-library/react';
8282
import { MemoryRouter, Route, Routes } from 'react-router-dom';
8383
import { createI18n } from '@object-ui/i18n';
84+
import userEvent from '@testing-library/user-event';
85+
import { toast } from 'sonner';
8486
import { FormPage } from './FormPage';
8587

8688
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
@@ -119,6 +121,17 @@ const NAMELESS_AUTHORED = 'Attachments';
119121
*/
120122
const DECOY = '⛔ keyed by the authored label';
121123

124+
/**
125+
* The entry-label fixture's two object fields: what the object declares, and
126+
* what the app bundle translates that OBJECT label to — the agent-side copy.
127+
*/
128+
const AGENT_NAME_AUTHORED = 'Submitter name';
129+
const AGENT_NAME_TRANSLATED = '提交人姓名';
130+
const AGENT_EMAIL_AUTHORED = 'Submitter email';
131+
const AGENT_EMAIL_TRANSLATED = '提交人邮箱';
132+
/** The form ENTRY's own label, as the form endpoint serves it (already localized). */
133+
const ENTRY_NAME_SERVED = '您的姓名';
134+
122135
const BUNDLE = {
123136
[NS]: {
124137
objects: {
@@ -132,6 +145,10 @@ const BUNDLE = {
132145
fields: {
133146
[API_NAME]: {
134147
full_name: FIELD_TRANSLATED,
148+
// The OBJECT fields' agent-side translations — see the entry-label
149+
// describe below. No entry in this file's first fixture names them.
150+
supplied_name: AGENT_NAME_TRANSLATED,
151+
supplied_email: AGENT_EMAIL_TRANSLATED,
135152
},
136153
},
137154
},
@@ -195,8 +212,8 @@ function stubFetch(body: unknown) {
195212
* around it would move this file off the route and onto a harness — see the
196213
* header.
197214
*/
198-
function renderPublicRoute() {
199-
vi.stubGlobal('fetch', stubFetch(SERVED));
215+
function renderPublicRoute(served: unknown = SERVED) {
216+
vi.stubGlobal('fetch', stubFetch(served));
200217
return render(
201218
<MemoryRouter initialEntries={['/f/apply']}>
202219
<Routes>
@@ -331,3 +348,94 @@ describe('objectui#8813 — public form i18n on the /f/:slug route', () => {
331348
await expect(liveSections()).rejects.toThrow();
332349
});
333350
});
351+
352+
/**
353+
* A form ENTRY that declares its own `label` is the form's visitor-facing copy,
354+
* served already localized by the form endpoint
355+
* (`_sections.{section}.fields.{field}.label`). The bundle's
356+
* `fields.{object}.{field}` translates a different text — the OBJECT field's,
357+
* the agent-side label — so it may only overlay a row whose label came from
358+
* the object field. Every leg asserts both strings, so an overlay that wins
359+
* and an entry label that wins can never read alike.
360+
*/
361+
describe('a form entry\'s own label wins over the bundle\'s object-field translation', () => {
362+
const ENTRY_FORM = {
363+
type: 'simple',
364+
columns: 1,
365+
title: 'Support',
366+
sections: [
367+
{
368+
name: 'how_can_we_help',
369+
fields: [
370+
// Entry-declared label — printed as served.
371+
{ field: 'supplied_name', label: ENTRY_NAME_SERVED, required: true },
372+
// No entry label — the object field's label, and its bundle overlay.
373+
{ field: 'supplied_email', required: true },
374+
],
375+
},
376+
],
377+
};
378+
const ENTRY_SERVED = {
379+
slug: 'apply',
380+
object: API_NAME,
381+
form: ENTRY_FORM,
382+
objectSchema: {
383+
name: API_NAME,
384+
label: 'Inquiry',
385+
fields: {
386+
supplied_name: { type: 'text', label: AGENT_NAME_AUTHORED },
387+
supplied_email: { type: 'text', label: AGENT_EMAIL_AUTHORED },
388+
},
389+
},
390+
};
391+
392+
/** The two row labels, in order, once the form has drawn both. */
393+
async function rowLabels(): Promise<string[]> {
394+
await waitFor(() => expect(document.body.querySelectorAll('form label').length).toBe(2));
395+
return Array.from(document.body.querySelectorAll('form label')).map(
396+
// The visual-only required `*` sits inside the label.
397+
(l) => (l.textContent ?? '').replace(/\*$/, ''),
398+
);
399+
}
400+
401+
it('ENTRY_LABEL_RENDERS_AS_SERVED — the entry label, not the object field\'s translation', async () => {
402+
renderPublicRoute(ENTRY_SERVED);
403+
const [name] = await rowLabels();
404+
405+
expect(name).toBe(ENTRY_NAME_SERVED);
406+
expect(document.body.textContent).not.toContain(AGENT_NAME_TRANSLATED);
407+
expect(screen.getByLabelText(new RegExp(ENTRY_NAME_SERVED))).toBeInTheDocument();
408+
});
409+
410+
it('CONTROL OBJECT_LABEL_TAKES_THE_BUNDLE — a row with no entry label still reads the translation', async () => {
411+
renderPublicRoute(ENTRY_SERVED);
412+
const [, email] = await rowLabels();
413+
414+
expect(email).toBe(AGENT_EMAIL_TRANSLATED);
415+
expect(document.body.textContent).not.toContain(AGENT_EMAIL_AUTHORED);
416+
});
417+
418+
it('REQUIRED_REFUSAL_NAMES_THE_VISIBLE_LABELS — the entry label, and the overlay for the object row', async () => {
419+
renderPublicRoute(ENTRY_SERVED);
420+
await rowLabels();
421+
await userEvent.click(document.body.querySelector('button[type="submit"]') as HTMLButtonElement);
422+
423+
// The banner/toast frame names every refused row by the label on screen.
424+
await waitFor(() => expect(vi.mocked(toast.error)).toHaveBeenCalled());
425+
const calls = vi.mocked(toast.error).mock.calls;
426+
const msg = String(calls[calls.length - 1]?.[0]);
427+
expect(msg).toContain(ENTRY_NAME_SERVED);
428+
expect(msg).not.toContain(AGENT_NAME_TRANSLATED);
429+
expect(msg).toContain(AGENT_EMAIL_TRANSLATED);
430+
431+
// The per-row message the name input points at says the same.
432+
const input = screen.getByLabelText(new RegExp(ENTRY_NAME_SERVED));
433+
await waitFor(() => expect(input.getAttribute('aria-describedby')).toBeTruthy());
434+
const rowMsg = (input.getAttribute('aria-describedby') ?? '')
435+
.split(/\s+/)
436+
.map((id) => document.getElementById(id)?.textContent ?? '')
437+
.join(' ');
438+
expect(rowMsg).toContain(ENTRY_NAME_SERVED);
439+
expect(rowMsg).not.toContain(AGENT_NAME_TRANSLATED);
440+
});
441+
});

‎ui/apps/console/src/components/FormPage.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ describe('buildSections', () => {
224224

225225
describe('readPrefill', () => {
226226
const fields = [
227-
{ name: 'first_name', label: 'First name', type: 'text', required: false, readonly: false, hidden: false, colSpan: 1 as const },
228-
{ name: 'company', label: 'Company', type: 'text', required: false, readonly: false, hidden: false, colSpan: 1 as const, defaultValue: 'Acme' },
229-
{ name: 'phone', label: 'Phone', type: 'text', required: false, readonly: false, hidden: false, colSpan: 1 as const },
227+
{ name: 'first_name', label: 'First name', labelSource: 'object' as const, type: 'text', required: false, readonly: false, hidden: false, colSpan: 1 as const },
228+
{ name: 'company', label: 'Company', labelSource: 'object' as const, type: 'text', required: false, readonly: false, hidden: false, colSpan: 1 as const, defaultValue: 'Acme' },
229+
{ name: 'phone', label: 'Phone', labelSource: 'object' as const, type: 'text', required: false, readonly: false, hidden: false, colSpan: 1 as const },
230230
];
231231

232232
it('applies defaultValue from the field definition', () => {
@@ -327,6 +327,7 @@ describe('readPrefill', () => {
327327
{
328328
name: 'remind_at',
329329
label: 'Remind at',
330+
labelSource: 'object' as const,
330331
type: 'datetime',
331332
required: false,
332333
readonly: false,

‎ui/apps/console/src/components/FormPage.tsx‎

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,20 @@ type EffectiveSubmitBehavior = SubmitBehavior | { kind: 'created-record' };
496496
interface RenderableField {
497497
name: string;
498498
label: string;
499+
/**
500+
* Where {@link RenderableField.label} came from, decided where the row is
501+
* built and never re-guessed from the string: `'entry'` when the form
502+
* view's field entry declared its own `label`, `'object'` when the row fell
503+
* back to the object field's label (or its name).
504+
*
505+
* The two are different texts. An entry label is the visitor-facing copy
506+
* the author wrote for THIS form, served already localized by the form
507+
* endpoint (`_sections.{section}.fields.{field}.label`); the app bundle's
508+
* `fields.{object}.{field}` translates the OBJECT field, the agent-side
509+
* label. So only an `'object'` row takes the bundle overlay — see
510+
* `rowLabel` in {@link FormPage}.
511+
*/
512+
labelSource: 'entry' | 'object';
499513
type: string;
500514
required: boolean;
501515
readonly: boolean;
@@ -853,6 +867,10 @@ export function buildSections(
853867
// objectui#13380 — the three `I18nLabel` keys, collapsed to the
854868
// visitor's language before they reach a `string` slot.
855869
label: localized(override.label ?? def.label) ?? override.field,
870+
// The same `??` as the line above, read once more for its branch: an
871+
// entry that declared a label is the visitor's copy, never overlaid
872+
// by the object field's bundle translation at render.
873+
labelSource: override.label != null ? 'entry' : 'object',
856874
type: def.type ?? 'text',
857875
required: override.required ?? def.required ?? false,
858876
readonly: override.readonly ?? false,
@@ -2529,6 +2547,19 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
25292547
* and NO in the same position with the wrapper removed.
25302548
*/
25312549
const { sectionLabel, fieldLabel, objectLabel } = useSafeFieldLabel();
2550+
/**
2551+
* The label a row is NAMED by, on screen and in every refusal that names
2552+
* it — one rule for all of them, so a message never calls a field something
2553+
* the visitor cannot see.
2554+
*
2555+
* An entry-declared label (`labelSource: 'entry'`) is printed as served: it
2556+
* is this form's own copy, already localized by the form endpoint, and the
2557+
* bundle's `fields.{object}.{field}` translates a different text — the
2558+
* object field's. Only a row whose label came from the object field takes
2559+
* that overlay, falling back to the served label on a miss.
2560+
*/
2561+
const rowLabel = (object: string, f: Pick<RenderableField, 'name' | 'label' | 'labelSource'>): string =>
2562+
f.labelSource === 'entry' ? f.label : fieldLabel(object, f.name, f.label);
25322563
// The page's own chrome — the loading line, the success toast, the
25332564
// thank-you panel's defaults, and (objectui#11071) the submit button, the
25342565
// pending-redirect line and the required refusal's frame — through the same
@@ -2817,7 +2848,7 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
28172848
if (faultedVisibleWhen.length > 0) {
28182849
const msg = t('form.visibleWhenFaulted', {
28192850
fields: faultedVisibleWhen
2820-
.map((f) => fieldLabel(object, f.name, f.label))
2851+
.map((f) => rowLabel(object, f))
28212852
.join(t('validation.formInvalidJoiner')),
28222853
});
28232854
setError(msg);
@@ -2835,15 +2866,15 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
28352866
// the words are the locale's, not a concatenation of English.
28362867
const msg = t('publicForm.requiredFields', {
28372868
fields: missing
2838-
.map((f) => fieldLabel(object, f.name, f.label))
2869+
.map((f) => rowLabel(object, f))
28392870
.join(t('validation.formInvalidJoiner')),
28402871
});
28412872
setError(msg);
28422873
toast.error(msg, { id: outcomeToastId });
28432874
// The record form's message for an empty required field, per row.
28442875
setFieldErrors(Object.fromEntries(missing.map((f) => [
28452876
f.name,
2846-
t('validation.required', { field: fieldLabel(object, f.name, f.label) }),
2877+
t('validation.required', { field: rowLabel(object, f) }),
28472878
])));
28482879
return true;
28492880
}
@@ -3297,9 +3328,11 @@ export function FormPage({ mode, recordPath, cancelPath }: FormPageProps) {
32973328
* payload, which is why the symptom looked like "field
32983329
* labels translate, section headings do not"; the client
32993330
* lookup is the overlay an app bundle can put on top,
3300-
* not a replacement for that server value.
3331+
* not a replacement for that server value — and only for
3332+
* a row whose label IS the object field's (`rowLabel`):
3333+
* an entry-declared label is printed as served.
33013334
*/}
3302-
{fieldLabel(loaded.object, f.name, f.label)}
3335+
{rowLabel(loaded.object, f)}
33033336
{/* Visual-only (objectui#3299): the control's `required` /
33043337
`aria-required` is the announced channel; hiding the `*`
33053338
keeps it out of the control's accessible name. */}

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ export interface RecordActivityTimelineProps {
9797
* the failure is the host's job.
9898
*/
9999
onAddComment?: (text: string, attachments?: Attachment[]) => void | Promise<void>;
100+
/**
101+
* Whether the feed this timeline draws can show a comment at all
102+
* (objectstack#34371). `false` — a `types` allow-list that leaves out
103+
* `comment` — withdraws the comment composer and the Comments-only filter, so
104+
* the timeline never offers a post it would then filter out of view. Absent
105+
* means `true`.
106+
*/
107+
commentsShown?: boolean;
100108
/** Called when a reply is submitted — a rejection keeps the reply draft, as above. */
101109
onAddReply?: (parentId: string | number, text: string) => void | Promise<void>;
102110
/** Called when user toggles a reaction */
@@ -225,16 +233,19 @@ const FEED_TYPE_COLORS: Record<FeedItemType, string> = {
225233
* The dropdown's options, given whether the record's field history is shown
226234
* (`RecordFieldHistoryContext`): `changes_only` is offered exactly when the
227235
* stream offers its 变更 chip — the one rule, `timelineStreamFilters`
228-
* (objectstack#30074, objectstack#30344).
236+
* (objectstack#30074, objectstack#30344). `comments_only` is offered exactly
237+
* when the feed can show a comment (`commentsShown`, objectstack#34371).
229238
*/
230239
function getFilterOptions(
231240
t: (key: string) => string,
232241
fieldHistory: boolean,
242+
commentsShown: boolean,
233243
): { value: FeedFilterMode; label: string }[] {
234244
const changesOffered = timelineStreamFilters(fieldHistory).includes('changes');
235245
return [
236246
{ value: 'all', label: t('detail.allActivity') },
237-
{ value: 'comments_only', label: t('detail.commentsOnly') },
247+
// A feed that cannot show a comment offers no filter for them (objectstack#34371).
248+
...(commentsShown ? [{ value: 'comments_only' as const, label: t('detail.commentsOnly') }] : []),
238249
...(changesOffered ? [{ value: 'changes_only' as const, label: t('detail.fieldChangesFilter') }] : []),
239250
{ value: 'tasks_only', label: t('detail.tasksOnly') },
240251
];
@@ -343,6 +354,7 @@ export const RecordActivityTimeline: React.FC<RecordActivityTimelineProps> = ({
343354
onLoadMore,
344355
loading = false,
345356
onAddComment,
357+
commentsShown = true,
346358
onAddReply,
347359
onToggleReaction,
348360
onEditComment,
@@ -478,11 +490,11 @@ export const RecordActivityTimeline: React.FC<RecordActivityTimelineProps> = ({
478490

479491
// A filter the dropdown does not offer filters nothing: it reads as `all`,
480492
// as the stream's chips do.
481-
const filterOptions = getFilterOptions(t, React.useContext(RecordFieldHistoryContext));
493+
const filterOptions = getFilterOptions(t, React.useContext(RecordFieldHistoryContext), commentsShown);
482494
const chosenFilter = controlledFilter ?? internalFilter;
483495
const activeFilter: FeedFilterMode = filterOptions.some((opt) => opt.value === chosenFilter) ? chosenFilter : 'all';
484496
const showFilter = config?.showFilterToggle !== false;
485-
const showCommentInput = config?.showCommentInput !== false && !!onAddComment;
497+
const showCommentInput = config?.showCommentInput !== false && !!onAddComment && commentsShown;
486498
const enableReactions = config?.enableReactions ?? false;
487499
const enableThreading = config?.enableThreading ?? false;
488500
const showSubscription = config?.showSubscriptionToggle ?? false;

0 commit comments

Comments
 (0)