Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/36193-recent-activity-card-no-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@object-ui/plugin-detail': patch
---

fix(plugin-detail): a slotted page's record:chatter on the 动态 tab lists the system history alone while the comment panel holds the comments

Clause-②: no
Metadata-protocol: none

- A page whose `discussion` slot holds `record:chatter` or `record:discussion` draws that block on the record page's 动态 tab. While the comment panel is offered beside the record, on the page or in the drawer (objectstack#36075), the block now draws the system entries alone, as the platform's own 动态 stream does there: no comment and no reply, no comment box, no Comments-only filter, a count without the comments, the 动态 heading instead of 「讨论」, and the activity empty line instead of 「暂无评论」. A refused or failed comment read is the panel's to report, not this block's.
- Not changed: the platform's own 动态 stream, the 动态 tab's label, a page an author composed whole, and the phone while it has no comment surface.
31 changes: 22 additions & 9 deletions ui/packages/plugin-detail/src/RecordChatterPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import * as React from 'react';
import { cn, Button } from '@object-ui/components';
import { MessageSquare, PanelRightOpen, PanelRightClose, X } from 'lucide-react';
import { Activity, MessageSquare, PanelRightOpen, PanelRightClose, X } from 'lucide-react';
import type { RecordChatterComponentProps, FeedItem, RecordSubscription } from '@object-ui/types';
import { RecordActivityTimeline } from './RecordActivityTimeline';
import type { FeedFilterMode } from './RecordActivityTimeline';
Expand Down Expand Up @@ -94,6 +94,13 @@ export interface RecordChatterPanelProps {
commentsFailed?: boolean;
/** Read the failed feed reads again; forwarded to the timeline's Retry. */
onRetryFeed?: () => void;
/**
* The panel's heading, in place of 「讨论」, and its empty line, in place of
* 「暂无评论」. The renderer names them when the panel holds no comments
* (objectstack#36193: the comment panel holds them).
*/
titleLabel?: string;
emptyLabel?: string;
className?: string;
}

Expand Down Expand Up @@ -131,6 +138,8 @@ export const RecordChatterPanel: React.FC<RecordChatterPanelProps> = ({
activityFailed,
commentsFailed,
onRetryFeed,
titleLabel,
emptyLabel,
className,
}) => {
const position = config?.position ?? 'right';
Expand All @@ -139,6 +148,10 @@ export const RecordChatterPanel: React.FC<RecordChatterPanelProps> = ({
const defaultCollapsed = (collapseWhenEmpty && items.length === 0) || (config?.defaultCollapsed ?? false);

const { t } = useDetailTranslation();
const title = titleLabel ?? t('detail.discussion');
// A heading named by the caller (动态, objectstack#36193) takes the stream's icon.
const TitleIcon = titleLabel ? Activity : MessageSquare;
const empty = emptyLabel ?? t('detail.noCommentsYet');
const [collapsed, setCollapsed] = React.useState(defaultCollapsed);
/**
* The feed's own `aria` bag (objectui#11083). The spec declares `feed` as
Expand Down Expand Up @@ -204,8 +217,8 @@ export const RecordChatterPanel: React.FC<RecordChatterPanelProps> = ({
{/* Header */}
<div className="flex items-center justify-between px-4 py-3 border-b">
<div className="flex items-center gap-2">
<MessageSquare className="h-4 w-4" />
<span className="text-sm font-medium">{t('detail.discussion')}</span>
<TitleIcon className="h-4 w-4" />
<span className="text-sm font-medium">{title}</span>
</div>
{collapsible && (
<Button
Expand Down Expand Up @@ -243,8 +256,8 @@ export const RecordChatterPanel: React.FC<RecordChatterPanelProps> = ({
mentionSuggestions={mentionSuggestions}
onMentionSuggestionsWanted={onMentionSuggestionsWanted}
onUploadAttachments={onUploadAttachments}
titleLabel={t('detail.discussion')}
emptyLabel={t('detail.noCommentsYet')}
titleLabel={title}
emptyLabel={empty}
activityDenied={activityDenied}
commentsDenied={commentsDenied}
activityFailed={activityFailed}
Expand Down Expand Up @@ -276,8 +289,8 @@ export const RecordChatterPanel: React.FC<RecordChatterPanelProps> = ({
{collapsible && (
<div className="flex items-center justify-between mb-2">
<div className="flex items-center gap-2 text-sm font-medium">
<MessageSquare className="h-4 w-4" />
{t('detail.discussion')}
<TitleIcon className="h-4 w-4" />
{title}
</div>
<Button
variant="ghost"
Expand Down Expand Up @@ -311,8 +324,8 @@ export const RecordChatterPanel: React.FC<RecordChatterPanelProps> = ({
mentionSuggestions={mentionSuggestions}
onMentionSuggestionsWanted={onMentionSuggestionsWanted}
onUploadAttachments={onUploadAttachments}
titleLabel={t('detail.discussion')}
emptyLabel={t('detail.noCommentsYet')}
titleLabel={title}
emptyLabel={empty}
activityDenied={activityDenied}
commentsDenied={commentsDenied}
activityFailed={activityFailed}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* 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#36193 — a slotted page's `discussion` slot holding
* `record:chatter` (or `record:discussion`) is drawn on the record page's 动态
* tab. While the comment panel beside the record holds the comments
* (objectstack#36075), that block draws the system entries alone: no comment
* and no reply, no composer, no Comments-only filter, a count without the
* comments, and the 动态 heading rather than 「讨论」.
*
* CONTROLS: without the panel (the phone, or no host saying), and off the
* default page (a page an author composed whole), the block is as it was.
*/

import * as React from 'react';
import { describe, it, expect, afterEach } from 'vitest';
import { render, cleanup } from '@testing-library/react';
import { DiscussionContextProvider } from '@object-ui/react';
import type { FeedItem } from '@object-ui/types';
import { RecordChatterRenderer } from '../record-chatter';
import { RecordCommentsInPanelContext } from '../../recordTimelineStream';
import { DefaultRecordPageContext } from '../../defaultRecordPage';

afterEach(cleanup);

const comment: FeedItem = { id: 'c1', type: 'comment', actor: 'Ada', body: 'Follow up on the renewal quote', createdAt: '2026-11-21T10:00:00Z' };
const reply: FeedItem = { id: 'c2', type: 'comment', actor: 'Ada', body: 'Got it', parentId: 'c1', createdAt: '2026-11-21T10:05:00Z' };
const system: FeedItem = { id: 's1', type: 'system', actor: 'System', body: 'Owner changed to Ada', createdAt: '2026-11-20T09:00:00Z' };

function mount({
inPanel,
onDefaultPage = true,
items = [system, comment, reply],
type = 'record:chatter',
commentsDenied = false,
}: { inPanel: boolean; onDefaultPage?: boolean; items?: FeedItem[]; type?: string; commentsDenied?: boolean }) {
return render(
<DefaultRecordPageContext.Provider value={onDefaultPage}>
<RecordCommentsInPanelContext.Provider value={inPanel}>
<DiscussionContextProvider items={items as any[]} loading={false} commentsDenied={commentsDenied} onAddComment={() => undefined}>
<RecordChatterRenderer schema={{ type, position: 'bottom', collapsible: false } as any} />
</DiscussionContextProvider>
</RecordCommentsInPanelContext.Provider>
</DefaultRecordPageContext.Provider>,
);
}

const heading = (container: HTMLElement) => container.querySelector('h2')?.textContent ?? '';

describe('record:chatter on the 动态 tab while the comments are in the panel (objectstack#36193)', () => {
it.each(['record:chatter', 'record:discussion'])('%s: system entries only, no comment box, no Discussion heading, the count without comments', (type) => {
const { container } = mount({ inPanel: true, type });
expect(container.textContent).toContain('Owner changed to Ada');
expect(container.textContent).not.toContain('Follow up on the renewal quote');
expect(container.textContent).not.toContain('Got it');
expect(container.querySelector('textarea')).toBeNull();
expect(heading(container)).not.toMatch(/Discussion/);
expect(container.querySelector('[data-testid="activity-count"]')?.textContent).toContain('1');
});

it('no system history: the empty line names activity, not comments', () => {
const { container } = mount({ inPanel: true, items: [comment, reply] });
expect(container.textContent).not.toContain('Follow up on the renewal quote');
expect(container.textContent).not.toMatch(/No comments yet/);
});

it('a refused comment read is the panel\'s to say, not this block\'s', () => {
const { container } = mount({ inPanel: true, commentsDenied: true });
expect(container.textContent).toContain('Owner changed to Ada');
expect(container.querySelector('[data-testid="activity-count"]')?.textContent).toContain('1');
});

it('CONTROL — without the panel (the phone) the block keeps its comments, composer and heading', () => {
const { container } = mount({ inPanel: false });
expect(container.textContent).toContain('Follow up on the renewal quote');
expect(container.querySelector('textarea')).toBeTruthy();
expect(heading(container)).toMatch(/Discussion/);
});

it('CONTROL — off the default page (an authored page) the flag changes nothing', () => {
const { container } = mount({ inPanel: true, onDefaultPage: false });
expect(container.textContent).toContain('Follow up on the renewal quote');
expect(container.querySelector('textarea')).toBeTruthy();
});
});
35 changes: 27 additions & 8 deletions ui/packages/plugin-detail/src/renderers/record-chatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ import {
} from './recordActivityFeed';
import { useRecordAriaProps } from './recordComponentAria';
import { useDefaultRecordPage } from '../defaultRecordPage';
import { RecordFieldChangesContext, RecordFieldHistoryContext, mergeFieldHistoryIntoFeed } from '../recordTimelineStream';
import { RecordCommentsInPanelContext, RecordFieldChangesContext, RecordFieldHistoryContext, mergeFieldHistoryIntoFeed } from '../recordTimelineStream';
import { useDetailTranslation } from '../useDetailTranslation';

/** Dev mode, read per call — the guard `record-activity.tsx` puts on the same diagnostic. */
const isDevBuild = (): boolean =>
Expand Down Expand Up @@ -257,10 +258,23 @@ export const RecordChatterRenderer: React.FC<RecordChatterRendererProps> = ({
const onDefaultPage = useDefaultRecordPage();
const fieldHistoryShown =
React.useContext(RecordFieldHistoryContext) && !onDefaultPage && feed?.unifiedTimeline !== false;
// objectstack#36193 — a slotted page's chatter is drawn on the record page's
// 动态 tab. While the comment panel beside the record holds the comments
// (objectstack#36075), this block draws the system entries alone, as the
// platform's own stream does there: no comment and no reply, no composer,
// no Comments-only filter, a count without the comments, and the 动态
// heading rather than 「讨论」. Off the default page (an authored page), and
// on the phone (no panel), the block is as it was.
const commentsInPanel = React.useContext(RecordCommentsInPanelContext) && onDefaultPage;
const { t } = useDetailTranslation();
const sourceItems = React.useMemo(
() => (commentsInPanel ? (discussionItems ?? []).filter((item) => item.type !== 'comment') : discussionItems ?? []),
[commentsInPanel, discussionItems],
);
const applied = React.useMemo(
() =>
applyFeedConfig(
onDefaultPage ? discussionItems ?? [] : mergeFieldHistoryIntoFeed(discussionItems ?? [], fieldChanges),
onDefaultPage ? sourceItems : mergeFieldHistoryIntoFeed(sourceItems, fieldChanges),
{
types: feed?.types,
showCompleted: feed?.showCompleted,
Expand All @@ -269,7 +283,7 @@ export const RecordChatterRenderer: React.FC<RecordChatterRendererProps> = ({
pageSize,
blockName,
),
[discussionItems, onDefaultPage, fieldChanges, feed?.types, feed?.showCompleted, feed?.unifiedTimeline, pageSize, blockName],
[sourceItems, onDefaultPage, fieldChanges, feed?.types, feed?.showCompleted, feed?.unifiedTimeline, pageSize, blockName],
);

// `record-activity.tsx` writes its own `handleLoadMore` with an empty
Expand All @@ -288,8 +302,9 @@ export const RecordChatterRenderer: React.FC<RecordChatterRendererProps> = ({
// predicate and the same block name `applyFeedConfig` filters by
// (objectstack#34525). Where the composer would have been offered, the
// author is told why once, in development.
const commentsShown = feedTypesAdmitComments(feed?.types, blockName);
const composerWithheld = !commentsShown && feed?.showCommentInput !== false;
const typesAdmitComments = feedTypesAdmitComments(feed?.types, blockName);
const commentsShown = typesAdmitComments && !commentsInPanel;
const composerWithheld = !typesAdmitComments && feed?.showCommentInput !== false;
const nodeId: string | undefined = typeof schema.id === 'string' ? schema.id : undefined;
const typesKey = JSON.stringify(feed?.types ?? null);
React.useEffect(() => {
Expand Down Expand Up @@ -328,7 +343,7 @@ export const RecordChatterRenderer: React.FC<RecordChatterRendererProps> = ({
// renderer was the only missing end of the wire.
filterMode={filterMode}
onFilterChange={setFilterMode}
onAddComment={discussion?.onAddComment as any}
onAddComment={commentsInPanel ? undefined : (discussion?.onAddComment as any)}
commentsShown={commentsShown}
onAddReply={discussion?.onAddReply as any}
onToggleReaction={discussion?.onToggleReaction as any}
Expand All @@ -343,11 +358,15 @@ export const RecordChatterRenderer: React.FC<RecordChatterRendererProps> = ({
// REFUSED. The host that owns the fetch decides it, the same way it
// decides `loading` above; the panel only renders it.
activityDenied={discussion?.activityDenied}
commentsDenied={discussion?.commentsDenied}
// A refused or failed comment read is the comment panel's to say.
commentsDenied={!commentsInPanel && discussion?.commentsDenied}
// objectstack#29188: which of them FAILED (5xx, network), and the
// host's re-read of those; the panel only renders it.
activityFailed={discussion?.activityFailed}
commentsFailed={discussion?.commentsFailed}
commentsFailed={!commentsInPanel && discussion?.commentsFailed}
{...(commentsInPanel
? { titleLabel: t('detail.timeline', { defaultValue: 'Activity' }), emptyLabel: t('detail.noActivity', { defaultValue: 'No activity recorded' }) }
: {})}
onRetryFeed={discussion?.onRetryFeed}
/>
</RecordFieldHistoryContext.Provider>
Expand Down
Loading