Skip to content

Commit f94bec0

Browse files
committed
fix(plugin-detail): the overview's 最近动态 card lists the system history alone while the comment panel holds the comments
A slotted page's record:chatter / record:discussion stream is drawn in the card as the record:activity block its feed configures, in the peek face: no comments, no replies, no 讨论 heading, a count of the system entries, no card without system history. The 动态 tab and its label are unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgXV5qLuX94Bn6aqb4y
1 parent fa30414 commit f94bec0

3 files changed

Lines changed: 158 additions & 7 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
---
4+
5+
fix(plugin-detail): the overview's 最近动态 card lists the system history alone while the comment panel holds the comments, on a slotted page with a `record:chatter` stream too
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- On a page whose `discussion` slot holds `record:chatter` or `record:discussion`, the 概览 tab's 最近动态 card drew the chatter's own panel face: a 「讨论 (N)」 heading counting comments, the 全部动态 filter, every comment and its replies, and 加载更多. While the comment panel is offered (desktop page, objectstack#36075), the card now draws that stream as the `record:activity` block its `feed` configures, in the peek face the default page's card already uses: the newest three system entries, no comment or reply, no 讨论 heading, and a count of the system entries alone. With no system history the card is not drawn, whatever the comments.
11+
- The card keeps that count to itself: the 动态 tab still draws the chatter with its comments, so its label in the tab row is unchanged.
12+
- Not changed: the 动态 tab, the comment panel, the default page's card (already system history only), the drawer (draws no rail), the phone (no comment panel), and an authored page.

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

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { columnIdentity, composeParentScopeFilter, mergeFilterNodes, type FieldC
1313
import { formatCurrency } from '@object-ui/fields';
1414
import { resolveFieldCurrency, useDisplayLocale, useLocalization, withFollowedParent } from '@object-ui/i18n';
1515
import { SchemaRenderer, toRenderableSchema, useRecordContext } from '@object-ui/react';
16-
import { RecordTimelinePanelContext, type RecordTimelinePanel } from './recordTimelineStream';
16+
import { RecordCommentsInPanelContext, RecordTimelinePanelContext, type RecordTimelinePanel } from './recordTimelineStream';
1717
import { resolveTitleField } from './synth/buildDefaultPageSchema';
1818
import type { RelatedCardId } from './synth/relatedArrangement';
1919
import { useDetailTranslation } from './useDetailTranslation';
@@ -342,19 +342,30 @@ const TimelineSummary: React.FC<{
342342
timelineId: string;
343343
}> = ({ nodes, count, onCount, onOpen, timelineId }) => {
344344
const { t } = useDetailTranslation();
345+
const commentsInPanel = React.useContext(RecordCommentsInPanelContext);
346+
const peekNodes = React.useMemo(
347+
() => railStreamNodes(nodes, commentsInPanel).map(readOnlyStreamNode),
348+
[nodes, commentsInPanel],
349+
);
350+
// A chatter stream drawn as the system history (objectstack#36193) keeps its
351+
// count to this card: the 动态 tab still draws that chatter, comments and
352+
// all, so the tab row is not handed a count of the system entries alone.
353+
const ownCount = peekNodes.some((node, index) => node !== nodes[index] && node?.type === 'record:activity' && nodes[index]?.type !== 'record:activity');
354+
const [cardCount, setCardCount] = React.useState<number | null>(null);
355+
const reportCount = ownCount ? setCardCount : onCount;
356+
const shownCount = ownCount ? cardCount : count;
345357
const panel = React.useMemo<RecordTimelinePanel>(
346-
() => ({ entries: RECORD_SUMMARY_ROWS, onCount }),
347-
[onCount],
358+
() => ({ entries: RECORD_SUMMARY_ROWS, onCount: reportCount }),
359+
[reportCount],
348360
);
349-
const peekNodes = React.useMemo(() => nodes.map(readOnlyStreamNode), [nodes]);
350-
const counted = nodes.some((node) => node && typeof node === 'object' && node.type === 'record:activity');
361+
const counted = peekNodes.some((node) => node && typeof node === 'object' && node.type === 'record:activity');
351362
return (
352363
<RecordSummaryCard
353364
id={timelineId}
354365
title={t('detail.summaryRecentActivity', { defaultValue: 'Recent activity' })}
355-
count={count}
366+
count={shownCount}
356367
onOpen={onOpen}
357-
hidden={counted && !(typeof count === 'number' && count > 0)}
368+
hidden={counted && !(typeof shownCount === 'number' && shownCount > 0)}
358369
>
359370
{/* Edge to edge: the peek rows pad themselves, and a chatter stream
360371
insets itself in a timeline card (objectstack#34676). */}
@@ -369,6 +380,28 @@ const TimelineSummary: React.FC<{
369380
);
370381
};
371382

383+
/**
384+
* objectstack#36193 — the stream blocks the 最近动态 card draws. While the
385+
* comment panel holds the comments (`RecordCommentsInPanelContext`), the card
386+
* lists the system history alone, as the 动态 stream does (objectstack#36075):
387+
* a slotted page's `record:chatter` / `record:discussion` stream is drawn
388+
* there as the `record:activity` block its `feed` configures (the spec's
389+
* `feed` IS `RecordActivityProps`), whose peek drops the comments and their
390+
* replies, has no 「讨论」 heading, and counts the system entries only — so a
391+
* card with no system history is not drawn. Without the panel the nodes are
392+
* the page's own, unchanged.
393+
*/
394+
export function railStreamNodes(nodes: readonly any[], commentsInPanel: boolean): any[] {
395+
if (!commentsInPanel) return nodes as any[];
396+
return nodes.map((node) => {
397+
if (!node || typeof node !== 'object') return node;
398+
if (node.type !== 'record:chatter' && node.type !== 'record:discussion') return node;
399+
const props = node.properties ?? {};
400+
const feed = { ...(node.feed ?? {}), ...(props.feed ?? {}) };
401+
return { type: 'record:activity', ...(node.id ? { id: node.id } : {}), properties: feed };
402+
});
403+
}
404+
372405
/** A stream block as the rail draws it: read-only, the newest few. */
373406
function readOnlyStreamNode(node: any): any {
374407
if (!node || typeof node !== 'object') return node;
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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#36193 — while the comment panel holds the record's comments
11+
* (objectstack#36075), the 概览 tab's 「最近动态」 card lists the system
12+
* history alone: no comment, no reply, no 「讨论」 heading, a count of the
13+
* system entries only, and no card at all when there is no system history.
14+
*
15+
* The case that broke it: a slotted page whose `discussion` slot holds
16+
* `record:chatter`. The chatter block draws the timeline's panel face — the
17+
* 「讨论 (N)」 heading, the 全部动态 filter, every comment and its replies —
18+
* and the card drew it as it came. The default `record:activity` stream
19+
* already dropped the comments (objectstack#36075); it is the CONTROL here.
20+
*
21+
* Drawn through the real page (`buildDefaultPageSchema` →
22+
* `buildDefaultPageColumns` → `RecordPageColumns`, real block renderers).
23+
*/
24+
25+
import * as React from 'react';
26+
import { describe, it, expect, afterEach } from 'vitest';
27+
import { render, cleanup, waitFor } from '@testing-library/react';
28+
import { DiscussionContextProvider } from '@object-ui/react';
29+
import type { FeedItem } from '@object-ui/types';
30+
import { RecordPageColumns } from '../RecordPageColumns';
31+
import { RecordCommentsInPanelContext } from '../recordTimelineStream';
32+
import { buildDefaultPageColumns } from '../synth/recordPageColumns';
33+
import { buildDefaultPageSchema } from '../synth/buildDefaultPageSchema';
34+
import { railStreamNodes } from '../RecordSummaryRail';
35+
import '../index';
36+
37+
afterEach(cleanup);
38+
39+
const comment: FeedItem = { id: 'c1', type: 'comment', actor: 'Ada', body: 'Follow up on the renewal quote', createdAt: '2026-11-21T10:00:00Z' };
40+
const reply: FeedItem = { id: 'c2', type: 'comment', actor: 'Ada', body: 'Got it', parentId: 'c1', createdAt: '2026-11-21T10:05:00Z' };
41+
const system: FeedItem = { id: 's1', type: 'system', actor: 'System', body: 'Owner changed to Ada', createdAt: '2026-11-20T09:00:00Z' };
42+
43+
const OBJECT = { name: 'account', label: 'Account', fields: { name: { name: 'name', type: 'text' } } };
44+
45+
const chatterColumns = () =>
46+
buildDefaultPageColumns(
47+
buildDefaultPageSchema(OBJECT as any, {
48+
slots: { discussion: { type: 'record:chatter', id: 'account_chatter', properties: {} } },
49+
} as any),
50+
)!;
51+
const activityColumns = () => buildDefaultPageColumns(buildDefaultPageSchema(OBJECT as any, {}))!;
52+
53+
function draw(columns: ReturnType<typeof chatterColumns>, items: FeedItem[], inPanel: boolean) {
54+
return render(
55+
<RecordCommentsInPanelContext.Provider value={inPanel}>
56+
<DiscussionContextProvider items={items as any[]} loading={false} onAddComment={(async () => {}) as any}>
57+
<RecordPageColumns tier="wide" columns={columns} onEnlargeRelated={() => {}} />
58+
</DiscussionContextProvider>
59+
</RecordCommentsInPanelContext.Provider>,
60+
);
61+
}
62+
63+
const CARD = '[data-record-summary-card="timeline"]';
64+
const cardOf = (container: HTMLElement) => container.querySelector(CARD) as HTMLElement | null;
65+
const shown = (card: HTMLElement | null) => !!card && !card.closest('[hidden]') && !card.hasAttribute('hidden');
66+
67+
describe('the 最近动态 card while the comments are in the panel (objectstack#36193)', () => {
68+
it('a slotted record:chatter stream: system history only, no 讨论 heading, the system count', async () => {
69+
const { container } = draw(chatterColumns(), [system, comment, reply], true);
70+
const card = cardOf(container)!;
71+
await waitFor(() => expect(card.textContent).toContain('Owner changed to Ada'));
72+
expect(card.textContent).not.toContain('Follow up on the renewal quote');
73+
expect(card.textContent).not.toContain('Got it');
74+
expect(card.textContent).not.toMatch(/Discussion|讨论/);
75+
expect(card.querySelector('[data-record-timeline-peek]')).toBeTruthy();
76+
expect(card.querySelector('textarea')).toBeNull();
77+
await waitFor(() => expect(card.querySelector('[data-record-summary-card-count]')?.textContent).toBe('1'));
78+
expect(shown(card)).toBe(true);
79+
});
80+
81+
it('no system history: the card is not drawn, a comment does not bring it back', async () => {
82+
const { container } = draw(chatterColumns(), [comment, reply], true);
83+
await waitFor(() => expect(shown(cardOf(container))).toBe(false));
84+
});
85+
86+
it('CONTROL — without the panel the chatter card is the page\'s own: comments and all', async () => {
87+
const { container } = draw(chatterColumns(), [system, comment], false);
88+
const card = cardOf(container)!;
89+
await waitFor(() => expect(card.textContent).toContain('Follow up on the renewal quote'));
90+
});
91+
92+
it('CONTROL — the default record:activity stream already lists the system history only', async () => {
93+
const { container } = draw(activityColumns(), [system, comment, reply], true);
94+
const card = cardOf(container)!;
95+
await waitFor(() => expect(card.textContent).toContain('Owner changed to Ada'));
96+
expect(card.textContent).not.toContain('Follow up on the renewal quote');
97+
});
98+
99+
it('railStreamNodes hands the nodes back untouched without the panel, and leaves record:activity alone', () => {
100+
const nodes = [{ type: 'record:chatter', properties: { feed: { types: ['comment', 'system'] } } }, { type: 'record:activity' }];
101+
expect(railStreamNodes(nodes, false)).toBe(nodes);
102+
const drawn = railStreamNodes(nodes, true);
103+
expect(drawn[0]).toEqual({ type: 'record:activity', properties: { types: ['comment', 'system'] } });
104+
expect(drawn[1]).toBe(nodes[1]);
105+
});
106+
});

0 commit comments

Comments
 (0)