🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(acceptance): count round notes and align discussion timeline (#19909)
AmAzing-829f4087cc2a
diff --git a/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx b/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsxindex 43d750a920e..d85a497fbb0 100644--- a/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx+++ b/apps/workbench/src/features/acceptance/AcceptanceEmbed.tsx@@ -9,7 +9,7 @@ import {AcceptanceScope,useAcceptanceScope,} from '@/features/Acceptance/Viewer/AcceptanceScope';-import { messageThreads } from '@/features/Acceptance/Viewer/Comments/discussionTimeline';+import { countDiscussionMessages } from '@/features/Acceptance/Viewer/Comments/discussionTimeline';import { groupCommentThreads } from '@/features/Acceptance/Viewer/Comments/threads';import { useAcceptanceCommentList } from '@/features/Acceptance/Viewer/Comments/useAcceptanceCommentList';import AcceptanceResources from '@/features/Acceptance/Viewer/Evidence/AcceptanceResources';@@ -67,8 +67,13 @@ const EmbedContent = () => {<AcceptanceTabsactive={tab}checkCount={data?.checks.length ?? 0}- discussionCount={messageThreads(groupCommentThreads(discussion?.items ?? [])).length}resourceCount={resources.size}+ discussionCount={countDiscussionMessages({+ approvals: [],+ items: discussion?.items ?? [],+ rounds: data?.rounds.map(({ run }) => run) ?? [],+ threads: groupCommentThreads(discussion?.items ?? []),+ })}onChange={setTab}/>{/* Keep read capabilities mounted so tab and appearance changes preserve disclosure state. */}diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 73cfdcf6fb5..9196e8eff31 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -125,9 +125,9 @@"acceptance.comments.resolve": "Mark resolved","acceptance.comments.resolved": "Resolved","acceptance.comments.resolvedSummary": "Resolved · {{name}} · {{count}} message(s)",- "acceptance.comments.roundCompletedBy": "{{name}} completed round {{round}}",+ "acceptance.comments.roundCompletedBy": "{{name}} submitted round {{round}} for review","acceptance.comments.roundContext": "Round {{round}}",- "acceptance.comments.roundLanded": "Round {{round}} completed",+ "acceptance.comments.roundLanded": "Round {{round}} submitted for review","acceptance.comments.send": "Send","acceptance.comments.signIn": "Sign in","acceptance.comments.signInDescription": "Sign in to comment, reply, and mark up screenshots.",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex fda36041a5c..d1666aa347b 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -125,9 +125,9 @@"acceptance.comments.resolve": "标记为已解决","acceptance.comments.resolved": "已解决","acceptance.comments.resolvedSummary": "已解决 · {{name}} · {{count}} 条",- "acceptance.comments.roundCompletedBy": "{{name}} 已完成第 {{round}} 轮",+ "acceptance.comments.roundCompletedBy": "{{name}} 提交了第 {{round}} 轮验收","acceptance.comments.roundContext": "第 {{round}} 轮",- "acceptance.comments.roundLanded": "第 {{round}} 轮已完成",+ "acceptance.comments.roundLanded": "第 {{round}} 轮已提交验收","acceptance.comments.send": "发送","acceptance.comments.signIn": "登录","acceptance.comments.signInDescription": "登录后就能在这里评论、回复、在截图上圈出问题。",diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex c1413c8104f..8215f593af0 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -208,12 +208,12 @@ export default {'acceptance.comments.evidenceFromRound':'Evidence from round {{round}} — replaced in a later round','acceptance.comments.evidenceThisRound': 'Current evidence for this check',- 'acceptance.comments.roundLanded': 'Round {{round}} completed',+ 'acceptance.comments.roundLanded': 'Round {{round}} submitted for review','acceptance.comments.signIn': 'Sign in','acceptance.comments.signInDescription': 'Sign in to comment, reply, and mark up screenshots.','acceptance.comments.signInTitle': 'Join the discussion','acceptance.comments.signUp': 'Sign up',- 'acceptance.comments.roundCompletedBy': '{{name}} completed round {{round}}',+ 'acceptance.comments.roundCompletedBy': '{{name}} submitted round {{round}} for review','acceptance.comments.approvedBy': '{{name}} approved this delivery','acceptance.comments.approvedByAtRound': '{{name}} approved round {{round}}','acceptance.comments.historicalRegions':diff --git a/src/features/Acceptance/Viewer/AcceptanceOverview.tsx b/src/features/Acceptance/Viewer/AcceptanceOverview.tsxindex e4511e2a4f0..83812986fc1 100644--- a/src/features/Acceptance/Viewer/AcceptanceOverview.tsx+++ b/src/features/Acceptance/Viewer/AcceptanceOverview.tsx@@ -10,7 +10,7 @@ import AcceptanceCheckInventory from './Checks/AcceptanceCheckInventory';import AcceptanceCheckOwnerToolbar from './Checks/AcceptanceCheckOwnerToolbar';import AcceptanceDiscussion from './Comments/AcceptanceDiscussion';import { commentIdFromHash } from './Comments/anchor';-import { messageThreads } from './Comments/discussionTimeline';+import { countDiscussionMessages } from './Comments/discussionTimeline';import { useAcceptanceComments } from './Comments/hooks';import ReviewerApprovalBar from './Comments/ReviewerApprovalBar';import AcceptanceOriginTopic from './Conversation/AcceptanceOriginTopic';@@ -64,7 +64,7 @@ export const AcceptanceOverview = ({const { acceptanceId, embedded } = useAcceptanceScope();const { turn } = useAcceptanceTurn(embedded);const { data } = useAcceptanceBundle(acceptanceId);- const { threads } = useAcceptanceComments(acceptanceId);+ const { items, threads } = useAcceptanceComments(acceptanceId);const [requestedTab, setTab] = useState<AcceptanceTabKey>();// A link to one comment has to land on the tab that shows it. The reader can// still leave: their own tab choice, once made, outranks the fragment.@@ -102,9 +102,14 @@ export const AcceptanceOverview = ({<AcceptanceTabsactive={tab}checkCount={checks.length}- discussionCount={messageThreads(threads).length}flowCount={md ? flowCount : 0}resourceCount={resourceCount}+ discussionCount={countDiscussionMessages({+ approvals: [],+ items,+ rounds: data?.rounds.map(({ run }) => run) ?? [],+ threads,+ })}onChange={setTab}/></Flexbox>diff --git a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsxindex 771758862a8..9c812d93197 100644--- a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx+++ b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx@@ -73,7 +73,7 @@ const local = createStaticStyles(({ css }) => ({/*** A round. With a note it IS the agent's turn: one entry whose header says- * "<agent> completed round N" and whose body is what they wrote. The landing+ * "<agent> submitted round N for review" and whose body is what they wrote. The landing* and the author are the same sentence, so neither an event row above the note* nor a second author line is needed. Without a note it stays the plain event.*/@@ -157,12 +157,6 @@ const TimelineMessage = memo<{TimelineMessage.displayName = 'AcceptanceTimelineMessage';-/*- * The rail runs inside the boxes rather than under the avatars, so nothing here- * needs to sit above the line: the opaque boxes cover it, the event dots stand- * on it, and the gaps between turns are where it shows.- */-/*** The delivery's chat: one message per turn, strung on a rail with the rounds* that landed and the approvals people gave, and the composer at the end.@@ -255,11 +249,11 @@ const AcceptanceDiscussion = memo(() => {{timeline.length === 0 && (<span className={local.empty}>{t('acceptance.comments.empty')}</span>)}- {timeline.map((entry) => renderEntry(entry))}+ <Flexbox className={styles.timeline}>{timeline.map((entry) => renderEntry(entry))}</Flexbox>{/* Last, like GitHub's Conversation: you read the thread, then answer it. */}{canComment ? (- <Flexbox className={cx(styles.timelineEntry, styles.nodelessEntry, styles.tailEntry)}>+ <Flexbox className={styles.nodelessEntry}><Flexbox className={styles.composerBlock}><CommentComposerminHeight={COMPOSER_MIN_HEIGHT}diff --git a/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx b/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsxindex de314f6229c..1475ef8e60e 100644--- a/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx+++ b/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx@@ -1,5 +1,4 @@import { Flexbox, Icon } from '@lobehub/ui';-import { cx } from 'antd-style';import type { LucideIcon } from 'lucide-react';import { useActivityTime } from '@/hooks/useActivityTime';@@ -10,14 +9,11 @@ import { styles } from './styles';const TimelineEvent = ({ at, icon, text }: { at: Date; icon: LucideIcon; text: string }) => {const time = useActivityTime(at);return (- <Flexbox- horizontal- align={'center'}- className={cx(styles.timelineEntry, styles.eventEntry)}- gap={12}- >- <span className={styles.eventDot}>- <Icon icon={icon} size={12} />+ <Flexbox horizontal align={'flex-start'} className={styles.timelineEntry} gap={12}>+ <span className={styles.timelineNode}>+ <span className={styles.eventDot}>+ <Icon icon={icon} size={12} />+ </span></span><Flexbox horizontal align={'center'} className={styles.event} gap={8} wrap={'wrap'}><span>{text}</span>diff --git a/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts b/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.tsindex 30559fc9f64..59b062f69f3 100644--- a/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts+++ b/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts@@ -1,7 +1,12 @@import type { AcceptanceCommentItem, AcceptanceCommentThread } from '@lobechat/types';import { describe, expect, it } from 'vitest';-import { buildDiscussionTimeline, messageThreads, regionThreads } from './discussionTimeline';+import {+ buildDiscussionTimeline,+ countDiscussionMessages,+ messageThreads,+ regionThreads,+} from './discussionTimeline';import { groupCommentThreads } from './threads';let seq = 0;@@ -96,6 +101,73 @@ describe('discussion split', () => {});});+describe('discussion count', () => {+ const rounds = [{ createdAt: '2026-09-01T10:00:00Z', id: 'run', roundIndex: 1 }];+ const count = (items: AcceptanceCommentItem[]) =>+ countDiscussionMessages({+ approvals: items.filter((comment) => comment.kind === 'approval'),+ items,+ rounds,+ threads: groupCommentThreads(items),+ });++ it('counts a round note as the first contribution and a new comment as the second', () => {+ const proposal = item({ contextRunId: 'run', kind: 'proposal' });++ expect(count([proposal])).toBe(1);+ expect(count([proposal, item()])).toBe(2);+ });++ it('counts replies as individual contributions', () => {+ const root = item();+ const reply = item({ parentCommentId: root.id });++ expect(count([root, reply])).toBe(2);+ });++ it('counts only the surviving note displayed for a round', () => {+ const old = item({ contextRunId: 'run', kind: 'proposal' });+ const latest = item({ contextRunId: 'run', kind: 'proposal' });+ const deleted = item({ contextRunId: 'run', deletedAt: new Date(), kind: 'proposal' });+ const orphan = item({ contextRunId: 'missing-run', kind: 'proposal' });++ expect(count([old, latest, deleted, orphan])).toBe(1);+ });++ it('excludes bare round events, approvals, empty notes and evidence threads', () => {+ const region = item({ anchorType: 'evidence', evidenceId: 'ev1' });++ expect(count([])).toBe(0);+ expect(+ count([+ item({ content: ' ', contextRunId: 'run', kind: 'proposal' }),+ item({ kind: 'approval' }),+ region,+ item({ parentCommentId: region.id }),+ ]),+ ).toBe(0);+ });++ it('excludes deleted messages while keeping their surviving replies', () => {+ const root = item({ deletedAt: new Date() });+ const reply = item({ parentCommentId: root.id });+ const deletedReply = item({ deletedAt: new Date(), parentCommentId: root.id });++ expect(count([root])).toBe(0);+ expect(count([root, reply, deletedReply])).toBe(1);+ });++ it('counts attachment-only comments once regardless of emoji reactions', () => {+ const comment = item({+ attachments: [{ id: 'image', name: 'image.png', url: '/image.png' }],+ content: '',+ reactions: [{ authorNames: ['u'], count: 3, emoji: '👍', mine: false }],+ });++ expect(count([comment])).toBe(1);+ });+});+describe('buildDiscussionTimeline', () => {it('preserves approvals and interleaves replies from separate threads with round events', () => {const first = item({ createdAt: new Date('2026-09-01T10:00:00Z'), id: 'first' });diff --git a/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts b/src/features/Acceptance/Viewer/Comments/discussionTimeline.tsindex 8d318ecfcea..9bcaaf2fe4d 100644--- a/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts+++ b/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts@@ -89,3 +89,10 @@ export const buildDiscussionTimeline = ({return entries.sort((a, b) => a.at.getTime() - b.at.getTime());};++/** The discussion badge counts contributions, including the round's own note. */+export const countDiscussionMessages = (input: BuildInput): number =>+ buildDiscussionTimeline(input).filter((entry) => {+ if (entry.kind === 'message') return !entry.comment.deletedAt;+ return entry.kind === 'round' && Boolean(entry.proposal?.content.trim());+ }).length;diff --git a/src/features/Acceptance/Viewer/Comments/styles.ts b/src/features/Acceptance/Viewer/Comments/styles.tsindex 556f4e4bd69..b3ba31947ea 100644--- a/src/features/Acceptance/Viewer/Comments/styles.ts+++ b/src/features/Acceptance/Viewer/Comments/styles.ts@@ -14,15 +14,9 @@ import { createStaticStyles, cssVar } from 'antd-style';export const TIMELINE_NODE = 32;const NODE_GUTTER = 12;const EVENT_DOT = 20;-/** Breathing room under each entry — spacing, never part of the rail. */-const ENTRY_GAP = 14;-/**- * GitHub does not run the rail through the avatars. It runs it just inside the- * content column's left edge, where the opaque comment boxes cover it and only- * the gaps between turns show a line; the avatar hangs off to its left.- * Measured off the reference: 19px in from the box.- */-const RAIL = TIMELINE_NODE + NODE_GUTTER + 19;+/** Space between submitted records. The composer sits outside the timeline. */+const ENTRY_GAP = 16;+const RAIL = TIMELINE_NODE / 2;/*** The accent, diluted well past the reference. A blue box line reads much@@ -46,9 +40,6 @@ export const styles = createStaticStyles(({ css }) => ({`,/** A discussion message: header strip, then the words. */box: css`- /* Positioned so it paints after the entry's rail pseudo-element. Without- it the line ran straight over the box and clipped the first glyph of- every line that crossed x = RAIL. */position: relative;flex: 1;@@ -98,13 +89,9 @@ export const styles = createStaticStyles(({ css }) => ({`,/** The composer, wrapped so it reads as one block rather than a loose field. */composerBlock: css`- /* Same reason as the message box: it has to cover the rail, not sit under it. */- position: relative;-padding: 12px;border: 1px solid ${cssVar.colorBorderSecondary};border-radius: ${cssVar.borderRadius};-background: ${cssVar.colorBgContainer};`,deleted: css`@@ -122,9 +109,6 @@ export const styles = createStaticStyles(({ css }) => ({* the dot, which read as a smudge rather than as a node on the line.*/eventDot: css`- /* Same reason as the message box: the rail is the entry's absolutely- positioned pseudo-element, so an unpositioned dot paints under it and the- line cuts straight across the circle. */position: relative;display: inline-flex;@@ -222,7 +206,7 @@ export const styles = createStaticStyles(({ css }) => ({`,/*** A headline is a sentence, not a name: it may wrap, and it must never be- * cut at the name cap — "Acceptance Builder 已完成…" says nothing.+ * cut at the name cap — "Acceptance Builder 提交了…" says nothing.*/headline: css`min-width: 0;@@ -242,33 +226,12 @@ export const styles = createStaticStyles(({ css }) => ({nodelessEntry: css`padding-inline-start: ${TIMELINE_NODE + NODE_GUTTER}px;`,- /** An event has no avatar; its dot takes the rail's place on the line. */- eventEntry: css`- padding-inline-start: ${RAIL - EVENT_DOT / 2}px;- `,- /**- * The stream's last turn. Without this the rail stopped at the composer's top- * edge and the box hung off the end of the line instead of closing it.- */- tailEntry: css`- /* Outranks the last-of-type truncation, which would otherwise stop the- line 10px in and leave the composer hanging off the end. It stops AT the- composer's bottom edge: the entry's own bottom padding is spacing, and a- rail drawn through it is a line pointing at nothing. */- &&&::before {- inset-block: 0 ${ENTRY_GAP}px;- height: auto;- }- `,/**- * The continuous line behind the nodes. Drawn on the entry rather than the- * list so the last entry can stop it, and inset to the node's centre.+ * Only the historical stream connects nodes. Read-only cards and the composer+ * can reuse entry styles without accidentally extending the rail.*/- timelineEntry: css`- position: relative;- padding-block-end: ${ENTRY_GAP}px;-- &::before {+ timeline: css`+ > *::before {content: '';position: absolute;@@ -280,27 +243,42 @@ export const styles = createStaticStyles(({ css }) => ({background: ${cssVar.colorBorderSecondary};}- &:hover [data-comment-actions] {- opacity: 1;+ > :first-child::before {+ inset-block-start: ${TIMELINE_NODE / 2}px;}- &:first-of-type::before {- inset-block-start: ${EVENT_DOT / 2}px;+ > :last-child::before {+ inset-block-end: auto;+ height: ${TIMELINE_NODE / 2}px;}- &:last-of-type::before {- inset-block-end: auto;- height: ${EVENT_DOT / 2}px;+ > :only-child::before {+ content: none;+ }+ `,+ timelineEntry: css`+ position: relative;+ padding-block-end: ${ENTRY_GAP}px;++ &:hover [data-comment-actions] {+ opacity: 1;}`,- /** The author's column, left of the rail — GitHub keeps the face off the line. */+ /** Avatars and event dots share one centre line, with an opaque node above it. */timelineNode: css`+ position: relative;+display: flex;flex: none;+ align-items: center;justify-content: center;width: ${TIMELINE_NODE}px;+ height: ${TIMELINE_NODE}px;+ border-radius: 50%;line-height: 0;++ background: ${cssVar.colorBgContainer};`,}));diff --git a/src/features/Acceptance/Viewer/Header/AcceptanceTabs.tsx b/src/features/Acceptance/Viewer/Header/AcceptanceTabs.tsxindex 2701e8af1f1..67137907b4d 100644--- a/src/features/Acceptance/Viewer/Header/AcceptanceTabs.tsx+++ b/src/features/Acceptance/Viewer/Header/AcceptanceTabs.tsx@@ -21,7 +21,7 @@ const styles = createStaticStyles(({ css }) => ({interface AcceptanceTabsProps {active: AcceptanceTabKey;checkCount: number;- /** Open discussion threads on this delivery. */+ /** Visible contributions: round notes, comments and replies, excluding status events. */discussionCount: number;flowCount?: number;onChange: (key: AcceptanceTabKey) => void;