Skip to content

🤯 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.

🐛 fix(acceptance): show region comments and send-backs in the discussion, float a comment action on evidence (#20459)

Arvin Xu0be6d9a30105
diff --git a/locales/en-US/verify.json b/locales/en-US/verify.json
index 783d87ba23d..87f0c5f7577 100644
--- a/locales/en-US/verify.json
+++ b/locales/en-US/verify.json
@@ -91,8 +91,11 @@
"acceptance.comments.author.agent": "Agent",
"acceptance.comments.author.deactivated": "Deactivated",
"acceptance.comments.author.former": "Former member",
+ "acceptance.comments.checkRejected": "sent back · round {{round}}",
+ "acceptance.comments.checkRejectedRegions": "{{count}} marked region(s)",
"acceptance.comments.collapseThread": "Collapse",
"acceptance.comments.commentEvidence": "Comment on a region",
+ "acceptance.comments.commentThisEvidence": "Comment on this screenshot",
"acceptance.comments.commented": "commented {{time}}",
"acceptance.comments.copyLink": "Copy link",
"acceptance.comments.copyLinkHint": "{{time}} · click to copy this comment’s link",
@@ -116,6 +119,7 @@
"acceptance.comments.regionHint": "Drag a box on the image, then write your note.",
"acceptance.comments.regionMissing": "Mark a region first.",
"acceptance.comments.regionModalTitle": "Mark the area you mean",
+ "acceptance.comments.regionOn": "{{name}} commented on",
"acceptance.comments.removeOthers": "Remove",
"acceptance.comments.removeOthersConfirm": "Remove this comment by another member? It will disappear from the discussion.",
"acceptance.comments.reopen": "Reopen",
@@ -127,6 +131,7 @@
"acceptance.comments.roundCompletedBy": "{{name}} submitted round {{round}} for review",
"acceptance.comments.roundContext": "Round {{round}}",
"acceptance.comments.roundLanded": "Round {{round}} submitted for review",
+ "acceptance.comments.roundRejected": "Round {{round}} delivery sent back",
"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.json
index 5d272786fed..9f07f24ec1d 100644
--- a/locales/zh-CN/verify.json
+++ b/locales/zh-CN/verify.json
@@ -91,8 +91,11 @@
"acceptance.comments.author.agent": "智能体",
"acceptance.comments.author.deactivated": "已注销",
"acceptance.comments.author.former": "已离开",
+ "acceptance.comments.checkRejected": "被打回 · 第 {{round}} 轮",
+ "acceptance.comments.checkRejectedRegions": "圈注了 {{count}} 处",
"acceptance.comments.collapseThread": "收起",
"acceptance.comments.commentEvidence": "圈选评论",
+ "acceptance.comments.commentThisEvidence": "评论这张截图",
"acceptance.comments.commented": "评论于 {{time}}",
"acceptance.comments.copyLink": "复制链接",
"acceptance.comments.copyLinkHint": "{{time}} · 点一下复制这条评论的链接",
@@ -116,6 +119,7 @@
"acceptance.comments.regionHint": "在图上拖一个框,然后写下你的意见。",
"acceptance.comments.regionMissing": "先在图上圈出一处。",
"acceptance.comments.regionModalTitle": "在截图上圈出要说的位置",
+ "acceptance.comments.regionOn": "{{name}} 评论了",
"acceptance.comments.removeOthers": "移除",
"acceptance.comments.removeOthersConfirm": "移除这条别人写的评论?它会从讨论里消失。",
"acceptance.comments.reopen": "重新打开",
@@ -127,6 +131,7 @@
"acceptance.comments.roundCompletedBy": "{{name}} 提交了第 {{round}} 轮验收",
"acceptance.comments.roundContext": "第 {{round}} 轮",
"acceptance.comments.roundLanded": "第 {{round}} 轮已提交验收",
+ "acceptance.comments.roundRejected": "第 {{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.ts
index 5ab53e45e4b..2b5a4898b06 100644
--- a/packages/locales/src/default/verify.ts
+++ b/packages/locales/src/default/verify.ts
@@ -249,6 +249,11 @@ export default {
'Evidence from round {{round}} — replaced in a later round',
'acceptance.comments.evidenceThisRound': 'Current evidence for this check',
'acceptance.comments.roundLanded': 'Round {{round}} submitted for review',
+ 'acceptance.comments.checkRejected': 'sent back · round {{round}}',
+ 'acceptance.comments.checkRejectedRegions': '{{count}} marked region(s)',
+ 'acceptance.comments.regionOn': '{{name}} commented on',
+ 'acceptance.comments.roundRejected': 'Round {{round}} delivery sent back',
+ 'acceptance.comments.commentThisEvidence': 'Comment on this screenshot',
'acceptance.comments.signIn': 'Sign in',
'acceptance.comments.signInDescription': 'Sign in to comment, reply, and mark up screenshots.',
'acceptance.comments.signInTitle': 'Join the discussion',
diff --git a/src/features/Acceptance/Viewer/AcceptanceOverview.tsx b/src/features/Acceptance/Viewer/AcceptanceOverview.tsx
index 83812986fc1..fcb51fcb197 100644
--- a/src/features/Acceptance/Viewer/AcceptanceOverview.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceOverview.tsx
@@ -106,6 +106,7 @@ export const AcceptanceOverview = ({
resourceCount={resourceCount}
discussionCount={countDiscussionMessages({
approvals: [],
+ checks: data?.checks,
items,
rounds: data?.rounds.map(({ run }) => run) ?? [],
threads,
diff --git a/src/features/Acceptance/Viewer/Checks/CheckRow.tsx b/src/features/Acceptance/Viewer/Checks/CheckRow.tsx
index 91a88d54483..8618ac46ca8 100644
--- a/src/features/Acceptance/Viewer/Checks/CheckRow.tsx
+++ b/src/features/Acceptance/Viewer/Checks/CheckRow.tsx
@@ -42,6 +42,7 @@ import { threadsForCheck } from '../Comments/threads';
import {
canMarkEvidence,
evidenceCounts,
+ evidenceShortcut,
hasAnnotatableEvidence,
isRejectable,
} from '../Evidence/evidence';
@@ -235,9 +236,10 @@ export const AcceptanceCheckRow = memo<{
canCommentOnAcceptanceEvidence(bundle, comments.canComment) &&
Boolean(check.result) &&
hasAnnotatableEvidence(check);
- const openEvidenceComment = () =>
+ const openEvidenceComment = (initialEvidenceId?: string) =>
openEvidenceCommentModal({
evidence: check.evidence,
+ initialEvidenceId,
onConfirm: async ({ content, evidenceId, rect }) => {
await comments.create({
anchor: { checkItemId: check.id, evidenceId, rect },
@@ -249,6 +251,25 @@ export const AcceptanceCheckRow = memo<{
},
});
+ // The picture's own shortcut opens whatever the bottom of the row offers:
+ // a region comment for a reader, marking a send-back for the author, who
+ // gives region feedback through the reject instead.
+ const shortcut = evidenceShortcut({
+ canComment: canCommentEvidence,
+ canMark: reviewable && !activeReview && canMarkEvidence(check, desktop),
+ // EvidenceList turns a phone reviewer's tap into the same marking.
+ tapMarks: !desktop && canReview,
+ });
+ const floatingComment =
+ shortcut === 'comment'
+ ? { label: t('acceptance.comments.commentThisEvidence'), open: openEvidenceComment }
+ : shortcut === 'annotate'
+ ? {
+ label: t('acceptance.review.annotate'),
+ open: (id: string) => openReject(undefined, id),
+ }
+ : undefined;
+
/**
* @param fromProposal - when set, the modal opens prefilled with the
* model's note and regions, and the submitted result is diffed against it
@@ -653,6 +674,7 @@ export const AcceptanceCheckRow = memo<{
evidence={check.evidence}
overlays={commentOverlays}
reviewNotes={activeReview?.action === 'reject' ? activeReview.annotations : undefined}
+ onComment={floatingComment}
onRefreshEvidenceUrl={refreshEvidenceUrl}
onReviewEvidence={canReview ? (id) => openReject(undefined, id) : undefined}
/>
diff --git a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx
index 9c812d93197..e248010ec14 100644
--- a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx
+++ b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx
@@ -1,27 +1,34 @@
'use client';
-import type { AcceptanceCommentItem } from '@lobechat/types';
-import { Flexbox } from '@lobehub/ui';
+import type { AcceptanceCommentItem, AcceptanceCommentThread } from '@lobechat/types';
+import { Flexbox, Icon } from '@lobehub/ui';
import { Button, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
-import { BadgeCheck, GitCommitHorizontal } from 'lucide-react';
+import { BadgeCheck, GitCommitHorizontal, MessageSquare, Undo2 } from 'lucide-react';
import { nanoid } from 'nanoid';
-import { memo, useMemo } from 'react';
+import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { Link } from 'react-router';
import { useUserStore } from '@/store/user';
import { authSelectors, userProfileSelectors } from '@/store/user/selectors';
import { buildAuthReturnUrl, currentReturnPath } from '@/utils/authReturnUrl';
+import { checkDisplayTitle } from '../../utils';
import { useAcceptanceScope } from '../AcceptanceScope';
+import { collectEvidenceById } from '../Checks/CheckHistory';
+import type { AcceptanceCheck } from '../Checks/types';
+import { acceptanceCheckPath } from '../routes';
import { useAcceptanceBundle } from '../useAcceptanceBundle';
import { commentAnchorId, useCommentAnchor } from './anchor';
import CommentCard, { commentAuthorName, CommentAvatar } from './CommentCard';
import CommentComposer from './CommentComposer';
+import CommentThread from './CommentThread';
import type { DiscussionEntry } from './discussionTimeline';
import { buildDiscussionTimeline } from './discussionTimeline';
import { useAcceptanceComments } from './hooks';
import { styles, TIMELINE_NODE } from './styles';
+import ThreadEvidence from './ThreadEvidence';
import TimelineEvent from './TimelineEvent';
/** Enough room to start writing without the box dominating the column. */
@@ -61,6 +68,36 @@ const local = createStaticStyles(({ css }) => ({
font-size: 13px;
color: ${cssVar.colorTextTertiary};
`,
+ checkLink: css`
+ font-weight: 500;
+ color: ${cssVar.colorText};
+
+ &:hover {
+ color: ${cssVar.colorText};
+ text-decoration: underline;
+ }
+ `,
+ quote: css`
+ padding-block: 8px;
+ padding-inline: 12px;
+ border-inline-start: 2px solid ${cssVar.colorBorder};
+
+ font-size: 13px;
+ line-height: 1.65;
+ color: ${cssVar.colorText};
+ overflow-wrap: anywhere;
+ white-space: pre-wrap;
+ `,
+ regionBody: css`
+ padding-block: 4px 12px;
+ padding-inline: 14px;
+ `,
+ regionHeader: css`
+ padding-block: 10px 6px;
+ padding-inline: 14px;
+ font-size: 13px;
+ color: ${cssVar.colorTextSecondary};
+ `,
signInPrompt: css`
padding-block: 16px;
padding-inline: 16px;
@@ -157,6 +194,107 @@ const TimelineMessage = memo<{
TimelineMessage.displayName = 'AcceptanceTimelineMessage';
+/**
+ * "C2 · title", the way the checklist names a check. A link out of the page
+ * route opens that check's own view; an embedded viewer has no route of its own,
+ * so there it is just the name.
+ */
+const CheckReference = memo<{ check?: AcceptanceCheck }>(({ check }) => {
+ const { t } = useTranslation('verify');
+ const { acceptanceId, embedded } = useAcceptanceScope();
+ if (!check) return null;
+ const label = `C${check.seq} · ${checkDisplayTitle(check.title, t('acceptance.checks.holisticTitle'))}`;
+ if (embedded) return <span className={local.checkLink}>{label}</span>;
+ return (
+ <Link className={local.checkLink} to={acceptanceCheckPath(acceptanceId, check.id)}>
+ {label}
+ </Link>
+ );
+});
+
+CheckReference.displayName = 'AcceptanceDiscussionCheckReference';
+
+/**
+ * A note circled on a screenshot, as a pull request shows a review comment in
+ * its Conversation: which check it is about, the picture it points at, and the
+ * thread itself — still answerable and closable from here.
+ */
+const TimelineRegion = memo<{
+ anchored: boolean;
+ canComment: boolean;
+ canResolve: boolean;
+ check?: AcceptanceCheck;
+ onDelete: (id: string) => Promise<void>;
+ onReply: (rootId: string, content: string, attachments: { fileId: string }[]) => Promise<void>;
+ onResolve: (rootId: string, resolved: boolean) => Promise<void>;
+ thread: AcceptanceCommentThread;
+}>(({ anchored, canComment, canResolve, check, onDelete, onReply, onResolve, thread }) => {
+ const { t } = useTranslation('verify');
+ const { root } = thread;
+ const evidence =
+ check && root.evidenceId ? collectEvidenceById(check).get(root.evidenceId) : undefined;
+ const stale = Boolean(
+ check && root.evidenceId && !check.evidence.some((item) => item.id === root.evidenceId),
+ );
+
+ return (
+ <Flexbox
+ horizontal
+ align={'flex-start'}
+ className={styles.timelineEntry}
+ gap={12}
+ id={commentAnchorId(root.id)}
+ >
+ <span className={styles.timelineNode}>
+ <CommentAvatar comment={root} size={TIMELINE_NODE} />
+ </span>
+ <Flexbox className={cx(styles.box, anchored && styles.boxAnchored)}>
+ <Flexbox horizontal align={'center'} className={local.regionHeader} gap={6} wrap={'wrap'}>
+ <Icon icon={MessageSquare} size={13} />
+ <span>
+ {check
+ ? t('acceptance.comments.regionOn', { name: commentAuthorName(root.author) })
+ : commentAuthorName(root.author)}
+ </span>
+ <CheckReference check={check} />
+ </Flexbox>
+ <Flexbox
+ horizontal
+ align={'flex-start'}
+ className={local.regionBody}
+ gap={16}
+ wrap={'wrap'}
+ >
+ {evidence && (
+ <ThreadEvidence
+ comment={root}
+ evidence={evidence}
+ stale={stale}
+ roundIndex={
+ check?.timeline.find((entry) =>
+ entry.evidence.some((item) => item.id === root.evidenceId),
+ )?.roundIndex
+ }
+ />
+ )}
+ <Flexbox flex={1} style={{ minWidth: 220 }}>
+ <CommentThread
+ canComment={canComment}
+ canResolve={canResolve}
+ thread={thread}
+ onDelete={onDelete}
+ onReply={onReply}
+ onResolve={onResolve}
+ />
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+TimelineRegion.displayName = 'AcceptanceTimelineRegion';
+
/**
* 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.
@@ -172,26 +310,60 @@ const AcceptanceDiscussion = memo(() => {
const viewerId = useUserStore(userProfileSelectors.userId);
const isSignedIn = useUserStore(authSelectors.isLogin);
const { data } = useAcceptanceBundle(acceptanceId);
- const { canComment, create, error, isLoading, items, react, remove, threads } =
- useAcceptanceComments(acceptanceId);
+ const {
+ canApprove,
+ canComment,
+ create,
+ error,
+ isLoading,
+ items,
+ react,
+ remove,
+ setResolved,
+ threads,
+ } = useAcceptanceComments(acceptanceId);
const currentRunId = data?.rounds.at(-1)?.run.id;
const anchoredId = useCommentAnchor(items, embedded);
+ const checksById = useMemo(
+ () => new Map((data?.checks ?? []).map((check) => [check.id, check])),
+ [data?.checks],
+ );
const timeline = useMemo(
() =>
buildDiscussionTimeline({
approvals: items.filter((item) => item.kind === 'approval'),
+ checks: data?.checks,
items,
rounds: (data?.rounds ?? []).map(({ run }) => ({
createdAt: run.createdAt,
+ decisionDetail: run.decisionDetail,
id: run.id,
roundIndex: run.roundIndex,
+ userDecision: run.userDecision,
})),
threads,
}),
- [data?.rounds, items, threads],
+ [data?.checks, data?.rounds, items, threads],
+ );
+
+ // Same rule as on the check row: whoever raised a note may close it, and
+ // the delivery's reviewers may close anyone's.
+ const canResolveThread = useCallback(
+ (thread: AcceptanceCommentThread) =>
+ canApprove ||
+ (Boolean(viewerId) && thread.root.authorUserId === viewerId && !thread.root.deletedAt),
+ [canApprove, viewerId],
);
+ const replyToRegion = (rootId: string, content: string, attachments: { fileId: string }[]) =>
+ create({
+ attachments,
+ clientId: `${rootId}:${Date.now()}`,
+ content,
+ contextRunId: currentRunId,
+ parentCommentId: rootId,
+ });
if (isLoading && timeline.length === 0 && !canComment) return null;
@@ -208,6 +380,55 @@ const AcceptanceDiscussion = memo(() => {
onReact={react}
/>
);
+ if (entry.kind === 'region')
+ return (
+ <TimelineRegion
+ anchored={entry.thread.root.id === anchoredId}
+ canComment={canComment}
+ canResolve={canResolveThread(entry.thread)}
+ key={entry.thread.root.id}
+ thread={entry.thread}
+ check={
+ entry.thread.root.checkItemId
+ ? checksById.get(entry.thread.root.checkItemId)
+ : undefined
+ }
+ onDelete={remove}
+ onReply={replyToRegion}
+ onResolve={setResolved}
+ />
+ );
+ if (entry.kind === 'checkReject') {
+ const check = checksById.get(entry.checkItemId);
+ return (
+ <TimelineEvent
+ at={entry.at}
+ icon={Undo2}
+ key={`reject-${entry.checkItemId}-${entry.at.getTime()}`}
+ text={
+ <>
+ <CheckReference check={check} />{' '}
+ {t('acceptance.comments.checkRejected', { round: entry.roundIndex })}
+ {entry.annotationCount > 0 &&
+ ` · ${t('acceptance.comments.checkRejectedRegions', { count: entry.annotationCount })}`}
+ </>
+ }
+ >
+ {entry.comment && <div className={local.quote}>{entry.comment}</div>}
+ </TimelineEvent>
+ );
+ }
+ if (entry.kind === 'roundReject')
+ return (
+ <TimelineEvent
+ at={entry.at}
+ icon={Undo2}
+ key={`round-reject-${entry.roundIndex}`}
+ text={t('acceptance.comments.roundRejected', { round: entry.roundIndex })}
+ >
+ {entry.comment && <div className={local.quote}>{entry.comment}</div>}
+ </TimelineEvent>
+ );
if (entry.kind === 'approval') {
const who =
entry.approval.contextRoundIndex === null
diff --git a/src/features/Acceptance/Viewer/Comments/ThreadEvidence.test.ts b/src/features/Acceptance/Viewer/Comments/ThreadEvidence.test.ts
new file mode 100644
index 00000000000..62ea0e6f8b2
--- /dev/null
+++ b/src/features/Acceptance/Viewer/Comments/ThreadEvidence.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it } from 'vitest';
+
+import { thumbnailCropOffset } from './ThreadEvidence';
+
+describe('thumbnailCropOffset', () => {
+ it('leaves a thumbnail that already fits untouched', () => {
+ expect(thumbnailCropOffset({ height: 800, width: 1280 }, { height: 0.1, y: 0.8 })).toBe(0);
+ });
+
+ it('centers the circled region of a tall screenshot in the window', () => {
+ // 1170×3600 at 220px wide is ~677px tall; a region centered at 50% sits at ~338px.
+ const offset = thumbnailCropOffset({ height: 3600, width: 1170 }, { height: 0.1, y: 0.45 });
+ expect(offset).toBeCloseTo(677 / 2 - 120, 0);
+ });
+
+ it('never crops past either end of the picture', () => {
+ const size = { height: 3600, width: 1170 };
+ expect(thumbnailCropOffset(size, { height: 0.02, y: 0 })).toBe(0);
+ expect(thumbnailCropOffset(size, { height: 0.02, y: 0.98 })).toBeCloseTo(677 - 240, 0);
+ });
+
+ it('cannot crop without the picture size', () => {
+ expect(thumbnailCropOffset({}, { height: 0.1, y: 0.9 })).toBe(0);
+ });
+});
diff --git a/src/features/Acceptance/Viewer/Comments/ThreadEvidence.tsx b/src/features/Acceptance/Viewer/Comments/ThreadEvidence.tsx
index a9d4253eb5a..c4f79ed2412 100644
--- a/src/features/Acceptance/Viewer/Comments/ThreadEvidence.tsx
+++ b/src/features/Acceptance/Viewer/Comments/ThreadEvidence.tsx
@@ -4,7 +4,7 @@ import type { AcceptanceCommentItem } from '@lobechat/types';
import { Flexbox } from '@lobehub/ui';
import { Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
-import { memo } from 'react';
+import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import type { AcceptanceEvidence } from '../Checks/types';
@@ -12,8 +12,30 @@ import { AnnotatedImage } from '../Evidence/Annotation';
import { useAcceptanceAuthorColor } from './authorColor';
const THUMBNAIL_WIDTH = 220;
+/** A long screenshot at thumbnail width would run the height of the page. */
+const THUMBNAIL_MAX_HEIGHT = 240;
+
+/**
+ * How far to pull a tall thumbnail up so the circled region sits in the
+ * window — the region is what the remark is about, not the top of the page.
+ */
+export const thumbnailCropOffset = (
+ size: { height?: number | null; width?: number | null },
+ rect: { height: number; y: number },
+) => {
+ if (!size.width || !size.height) return 0;
+ const height = (THUMBNAIL_WIDTH * size.height) / size.width;
+ if (height <= THUMBNAIL_MAX_HEIGHT) return 0;
+ const center = (rect.y + rect.height / 2) * height;
+ return Math.min(Math.max(center - THUMBNAIL_MAX_HEIGHT / 2, 0), height - THUMBNAIL_MAX_HEIGHT);
+};
const styles = createStaticStyles(({ css }) => ({
+ crop: css`
+ overflow: hidden;
+ max-height: ${THUMBNAIL_MAX_HEIGHT}px;
+ border-radius: ${cssVar.borderRadius};
+ `,
caption: css`
font-size: 12px;
color: ${cssVar.colorTextTertiary};
@@ -43,16 +65,36 @@ interface ThreadEvidenceProps {
const ThreadEvidence = memo<ThreadEvidenceProps>(({ comment, evidence, roundIndex, stale }) => {
const { t } = useTranslation('verify');
const authorColor = useAcceptanceAuthorColor();
+ // Imported or older evidence may carry no stored size; the picture itself
+ // knows it once loaded, and until then the crop stays at the top.
+ const [loaded, setLoaded] = useState<{ height: number; width: number }>();
if (!evidence.fileUrl || !comment.rect) return null;
+ const size =
+ evidence.fileWidth && evidence.fileHeight
+ ? { height: evidence.fileHeight, width: evidence.fileWidth }
+ : loaded;
return (
<Flexbox className={styles.wrapper} gap={4}>
- <AnnotatedImage
- annotations={[{ color: authorColor(comment.authorUserId), rect: comment.rect }]}
- imageStyle={{ width: THUMBNAIL_WIDTH }}
- showComments={false}
- src={evidence.fileUrl}
- />
+ <div className={styles.crop}>
+ <div
+ style={{
+ marginBlockStart: -thumbnailCropOffset(size ?? {}, comment.rect),
+ }}
+ >
+ <AnnotatedImage
+ annotations={[{ color: authorColor(comment.authorUserId), rect: comment.rect }]}
+ imageStyle={{ width: THUMBNAIL_WIDTH }}
+ showComments={false}
+ src={evidence.fileUrl}
+ onLoad={(event) => {
+ const { naturalHeight, naturalWidth } = event.currentTarget;
+ if (naturalWidth && naturalHeight)
+ setLoaded({ height: naturalHeight, width: naturalWidth });
+ }}
+ />
+ </div>
+ </div>
<span className={styles.caption}>
{stale && roundIndex !== undefined
? t('acceptance.comments.evidenceFromRound', { round: roundIndex })
diff --git a/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx b/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx
index 1475ef8e60e..ff3fc3d370f 100644
--- a/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx
+++ b/src/features/Acceptance/Viewer/Comments/TimelineEvent.tsx
@@ -1,12 +1,24 @@
import { Flexbox, Icon } from '@lobehub/ui';
import type { LucideIcon } from 'lucide-react';
+import type { ReactNode } from 'react';
import { useActivityTime } from '@/hooks/useActivityTime';
import { styles } from './styles';
/** A persisted event, shared by the interactive discussion and read-only report. */
-const TimelineEvent = ({ at, icon, text }: { at: Date; icon: LucideIcon; text: string }) => {
+const TimelineEvent = ({
+ at,
+ children,
+ icon,
+ text,
+}: {
+ at: Date;
+ /** What the event said, under its one line — a send-back's reason. */
+ children?: ReactNode;
+ icon: LucideIcon;
+ text: ReactNode;
+}) => {
const time = useActivityTime(at);
return (
<Flexbox horizontal align={'flex-start'} className={styles.timelineEntry} gap={12}>
@@ -15,11 +27,14 @@ const TimelineEvent = ({ at, icon, text }: { at: Date; icon: LucideIcon; text: s
<Icon icon={icon} size={12} />
</span>
</span>
- <Flexbox horizontal align={'center'} className={styles.event} gap={8} wrap={'wrap'}>
- <span>{text}</span>
- <span className={styles.meta} title={time.title}>
- {time.text}
- </span>
+ <Flexbox flex={1} gap={6} style={{ minWidth: 0 }}>
+ <Flexbox horizontal align={'center'} className={styles.event} gap={8} wrap={'wrap'}>
+ <span>{text}</span>
+ <span className={styles.meta} title={time.title}>
+ {time.text}
+ </span>
+ </Flexbox>
+ {children}
</Flexbox>
</Flexbox>
);
diff --git a/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts b/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts
index 59b062f69f3..28c344c211e 100644
--- a/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts
+++ b/src/features/Acceptance/Viewer/Comments/discussionTimeline.test.ts
@@ -92,7 +92,7 @@ describe('round notes', () => {
});
describe('discussion split', () => {
- it('keeps delivery-wide remarks and leaves circled regions to the checks', () => {
+ it('splits delivery-wide remarks from circled regions', () => {
const message = thread(item());
const region = thread(item({ anchorType: 'evidence', checkItemId: 'c2', evidenceId: 'ev1' }));
@@ -134,20 +134,49 @@ describe('discussion count', () => {
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' });
-
+ it('excludes bare round events, approvals and empty notes', () => {
expect(count([])).toBe(0);
expect(
count([
item({ content: ' ', contextRunId: 'run', kind: 'proposal' }),
item({ kind: 'approval' }),
- region,
- item({ parentCommentId: region.id }),
]),
).toBe(0);
});
+ it('counts a circled note and each of its replies', () => {
+ const region = item({ anchorType: 'evidence', evidenceId: 'ev1' });
+
+ expect(count([region, item({ parentCommentId: region.id })])).toBe(2);
+ });
+
+ it('counts send-backs that say why, and skips bare ones', () => {
+ const base = { approvals: [], rounds: [], threads: [] };
+ const review = (overrides: object) => ({
+ action: 'reject' as const,
+ createdAt: '2026-09-01T11:00:00Z',
+ roundIndex: 1,
+ ...overrides,
+ });
+
+ expect(
+ countDiscussionMessages({
+ ...base,
+ checks: [
+ {
+ id: 'c1',
+ reviews: [
+ review({ comment: 'still red' }),
+ review({ annotations: [{}] }),
+ review({}),
+ review({ action: 'accept', comment: 'fine' }),
+ ],
+ },
+ ],
+ }),
+ ).toBe(2);
+ });
+
it('excludes deleted messages while keeping their surviving replies', () => {
const root = item({ deletedAt: new Date() });
const reply = item({ parentCommentId: root.id });
@@ -265,17 +294,66 @@ describe('buildDiscussionTimeline', () => {
]);
});
- it('leaves the answers to a circled region out of the chat', () => {
+ it('keeps the answers to a circled region inside its region entry', () => {
const root = item({ anchorType: 'evidence', evidenceId: 'ev1' });
const reply = item({ parentCommentId: root.id });
+ const region = thread(root, [reply]);
+ const timeline = buildDiscussionTimeline({ approvals: [], rounds: [], threads: [region] });
+
+ expect(timeline).toEqual([{ at: new Date(root.createdAt), kind: 'region', thread: region }]);
+ });
+
+ it('drops a withdrawn region note nobody answered', () => {
+ const root = item({ anchorType: 'evidence', deletedAt: new Date(), evidenceId: 'ev1' });
const timeline = buildDiscussionTimeline({
approvals: [],
rounds: [],
- threads: [thread(root, [reply])],
+ threads: [thread(root)],
});
+
expect(timeline).toEqual([]);
});
+ it('lists check and round send-backs with their reasons, in order', () => {
+ const timeline = buildDiscussionTimeline({
+ approvals: [],
+ checks: [
+ {
+ id: 'c2',
+ reviews: [
+ { action: 'accept', createdAt: '2026-09-01T10:30:00Z', roundIndex: 1 },
+ {
+ action: 'reject',
+ annotations: [{}, {}],
+ comment: ' not like web ',
+ createdAt: '2026-09-01T11:00:00Z',
+ roundIndex: 1,
+ },
+ ],
+ },
+ ],
+ rounds: [
+ {
+ createdAt: '2026-09-01T10:00:00Z',
+ decisionDetail: { comment: 'redo grouping', decidedAt: '2026-09-01T11:05:00Z' },
+ id: 'run-1',
+ roundIndex: 1,
+ userDecision: 'reject',
+ },
+ ],
+ threads: [],
+ });
+
+ expect(timeline.map((entry) => entry.kind)).toEqual(['round', 'checkReject', 'roundReject']);
+ expect(timeline[1]).toMatchObject({
+ annotationCount: 2,
+ checkItemId: 'c2',
+ comment: 'not like web',
+ roundIndex: 1,
+ });
+ expect(timeline[2]).toMatchObject({ comment: 'redo grouping', roundIndex: 1 });
+ });
+
it('drops rounds with no index and withdrawn approvals', () => {
const timeline = buildDiscussionTimeline({
approvals: [item({ deletedAt: new Date(), kind: 'approval' })],
@@ -289,9 +367,9 @@ describe('buildDiscussionTimeline', () => {
expect(timeline).toEqual([]);
});
- it('never lists a circled region as a message', () => {
+ it('never lists a circled region as a flat message', () => {
const region = thread(item({ anchorType: 'evidence', evidenceId: 'ev1' }));
const timeline = buildDiscussionTimeline({ approvals: [], rounds: [], threads: [region] });
- expect(timeline).toEqual([]);
+ expect(timeline.map((entry) => entry.kind)).toEqual(['region']);
});
});
diff --git a/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts b/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts
index 9bcaaf2fe4d..fce14376d02 100644
--- a/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts
+++ b/src/features/Acceptance/Viewer/Comments/discussionTimeline.ts
@@ -3,14 +3,25 @@ import type { AcceptanceCommentItem, AcceptanceCommentThread } from '@lobechat/t
/**
* The discussion is a conversation, not a filing cabinet: it carries messages
* about the delivery as a whole, strung together with the events that happened
- * between them (a round landing, a reviewer approving).
+ * between them (a round landing, a reviewer approving, a check sent back).
*
- * Comments circled on a screenshot are deliberately NOT here — a region note
- * only means anything next to the pixels it points at, so it lives on the check
- * that owns that evidence.
+ * A note circled on a screenshot is still a turn in that conversation — the way
+ * a review comment on a diff line shows up in a pull request's Conversation
+ * tab. It keeps its own shape (`region`) so it renders with the picture and the
+ * check it points at, and stays one thread instead of being flattened.
*/
export type DiscussionEntry =
| { at: Date; comment: AcceptanceCommentItem; kind: 'message' }
+ | { at: Date; kind: 'region'; thread: AcceptanceCommentThread }
+ | {
+ annotationCount: number;
+ at: Date;
+ checkItemId: string;
+ comment?: string;
+ kind: 'checkReject';
+ roundIndex: number;
+ }
+ | { at: Date; comment?: string; kind: 'roundReject'; roundIndex: number }
| {
at: Date;
kind: 'round';
@@ -31,15 +42,34 @@ export const messageThreads = (threads: AcceptanceCommentThread[]) =>
(thread) => thread.root.anchorType === 'acceptance' && thread.root.kind !== 'proposal',
);
-/** Threads circled on evidence, which belong on the check rows instead. */
+/** Threads circled on evidence: shown on their check, and as a region entry here. */
export const regionThreads = (threads: AcceptanceCommentThread[]) =>
threads.filter((thread) => thread.root.anchorType === 'evidence');
+interface ReviewInput {
+ action: 'accept' | 'ignore' | 'reject';
+ annotations?: unknown[];
+ comment?: string;
+ createdAt: string;
+ roundIndex: number;
+}
+
+interface RoundInput {
+ createdAt: Date | string | null;
+ /** The round's own verdict — only its `comment` is read. */
+ decisionDetail?: { comment?: string; decidedAt?: string } | null;
+ id?: string;
+ roundIndex: number | null;
+ userDecision?: string | null;
+}
+
interface BuildInput {
approvals: AcceptanceCommentItem[];
+ /** Union checks — their reject trail is the reviewer's side of the story. */
+ checks?: { id: string; reviews: ReviewInput[] }[];
/** Every comment of the acceptance — proposals are read straight off it. */
items?: AcceptanceCommentItem[];
- rounds: { createdAt: Date | string | null; id?: string; roundIndex: number | null }[];
+ rounds: RoundInput[];
threads: AcceptanceCommentThread[];
}
@@ -50,6 +80,7 @@ interface BuildInput {
*/
export const buildDiscussionTimeline = ({
approvals,
+ checks = [],
items = [],
rounds,
threads,
@@ -71,8 +102,39 @@ export const buildDiscussionTimeline = ({
for (const comment of [thread.root, ...thread.replies])
entries.push({ at: new Date(comment.createdAt), comment, kind: 'message' });
+ // A region note leads with its root: that is when it was said, and its
+ // replies stay under it because they are about the same spot.
+ // A withdrawn note with nobody answering it has nothing left to show.
+ for (const thread of regionThreads(threads)) {
+ if (thread.root.deletedAt && thread.replies.every((reply) => reply.deletedAt)) continue;
+ entries.push({ at: new Date(thread.root.createdAt), kind: 'region', thread });
+ }
+
+ // Sending a check back is the reviewer's loudest turn, and it lives on the
+ // check's result row rather than in the comment table — without it the
+ // discussion of a rejected delivery reads as if nobody had said anything.
+ for (const check of checks)
+ for (const review of check.reviews) {
+ if (review.action !== 'reject' || !review.createdAt) continue;
+ entries.push({
+ annotationCount: review.annotations?.length ?? 0,
+ at: new Date(review.createdAt),
+ checkItemId: check.id,
+ comment: review.comment?.trim() || undefined,
+ kind: 'checkReject',
+ roundIndex: review.roundIndex,
+ });
+ }
+
for (const round of rounds) {
if (round.roundIndex === null || !round.createdAt) continue;
+ if (round.userDecision === 'reject')
+ entries.push({
+ at: new Date(round.decisionDetail?.decidedAt ?? round.createdAt),
+ comment: round.decisionDetail?.comment?.trim() || undefined,
+ kind: 'roundReject',
+ roundIndex: round.roundIndex,
+ });
entries.push({
at: new Date(round.createdAt),
kind: 'round',
@@ -90,9 +152,32 @@ 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. */
+/**
+ * The discussion badge counts contributions: every surviving remark (a region
+ * note and each of its replies included), the round's own note, and each
+ * send-back that says why.
+ */
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;
+ buildDiscussionTimeline(input).reduce((total, entry) => {
+ switch (entry.kind) {
+ case 'message': {
+ return total + (entry.comment.deletedAt ? 0 : 1);
+ }
+ case 'region': {
+ const { replies, root } = entry.thread;
+ return total + [root, ...replies].filter((comment) => !comment.deletedAt).length;
+ }
+ case 'round': {
+ return total + (entry.proposal?.content.trim() ? 1 : 0);
+ }
+ case 'checkReject': {
+ return total + (entry.comment || entry.annotationCount > 0 ? 1 : 0);
+ }
+ case 'roundReject': {
+ return total + (entry.comment ? 1 : 0);
+ }
+ default: {
+ return total;
+ }
+ }
+ }, 0);
diff --git a/src/features/Acceptance/Viewer/Evidence/Annotation.tsx b/src/features/Acceptance/Viewer/Evidence/Annotation.tsx
index b6e5ea66281..691bb102890 100644
--- a/src/features/Acceptance/Viewer/Evidence/Annotation.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/Annotation.tsx
@@ -156,6 +156,7 @@ interface AnnotatedImageProps {
*/
annotations: EvidenceOverlay[];
imageStyle?: React.CSSProperties;
+ onLoad?: React.ReactEventHandler<HTMLImageElement>;
/** Render the per-region notes under the image. Off when a caller already lists them. */
showComments?: boolean;
src: string;
@@ -163,7 +164,7 @@ interface AnnotatedImageProps {
/** An evidence image with its circled regions (read-only display). */
export const AnnotatedImage = memo<AnnotatedImageProps>(
- ({ annotations, imageStyle, showComments = true, src }) => {
+ ({ annotations, imageStyle, onLoad, showComments = true, src }) => {
// A badge is noise on a single unnumbered region, but required as soon as
// anything refers to a region by number.
const numbered = annotations.length > 1 || annotations.some((item) => item.label !== undefined);
@@ -171,7 +172,7 @@ export const AnnotatedImage = memo<AnnotatedImageProps>(
return (
<Flexbox gap={6} style={{ maxWidth: '100%', width: 'fit-content' }}>
<div className={styles.frame}>
- <img alt={''} className={styles.image} src={src} style={imageStyle} />
+ <img alt={''} className={styles.image} src={src} style={imageStyle} onLoad={onLoad} />
{annotations.map((annotation, index) => (
<div
className={styles.rect}
diff --git a/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx b/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx
index 6d7e5f42eec..9171e9af0fb 100644
--- a/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/EvidenceList.tsx
@@ -4,7 +4,7 @@ import { readEvidenceChapters } from '@lobechat/const/verify';
import type { AcceptanceReviewAnnotation } from '@lobechat/types';
import { Flexbox, Image } from '@lobehub/ui';
import { useResponsive } from 'antd-style';
-import { memo } from 'react';
+import { memo, type ReactNode } from 'react';
import AudioPlayer from '@/features/AudioPlayer';
@@ -22,13 +22,14 @@ import {
import type { AcceptanceEvidence } from '../Checks/types';
import { AnnotatedImage } from '../Evidence/Annotation';
import { ScreenshotTiles } from '../Evidence/ScreenshotTiles';
-import { IMAGE_EVIDENCE, imageRatio, isVisual } from './evidence';
+import { IMAGE_EVIDENCE, imageRatio, isAnnotatable, isVisual } from './evidence';
+import FloatingCommentAction, { FLOATING_ACTION_HOST } from './FloatingCommentAction';
import type { EvidenceOverlayMap } from './overlay';
import { styles } from './styles';
import { VideoEvidencePlayer } from './Video/VideoEvidencePlayer';
/** Flat media for a comparison side — the card frames it, so no own border/radius. */
-const comparisonContent = (item: AcceptanceEvidence) => {
+const comparisonContent = (item: AcceptanceEvidence, action?: ReactNode) => {
if (item.type === 'video')
return <video controls src={item.fileUrl!} style={{ display: 'block', width: '100%' }} />;
if (item.type === 'audio')
@@ -44,13 +45,14 @@ const comparisonContent = (item: AcceptanceEvidence) => {
return (
<ScreenshotTiles
flat
+ action={action}
alt={item.description ?? item.fileName ?? item.type}
fileHeight={item.fileHeight}
fileWidth={item.fileWidth}
src={item.fileUrl}
/>
);
- return (
+ const image = (
<Image
preview
alt={item.description ?? item.fileName ?? item.type}
@@ -60,10 +62,22 @@ const comparisonContent = (item: AcceptanceEvidence) => {
variant={'borderless'}
/>
);
+ if (!action) return image;
+ return (
+ <div style={{ position: 'relative' }} {...{ [FLOATING_ACTION_HOST]: '' }}>
+ {image}
+ {action}
+ </div>
+ );
};
export const EvidenceList = memo<{
evidence: AcceptanceEvidence[];
+ /**
+ * Comment on (or mark) one picture straight from it — floats over each
+ * annotatable image, labelled for what it opens.
+ */
+ onComment?: { label: string; open: (id: string) => void };
onReviewEvidence?: (id: string) => void;
/**
* Regions to draw over an evidence image, keyed by evidence id. Used by the
@@ -76,8 +90,12 @@ export const EvidenceList = memo<{
onRefreshEvidenceUrl?: (evidenceId: string) => Promise<string | undefined>;
/** The standing reject's notes — video ones are pinned to the player's timeline. */
reviewNotes?: AcceptanceReviewAnnotation[];
-}>(({ evidence, overlays, onRefreshEvidenceUrl, onReviewEvidence, reviewNotes }) => {
+}>(({ evidence, overlays, onComment, onRefreshEvidenceUrl, onReviewEvidence, reviewNotes }) => {
const { md = true } = useResponsive();
+ const commentAction = (item: AcceptanceEvidence) =>
+ onComment && isAnnotatable(item) ? (
+ <FloatingCommentAction title={onComment.label} onClick={() => onComment.open(item.id)} />
+ ) : undefined;
const sorted = [...evidence].sort((a, b) => (isVisual(b) ? 1 : 0) - (isVisual(a) ? 1 : 0));
if (sorted.length === 0) return null;
@@ -104,7 +122,7 @@ export const EvidenceList = memo<{
readEvidenceComparison(item.metadata)?.label ??
meaningfulEvidenceCaption(item.description) ??
undefined,
- content: comparisonContent(item),
+ content: comparisonContent(item, commentAction(item)),
});
const consumedScreenshotIds = new Set<string>();
@@ -158,36 +176,45 @@ export const EvidenceList = memo<{
</Flexbox>
);
if (!md && onReviewEvidence && item.fileUrl && IMAGE_EVIDENCE.has(item.type)) {
+ const action = commentAction(item);
+ // The tap reviews; the comment shortcut sits beside the button rather
+ // than inside it, since a button cannot hold another one.
return (
- <button
+ <div
key={item.id}
- type={'button'}
- style={{
- padding: 0,
- width: '100%',
- border: 0,
- background: 'none',
- textAlign: 'start',
- cursor: 'pointer',
- }}
- onClick={() => onReviewEvidence(item.id)}
+ style={{ position: 'relative', width: '100%' }}
+ {...(action ? { [FLOATING_ACTION_HOST]: '' } : {})}
>
- <img
- alt={item.description ?? item.fileName ?? item.type}
- loading={'lazy'}
- src={item.fileUrl}
+ <button
+ type={'button'}
style={{
- display: 'block',
- maxWidth: '100%',
+ padding: 0,
width: '100%',
- height: 180,
- objectFit: 'cover',
- objectPosition: 'top',
- borderRadius: 8,
+ border: 0,
+ background: 'none',
+ textAlign: 'start',
+ cursor: 'pointer',
}}
- />
- {caption}
- </button>
+ onClick={() => onReviewEvidence(item.id)}
+ >
+ <img
+ alt={item.description ?? item.fileName ?? item.type}
+ loading={'lazy'}
+ src={item.fileUrl}
+ style={{
+ display: 'block',
+ maxWidth: '100%',
+ width: '100%',
+ height: 180,
+ objectFit: 'cover',
+ objectPosition: 'top',
+ borderRadius: 8,
+ }}
+ />
+ {caption}
+ </button>
+ {action}
+ </div>
);
}
const overlay = overlays?.get(item.id);
@@ -213,6 +240,7 @@ export const EvidenceList = memo<{
const shotCaption = meaningfulEvidenceCaption(shot.description);
return (
<ScreenshotTiles
+ action={commentAction(shot)}
alt={shot.description ?? shot.fileName ?? shot.type}
annotations={overlays?.get(shot.id)}
fileHeight={shot.fileHeight}
@@ -231,8 +259,15 @@ export const EvidenceList = memo<{
);
}
if (item.fileUrl && IMAGE_EVIDENCE.has(item.type)) {
+ const action = commentAction(item);
return (
- <Flexbox gap={4} key={item.id} style={{ maxWidth: '100%', width: 'fit-content' }}>
+ <Flexbox
+ gap={4}
+ key={item.id}
+ style={{ maxWidth: '100%', position: 'relative', width: 'fit-content' }}
+ {...(action ? { [FLOATING_ACTION_HOST]: '' } : {})}
+ >
+ {action}
{overlay?.length ? (
<AnnotatedImage
annotations={overlay}
diff --git a/src/features/Acceptance/Viewer/Evidence/FloatingCommentAction.tsx b/src/features/Acceptance/Viewer/Evidence/FloatingCommentAction.tsx
new file mode 100644
index 00000000000..494babb2d11
--- /dev/null
+++ b/src/features/Acceptance/Viewer/Evidence/FloatingCommentAction.tsx
@@ -0,0 +1,88 @@
+'use client';
+
+import { ActionIcon } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { MessageSquarePlus } from 'lucide-react';
+import { memo } from 'react';
+
+/** Marks the box the action floats over; hovering it reveals the action. */
+export const FLOATING_ACTION_HOST = 'data-floating-action-host';
+
+const styles = createStaticStyles(({ css }) => ({
+ button: css`
+ pointer-events: auto;
+
+ position: sticky;
+ inset-block-start: 12px;
+
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 50%;
+
+ opacity: 0;
+ background: ${cssVar.colorBgElevated};
+ box-shadow: ${cssVar.boxShadowTertiary};
+
+ transition: opacity ${cssVar.motionDurationMid};
+
+ [${FLOATING_ACTION_HOST}]:hover &,
+ &:focus-visible {
+ opacity: 1;
+ }
+
+ /* No hover to reveal it with: a touch reader has to see it to use it. */
+ @media (hover: none) {
+ opacity: 1;
+ }
+ `,
+ /**
+ * Spans the whole picture so the button can stick to the top of the viewport
+ * while a long screenshot scrolls past, and never leave the picture it
+ * belongs to. It sits in the margin to the right of the picture, so it never
+ * covers what is being commented on, and outside the comment pins that
+ * straddle the right edge. Still a child of the host, so moving the pointer
+ * onto it keeps it revealed.
+ */
+ rail: css`
+ pointer-events: none;
+
+ position: absolute;
+ z-index: 5;
+ inset-block: 0;
+ inset-inline-end: -40px;
+
+ /* A phone column has no margin to spare: tuck it inside the picture. */
+ @media (width <= 767px) {
+ inset-block: 8px;
+ inset-inline-end: 8px;
+ }
+ `,
+}));
+
+/**
+ * Comment on this picture without leaving it. The check's own comment and
+ * annotate buttons sit under all of its evidence, so on a check with a few tall
+ * screenshots the reviewer scrolled past everything they were looking at to
+ * reach them — and then had to pick the picture again in the modal.
+ *
+ * Render inside a positioned box carrying {@link FLOATING_ACTION_HOST}.
+ */
+const FloatingCommentAction = memo<{ onClick: () => void; title: string }>(({ onClick, title }) => {
+ return (
+ <div className={styles.rail}>
+ <ActionIcon
+ className={styles.button}
+ icon={MessageSquarePlus}
+ size={'small'}
+ title={title}
+ onClick={(event) => {
+ event.stopPropagation();
+ onClick();
+ }}
+ />
+ </div>
+ );
+});
+
+FloatingCommentAction.displayName = 'AcceptanceFloatingCommentAction';
+
+export default FloatingCommentAction;
diff --git a/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx b/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx
index 8eb3d9fcc17..3efd40d8594 100644
--- a/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/ScreenshotTiles.tsx
@@ -7,6 +7,7 @@ import { Check, MessageSquare, X } from 'lucide-react';
import { memo, type ReactNode, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { FLOATING_ACTION_HOST } from './FloatingCommentAction';
import type { EvidenceOverlay } from './overlay';
import {
annotationInSlice,
@@ -329,6 +330,8 @@ const AnnotationFace = memo<{ name?: string; size?: number; src?: string | null
AnnotationFace.displayName = 'AcceptanceAnnotationFace';
interface ScreenshotTilesProps {
+ /** Floats over the picture (see `FloatingCommentAction`). */
+ action?: ReactNode;
alt: string;
annotations?: EvidenceOverlay[];
caption?: ReactNode;
@@ -340,7 +343,7 @@ interface ScreenshotTilesProps {
}
export const ScreenshotTiles = memo<ScreenshotTilesProps>(
- ({ alt, annotations, caption, fileHeight, fileWidth, flat = false, src }) => {
+ ({ action, alt, annotations, caption, fileHeight, fileWidth, flat = false, src }) => {
const { t } = useTranslation('verify');
const [natural, setNatural] = useState(
fileWidth && fileHeight ? { height: fileHeight, width: fileWidth } : undefined,
@@ -429,10 +432,11 @@ export const ScreenshotTiles = memo<ScreenshotTilesProps>(
const shell = (width: string | number, body: ReactNode) => (
<Flexbox gap={4} style={{ maxWidth: '100%', width }}>
- <div className={styles.stage}>
+ <div className={styles.stage} {...(action ? { [FLOATING_ACTION_HOST]: '' } : {})}>
{body}
{pins}
{note}
+ {action}
</div>
{caption}
</Flexbox>
diff --git a/src/features/Acceptance/Viewer/Evidence/evidence.ts b/src/features/Acceptance/Viewer/Evidence/evidence.ts
index 18c8be6d1ee..224aaca741c 100644
--- a/src/features/Acceptance/Viewer/Evidence/evidence.ts
+++ b/src/features/Acceptance/Viewer/Evidence/evidence.ts
@@ -49,3 +49,23 @@ export const evidenceCounts = (evidence: AcceptanceEvidence[]) => {
export const imageRatio = (item: AcceptanceEvidence): string | undefined =>
item.fileWidth && item.fileHeight ? `${item.fileWidth} / ${item.fileHeight}` : undefined;
+
+/**
+ * What the shortcut floating on each picture opens. A reader comments on a
+ * region; the author, who gives region feedback through the reject, marks one.
+ * Where tapping the picture already opens that marking (a reviewer's phone),
+ * a second control for the same thing is left out.
+ */
+export const evidenceShortcut = ({
+ canComment,
+ canMark,
+ tapMarks,
+}: {
+ canComment: boolean;
+ canMark: boolean;
+ tapMarks: boolean;
+}): 'annotate' | 'comment' | undefined => {
+ if (canComment) return 'comment';
+ if (canMark && !tapMarks) return 'annotate';
+ return undefined;
+};
diff --git a/src/features/Acceptance/Viewer/Evidence/evidenceShortcut.test.ts b/src/features/Acceptance/Viewer/Evidence/evidenceShortcut.test.ts
new file mode 100644
index 00000000000..e9e74305fd4
--- /dev/null
+++ b/src/features/Acceptance/Viewer/Evidence/evidenceShortcut.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest';
+
+import { evidenceShortcut } from './evidence';
+
+describe('evidenceShortcut', () => {
+ it('offers a region comment to a reader who may comment, even where the tap reviews', () => {
+ expect(evidenceShortcut({ canComment: true, canMark: true, tapMarks: true })).toBe('comment');
+ expect(evidenceShortcut({ canComment: true, canMark: false, tapMarks: false })).toBe('comment');
+ });
+
+ it('offers marking to the author on desktop', () => {
+ expect(evidenceShortcut({ canComment: false, canMark: true, tapMarks: false })).toBe(
+ 'annotate',
+ );
+ });
+
+ it('leaves the author no duplicate where tapping the picture already marks it', () => {
+ expect(evidenceShortcut({ canComment: false, canMark: true, tapMarks: true })).toBeUndefined();
+ });
+
+ it('offers nothing when the viewer can neither comment nor mark', () => {
+ expect(
+ evidenceShortcut({ canComment: false, canMark: false, tapMarks: false }),
+ ).toBeUndefined();
+ });
+});
diff --git a/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsx b/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsx
index d6942d4cf10..d9e0a5fbc6b 100644
--- a/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsx
+++ b/src/features/Acceptance/Viewer/ReadOnly/Discussion.tsx
@@ -128,6 +128,18 @@ const ReadDiscussion = () => {
/>
);
}
+ // A circled note reads as its thread; the picture it points at stays on
+ // the check section of this report.
+ if (entry.kind === 'region')
+ return (
+ <Flexbox gap={8} key={entry.thread.root.id}>
+ {[entry.thread.root, ...entry.thread.replies].map((comment) => (
+ <ReadComment comment={comment} key={comment.id} />
+ ))}
+ </Flexbox>
+ );
+ // Send-backs are only built from the checks, which this report does not pass.
+ if (entry.kind !== 'message') return null;
return <ReadComment comment={entry.comment} key={entry.comment.id} threaded={false} />;
})}
</Flexbox>