Skip to content
Merged
20 changes: 20 additions & 0 deletions .changeset/36070-comment-small-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@object-ui/plugin-detail': patch
'@object-ui/fields': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

fix(comments): Reply puts the caret in the reply box, comments show the author's avatar or initials, the mention menu opens at the caret, and a delete says it went through

Clause-②: yes (widening)
Metadata-protocol: none

Four small fixes to comments on the record page:

- **Reply.** Pressing Reply on a comment opened the reply box but left focus on the button, so typing went nowhere (or into the main comment box). The caret now goes into the reply box. On a comment whose replies were collapsed, Reply also expands them first.
- **Author avatar.** A comment by someone without an avatar showed a generic comment icon. Every comment and reply now leads with a 20 px avatar: the author's image, or their initials on the same round disc the people chips draw.
- **Mention menu.** Typing `@` opened the people menu at the top left of the comment box. It now opens under the caret, or above it when the window has no room below.
- **Delete.** Deleting a comment now shows a "Comment deleted" toast (zh: 评论已删除). A refused delete still shows its error, as before.

Additions, nothing removed or changed in meaning: `@object-ui/plugin-detail` exports `CommentAuthorAvatar` (and its props type), and `ThreadedReplies` takes a new optional `focusReplyOnOpen` prop (default `false`, so a host that always shows the reply box keeps today's focus behaviour). `@object-ui/fields` exports `getPersonInitials`. New locale key `detail.commentDeleted` in all eleven locale packs.
14 changes: 13 additions & 1 deletion content/docs/frontend/plugins/plugin-detail.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The Feed & Chatter system provides Airtable-style record-level collaboration. It
| `FieldChangeItem` | Field change history display (old → new values) |
| `ReactionPicker` | Emoji reaction selector |
| `ThreadedReplies` | Collapsible reply threading |
| `CommentAuthorAvatar` | 20 px author avatar in front of a comment or reply: the image, or the person chips' initials disc |
| `SubscriptionToggle` | Bell notification toggle |

## Usage
Expand Down Expand Up @@ -569,11 +570,22 @@ decision as a defect is how a warning channel gets ignored:
| `parentItem` | `FeedItem` | required | Parent comment item |
| `replies` | `FeedItem[]` | required | Reply items |
| `onAddReply` | `(parentId, text) => void` | — | Add reply callback |
| `showReplyInput` | `boolean` | `false` | Show reply input |
| `showReplyInput` | `boolean` | `true` | Show reply input |
| `focusReplyOnOpen` | `boolean` | `false` | Each time the input opens, expand the replies and put the caret in the input. Pass it when the input opens behind your own Reply button; leave it off when the input always shows, or every thread takes focus on mount |
| `onEditComment` | `(itemId, text) => void \| Promise<void>` | — | Edit on a reply whose `authoredByViewer` is `true` |
| `onDeleteComment` | `(itemId) => void \| Promise<void>` | — | Delete on the same replies |
| `className` | `string` | `''` | Additional CSS classes |

### CommentAuthorAvatar

| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `name` | `string` | required | Author display name; the initials come from it (`getPersonInitials` of `@object-ui/fields`) |
| `avatarUrl` | `string` | — | Author image; without one, or when it fails to load, the initials disc shows |
| `className` | `string` | — | Additional CSS classes |

`RecordActivityTimeline` draws it in front of every comment and every reply. In `RichTextCommentInput`, typing `@` opens the mention menu under the caret, or above it when the window has no room below.

### SubscriptionToggle

| Property | Type | Default | Description |
Expand Down
2 changes: 1 addition & 1 deletion ui/e2e/narrow-drawer-time-34614.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const CLS = {
metaDot: grab(META, /data-record-meta-when="">\s*\{user \? <span className="([^"]+)">·<\/span>/, ['text-muted-foreground/40']),
metaTime: grab(META, /<time\s+dateTime=\{[^}]+\}\s+className="([^"]+)"/, ['cursor-default']),
feedRow: grab(FEED, /<div key=\{item\.id\} className="group" data-stream-comment-row="">\s*<div className="([^"]+)">/, ['flex', 'gap-2']),
feedIcon: grab(FEED, /const STREAM_ICON_CELL =\s*'([^']+)'/, ['shrink-0', 'w-3.5']),
feedIcon: grab(FEED, /const COMMENT_AVATAR_CELL =\s*'([^']+)'/, ['shrink-0', 'w-5']),
feedContent: grab(FEED, /\{\/\* Content[^*]*\*\/\}\s*<div className="([^"]+)">/, ['flex-1', 'min-w-0']),
feedHeader: grab(FEED, /const STREAM_COMMENT_HEADER =\s*'([^']+)'/, ['flex', 'flex-wrap', 'items-center']),
feedActor: grab(FEED, /<span className="([^"]+)">\{item\.actor\}<\/span>\s*\{item\.source/, ['font-medium']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,10 @@ describe('an authored record:activity with enableThreading shows a stored reply

it('a read with a parent and one child shows the child under the parent, not as a row of its own', async () => {
const { view } = await mount([PARENT, CHILD, LONE], { perms: answer(CREATE_ONLY) });
const parentRow = rootRowOf(view, PARENT_BODY);
// Collapsed until asked.
expect(view.queryByText(CHILD_BODY)).toBeNull();
fireEvent.click(within(parentRow).getByRole('button', { name: /1 reply/ }));
// `rootRowOf` presses 「回复」, which expands the replies first (objectstack#36070).
const parentRow = rootRowOf(view, PARENT_BODY);
expect(within(parentRow).getByText(CHILD_BODY)).toBeInTheDocument();
expect(replyToggles(view)).toHaveLength(1);
});
Expand Down Expand Up @@ -321,7 +322,8 @@ describe('an authored record:activity with enableThreading offers the reply inpu
expect(dataSource.create).toHaveBeenCalledTimes(1);
expect(dataSource.create.mock.calls[0][0]).toBe(COMMENT);
expect(dataSource.create.mock.calls[0][1]).toMatchObject({ thread_id: THREAD, parent_id: 'c-lone', body: NEW_REPLY });
fireEvent.click(within(loneRow).getByRole('button', { name: /1 reply/ }));
// The reply opened behind 「回复」 expanded the thread (objectstack#36070).
expect(within(loneRow).getByRole('button', { name: /1 reply/ })).toBeInTheDocument();
expect(within(loneRow).getByText(NEW_REPLY)).toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type Pack = {
deleteCommentConfirm: string;
commentEditFailed: string;
commentDeleteFailed: string;
commentDeleted: string;
edited: string;
save: string;
cancel: string;
Expand Down Expand Up @@ -434,6 +435,7 @@ describe.each<Block>(['record:activity', 'record:discussion'])(
await waitFor(() => expect(screen.queryByRole('alertdialog')).toBeNull());
expect(dataSource.delete).not.toHaveBeenCalled();
expect(view.getByText(ADA_BODY)).toBeInTheDocument();
expect(toast.success).not.toHaveBeenCalledWith(EN.detail.commentDeleted);

fireEvent.click(deleteIn(rowOf(view, ADA_BODY))!);
dialog = await screen.findByRole('alertdialog');
Expand All @@ -446,6 +448,8 @@ describe.each<Block>(['record:activity', 'record:discussion'])(
await waitFor(() => expect(view.queryByText(ADA_BODY)).toBeNull());
expect(view.getByText(GRACE_BODY)).toBeInTheDocument();
expect(toast.error).not.toHaveBeenCalled();
// The delete says it went through (objectstack#36070).
expect(toast.success).toHaveBeenCalledWith(EN.detail.commentDeleted);
});

it("deleting the author's comment keeps another member's reply to it on the page, at once and after the feed is read again", async () => {
Expand Down Expand Up @@ -494,6 +498,7 @@ describe.each<Block>(['record:activity', 'record:discussion'])(
});
await waitFor(() => expect(toast.error).toHaveBeenCalledWith(EN.detail.commentDeleteFailed));
expect(view.getByText(ADA_BODY)).toBeInTheDocument();
expect(toast.success).not.toHaveBeenCalledWith(EN.detail.commentDeleted);
});
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,23 @@ afterEach(() => {
describe('a stored reply shows under its parent on the default record page (objectui#12144)', () => {
it('a read with a parent and one child shows the child under the parent, not as a row of its own', async () => {
const { view } = await mount([PARENT, CHILD]);
const parentRow = rootRowOf(view, PARENT_BODY);
// Collapsed until asked: the reply is not on screen yet, and not as a root row either.
expect(view.queryByText(CHILD_BODY)).toBeNull();
const toggle = within(parentRow).getByRole('button', { name: /1 reply/ });
fireEvent.click(toggle);
// `rootRowOf` presses 「回复」, which expands the replies first (objectstack#36070).
const parentRow = rootRowOf(view, PARENT_BODY);
expect(within(parentRow).getByText(CHILD_BODY)).toBeInTheDocument();
expect(replyToggles(view)).toHaveLength(1);
// The count toggle still folds them away.
fireEvent.click(within(parentRow).getByRole('button', { name: /1 reply/ }));
expect(view.queryByText(CHILD_BODY)).toBeNull();
});

it('the count is the children in the read: two stored replies read as two', async () => {
const second = { ...CHILD, id: 'c-child-2', body: 'Second stored reply', created_at: '2026-10-01T09:30:00.000Z' };
const { view } = await mount([PARENT, CHILD, second]);
const parentRow = rootRowOf(view, PARENT_BODY);
fireEvent.click(within(parentRow).getByRole('button', { name: /2 replies/ }));
// Expanded by 「回复」 (objectstack#36070); the toggle reads the count.
expect(within(parentRow).getByRole('button', { name: /2 replies/ })).toBeInTheDocument();
expect(within(parentRow).getByText(CHILD_BODY)).toBeInTheDocument();
expect(within(parentRow).getByText('Second stored reply')).toBeInTheDocument();
});
Expand Down Expand Up @@ -288,7 +291,9 @@ describe('a comment read from the server offers the reply input where the caller
expect(dataSource.create).toHaveBeenCalledTimes(1);
expect(dataSource.create.mock.calls[0][0]).toBe(COMMENT);
expect(dataSource.create.mock.calls[0][1]).toMatchObject({ thread_id: THREAD, parent_id: 'c-lone', body: NEW_REPLY });
fireEvent.click(within(loneRow).getByRole('button', { name: /1 reply/ }));
// The reply opened behind 「回复」 expanded the thread (objectstack#36070), so
// the new reply shows at once under its count.
expect(within(loneRow).getByRole('button', { name: /1 reply/ })).toBeInTheDocument();
expect(within(loneRow).getByText(NEW_REPLY)).toBeInTheDocument();
});

Expand Down
7 changes: 5 additions & 2 deletions ui/packages/app-shell/src/views/RecordDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3978,8 +3978,8 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
* It asks first, through the console's ordinary destructive-action confirm:
* this page's own `confirmHandler`, the `ActionConfirmDialog` the record's
* Delete opens, painted destructive. A cancel settles `false` and nothing is
* sent. The row leaves the panel only once the server has deleted it; a
* refused delete raises a localized error and leaves the row where it was.
* sent. The row leaves the panel only once the server has deleted it, with a
* "Comment deleted" toast (objectstack#36070); a refused delete raises a localized error and leaves the row where it was.
* A deleted reply takes one off its parent's `replyCount`, the count
* `handleAddReply` adds one to.
*/
Expand Down Expand Up @@ -4023,6 +4023,9 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri
: item,
),
}));
// The row is gone; say so, so the reader knows the delete went through
// and the comment did not just scroll away (objectstack#36070).
toast.success(t('detail.commentDeleted', { defaultValue: 'Comment deleted' }));
},
[dataSource, feedRecordKey, feedItemsByRecord, confirmHandler, t],
);
Expand Down
4 changes: 4 additions & 0 deletions ui/packages/fields/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5398,6 +5398,10 @@ export * from './widgets/BooleanField.js';
// highlights chip). `BooleanValueText` stays internal: its only caller is the
// lookup column renderer in this package.
export { useBooleanValueLabel, type BooleanValueLabel } from './widgets/booleanValueLabel.js';
// objectstack#36070 — the up-to-two-character initials a person chip draws
// when it has no avatar image (PersonRow, the people-field chips). Exported so
// `@object-ui/plugin-detail`'s comment author avatar draws the same initials.
export { getPersonInitials } from './widgets/personDisplay.js';
export * from './widgets/SelectField.js';
export * from './widgets/DateField.js';
export * from './widgets/DateTimeField.js';
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,7 @@ const ar = {
deleteCommentConfirm: "هل أنت متأكد أنك تريد حذف هذا التعليق؟",
commentEditFailed: "لم يُحفظ تعديلك. يحتفظ التعليق بنصه السابق.",
commentDeleteFailed: "لم يُحذف التعليق. يُرجى المحاولة مرة أخرى.",
commentDeleted: "تم حذف التعليق",
mentionsWithheld: "لن يُرسَل إشعار بهذا التعليق إلى {{names}}.",
linkCopyFailed: "فشل نسخ الرابط",
claim: "استلام",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,7 @@ const de = {
deleteCommentConfirm: "Möchten Sie diesen Kommentar wirklich löschen?",
commentEditFailed: "Ihre Änderung wurde nicht gespeichert. Der Kommentar behält seinen bisherigen Text.",
commentDeleteFailed: "Der Kommentar wurde nicht gelöscht. Bitte versuchen Sie es erneut.",
commentDeleted: "Kommentar gelöscht",
mentionsWithheld: "Über diesen Kommentar wird keine Benachrichtigung an {{names}} gesendet.",
linkCopyFailed: "Link konnte nicht kopiert werden",
claim: "Übernehmen",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,7 @@ const en = {
deleteCommentConfirm: 'Are you sure you want to delete this comment?',
commentEditFailed: 'Your edit was not saved. The comment keeps its previous text.',
commentDeleteFailed: 'The comment was not deleted. Please try again.',
commentDeleted: 'Comment deleted',
// objectstack#28218 — a comment write whose answer names mentioned users the
// server will not notify (`withheldMentions`): one sentence naming them, no reason.
mentionsWithheld: '{{names}} will not be notified of this comment.',
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ const es = {
deleteCommentConfirm: "¿Está seguro de que desea eliminar este comentario?",
commentEditFailed: "Tu edición no se ha guardado. El comentario conserva su texto anterior.",
commentDeleteFailed: "El comentario no se ha eliminado. Inténtalo de nuevo.",
commentDeleted: "Comentario eliminado",
mentionsWithheld: "No se enviará ninguna notificación de este comentario a {{names}}.",
linkCopyFailed: "No se pudo copiar el enlace",
claim: "Reclamar",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ const fr = {
deleteCommentConfirm: "Êtes-vous sûr de vouloir supprimer ce commentaire ?",
commentEditFailed: "Votre modification n'a pas été enregistrée. Le commentaire conserve son texte précédent.",
commentDeleteFailed: "Le commentaire n'a pas été supprimé. Veuillez réessayer.",
commentDeleted: "Commentaire supprimé",
mentionsWithheld: "Aucune notification de ce commentaire ne sera envoyée à {{names}}.",
linkCopyFailed: "Impossible de copier le lien",
claim: "Prendre en charge",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@ const ja = {
deleteCommentConfirm: "このコメントを削除してもよろしいですか?",
commentEditFailed: "編集内容は保存されませんでした。コメントは以前の内容のままです。",
commentDeleteFailed: "コメントは削除されませんでした。もう一度お試しください。",
commentDeleted: "コメントを削除しました",
mentionsWithheld: "{{names}} にはこのコメントの通知が届きません。",
linkCopyFailed: "リンクのコピーに失敗しました",
claim: "担当する",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,7 @@ const ko = {
deleteCommentConfirm: "이 댓글을 삭제하시겠습니까?",
commentEditFailed: "수정 내용이 저장되지 않았습니다. 댓글은 이전 내용을 유지합니다.",
commentDeleteFailed: "댓글이 삭제되지 않았습니다. 다시 시도해 주세요.",
commentDeleted: "댓글이 삭제되었습니다",
mentionsWithheld: "{{names}}에게는 이 댓글의 알림이 전송되지 않습니다.",
linkCopyFailed: "링크 복사 실패",
claim: "담당하기",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ const pt = {
deleteCommentConfirm: "Tem certeza de que deseja excluir este comentário?",
commentEditFailed: "Sua edição não foi salva. O comentário mantém o texto anterior.",
commentDeleteFailed: "O comentário não foi excluído. Tente novamente.",
commentDeleted: "Comentário excluído",
mentionsWithheld: "Nenhuma notificação deste comentário será enviada para {{names}}.",
linkCopyFailed: "Falha ao copiar o link",
claim: "Assumir",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,7 @@ const ru = {
deleteCommentConfirm: "Вы уверены, что хотите удалить этот комментарий?",
commentEditFailed: "Изменения не сохранены. Комментарий сохраняет прежний текст.",
commentDeleteFailed: "Комментарий не удалён. Попробуйте ещё раз.",
commentDeleted: "Комментарий удалён",
mentionsWithheld: "Уведомление об этом комментарии не будет отправлено: {{names}}.",
linkCopyFailed: "Не удалось скопировать ссылку",
claim: "Взять в работу",
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ const zh = {
deleteCommentConfirm: '确定要删除这条评论吗?',
commentEditFailed: '您的修改未保存,评论保留原有内容。',
commentDeleteFailed: '评论未删除,请重试。',
commentDeleted: '评论已删除',
mentionsWithheld: '{{names}} 不会收到这条评论的通知。',
linkCopyFailed: '复制链接失败',
claim: '认领',
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@ const zhHant = {
deleteCommentConfirm: '確定要刪除這條評論嗎?',
commentEditFailed: '您的修改未儲存,評論保留原有內容。',
commentDeleteFailed: '評論未刪除,請重試。',
commentDeleted: '評論已刪除',
mentionsWithheld: '{{names}} 不會收到這條評論的通知。',
linkCopyFailed: '複製連結失敗',
claim: '認領',
Expand Down
11 changes: 11 additions & 0 deletions ui/packages/plugin-detail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,17 @@ affordances (View, Edit, Delete) are not governed by this key.
}
```

### Comments: author avatar, reply focus, mention menu

Every comment and reply in `RecordActivityTimeline` leads with
`CommentAuthorAvatar`: the author's 20 px image, or their initials on the round
disc the person chips draw (`getPersonInitials` from `@object-ui/fields`).
`ThreadedReplies` takes `focusReplyOnOpen`: each time its reply input opens it
expands the replies and puts the caret in the input, so a host whose input opens
behind its own Reply button lets the reader type straight away. In
`RichTextCommentInput`, the `@` mention menu opens under the caret, or above it
when the window has no room below.

### InlineEditSaveBar & InlineFieldInput

The record-level inline-edit session (#2407): double-clicking a field (or its
Expand Down
Loading
Loading