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: improve mobile Acceptance review and repair handoff (#19260)

Arvin Xuf648b9a81c15
diff --git a/locales/en-US/verify.json b/locales/en-US/verify.json
index cf193a3541a..469ed68b286 100644
--- a/locales/en-US/verify.json
+++ b/locales/en-US/verify.json
@@ -22,8 +22,9 @@
"acceptance.bar.addComment": "Add note",
"acceptance.bar.addCommentDescription": "A delivery-wide note for what the queued feedback misses — the next verification round reads it.",
"acceptance.bar.copied": "Copied — paste it to any agent to start the repair.",
- "acceptance.bar.copyReview": "Copy review prompt",
+ "acceptance.bar.copyReview": "Copy repair prompt",
"acceptance.bar.feedback": "Feedback {{count}}",
+ "acceptance.bar.mobileProgress": "Delivery: {{done}} / {{total}} reviewed",
"acceptance.bar.needsFix": "All reviewed — {{count}} to fix",
"acceptance.bar.progress": "Confirmed {{done}} / {{total}} checks — {{rest}} awaiting your review",
"acceptance.bar.progressDone": "All {{total}} checks confirmed — ready to accept",
@@ -103,6 +104,8 @@
"acceptance.focus.enter": "Review checks",
"acceptance.focus.evidenceCount": "{{count}} evidence items",
"acceptance.focus.evidenceHint": "Review the acceptance criterion, evidence, and feedback for this check.",
+ "acceptance.focus.next": "Next check",
+ "acceptance.focus.previous": "Previous check",
"acceptance.focus.state.accepted": "Accepted",
"acceptance.focus.state.ignored": "Ignored",
"acceptance.focus.state.needsFix": "Needs fix",
@@ -177,23 +180,37 @@
"acceptance.review.attachFailed": "Screenshot upload failed — please try again.",
"acceptance.review.attachLimit": "Up to {{count}} screenshots.",
"acceptance.review.attachTooLarge": "The image is too large (10MB max).",
+ "acceptance.review.backToImages": "Back to images",
+ "acceptance.review.browseImage": "Browse",
"acceptance.review.confirmReject": "Submit feedback",
"acceptance.review.detailPlaceholder": "Leave a comment for this check. It will be submitted with your decision…",
+ "acceptance.review.draftSaved": "Your draft is saved on this device.",
+ "acceptance.review.drawRegion": "Draw region",
"acceptance.review.feedbackLabel": "Feedback",
"acceptance.review.fullscreen": "Annotate fullscreen",
"acceptance.review.fullscreenDone": "Done annotating",
+ "acceptance.review.historicalReadOnly": "This is a past round. Return to all rounds to review the current delivery.",
"acceptance.review.ignore": "Ignore",
"acceptance.review.ignoredNote": "Ignored · {{time}}",
+ "acceptance.review.imageNumber": "Image {{current}} / {{total}}",
+ "acceptance.review.mobileBrowseHint": "Swipe to switch · scroll to read",
+ "acceptance.review.mobileDrawHint": "Drag to mark an issue",
+ "acceptance.review.nextImage": "Next image",
+ "acceptance.review.previousImage": "Previous image",
"acceptance.review.regionComments": "Region comments",
"acceptance.review.regionCommentsEmpty": "Drag on the image to circle a region — its comment lands here.",
+ "acceptance.review.regionImage": "Image {{image}} · Region {{region}}",
"acceptance.review.reject": "Reject with comment",
"acceptance.review.rejectDescription": "Reject \"{{title}}\" — your feedback is what the next verification round acts on.",
"acceptance.review.rejectPlaceholder": "What is wrong, and what do you expect instead…",
"acceptance.review.rejectedHint": "You rejected this check — the next round reads your feedback.",
+ "acceptance.review.removeAttachment": "Remove attachment",
"acceptance.review.removeRegion": "Remove this region",
"acceptance.review.revertToAccept": "Undo send-back · mark accepted",
"acceptance.review.revertToReject": "Change to reject with comment",
+ "acceptance.review.submitFailed": "Could not submit. Your draft is saved; please try again.",
"acceptance.review.supplement": "Additional notes (optional)",
+ "acceptance.review.writeFeedback": "Write feedback",
"acceptance.review.zoomIn": "Zoom in",
"acceptance.review.zoomOut": "Zoom out",
"acceptance.round": "Round {{round}}",
diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.json
index 35bdfcbd540..6881bba8556 100644
--- a/locales/zh-CN/verify.json
+++ b/locales/zh-CN/verify.json
@@ -22,8 +22,9 @@
"acceptance.bar.addComment": "补充评论",
"acceptance.bar.addCommentDescription": "面向整个交付的补充说明,不局限于单个检查项——下一轮验证会读取。",
"acceptance.bar.copied": "已复制,粘贴给任意 agent 即可开始修复。",
- "acceptance.bar.copyReview": "复制 review 建议",
+ "acceptance.bar.copyReview": "复制修改 prompt",
"acceptance.bar.feedback": "反馈 {{count}}",
+ "acceptance.bar.mobileProgress": "整体交付 · {{done}} / {{total}} 项已验收",
"acceptance.bar.needsFix": "已全部评审 · {{count}} 项待修复",
"acceptance.bar.progress": "已完成 {{done}} / {{total}} 项验证项,剩余 {{rest}} 项等待你的验收",
"acceptance.bar.progressDone": "{{total}} 项验证项已全部确认,可以接受交付",
@@ -103,6 +104,8 @@
"acceptance.focus.enter": "逐项验收",
"acceptance.focus.evidenceCount": "{{count}} 份证据",
"acceptance.focus.evidenceHint": "集中检查该项的验收标准、证据和反馈。",
+ "acceptance.focus.next": "下一项",
+ "acceptance.focus.previous": "上一项",
"acceptance.focus.state.accepted": "已验收",
"acceptance.focus.state.ignored": "已忽略",
"acceptance.focus.state.needsFix": "待修复",
@@ -177,23 +180,37 @@
"acceptance.review.attachFailed": "截图上传失败,请重试。",
"acceptance.review.attachLimit": "最多添加 {{count}} 张截图。",
"acceptance.review.attachTooLarge": "图片过大(最大 10MB)。",
+ "acceptance.review.backToImages": "返回图片",
+ "acceptance.review.browseImage": "浏览图片",
"acceptance.review.confirmReject": "提交反馈",
"acceptance.review.detailPlaceholder": "留下对该检查项的评论,提交审核决定时会一并发送…",
+ "acceptance.review.draftSaved": "草稿会保存在此设备,关闭后可继续填写。",
+ "acceptance.review.drawRegion": "圈画评论",
"acceptance.review.feedbackLabel": "反馈",
"acceptance.review.fullscreen": "全屏标注",
"acceptance.review.fullscreenDone": "完成标注",
+ "acceptance.review.historicalReadOnly": "当前为历史轮次,仅供查看。返回全部轮次后可验收当前交付。",
"acceptance.review.ignore": "忽略",
"acceptance.review.ignoredNote": "已于 {{time}} 忽略,不再参与验收",
+ "acceptance.review.imageNumber": "图片 {{current}} / {{total}}",
+ "acceptance.review.mobileBrowseHint": "左右切图 · 上下阅读",
+ "acceptance.review.mobileDrawHint": "拖动圈选问题区域",
+ "acceptance.review.nextImage": "下一张图片",
+ "acceptance.review.previousImage": "上一张图片",
"acceptance.review.regionComments": "圈选评论",
"acceptance.review.regionCommentsEmpty": "在左侧图片上拖拽圈出区域,评论会出现在这里。",
+ "acceptance.review.regionImage": "图片 {{image}} · 区域 {{region}}",
"acceptance.review.reject": "拒绝并评论",
"acceptance.review.rejectDescription": "拒绝「{{title}}」——你的反馈将成为下一轮验证的处理输入。",
"acceptance.review.rejectPlaceholder": "哪里不对、你期望的是什么…",
"acceptance.review.rejectedHint": "你已拒绝该项——下一轮将读取你的反馈。",
+ "acceptance.review.removeAttachment": "移除附件",
"acceptance.review.removeRegion": "删除该圈选",
"acceptance.review.revertToAccept": "撤销打回 · 改为验收通过",
"acceptance.review.revertToReject": "改为拒绝并评论",
+ "acceptance.review.submitFailed": "提交失败,草稿已保留,请重试。",
"acceptance.review.supplement": "补充说明(可选)",
+ "acceptance.review.writeFeedback": "填写反馈",
"acceptance.review.zoomIn": "放大",
"acceptance.review.zoomOut": "缩小",
"acceptance.round": "第 {{round}} 轮",
diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.ts
index 704013fe217..243e4e31e1c 100644
--- a/packages/locales/src/default/verify.ts
+++ b/packages/locales/src/default/verify.ts
@@ -1,4 +1,24 @@
export default {
+ 'acceptance.review.submitFailed': 'Could not submit. Your draft is saved; please try again.',
+ 'acceptance.bar.mobileProgress': 'Delivery: {{done}} / {{total}} reviewed',
+ 'acceptance.review.historicalReadOnly':
+ 'This is a past round. Return to all rounds to review the current delivery.',
+ 'acceptance.review.backToImages': 'Back to images',
+ 'acceptance.review.writeFeedback': 'Write feedback',
+ 'acceptance.review.mobileDrawHint': 'Drag to mark an issue',
+ 'acceptance.review.mobileBrowseHint': 'Swipe to switch · scroll to read',
+ 'acceptance.review.draftSaved': 'Your draft is saved on this device.',
+ 'acceptance.review.removeAttachment': 'Remove attachment',
+ 'acceptance.review.regionImage': 'Image {{image}} · Region {{region}}',
+
+ 'acceptance.focus.previous': 'Previous check',
+ 'acceptance.focus.next': 'Next check',
+ 'acceptance.review.previousImage': 'Previous image',
+ 'acceptance.review.nextImage': 'Next image',
+ 'acceptance.review.imageNumber': 'Image {{current}} / {{total}}',
+ 'acceptance.review.drawRegion': 'Draw region',
+ 'acceptance.review.browseImage': 'Browse',
+
'acceptance.accept.exceptionsHint':
'Accepting means you have seen these exceptions and take the delivery with them.',
'acceptance.accept.exceptionsTitle': '{{count}} exception(s) still unresolved:',
@@ -30,7 +50,7 @@ export default {
'acceptance.bar.addCommentDescription':
'A delivery-wide note for what the queued feedback misses — the next verification round reads it.',
'acceptance.bar.copied': 'Copied — paste it to any agent to start the repair.',
- 'acceptance.bar.copyReview': 'Copy review prompt',
+ 'acceptance.bar.copyReview': 'Copy repair prompt',
'acceptance.bar.feedback': 'Feedback {{count}}',
'acceptance.bar.needsFix': 'All reviewed — {{count}} to fix',
'acceptance.bar.progress':
diff --git a/src/features/Acceptance/AcceptanceDrawer.tsx b/src/features/Acceptance/AcceptanceDrawer.tsx
new file mode 100644
index 00000000000..00218c9f154
--- /dev/null
+++ b/src/features/Acceptance/AcceptanceDrawer.tsx
@@ -0,0 +1,45 @@
+'use client';
+
+import { Drawer } from '@lobehub/ui/base-ui';
+import { useResponsive } from 'antd-style';
+import type { ComponentProps } from 'react';
+
+/** Keep each reading level full-width on phones, with a persistent exit. */
+export const AcceptanceDrawer = ({
+ noHeader,
+ push,
+ styles,
+ width,
+ ...props
+}: ComponentProps<typeof Drawer>) => {
+ const { md = true } = useResponsive();
+ const mobile = !md;
+
+ return (
+ <Drawer
+ {...props}
+ noHeader={mobile ? false : noHeader}
+ push={mobile ? false : push}
+ width={mobile ? '100%' : width}
+ styles={{
+ ...styles,
+ bodyContent: {
+ display: 'flex',
+ flexDirection: 'column',
+ ...styles?.bodyContent,
+ },
+ ...(mobile && {
+ close: { ...styles?.close, height: 44, width: 44 },
+ header: {
+ ...styles?.header,
+ paddingBlock: 'max(4px, env(safe-area-inset-top)) 4px',
+ },
+ panel: {
+ ...styles?.panel,
+ paddingBottom: 'env(safe-area-inset-bottom)',
+ },
+ }),
+ }}
+ />
+ );
+};
diff --git a/src/features/Acceptance/Report/MarkdownEvidence.tsx b/src/features/Acceptance/Report/MarkdownEvidence.tsx
index 3e5ffedb5f4..0905df22380 100644
--- a/src/features/Acceptance/Report/MarkdownEvidence.tsx
+++ b/src/features/Acceptance/Report/MarkdownEvidence.tsx
@@ -1,7 +1,7 @@
'use client';
import { Center, Flexbox, Highlighter, Icon, Markdown } from '@lobehub/ui';
-import { Drawer, Text } from '@lobehub/ui/base-ui';
+import { Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import { ChevronRight, FileText } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
@@ -11,6 +11,8 @@ import Loading from '@/components/Loading/BrandTextLoading';
import { useTextFileLoader } from '@/features/FileViewer/hooks/useTextFileLoader';
import { getLanguageFromFilename } from '@/utils/fileLanguage';
+import { AcceptanceDrawer } from '../AcceptanceDrawer';
+
/**
* Prose evidence (root-cause write-ups, findings) renders as body markdown, not
* a monospace raw box — shared by the verify report and the acceptance union so
@@ -30,6 +32,10 @@ const styles = createStaticStyles(({ css }) => ({
foldBody: css`
padding-block: 4px 8px;
padding-inline: 22px 0;
+
+ @media (width <= 767px) {
+ padding-inline: 0;
+ }
`,
/* Reviewer-directed: no fill, no border — the row is just a line of text
with a chevron; the surrounding check card provides the container. */
@@ -65,6 +71,10 @@ const styles = createStaticStyles(({ css }) => ({
&:hover [data-fold-title] {
color: ${cssVar.colorText};
}
+
+ @media (width <= 767px), (pointer: coarse) {
+ min-height: 44px;
+ }
`,
foldTitle: css`
overflow: hidden;
@@ -76,6 +86,11 @@ const styles = createStaticStyles(({ css }) => ({
white-space: nowrap;
transition: color 120ms ease;
+
+ @media (width <= 767px) {
+ overflow-wrap: anywhere;
+ white-space: normal;
+ }
`,
/* A plain block, deliberately not a Flexbox: `Markdown`'s root is
`overflow: hidden`, so as a flex item its automatic minimum size collapses
@@ -89,6 +104,10 @@ const styles = createStaticStyles(({ css }) => ({
min-height: 0;
padding-block: 12px;
padding-inline: 16px;
+
+ > * {
+ flex-shrink: 0;
+ }
`,
fileCard: css`
cursor: pointer;
@@ -334,7 +353,7 @@ export const EvidenceFileCard = memo<{
</span>
</button>
{open && (
- <Drawer
+ <AcceptanceDrawer
containerMaxWidth={'100%'}
open={open}
placement={'right'}
@@ -346,7 +365,7 @@ export const EvidenceFileCard = memo<{
onClose={() => setOpen(false)}
>
<DocumentViewer fileName={name} markdown={markdown} url={url} />
- </Drawer>
+ </AcceptanceDrawer>
)}
</>
);
diff --git a/src/features/Acceptance/Report/ReportViewer.tsx b/src/features/Acceptance/Report/ReportViewer.tsx
index f4565e820bb..7461940da1c 100644
--- a/src/features/Acceptance/Report/ReportViewer.tsx
+++ b/src/features/Acceptance/Report/ReportViewer.tsx
@@ -10,7 +10,7 @@ import type {
VerifyVerdict,
} from '@lobechat/types';
import { Block, Center, Empty, Flexbox, Icon, Image, Markdown } from '@lobehub/ui';
-import { Button, Drawer, Text } from '@lobehub/ui/base-ui';
+import { Button, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import type { TFunction } from 'i18next';
import {
@@ -46,6 +46,7 @@ import Loading from '@/components/Loading/BrandTextLoading';
import AudioPlayer from '@/features/AudioPlayer';
import type { VerifyEvidenceWithUrl } from '@/services/verify';
+import { AcceptanceDrawer } from '../AcceptanceDrawer';
import { useVerifyReportBundle } from '../hooks';
import {
buildCheckRows,
@@ -86,6 +87,12 @@ const styles = createStaticStyles(({ css }) => ({
/* Start-aligned with the 46px gutter a check row's body sits at, so the hero
prose and the expanded check prose share one text edge. */
padding-inline: 46px 32px;
+
+ @media (width <= 767px) {
+ padding-block: 16px calc(24px + env(safe-area-inset-bottom));
+ padding-inline: 16px;
+ overflow-wrap: anywhere;
+ }
`,
/* hero */
@@ -187,7 +194,7 @@ const styles = createStaticStyles(({ css }) => ({
align-items: center;
min-width: 0;
- max-width: 360px;
+ max-width: min(360px, 100%);
color: ${cssVar.colorTextTertiary};
@@ -400,6 +407,12 @@ const styles = createStaticStyles(({ css }) => ({
&:hover {
background: ${cssVar.colorFillQuaternary};
}
+
+ @media (width <= 767px) {
+ grid-template-columns: 20px minmax(0, 1fr);
+ gap: 6px 8px;
+ padding: 12px;
+ }
`,
rowTitle: css`
overflow: hidden;
@@ -412,11 +425,21 @@ const styles = createStaticStyles(({ css }) => ({
&[data-failed='true'] {
font-weight: 600;
}
+
+ @media (width <= 767px) {
+ overflow-wrap: anywhere;
+ white-space: normal;
+ }
`,
rowSide: css`
display: flex;
gap: 8px;
align-items: center;
+
+ @media (width <= 767px) {
+ grid-column: 2;
+ flex-wrap: wrap;
+ }
`,
softTag: css`
padding-block: 1px;
@@ -443,6 +466,10 @@ const styles = createStaticStyles(({ css }) => ({
padding-block: 2px 16px;
padding-inline: 46px 16px;
+
+ @media (width <= 767px) {
+ padding-inline: 12px;
+ }
`,
reasoning: css`
font-size: 13px;
@@ -467,6 +494,12 @@ const styles = createStaticStyles(({ css }) => ({
font-size: 13px;
line-height: 1.6;
color: ${cssVar.colorTextTertiary};
+
+ @media (width <= 767px) {
+ grid-template-columns: minmax(0, 1fr);
+ gap: 4px;
+ color: ${cssVar.colorTextSecondary};
+ }
`,
planDetailLabel: css`
color: ${cssVar.colorTextQuaternary};
@@ -621,11 +654,11 @@ const styles = createStaticStyles(({ css }) => ({
`,
evidenceDoc: css`
overflow: hidden;
+ display: flex;
+ flex: 1;
width: 100%;
- height: 320px;
- border: 1px solid ${cssVar.colorBorderSecondary};
- border-radius: ${cssVar.borderRadius};
+ min-height: 0;
`,
}));
@@ -749,12 +782,16 @@ const EvidenceItem = memo<{
// Inline media (image/gif/video) speaks for itself — the raw filename header
// is visual noise, so only keep a meaningful caption (description) for it.
const isMedia = isInlineVisualEvidence(e);
+ const isDocument = Boolean(e.fileUrl) && !isMedia && e.type !== 'audio';
const isInlineProse = Boolean(e.content) && markdownTextEvidenceTypes.has(e.type);
const hideLabel =
- isMedia || (markdownTextEvidenceTypes.has(e.type) && isFilenameLike(label)) || isInlineProse;
+ isDocument ||
+ isMedia ||
+ (markdownTextEvidenceTypes.has(e.type) && isFilenameLike(label)) ||
+ isInlineProse;
return (
- <Flexbox gap={6}>
+ <Flexbox gap={6} style={isDocument ? { flex: 1, minHeight: 0 } : undefined}>
{!hideLabel && (
<Text strong fontSize={13}>
{label}
@@ -853,7 +890,7 @@ const EvidenceDrawer = memo<{
open: boolean;
title: string;
}>(({ evidence, onClose, open, title }) => (
- <Drawer
+ <AcceptanceDrawer
containerMaxWidth={'100%'}
open={open}
placement={'right'}
@@ -880,7 +917,7 @@ const EvidenceDrawer = memo<{
<EvidenceItem evidence={e} index={index + 1} key={e.id} />
))}
</Flexbox>
- </Drawer>
+ </AcceptanceDrawer>
));
EvidenceItem.displayName = 'EvidenceItem';
@@ -968,6 +1005,7 @@ const CheckRow = memo<{ defaultOpen: boolean; row: CheckRowData }>(({ defaultOpe
return (
<div className={styles.row}>
<button
+ aria-expanded={hasBody ? open : undefined}
className={styles.rowHead}
type={'button'}
onClick={() => hasBody && setOpen((o) => !o)}
diff --git a/src/features/Acceptance/Viewer/AcceptanceCheckInventory.tsx b/src/features/Acceptance/Viewer/AcceptanceCheckInventory.tsx
index 4835c1c3723..2d6363311c0 100644
--- a/src/features/Acceptance/Viewer/AcceptanceCheckInventory.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceCheckInventory.tsx
@@ -27,7 +27,9 @@ import CheckList, {
userReviewState,
} from './CheckList';
import { EMPTY_ID_SET, setAggregateEntry } from './expandState';
+import { checksForTurn } from './turnChecks';
import { useAcceptanceBundle } from './useAcceptanceBundle';
+import { useAcceptanceTurn } from './useAcceptanceTurn';
import { canReviewAcceptance } from './visibility';
interface AcceptanceCheckInventoryProps {
@@ -42,7 +44,7 @@ const AcceptanceCheckInventory = ({
toolbar,
}: AcceptanceCheckInventoryProps) => {
const { t } = useTranslation('verify');
- const { lg = true } = useResponsive();
+ const { lg = true, md = true } = useResponsive();
const { acceptanceId, embedded } = useAcceptanceScope();
const compactToolbar = embedded || !lg;
const { data, mutate } = useAcceptanceBundle(acceptanceId);
@@ -70,7 +72,7 @@ const AcceptanceCheckInventory = ({
{ replace: true },
);
};
- const [roundFilter, setRoundFilter] = useState<number | null>(null);
+ const { turn: roundFilter, setTurn: setRoundFilter } = useAcceptanceTurn(embedded);
const [expandedById, setExpandedById] = useState<Map<string, Set<string>>>(() => new Map());
const [collapsedById, setCollapsedById] = useState<Map<string, Set<string>>>(() => new Map());
const expanded = expandedById.get(acceptanceId) ?? EMPTY_ID_SET;
@@ -96,6 +98,7 @@ const AcceptanceCheckInventory = ({
data.checks
.filter(
(check) =>
+ window.matchMedia('(min-width: 768px)').matches &&
userReviewState(check) !== 'accepted' &&
(isException(check) || hasVisualEvidence(check)),
)
@@ -114,7 +117,7 @@ const AcceptanceCheckInventory = ({
const defaultFilter: CheckFilter = data.rounds.length > 1 ? 'pending' : 'all';
if (embedded) {
setLocalFilter(defaultFilter);
- } else if (!urlFilterRaw && defaultFilter !== 'all') {
+ } else if (!urlFilterRaw && !roundFilter && defaultFilter !== 'all') {
setSearchParams(
(prev) => {
const params = new URLSearchParams(prev);
@@ -134,12 +137,16 @@ const AcceptanceCheckInventory = ({
setSearchParams,
t,
urlFilterRaw,
+ roundFilter,
+ md,
]);
if (!data) return null;
- const canReview = canReviewAcceptance(data);
- const checks = data.checks;
+ const canReview =
+ canReviewAcceptance(data) &&
+ (roundFilter === null || roundFilter === data.rounds.at(-1)?.run.roundIndex);
+ const checks = checksForTurn(data, roundFilter);
/**
* Every mutation the checklist fires goes through here.
@@ -184,9 +191,7 @@ const AcceptanceCheckInventory = ({
return (
<>
- <Flexbox horizontal align={'center'} gap={8} wrap={compactToolbar ? 'nowrap' : 'wrap'}>
- {/* The tab above already carries the count; stating it twice on the
- same screen makes the reader check whether they disagree. */}
+ <Flexbox horizontal align={'center'} gap={8} wrap={'wrap'}>
<Text strong style={{ fontSize: 14, whiteSpace: 'nowrap' }}>
{t('acceptance.checks.title')}
</Text>
@@ -194,7 +199,7 @@ const AcceptanceCheckInventory = ({
{toolbar}
<Select
size={'small'}
- style={{ height: 34, width: 118 }}
+ style={{ height: compactToolbar ? 44 : 34, width: 118 }}
value={filter}
variant={'filled'}
options={[
@@ -212,10 +217,10 @@ const AcceptanceCheckInventory = ({
]}
onChange={(value) => setFilter(value as CheckFilter)}
/>
- {data.rounds.length > 1 && canReview && (
+ {data.rounds.length > 1 && (
<Select
size={'small'}
- style={{ height: 34, width: 110 }}
+ style={{ height: compactToolbar ? 44 : 34, width: 110 }}
value={roundFilter === null ? 'all' : String(roundFilter)}
variant={'filled'}
options={[
@@ -253,6 +258,7 @@ const AcceptanceCheckInventory = ({
reviewPending={false}
round={roundFilter}
onOpenTrace={onOpenTrace}
+ onRound={setRoundFilter}
onDismissProposal={
canReview
? async (input) => {
diff --git a/src/features/Acceptance/Viewer/AcceptanceDecision.tsx b/src/features/Acceptance/Viewer/AcceptanceDecision.tsx
index b3ffd5ec136..a19a1094401 100644
--- a/src/features/Acceptance/Viewer/AcceptanceDecision.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceDecision.tsx
@@ -1,10 +1,11 @@
'use client';
import { copyToClipboard, Flexbox } from '@lobehub/ui';
-import { toast } from '@lobehub/ui/base-ui';
+import { Button, Text, toast } from '@lobehub/ui/base-ui';
import dayjs from 'dayjs';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router';
import { useIsHydrated } from '@/hooks/useIsHydrated';
import { mutate as globalMutate } from '@/libs/swr';
@@ -17,8 +18,9 @@ import { buildRepairPrompt } from './checkWork';
import DecisionBar from './DecisionBar';
import FeedbackDrawer, { type FeedbackListEntry } from './FeedbackDrawer';
import { openAcceptModal, openGroupFeedbackModal, openRejectModal } from './modals';
-import { dispatchRepairRerun } from './repairRerun';
+import { acceptanceCheckPath } from './routes';
import { useAcceptanceBundle } from './useAcceptanceBundle';
+import { useAcceptanceTurn } from './useAcceptanceTurn';
import { formatAcceptanceCountsText, LIVE_ACCEPTANCE_STATUSES } from './verdict';
import { canReviewAcceptance } from './visibility';
@@ -28,18 +30,25 @@ interface AcceptanceDecisionProps {
const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {
const { t } = useTranslation('verify');
+ const navigate = useNavigate();
const hydrated = useIsHydrated();
const { acceptanceId, embedded } = useAcceptanceScope();
const { data, mutate } = useAcceptanceBundle(acceptanceId);
+ const { turn, setTurn } = useAcceptanceTurn(embedded);
const [pending, setPending] = useState(false);
- const [rerunPending, setRerunPending] = useState(false);
- // Latched once a standalone dispatch reaches the server: the repair run has
- // started, so Fix must not offer a retry even if later bookkeeping failed.
- const [rerunDispatched, setRerunDispatched] = useState(false);
const [feedbackOpen, setFeedbackOpen] = useState(false);
if (!data || !canReviewAcceptance(data) || data.acceptance.status === 'closed') return null;
- const { acceptance, checks, origin, rounds } = data;
+ if (turn !== null && turn !== data.rounds.at(-1)?.run.roundIndex)
+ return (
+ <Flexbox gap={8}>
+ <Text type={'secondary'}>{t('acceptance.review.historicalReadOnly')}</Text>
+ <Button style={{ minHeight: 44 }} onClick={() => setTurn(null)}>
+ {t('acceptance.filter.roundAll')}
+ </Button>
+ </Flexbox>
+ );
+ const { acceptance, checks, rounds } = data;
const currentRound = rounds.at(-1);
const acceptedCount = checks.filter((check) => checkFilterState(check) === 'accepted').length;
const needsFixCount = checks.filter((check) => checkFilterState(check) === 'needsFix').length;
@@ -146,6 +155,10 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {
await mutate();
void globalMutate(isAcceptanceListKey);
return true;
+ } catch (cause) {
+ console.error('[acceptance:decision]', cause);
+ toast.error(cause instanceof Error ? cause.message : t('acceptance.actionError'));
+ return false;
} finally {
setPending(false);
}
@@ -163,8 +176,8 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {
needsFixCount={needsFixCount}
pending={pending}
repairing={acceptance.status === 'repairing'}
- rerunAvailable={embedded || (Boolean(origin?.topic) && !rerunDispatched)}
- rerunPending={rerunPending}
+ rerunAvailable={embedded}
+ rerunPending={false}
state={barState}
statusText={barTexts.statusText}
subText={barTexts.subText}
@@ -196,8 +209,7 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {
onCopyReview={async () => {
await copyToClipboard(repairPrompt);
toast.success({
- placement: 'bottom',
- style: { marginBlockEnd: 88 },
+ placement: 'top',
title: t('acceptance.bar.copied'),
});
}}
@@ -216,49 +228,18 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {
// to the clipboard so the click always hands the prompt over.
if (onDraftToComposer?.(repairPrompt)) {
toast.success({
- placement: 'bottom',
- style: { marginBlockEnd: 88 },
+ placement: 'top',
title: t('acceptance.bar.rerunDrafted'),
});
} else {
await copyToClipboard(repairPrompt);
toast.success({
- placement: 'bottom',
- style: { marginBlockEnd: 88 },
+ placement: 'top',
title: t('acceptance.bar.copied'),
});
}
return;
}
- if (!origin?.topic) return;
- setRerunPending(true);
- try {
- await dispatchRepairRerun({
- dispatch: () =>
- verifyService.dispatchAcceptanceRepair({
- agentId: origin.agent?.id,
- content: repairPrompt,
- topicId: origin.topic!.id,
- }),
- markRepairing: () => verifyService.markAcceptanceRepairing(acceptance.id),
- });
- // The run is live from here — even if the refresh below throws or
- // the repairing stamp failed (dispatchRepairRerun swallows it; the
- // aggregate converges once the repair round lands), the
- // `rerunDispatched` latch keeps Fix from double-running the repair.
- setRerunDispatched(true);
- await mutate();
- void globalMutate(isAcceptanceListKey);
- toast.success({
- placement: 'bottom',
- style: { marginBlockEnd: 88 },
- title: t('acceptance.bar.rerunSent'),
- });
- } catch (cause) {
- toast.error(cause instanceof Error ? cause.message : t('acceptance.actionError'));
- } finally {
- setRerunPending(false);
- }
}}
/>
<Flexbox style={{ height: 8 }} />
@@ -268,6 +249,10 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {
onClose={() => setFeedbackOpen(false)}
onJumpToCheck={(checkId) => {
setFeedbackOpen(false);
+ if (!embedded) {
+ navigate(acceptanceCheckPath(acceptanceId, checkId));
+ return;
+ }
setTimeout(() => {
document
.querySelector(`[data-check-row="${checkId}"]`)
diff --git a/src/features/Acceptance/Viewer/AcceptanceEnterFocus.tsx b/src/features/Acceptance/Viewer/AcceptanceEnterFocus.tsx
index 63699454516..b773742a6de 100644
--- a/src/features/Acceptance/Viewer/AcceptanceEnterFocus.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceEnterFocus.tsx
@@ -4,27 +4,34 @@ import { Icon } from '@lobehub/ui';
import { Button } from '@lobehub/ui/base-ui';
import { ChevronRight } from 'lucide-react';
import { useTranslation } from 'react-i18next';
-import { useNavigate } from 'react-router';
+import { useNavigate, useSearchParams } from 'react-router';
import { useAcceptanceScope } from './AcceptanceScope';
import { acceptanceCheckPath } from './routes';
+import { checksForTurn } from './turnChecks';
import { useAcceptanceBundle } from './useAcceptanceBundle';
+import { readAcceptanceTurn } from './useAcceptanceTurn';
const AcceptanceEnterFocus = () => {
const { t } = useTranslation('verify');
const navigate = useNavigate();
+ const [params] = useSearchParams();
const { acceptanceId, embedded } = useAcceptanceScope();
const { data } = useAcceptanceBundle(acceptanceId);
- if (embedded || !data || data.checks.length === 0) return null;
+ const checks = data ? checksForTurn(data, readAcceptanceTurn(params)) : [];
+ if (embedded || !data || checks.length === 0) return null;
return (
<Button
icon={<Icon icon={ChevronRight} />}
size={'small'}
- style={{ alignSelf: 'flex-start' }}
+ style={{ alignSelf: 'flex-start', minHeight: 44 }}
type={'text'}
onClick={() =>
- navigate(acceptanceCheckPath(acceptanceId, data.checks[0]!.id), { replace: true })
+ navigate(
+ acceptanceCheckPath(acceptanceId, checks[0]!.id) + (params.size ? `?${params}` : ''),
+ { replace: true },
+ )
}
>
{t('acceptance.focus.enter')}
diff --git a/src/features/Acceptance/Viewer/AcceptanceFocusReview.tsx b/src/features/Acceptance/Viewer/AcceptanceFocusReview.tsx
index e56082ebbb0..b94b61c2a8c 100644
--- a/src/features/Acceptance/Viewer/AcceptanceFocusReview.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceFocusReview.tsx
@@ -3,12 +3,14 @@
import type { AcceptanceChecklistItem } from '@lobechat/types';
import { Flexbox, Icon } from '@lobehub/ui';
import { Button, Tag, Text } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
+import { createStaticStyles, cssVar, useResponsive } from 'antd-style';
import {
ArrowLeft,
BadgeCheck,
Ban,
Check,
+ ChevronDown,
+ ChevronLeft,
ChevronRight,
CircleDashed,
HelpCircle,
@@ -17,6 +19,7 @@ import {
RotateCcw,
XCircle,
} from 'lucide-react';
+import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import NavItem from '@/features/NavPanel/components/NavItem';
@@ -34,6 +37,17 @@ import {
import { acceptanceFocusedLayout, acceptanceScrollLayout } from './layout';
const styles = createStaticStyles(({ css }) => ({
+ mobileNavigation: css`
+ position: sticky;
+ z-index: 2;
+ inset-block-start: -16px;
+
+ flex: none;
+
+ padding-block: 8px;
+
+ background: ${cssVar.colorBgContainer};
+ `,
countBadge: css`
padding-block: 1px;
padding-inline: 7px;
@@ -55,6 +69,9 @@ const styles = createStaticStyles(({ css }) => ({
@media (width <= 900px) {
grid-template-columns: 1fr;
+ grid-template-rows: auto minmax(0, 1fr);
+ flex: 1;
+ min-height: 0;
}
`,
outline: css`
@@ -78,14 +95,26 @@ const styles = createStaticStyles(({ css }) => ({
> * {
flex-shrink: 0;
}
+
+ @media (width <= 767px) {
+ overflow: auto;
+ max-height: 40dvh;
+ }
`,
main: css`
overflow: ${acceptanceScrollLayout.paneOverflow};
min-width: 0;
padding-block: ${acceptanceFocusedLayout.contentPaddingBlock};
padding-inline: 32px;
+
+ @media (width <= 767px) {
+ overflow: auto;
+ min-height: 0;
+ padding: 16px;
+ }
`,
content: css`
+ flex: none;
width: min(880px, 100%);
margin-inline: auto;
`,
@@ -137,22 +166,48 @@ const AcceptanceFocusReview = ({
subjectTitle,
}: AcceptanceFocusReviewProps) => {
const { t } = useTranslation('verify');
+ const { md = true } = useResponsive();
+ const [outlineOpen, setOutlineOpen] = useState(false);
const focusedStates = focusedCheckStates(focusedCheck);
+ const currentIndex = orderedChecks.findIndex((check) => check.id === focusedCheck.id);
return (
<div className={styles.layout}>
<Flexbox className={styles.outline}>
- <Flexbox flex={'none'} gap={10} paddingBlock={8} paddingInline={4}>
+ <Flexbox
+ align={md ? undefined : 'center'}
+ flex={'none'}
+ gap={md ? 10 : 0}
+ horizontal={!md}
+ paddingBlock={8}
+ paddingInline={4}
+ >
<Button
+ aria-label={t('acceptance.focus.back')}
icon={<Icon icon={ArrowLeft} />}
size={'small'}
- style={{ alignSelf: 'flex-start' }}
type={'text'}
+ style={{
+ alignSelf: 'flex-start',
+ minHeight: md ? undefined : 44,
+ minWidth: md ? undefined : 44,
+ }}
onClick={onBack}
>
- {t('acceptance.focus.back')}
+ {md ? t('acceptance.focus.back') : null}
</Button>
- <Flexbox gap={4} paddingInline={4}>
+ {!md && (
+ <Button
+ aria-expanded={outlineOpen}
+ icon={<Icon icon={outlineOpen ? ChevronDown : ChevronRight} />}
+ style={{ height: 'auto', minHeight: 44, textAlign: 'start', whiteSpace: 'normal' }}
+ type={'text'}
+ onClick={() => setOutlineOpen((open) => !open)}
+ >
+ {t('acceptance.checks.title')} · {currentIndex + 1} / {orderedChecks.length}
+ </Button>
+ )}
+ <Flexbox gap={4} paddingInline={4} style={!md ? { display: 'none' } : undefined}>
<Text strong style={{ fontSize: 15 }}>
{subjectTitle}
</Text>
@@ -163,7 +218,13 @@ const AcceptanceFocusReview = ({
</Text>
</Flexbox>
</Flexbox>
- <Flexbox horizontal align={'center'} gap={8} paddingInline={4}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={8}
+ paddingInline={4}
+ style={!md ? { display: 'none' } : undefined}
+ >
<Text strong style={{ fontSize: 13 }}>
{t('acceptance.checks.title')}
</Text>
@@ -181,85 +242,111 @@ const AcceptanceFocusReview = ({
)}
</Flexbox>
</Flexbox>
- <Flexbox className={styles.outlineList} flex={1}>
- {orderedChecks.map((check) => {
- const state = checkFilterState(check);
- const icon =
- state === 'accepted'
- ? BadgeCheck
- : state === 'needsFix'
- ? RotateCcw
- : state === 'ignored'
- ? Ban
- : CircleDashed;
- const color =
- state === 'accepted' ? 'success' : state === 'needsFix' ? 'error' : 'default';
+ {(md || outlineOpen) && (
+ <Flexbox className={styles.outlineList} flex={1}>
+ {orderedChecks.map((check) => {
+ const state = checkFilterState(check);
+ const icon =
+ state === 'accepted'
+ ? BadgeCheck
+ : state === 'needsFix'
+ ? RotateCcw
+ : state === 'ignored'
+ ? Ban
+ : CircleDashed;
+ const color =
+ state === 'accepted' ? 'success' : state === 'needsFix' ? 'error' : 'default';
- return (
- <NavItem
- active={check.id === focusedCheck.id}
- extra={<Icon color={cssVar.colorTextQuaternary} icon={ChevronRight} size={14} />}
- key={check.id}
- paddingBlock={acceptanceFocusedLayout.outlineItemPaddingBlock}
- paddingInline={acceptanceFocusedLayout.outlineItemPaddingInline}
- title={check.title}
- titleColor={cssVar.colorText}
- description={
- <Flexbox horizontal align={'center'} gap={8}>
- <Tag color={color} icon={<Icon icon={icon} />} size={'small'}>
- {t(`acceptance.focus.state.${state}`)}
- </Tag>
- <Text fontSize={12} type={'secondary'}>
- {t('acceptance.focus.evidenceCount', { count: check.evidence.length })}
- </Text>
- </Flexbox>
- }
- slots={{
- titlePrefix: (
- <Flexbox align={'center'} height={22} style={{ alignSelf: 'flex-start' }}>
- <Text
- style={{
- color: cssVar.colorTextQuaternary,
- fontFamily: cssVar.fontFamilyCode,
- fontSize: 11,
- }}
- >
- C{check.seq}
- </Text>
- </Flexbox>
- ),
- }}
- onClick={() => onSelectCheck(check.id)}
- />
- );
- })}
- {standingChecks.length > 0 && onEditStandingCheck && (
- <Flexbox gap={4} paddingBlock={8} paddingInline={8}>
- <Text fontSize={11} type={'secondary'}>
- {t('acceptance.checkCreate.pendingGroup')}
- </Text>
- {standingChecks.map((item) => (
+ return (
<NavItem
- extra={<Icon color={cssVar.colorTextQuaternary} icon={PencilLine} />}
- key={item.id}
+ active={check.id === focusedCheck.id}
+ extra={<Icon color={cssVar.colorTextQuaternary} icon={ChevronRight} size={14} />}
+ key={check.id}
paddingBlock={acceptanceFocusedLayout.outlineItemPaddingBlock}
paddingInline={acceptanceFocusedLayout.outlineItemPaddingInline}
- title={item.name}
+ title={check.title}
titleColor={cssVar.colorText}
description={
- <Text fontSize={12} type={'secondary'}>
- {item.method || t('acceptance.checkCreate.pendingDescription')}
- </Text>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Tag color={color} icon={<Icon icon={icon} />} size={'small'}>
+ {t(`acceptance.focus.state.${state}`)}
+ </Tag>
+ <Text fontSize={12} type={'secondary'}>
+ {t('acceptance.focus.evidenceCount', { count: check.evidence.length })}
+ </Text>
+ </Flexbox>
}
- onClick={() => onEditStandingCheck(item)}
+ slots={{
+ titlePrefix: (
+ <Flexbox align={'center'} height={22} style={{ alignSelf: 'flex-start' }}>
+ <Text
+ style={{
+ color: cssVar.colorTextQuaternary,
+ fontFamily: cssVar.fontFamilyCode,
+ fontSize: 11,
+ }}
+ >
+ C{check.seq}
+ </Text>
+ </Flexbox>
+ ),
+ }}
+ onClick={() => {
+ onSelectCheck(check.id);
+ setOutlineOpen(false);
+ }}
/>
- ))}
- </Flexbox>
- )}
- </Flexbox>
+ );
+ })}
+ {standingChecks.length > 0 && onEditStandingCheck && (
+ <Flexbox gap={4} paddingBlock={8} paddingInline={8}>
+ <Text fontSize={11} type={'secondary'}>
+ {t('acceptance.checkCreate.pendingGroup')}
+ </Text>
+ {standingChecks.map((item) => (
+ <NavItem
+ extra={<Icon color={cssVar.colorTextQuaternary} icon={PencilLine} />}
+ key={item.id}
+ paddingBlock={acceptanceFocusedLayout.outlineItemPaddingBlock}
+ paddingInline={acceptanceFocusedLayout.outlineItemPaddingInline}
+ title={item.name}
+ titleColor={cssVar.colorText}
+ description={
+ <Text fontSize={12} type={'secondary'}>
+ {item.method || t('acceptance.checkCreate.pendingDescription')}
+ </Text>
+ }
+ onClick={() => onEditStandingCheck(item)}
+ />
+ ))}
+ </Flexbox>
+ )}
+ </Flexbox>
+ )}
</Flexbox>
- <Flexbox className={styles.main}>
+ <Flexbox className={styles.main} key={focusedCheck.id}>
+ {!md && (
+ <Flexbox horizontal align={'center'} className={styles.mobileNavigation} gap={8}>
+ <Button
+ aria-label={t('acceptance.focus.previous')}
+ disabled={currentIndex <= 0}
+ icon={<Icon icon={ChevronLeft} />}
+ style={{ minHeight: 44, minWidth: 44 }}
+ onClick={() => onSelectCheck(orderedChecks[currentIndex - 1].id)}
+ />
+ <Text style={{ flex: 1, textAlign: 'center' }}>
+ {currentIndex + 1} / {orderedChecks.length}
+ </Text>
+ <Button
+ aria-label={t('acceptance.focus.next')}
+ disabled={currentIndex >= orderedChecks.length - 1}
+ icon={<Icon icon={ChevronRight} />}
+ style={{ minHeight: 44, minWidth: 44 }}
+ onClick={() => onSelectCheck(orderedChecks[currentIndex + 1].id)}
+ />
+ </Flexbox>
+ )}
<Flexbox className={styles.content} gap={16}>
<Flexbox gap={acceptanceFocusedLayout.headerGap}>
<Flexbox
@@ -334,15 +421,15 @@ const AcceptanceFocusReview = ({
>
C{focusedCheck.seq}
</Text>
- <Text as={'h2'} style={{ fontSize: 22, margin: 0 }}>
+ <Text as={'h2'} style={{ fontSize: md ? 22 : 18, margin: 0 }}>
{focusedCheck.title}
</Text>
</Flexbox>
- <Text fontSize={13} type={'secondary'}>
+ <Text fontSize={13} style={!md ? { display: 'none' } : undefined} type={'secondary'}>
{t(`acceptance.focus.verifierDescription.${focusedStates.verifierLabel}`)}
</Text>
</Flexbox>
- {onCheckWork && isCheckWorkActionable(focusedCheck) && (
+ {md && onCheckWork && isCheckWorkActionable(focusedCheck) && (
<Flexbox horizontal align={'center'} className={styles.work} gap={16}>
<Flexbox flex={1} gap={3}>
<Text strong>{t('acceptance.checkWork.title')}</Text>
@@ -363,6 +450,15 @@ const AcceptanceFocusReview = ({
onReview={onReview}
onRound={onRound}
/>
+ {!md && onCheckWork && isCheckWorkActionable(focusedCheck) && (
+ <Button
+ style={{ alignSelf: 'flex-start', minHeight: 44 }}
+ type={'text'}
+ onClick={onCheckWork}
+ >
+ {t('acceptance.checkWork.copy')}
+ </Button>
+ )}
</Flexbox>
</Flexbox>
</div>
diff --git a/src/features/Acceptance/Viewer/AcceptanceFocusWorkspace.tsx b/src/features/Acceptance/Viewer/AcceptanceFocusWorkspace.tsx
index 901cd61a535..943f0aea36f 100644
--- a/src/features/Acceptance/Viewer/AcceptanceFocusWorkspace.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceFocusWorkspace.tsx
@@ -3,7 +3,7 @@
import { copyToClipboard } from '@lobehub/ui';
import { toast } from '@lobehub/ui/base-ui';
import { useTranslation } from 'react-i18next';
-import { useNavigate, useParams } from 'react-router';
+import { useNavigate, useParams, useSearchParams } from 'react-router';
import { mutate as globalMutate } from '@/libs/swr';
import { isAcceptanceListKey } from '@/libs/swr/keys';
@@ -12,33 +12,27 @@ import { verifyService } from '@/services/verify';
import AcceptanceFocusReview from './AcceptanceFocusReview';
import { useAcceptanceScope } from './AcceptanceScope';
import { openAddCheckModal } from './AddCheckModal';
-import { type CheckFilter, checkFilterState } from './CheckList';
import { copyCheckRepairPrompt } from './checkWork';
import { acceptanceCheckPath, acceptanceOverviewPath } from './routes';
+import { checksForTurn } from './turnChecks';
import { useAcceptanceBundle } from './useAcceptanceBundle';
+import { useAcceptanceTurn } from './useAcceptanceTurn';
import { canReviewAcceptance } from './visibility';
-const CHECK_REVIEW_ORDER: Record<Exclude<CheckFilter, 'all'>, number> = {
- pending: 0,
- needsFix: 1,
- accepted: 2,
- ignored: 3,
-};
-
const AcceptanceFocusWorkspace = () => {
const { t } = useTranslation('verify');
const navigate = useNavigate();
+ const [searchParams] = useSearchParams();
+ const query = searchParams.toString() ? `?${searchParams}` : '';
const params = useParams<{ checkId?: string }>();
const { acceptanceId } = useAcceptanceScope();
const { data, mutate } = useAcceptanceBundle(acceptanceId);
- const focusedCheck = data?.checks.find((check) => check.id === params.checkId);
+ const { turn } = useAcceptanceTurn();
+ const turnChecks = data ? checksForTurn(data, turn) : [];
+ const focusedCheck = turnChecks.find((check) => check.id === params.checkId);
if (!data || !focusedCheck) return null;
- const orderedChecks = [...data.checks].sort(
- (a, b) =>
- CHECK_REVIEW_ORDER[checkFilterState(a)] - CHECK_REVIEW_ORDER[checkFilterState(b)] ||
- a.seq - b.seq,
- );
+ const orderedChecks = [...turnChecks].sort((a, b) => a.seq - b.seq);
const standing = (data.acceptance.config?.checklist ?? []).filter(
(item) => !data.checks.some((check) => check.id === item.id),
);
@@ -52,8 +46,7 @@ const AcceptanceFocusWorkspace = () => {
return (
<AcceptanceFocusReview
- canReview={canReviewAcceptance(data)}
- checks={data.checks}
+ checks={turnChecks}
focusedCheck={focusedCheck}
orderedChecks={orderedChecks}
reviewPending={false}
@@ -61,8 +54,13 @@ const AcceptanceFocusWorkspace = () => {
standingChecks={standing}
status={data.acceptance.status}
subjectTitle={data.subject.title ?? data.subject.id}
- onBack={() => navigate(acceptanceOverviewPath(acceptanceId), { replace: true })}
- onSelectCheck={(id) => navigate(acceptanceCheckPath(acceptanceId, id), { replace: true })}
+ canReview={
+ canReviewAcceptance(data) && (turn === null || turn === data.rounds.at(-1)?.run.roundIndex)
+ }
+ onBack={() => navigate(acceptanceOverviewPath(acceptanceId) + query, { replace: true })}
+ onSelectCheck={(id) =>
+ navigate(acceptanceCheckPath(acceptanceId, id) + query, { replace: true })
+ }
// Checklist authoring writes through the subject — creator-only until that
// path is reviewer-aware. Reviewing the checks themselves is not.
onAddChecks={
diff --git a/src/features/Acceptance/Viewer/AcceptanceIdentity.tsx b/src/features/Acceptance/Viewer/AcceptanceIdentity.tsx
index 3e9af43f6af..d8b5b95e25e 100644
--- a/src/features/Acceptance/Viewer/AcceptanceIdentity.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceIdentity.tsx
@@ -17,6 +17,11 @@ import { useAcceptanceBundle } from './useAcceptanceBundle';
import { formatAcceptanceCountsText } from './verdict';
const styles = createStaticStyles(({ css }) => ({
+ statusRow: css`
+ @media (width <= 767px) {
+ padding-inline-end: 48px;
+ }
+ `,
scopeChip: css`
font-size: 12px;
color: ${cssVar.colorTextSecondary};
@@ -78,12 +83,8 @@ const AcceptanceIdentity = ({ focusSlot, statusSlot, topicSlot }: AcceptanceIden
const showOrigin = Boolean(originAgent || topicSlot || pullRequest?.number);
return (
- <Flexbox gap={6}>
- {/* State leads, on its own line above the name — the delivery's standing
- is what a reader checks first, and it stops competing with the title
- for the same row. The per-check entry rides along with it: it acts on
- exactly the counts stated beside it. */}
- <Flexbox horizontal align={'center'} gap={10} wrap={'wrap'}>
+ <Flexbox gap={10}>
+ <Flexbox horizontal align={'center'} className={styles.statusRow} gap={10} wrap={'wrap'}>
{statusSlot ?? <AcceptanceStatusPill status={acceptance.status} />}
<Text fontSize={12} type={'secondary'}>
{[countsText, latestAt].filter(Boolean).join(' · ')}
diff --git a/src/features/Acceptance/Viewer/AcceptanceLedgerRail.tsx b/src/features/Acceptance/Viewer/AcceptanceLedgerRail.tsx
index 214e6602273..a2070ed57ab 100644
--- a/src/features/Acceptance/Viewer/AcceptanceLedgerRail.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceLedgerRail.tsx
@@ -1,12 +1,13 @@
'use client';
import { DraggablePanel, Flexbox, Icon } from '@lobehub/ui';
-import { Drawer, Text } from '@lobehub/ui/base-ui';
+import { Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, useResponsive } from 'antd-style';
import { PanelRightOpen } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useParams, useSearchParams } from 'react-router';
+import { AcceptanceDrawer } from '../AcceptanceDrawer';
import ReportViewer from '../Report/ReportViewer';
import { resolveRoundParam } from '../utils';
import { useAcceptanceScope } from './AcceptanceScope';
@@ -70,7 +71,7 @@ const AcceptanceLedgerRail = () => {
if (!data || !canViewAcceptanceHistory(data.isOwner)) return null;
- const urlRoundRaw = searchParams.get('r');
+ const urlRoundRaw = searchParams.get('report');
const reportRound = embedded ? null : resolveRoundParam(data.rounds, urlRoundRaw);
const reviewableChecks = data.checks;
const reviewByRound = (() => {
@@ -91,8 +92,8 @@ const AcceptanceLedgerRail = () => {
setSearchParams(
(prev) => {
const next = new URLSearchParams(prev);
- if (round?.run.roundIndex == null) next.delete('r');
- else next.set('r', String(round.run.roundIndex));
+ if (round?.run.roundIndex == null) next.delete('report');
+ else next.set('report', String(round.run.roundIndex));
return next;
},
{ replace: true },
@@ -119,6 +120,7 @@ const AcceptanceLedgerRail = () => {
const ledger = (
<LedgerPanel
+ hideCollapse={isNarrowViewport}
highlight={highlightRound}
reviewByRound={reviewByRound}
rounds={data.rounds}
@@ -142,18 +144,18 @@ const AcceptanceLedgerRail = () => {
</Flexbox>
)}
{isNarrowViewport ? (
- <Drawer
+ <AcceptanceDrawer
noHeader
- closable={false}
containerMaxWidth={'100%'}
open={expand}
placement={'right'}
styles={{ bodyContent: { padding: 0 } }}
+ title={t('acceptance.ledger.title')}
width={'min(340px, 88vw)'}
onClose={() => onExpandChange(false)}
>
{topic ?? ledger}
- </Drawer>
+ </AcceptanceDrawer>
) : (
<DraggablePanel
stableLayout
@@ -169,11 +171,12 @@ const AcceptanceLedgerRail = () => {
</Flexbox>
</DraggablePanel>
)}
- <Drawer
+ <AcceptanceDrawer
noHeader
containerMaxWidth={'100%'}
open={reportRound !== null}
placement={'right'}
+ title={t('report.titleFallback')}
width={'min(960px, 92vw)'}
styles={{
bodyContent: { height: '100%', minHeight: 0, overflow: 'hidden', padding: 0 },
@@ -185,7 +188,7 @@ const AcceptanceLedgerRail = () => {
<ReportViewer runId={reportRound.run.id} />
</Flexbox>
)}
- </Drawer>
+ </AcceptanceDrawer>
</>
);
};
diff --git a/src/features/Acceptance/Viewer/AcceptanceResources.tsx b/src/features/Acceptance/Viewer/AcceptanceResources.tsx
index 0cf4d526b7b..cdb94be0ad0 100644
--- a/src/features/Acceptance/Viewer/AcceptanceResources.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceResources.tsx
@@ -10,7 +10,9 @@ import { useTranslation } from 'react-i18next';
import { useIsHydrated } from '@/hooks/useIsHydrated';
import { useAcceptanceScope } from './AcceptanceScope';
+import { checksForTurn } from './turnChecks';
import { useAcceptanceBundle } from './useAcceptanceBundle';
+import { useAcceptanceTurn } from './useAcceptanceTurn';
const styles = createStaticStyles(({ css }) => ({
/**
@@ -82,12 +84,13 @@ const AcceptanceResources = () => {
const { t } = useTranslation('verify');
const { lg = true, md = true } = useResponsive();
const hydrated = useIsHydrated();
- const { acceptanceId } = useAcceptanceScope();
+ const { acceptanceId, embedded } = useAcceptanceScope();
+ const { turn } = useAcceptanceTurn(embedded);
const { data } = useAcceptanceBundle(acceptanceId);
if (!data) return null;
const seen = new Set<string>();
- const items = data.checks
+ const items = checksForTurn(data, turn)
.flatMap((check) =>
(check.evidence ?? []).map((evidence) => ({ check: check.title, evidence })),
)
diff --git a/src/features/Acceptance/Viewer/AcceptanceTabs.tsx b/src/features/Acceptance/Viewer/AcceptanceTabs.tsx
index 38c0d5a0783..a47a6b3a860 100644
--- a/src/features/Acceptance/Viewer/AcceptanceTabs.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceTabs.tsx
@@ -1,7 +1,7 @@
'use client';
import { Flexbox, Icon } from '@lobehub/ui';
-import { Text } from '@lobehub/ui/base-ui';
+import { Button, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import { ListChecks, Paperclip } from 'lucide-react';
import { useTranslation } from 'react-i18next';
@@ -81,12 +81,12 @@ const AcceptanceTabs = ({ active, checkCount, onChange, resourceCount }: Accepta
return (
<Flexbox horizontal align={'center'} gap={2}>
{tabs.map((tab) => (
- <Flexbox
- horizontal
- align={'center'}
+ <Button
+ aria-pressed={tab.key === active}
className={cx(styles.tab, tab.key === active && styles.tabActive)}
- gap={6}
key={tab.key}
+ style={{ minHeight: 44 }}
+ type={'text'}
onClick={() => onChange(tab.key)}
>
<Icon icon={tab.icon} size={14} style={{ color: cssVar.colorTextTertiary }} />
@@ -94,7 +94,7 @@ const AcceptanceTabs = ({ active, checkCount, onChange, resourceCount }: Accepta
{tab.label}
</Text>
<Text className={styles.count}>{tab.count}</Text>
- </Flexbox>
+ </Button>
))}
</Flexbox>
);
diff --git a/src/features/Acceptance/Viewer/AcceptanceViewReportLink.tsx b/src/features/Acceptance/Viewer/AcceptanceViewReportLink.tsx
index b1cfbb252ff..dd6c8b38612 100644
--- a/src/features/Acceptance/Viewer/AcceptanceViewReportLink.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceViewReportLink.tsx
@@ -11,12 +11,22 @@ import { canViewAcceptanceHistory } from './visibility';
const styles = createStaticStyles(({ css }) => ({
link: css`
cursor: pointer;
+
+ padding: 0;
+ border: 0;
+
font-size: 12px;
color: ${cssVar.colorTextQuaternary};
+ background: none;
+
&:hover {
color: ${cssVar.colorTextSecondary};
}
+
+ @media (width <= 767px) {
+ min-height: 44px;
+ }
`,
}));
@@ -30,14 +40,15 @@ const AcceptanceViewReportLink = () => {
const round = [...data.rounds].reverse().find((item) => item.report);
return (
- <span
+ <button
className={styles.link}
+ type={'button'}
onClick={() => {
if (round?.run.roundIndex == null) return;
setSearchParams(
(prev) => {
const params = new URLSearchParams(prev);
- params.set('r', String(round.run.roundIndex));
+ params.set('report', String(round.run.roundIndex));
return params;
},
{ replace: true },
@@ -45,7 +56,7 @@ const AcceptanceViewReportLink = () => {
}}
>
{t('acceptance.viewFullReport')}
- </span>
+ </button>
);
};
diff --git a/src/features/Acceptance/Viewer/Annotation.tsx b/src/features/Acceptance/Viewer/Annotation.tsx
index 1b8daa43d0f..18c71c499ce 100644
--- a/src/features/Acceptance/Viewer/Annotation.tsx
+++ b/src/features/Acceptance/Viewer/Annotation.tsx
@@ -5,7 +5,9 @@ import { Flexbox, Icon } from '@lobehub/ui';
import { Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import { Trash2 } from 'lucide-react';
-import { memo, useRef, useState } from 'react';
+import { memo } from 'react';
+
+import { useAnnotationGesture } from './useAnnotationGesture';
/**
* Region-comment primitives for acceptance evidence images. Rects are stored
@@ -63,6 +65,10 @@ const styles = createStaticStyles(({ css }) => ({
&:hover {
filter: brightness(1.15);
}
+
+ @media (width <= 767px) {
+ display: none;
+ }
`,
canvas: css`
cursor: crosshair;
@@ -110,6 +116,12 @@ const styles = createStaticStyles(({ css }) => ({
border-radius: 50%;
background: ${cssVar.colorBgContainer};
+
+ &::after {
+ content: '';
+ position: absolute;
+ inset: -16px;
+ }
`,
}));
@@ -178,6 +190,7 @@ export interface DraftAnnotation {
interface AnnotationCanvasProps {
annotations: DraftAnnotation[];
+ drawing?: boolean;
/**
* Explicit display width (CSS px) — the host computes viewport × zoom.
* Rects are normalized to the image box, so zooming never remaps them; the
@@ -191,97 +204,30 @@ interface AnnotationCanvasProps {
src: string;
}
-/** An in-flight pointer gesture: drawing a new region, or moving/resizing one. */
-type Gesture =
- | { kind: 'draw'; start: { x: number; y: number } }
- | { index: number; kind: 'move'; origin: Rect; start: { x: number; y: number } }
- | { index: number; kind: 'resize'; origin: Rect };
-
-const clamp01 = (value: number) => Math.min(Math.max(value, 0), 1);
-
/**
* Drag on the image to circle a region; drag a region to move it, drag its
* corner handle to resize; each region carries its own note.
*/
export const AnnotationCanvas = memo<AnnotationCanvasProps>(
- ({ annotations, imageWidth, onDraw, onRemove, onUpdate, src }) => {
- const imageRef = useRef<HTMLImageElement>(null);
- const [draft, setDraft] = useState<Rect | null>(null);
- const gestureRef = useRef<Gesture | null>(null);
-
- // Normalize against the image's own box — the frame may not equal it.
- const normalize = (event: React.MouseEvent) => {
- const box = imageRef.current?.getBoundingClientRect();
- if (!box || box.width === 0 || box.height === 0) return null;
- return {
- x: clamp01((event.clientX - box.left) / box.width),
- y: clamp01((event.clientY - box.top) / box.height),
- };
- };
-
- const toRect = (a: { x: number; y: number }, b: { x: number; y: number }): Rect => ({
- height: Math.abs(a.y - b.y),
- width: Math.abs(a.x - b.x),
- x: Math.min(a.x, b.x),
- y: Math.min(a.y, b.y),
+ ({ annotations, drawing = true, imageWidth, onDraw, onRemove, onUpdate, src }) => {
+ const { draft, handlers, imageRef, startEdit } = useAnnotationGesture({
+ drawing,
+ onDraw,
+ onUpdate,
});
- const endGesture = (event: React.MouseEvent) => {
- const gesture = gestureRef.current;
- gestureRef.current = null;
- setDraft(null);
- if (gesture?.kind !== 'draw') return;
- const point = normalize(event);
- if (!point) return;
- const rect = toRect(gesture.start, point);
- // Ignore accidental clicks — a region needs real area to comment on.
- if (rect.width < 0.01 || rect.height < 0.01) return;
- onDraw(rect);
- };
-
return (
<div
className={`${styles.frame} ${styles.canvas}`}
// With an explicit zoomed width the frame must OUTGROW its host —
// capping at 100% would clip the image instead of letting the host
// viewport scroll/pan over it.
- style={imageWidth ? { maxWidth: 'none' } : undefined}
- onMouseUp={endGesture}
- onMouseDown={(event) => {
- event.preventDefault();
- const start = normalize(event);
- if (start) gestureRef.current = { kind: 'draw', start };
- }}
- onMouseLeave={() => {
- gestureRef.current = null;
- setDraft(null);
- }}
- onMouseMove={(event) => {
- const gesture = gestureRef.current;
- if (!gesture) return;
- const point = normalize(event);
- if (!point) return;
- if (gesture.kind === 'draw') {
- setDraft(toRect(gesture.start, point));
- return;
- }
- const { index, origin } = gesture;
- if (gesture.kind === 'move') {
- onUpdate(index, {
- ...origin,
- x: Math.min(Math.max(origin.x + (point.x - gesture.start.x), 0), 1 - origin.width),
- y: Math.min(Math.max(origin.y + (point.y - gesture.start.y), 0), 1 - origin.height),
- });
- return;
- }
- // resize — the origin's top-left corner stays anchored.
- onUpdate(index, {
- height: Math.max(point.y - origin.y, 0.01),
- width: Math.max(point.x - origin.x, 0.01),
- x: origin.x,
- y: origin.y,
- });
+ style={{
+ maxWidth: imageWidth ? 'none' : undefined,
+ touchAction: drawing ? 'none' : 'pan-x pan-y',
+ cursor: drawing ? 'crosshair' : 'auto',
}}
+ {...handlers}
>
<img
alt={''}
@@ -297,20 +243,14 @@ export const AnnotationCanvas = memo<AnnotationCanvasProps>(
<div
className={`${styles.rect} ${styles.editableRect}`}
key={index}
- style={rectStyle(annotation.rect)}
- onMouseDown={(event) => {
- event.preventDefault();
- event.stopPropagation();
- const start = normalize(event);
- if (start)
- gestureRef.current = { index, kind: 'move', origin: annotation.rect, start };
- }}
+ style={{ ...rectStyle(annotation.rect), pointerEvents: drawing ? 'auto' : 'none' }}
+ onPointerDown={(event) => startEdit(event, index, annotation.rect, 'move')}
>
<span className={styles.badge}>{index + 1}</span>
<button
className={styles.badgeDelete}
type={'button'}
- onMouseDown={(event) => event.stopPropagation()}
+ onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
event.stopPropagation();
onRemove(index);
@@ -320,11 +260,7 @@ export const AnnotationCanvas = memo<AnnotationCanvasProps>(
</button>
<span
className={styles.resizeHandle}
- onMouseDown={(event) => {
- event.preventDefault();
- event.stopPropagation();
- gestureRef.current = { index, kind: 'resize', origin: annotation.rect };
- }}
+ onPointerDown={(event) => startEdit(event, index, annotation.rect, 'resize')}
/>
</div>
))}
diff --git a/src/features/Acceptance/Viewer/CheckList.test.ts b/src/features/Acceptance/Viewer/CheckList.test.ts
index 6c26f2ab5c5..68db334e448 100644
--- a/src/features/Acceptance/Viewer/CheckList.test.ts
+++ b/src/features/Acceptance/Viewer/CheckList.test.ts
@@ -19,6 +19,7 @@ import {
checkRejectModalSize,
mergeRejectComments,
rejectModalTitle,
+ serializeReviewAnnotations,
TEXT_REJECT_MODAL_WIDTH,
} from './CheckRejectModal';
@@ -351,3 +352,18 @@ describe('focusedCheckStates', () => {
},
);
});
+
+describe('review annotation payload', () => {
+ it('keeps circles described by the overall comment and their image identity', () => {
+ const rect = { x: 0.1, y: 0.2, width: 0.3, height: 0.4 };
+ expect(
+ serializeReviewAnnotations([
+ { key: 1, evidenceId: 'first-image', comment: '', rect },
+ { key: 2, evidenceId: 'second-image', comment: ' Note ', rect },
+ ]),
+ ).toEqual([
+ { evidenceId: 'first-image', comment: undefined, rect },
+ { evidenceId: 'second-image', comment: 'Note', rect },
+ ]);
+ });
+});
diff --git a/src/features/Acceptance/Viewer/CheckList.tsx b/src/features/Acceptance/Viewer/CheckList.tsx
index 11511d342c5..3bc2444fc23 100644
--- a/src/features/Acceptance/Viewer/CheckList.tsx
+++ b/src/features/Acceptance/Viewer/CheckList.tsx
@@ -9,7 +9,7 @@ import type {
} from '@lobechat/types';
import { copyToClipboard, Empty, Flexbox, Icon, Image, TextArea, Tooltip } from '@lobehub/ui';
import { ActionIcon, Button, Tag, Text } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar, cx } from 'antd-style';
+import { createStaticStyles, cssVar, cx, useResponsive } from 'antd-style';
import dayjs from 'dayjs';
import {
AudioLines,
@@ -443,6 +443,7 @@ const comparisonContent = (item: AcceptanceEvidence) => {
const EvidenceList = memo<{
evidence: AcceptanceEvidence[];
+ onReviewEvidence?: (id: string) => void;
/**
* Regions to draw over an evidence image, keyed by evidence id. Used by the
* AI proposal: rather than the card rendering its own copy of the screenshot
@@ -453,7 +454,8 @@ const EvidenceList = memo<{
string,
{ comment?: string; label?: number; rect: AcceptanceReviewAnnotation['rect'] }[]
>;
-}>(({ evidence, overlays }) => {
+}>(({ evidence, overlays, onReviewEvidence }) => {
+ const { md = true } = useResponsive();
const sorted = [...evidence].sort((a, b) => (isVisual(b) ? 1 : 0) - (isVisual(a) ? 1 : 0));
if (sorted.length === 0) return null;
@@ -489,7 +491,7 @@ const EvidenceList = memo<{
<Flexbox gap={12}>
{sorted.map((item) => {
if (consumedScreenshotIds.has(item.id)) return null;
- if (pairedIds.has(item.id)) {
+ if (pairedIds.has(item.id) && (md || !onReviewEvidence)) {
const comparison = readEvidenceComparison(item.metadata)!;
// The pair renders once, anchored at its `before` half.
if (comparison.role !== 'before') return null;
@@ -531,6 +533,39 @@ const EvidenceList = memo<{
{caption}
</Flexbox>
);
+ if (!md && onReviewEvidence && item.fileUrl && IMAGE_EVIDENCE.has(item.type)) {
+ return (
+ <button
+ key={item.id}
+ type={'button'}
+ style={{
+ padding: 0,
+ width: '100%',
+ border: 0,
+ background: 'none',
+ textAlign: 'start',
+ cursor: 'pointer',
+ }}
+ 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>
+ );
+ }
const overlay = overlays?.get(item.id);
if (item.fileUrl && item.type === 'screenshot') {
const run = [item];
@@ -949,6 +984,7 @@ export const AcceptanceCheckRow = memo<{
reviewPending,
}) => {
const { t } = useTranslation('verify');
+ const { md: desktop = true } = useResponsive();
// The judging narrative stays collapsed: level one is title + evidence.
const [historyOpen, setHistoryOpen] = useState(false);
const [seqCopied, setSeqCopied] = useState(false);
@@ -999,11 +1035,21 @@ export const AcceptanceCheckRow = memo<{
* model's note and regions, and the submitted result is diffed against it
* so the signal records WHICH part of the proposal was wrong.
*/
- const openReject = (fromProposal?: CheckProposal) =>
+ const openReject = (fromProposal?: CheckProposal, initialEvidenceId?: string) =>
openCheckRejectModal({
+ initialEvidenceId,
+ previousAttachments:
+ activeReview?.action === 'reject'
+ ? activeReview.attachments
+ ?.filter((item) => item.url)
+ .map((item) => ({ id: item.id, name: item.name, url: item.url! }))
+ : undefined,
+ previousAnnotations:
+ activeReview?.action === 'reject' ? activeReview.annotations : undefined,
+ previousComment: activeReview?.action === 'reject' ? activeReview.comment : undefined,
checkDescription: check.planItem?.description,
checkTitle: `C${check.seq} · ${title}`,
- draftKey: check.id,
+ draftKey: `${check.result?.id ?? 'unexecuted'}:${check.id}`,
evidence: check.evidence
.filter((item) => isAnnotatable(item))
.map((item) => ({ fileUrl: item.fileUrl!, id: item.id })),
@@ -1121,10 +1167,22 @@ export const AcceptanceCheckRow = memo<{
<Flexbox
horizontal
align={'flex-start'}
+ aria-expanded={expanded}
className={styles.rowHeader}
data-expanded={expanded ? '' : undefined}
gap={10}
+ role={'button'}
+ tabIndex={0}
onClick={onToggle}
+ onKeyDown={(event) => {
+ if (
+ event.target === event.currentTarget &&
+ (event.key === 'Enter' || event.key === ' ')
+ ) {
+ event.preventDefault();
+ onToggle();
+ }
+ }}
>
{reviewState === 'rejected' ? (
<Tooltip title={t('acceptance.review.rejectedHint')}>{headIconNode}</Tooltip>
@@ -1155,8 +1213,8 @@ export const AcceptanceCheckRow = memo<{
wrap={expanded ? 'wrap' : 'nowrap'}
>
<Text
- className={expanded ? undefined : styles.titleEllipsis}
- style={{ fontSize: 13, minWidth: 0 }}
+ className={expanded || !desktop ? undefined : styles.titleEllipsis}
+ style={{ fontSize: desktop ? 13 : 14, minWidth: 0 }}
>
{title}
</Text>
@@ -1169,7 +1227,7 @@ export const AcceptanceCheckRow = memo<{
far right: the claim you judge and the judgement you give land in
one glance, so a long checklist needs no eye round-trip across the
row (and no mis-click onto a neighbour's buttons). */}
- {reviewable && reviewState === 'pending' && (
+ {desktop && reviewable && reviewState === 'pending' && (
<Flexbox
horizontal
align={'center'}
@@ -1352,7 +1410,11 @@ export const AcceptanceCheckRow = memo<{
</Flexbox>
)}
{visualization && <VisualizationRenderer manifest={visualization} />}
- <EvidenceList evidence={check.evidence} overlays={proposalOverlays} />
+ <EvidenceList
+ evidence={check.evidence}
+ overlays={proposalOverlays}
+ onReviewEvidence={canReview ? (id) => openReject(undefined, id) : undefined}
+ />
{check.state === 'not_executed' && (
<Flexbox
diff --git a/src/features/Acceptance/Viewer/CheckRejectModal.tsx b/src/features/Acceptance/Viewer/CheckRejectModal.tsx
index fa30da3ccfc..455a7b71dec 100644
--- a/src/features/Acceptance/Viewer/CheckRejectModal.tsx
+++ b/src/features/Acceptance/Viewer/CheckRejectModal.tsx
@@ -3,19 +3,57 @@
import type { AcceptanceReviewAnnotation } from '@lobechat/types';
import { Flexbox, TextArea } from '@lobehub/ui';
import { ActionIcon, Button, createModal, Text, useModalContext } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar, cx } from 'antd-style';
-import { ZoomIn, ZoomOut } from 'lucide-react';
+import { createStaticStyles, cssVar, cx, useResponsive } from 'antd-style';
+import { Trash2, ZoomIn, ZoomOut } from 'lucide-react';
import { memo, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { AnnotationCanvas } from './Annotation';
+import type { PendingAttachment } from './attachments';
import { AttachmentStrip, AttachmentUploadButton, useFeedbackAttachments } from './attachments';
+import { MobileEvidenceReview } from './MobileEvidenceReview';
import { frostedModalStyles } from './modals';
+import { useReviewSubmit } from './useReviewSubmit';
export const CHECK_REJECT_MODAL_SIZE = { height: '98dvh', width: '98vw' } as const;
export const TEXT_REJECT_MODAL_WIDTH = 'min(560px, calc(100vw - 32px))';
const styles = createStaticStyles(({ css }) => ({
+ mobilePopup: css`
+ @media (width <= 767px) {
+ max-width: 100vw !important;
+
+ > div {
+ width: 100vw;
+ max-width: 100vw;
+ height: 100dvh;
+ max-height: 100dvh;
+ padding: 0;
+ border-radius: 0;
+ }
+ }
+ `,
+ mobileClose: css`
+ @media (width <= 767px) {
+ inset-block-start: max(4px, env(safe-area-inset-top));
+ inset-inline-end: 4px;
+ width: 44px;
+ height: 44px;
+ }
+ `,
+ mobileHeader: css`
+ @media (width <= 767px) {
+ min-height: 56px;
+ padding-block: max(12px, env(safe-area-inset-top)) 12px;
+ padding-inline: 12px 52px;
+ }
+ `,
+ mobileContent: css`
+ @media (width <= 767px) {
+ padding-block: 0 max(12px, env(safe-area-inset-bottom));
+ padding-inline: 12px;
+ }
+ `,
modalPopup: css`
> div {
display: flex;
@@ -27,6 +65,15 @@ const styles = createStaticStyles(({ css }) => ({
width: ${CHECK_REJECT_MODAL_SIZE.width};
max-width: ${CHECK_REJECT_MODAL_SIZE.width};
height: ${CHECK_REJECT_MODAL_SIZE.height};
+
+ @media (width <= 767px) {
+ width: 100vw;
+ max-width: 100vw;
+ height: 100dvh;
+ max-height: 100dvh;
+ padding: 0;
+ border-radius: 0;
+ }
}
`,
fullscreenBody: css`
@@ -35,7 +82,7 @@ const styles = createStaticStyles(({ css }) => ({
gap: 16px;
min-height: 0;
- @media (width <= 640px) {
+ @media (width <= 767px) {
flex-direction: column;
gap: 12px;
}
@@ -78,10 +125,10 @@ const styles = createStaticStyles(({ css }) => ({
width: 320px;
min-width: 0;
- @media (width <= 640px) {
+ @media (width <= 767px) {
flex: 0 1 auto;
width: 100%;
- max-height: 36%;
+ max-height: none;
}
`,
thumb: css`
@@ -109,10 +156,12 @@ const styles = createStaticStyles(({ css }) => ({
fits the stage, and scrolls from the edges once it grows past it. */
viewport: css`
overflow: auto;
+ overscroll-behavior: contain;
display: flex;
flex: 1;
min-width: 0;
+ min-height: 120px;
border: 1px solid ${cssVar.colorBorderSecondary};
border-radius: ${cssVar.borderRadiusLG};
@@ -143,6 +192,12 @@ const styles = createStaticStyles(({ css }) => ({
background: ${cssVar.colorBgElevated};
box-shadow: ${cssVar.boxShadowSecondary};
+
+ @media (width <= 767px) {
+ position: static;
+ transform: none;
+ align-self: center;
+ }
`,
zoomLabel: css`
min-width: 44px;
@@ -175,9 +230,19 @@ const nextAnnotationKey = () => ++draftAnnotationSeq;
/** What survives a refresh — typed feedback is too costly to lose to one F5. */
interface RejectDraft {
annotations: DraftAnnotationEntry[];
+ attachments?: PendingAttachment[];
comment: string;
}
+export const serializeReviewAnnotations = (
+ annotations: DraftAnnotationEntry[],
+): AcceptanceReviewAnnotation[] =>
+ annotations.map(({ comment, evidenceId, rect }) => ({
+ comment: comment.trim() || undefined,
+ evidenceId,
+ rect,
+ }));
+
const draftStorageKey = (key: string) => `acceptance-reject-draft:${key}`;
const readDraft = (key: string | undefined): RejectDraft | null => {
@@ -201,7 +266,10 @@ export const checkRejectModalShell = (evidenceCount: number) => {
const modalSize = checkRejectModalSize(evidenceCount);
return {
classNames: {
- popup: cx(styles.modalPopup, evidenceCount > 0 && styles.modalPopupMedia),
+ close: styles.mobileClose,
+ content: styles.mobileContent,
+ header: styles.mobileHeader,
+ popup: cx(styles.modalPopup, styles.mobilePopup, evidenceCount > 0 && styles.modalPopupMedia),
},
styles: {
...frostedModalStyles,
@@ -232,12 +300,16 @@ interface CheckRejectModalProps {
initialAnnotations?: AcceptanceReviewAnnotation[];
/** Feedback already typed in the focused detail before opening annotation. */
initialComment?: string;
+ initialEvidenceId?: string;
/** Perform the reject; resolve true to close, false to stay open. */
onConfirm: (value: {
annotations: AcceptanceReviewAnnotation[];
comment: string;
fileIds: string[];
}) => Promise<boolean>;
+ previousAnnotations?: AcceptanceReviewAnnotation[];
+ previousAttachments?: PendingAttachment[];
+ previousComment?: string;
}
export const mergeRejectComments = (initialComment = '', storedComment = '') => {
@@ -249,8 +321,23 @@ export const mergeRejectComments = (initialComment = '', storedComment = '') =>
};
const CheckRejectModalContent = memo<CheckRejectModalProps>(
- ({ checkTitle, draftKey, evidence, initialAnnotations, initialComment, onConfirm }) => {
+ ({
+ checkTitle,
+ draftKey,
+ evidence,
+ initialAnnotations,
+ initialComment,
+ initialEvidenceId,
+ previousAnnotations,
+ previousAttachments,
+ previousComment,
+ onConfirm,
+ }) => {
const { t: translate } = useTranslation('verify');
+ const { md = true } = useResponsive();
+ const [drawing, setDrawing] = useState(false);
+ const [showFeedback, setShowFeedback] = useState(evidence.length === 0);
+ const swipeStart = useRef<{ x: number; y: number } | null>(null);
const { close, setCanDismissByClickOutside } = useModalContext();
const [draft] = useState(() => readDraft(draftKey));
const [comment, setComment] = useState(() =>
@@ -259,12 +346,14 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
// feedback neither party wrote.
initialAnnotations?.length
? (initialComment ?? '')
- : mergeRejectComments(initialComment, draft?.comment),
+ : mergeRejectComments(initialComment, draft?.comment ?? previousComment),
);
- const [loading, setLoading] = useState(false);
- const [activeEvidenceId, setActiveEvidenceId] = useState(evidence[0]?.id);
+ const { failed, loading, submit } = useReviewSubmit();
+ const [activeEvidenceId, setActiveEvidenceId] = useState(initialEvidenceId ?? evidence[0]?.id);
const [annotations, setAnnotations] = useState<DraftAnnotationEntry[]>(() => {
- const source = initialAnnotations?.length ? initialAnnotations : (draft?.annotations ?? []);
+ const source = initialAnnotations?.length
+ ? initialAnnotations
+ : (draft?.annotations ?? previousAnnotations ?? []);
return (
source
// Only restore regions whose evidence still exists — a new round may
@@ -286,7 +375,7 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
// Your own screenshots (paste or upload) — attached to the reject alongside
// the note and any circled regions.
const { attachments, fileIds, handlePaste, remove, uploadFiles, uploading } =
- useFeedbackAttachments();
+ useFeedbackAttachments(6, draft?.attachments ?? previousAttachments);
const [zoom, setZoom] = useState(1);
const viewportRef = useRef<HTMLDivElement>(null);
@@ -315,25 +404,32 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
cancelAnimationFrame(raf);
observer?.disconnect();
};
- }, [activeEvidenceId, evidence.length]);
+ }, [activeEvidenceId, evidence.length, showFeedback]);
// Persist the draft as it is typed; an empty draft cleans the slot up.
useEffect(() => {
if (!draftKey) return;
try {
- if (!comment && annotations.length === 0) {
+ if (!comment && annotations.length === 0 && attachments.length === 0) {
localStorage.removeItem(draftStorageKey(draftKey));
} else {
localStorage.setItem(
draftStorageKey(draftKey),
- JSON.stringify({ annotations, comment } satisfies RejectDraft),
+ JSON.stringify({ annotations, attachments, comment } satisfies RejectDraft),
);
}
} catch {
/* quota/private mode — the draft is a convenience, never a blocker */
}
- }, [annotations, comment, draftKey]);
-
+ }, [annotations, attachments, comment, draftKey]);
+
+ const activeIndex = evidence.findIndex((item) => item.id === activeEvidenceId);
+ const selectEvidence = (index: number) => {
+ if (!evidence[index]) return;
+ setActiveEvidenceId(evidence[index].id);
+ setZoom(1);
+ viewportRef.current?.scrollTo(0, 0);
+ };
const activeEvidence = evidence.find((item) => item.id === activeEvidenceId);
const activeAnnotations = annotations.filter((item) => item.evidenceId === activeEvidenceId);
@@ -352,36 +448,32 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
fileIds.length > 0;
const handleConfirm = async () => {
- setLoading(true);
- try {
- const confirmed = await onConfirm({
- annotations: annotations
- .filter((annotation) => annotation.comment.trim())
- .map((annotation) => ({
- comment: annotation.comment.trim(),
- evidenceId: annotation.evidenceId,
- rect: annotation.rect,
- })),
+ const confirmed = await submit(() =>
+ onConfirm({
+ annotations: serializeReviewAnnotations(annotations),
comment: comment.trim(),
fileIds,
- });
- if (confirmed) {
- if (draftKey) localStorage.removeItem(draftStorageKey(draftKey));
- close();
- }
- } finally {
- setLoading(false);
+ }),
+ );
+ if (confirmed) {
+ if (draftKey) localStorage.removeItem(draftStorageKey(draftKey));
+ close();
}
};
const hasEvidence = evidence.length > 0;
const canvasHandlers = {
- onDraw: (rect: AcceptanceReviewAnnotation['rect']) =>
+ onDraw: (rect: AcceptanceReviewAnnotation['rect']) => {
setAnnotations((previous) => [
...previous,
{ comment: '', evidenceId: activeEvidence!.id, key: nextAnnotationKey(), rect },
- ]),
+ ]);
+ if (!md) {
+ setDrawing(false);
+ setShowFeedback(true);
+ }
+ },
onRemove: (index: number) => {
const target = activeAnnotations[index];
if (target)
@@ -396,39 +488,82 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
},
};
- const annotationInputs = activeAnnotations.map((annotation, index) => (
- <Flexbox horizontal align={'flex-start'} gap={8} key={annotation.key}>
- <span className={styles.regionIndex} style={{ marginBlockStart: 6 }}>
- {index + 1}
- </span>
- <TextArea
- autoSize={{ maxRows: 5, minRows: 1 }}
- style={{ flex: 1 }}
- value={annotation.comment}
- placeholder={translate('acceptance.review.annotationPlaceholder', {
- index: index + 1,
- })}
- onChange={(event) =>
- setAnnotations((previous) =>
- previous.map((item) =>
- item.key === annotation.key ? { ...item, comment: event.target.value } : item,
- ),
- )
- }
- />
+ const annotationInputs = (md ? activeAnnotations : annotations).map((annotation, index) => (
+ <Flexbox gap={8} key={annotation.key}>
+ {!md && (
+ <Button
+ style={{ alignSelf: 'flex-start', minHeight: 44 }}
+ type={'text'}
+ onClick={() => {
+ selectEvidence(evidence.findIndex((item) => item.id === annotation.evidenceId));
+ setDrawing(true);
+ setShowFeedback(false);
+ }}
+ >
+ {translate('acceptance.review.regionImage', {
+ image: evidence.findIndex((item) => item.id === annotation.evidenceId) + 1,
+ region:
+ annotations
+ .filter((item) => item.evidenceId === annotation.evidenceId)
+ .findIndex((item) => item.key === annotation.key) + 1,
+ })}
+ </Button>
+ )}
+ <Flexbox horizontal align={'flex-start'} gap={8}>
+ <span
+ className={styles.regionIndex}
+ style={{ marginBlockStart: 6, display: md ? undefined : 'none' }}
+ >
+ {index + 1}
+ </span>
+ <TextArea
+ aria-label={translate('acceptance.review.annotationPlaceholder', { index: index + 1 })}
+ autoSize={{ maxRows: 5, minRows: 1 }}
+ style={{ flex: 1, fontSize: md ? undefined : 16 }}
+ value={annotation.comment}
+ placeholder={translate(
+ md
+ ? 'acceptance.review.annotationPlaceholder'
+ : 'acceptance.review.rejectPlaceholder',
+ { index: index + 1 },
+ )}
+ onChange={(event) =>
+ setAnnotations((previous) =>
+ previous.map((item) =>
+ item.key === annotation.key ? { ...item, comment: event.target.value } : item,
+ ),
+ )
+ }
+ />
+ <ActionIcon
+ aria-label={translate('acceptance.review.removeRegion', { index: index + 1 })}
+ icon={Trash2}
+ size={{ blockSize: 44, size: 18 }}
+ onClick={() =>
+ setAnnotations((previous) => previous.filter((item) => item.key !== annotation.key))
+ }
+ />
+ </Flexbox>
</Flexbox>
));
const thumbnails = evidence.length > 1 && (
- <Flexbox horizontal gap={8} wrap={'wrap'}>
+ <Flexbox horizontal gap={8} style={{ overflowX: 'auto', flex: 'none' }}>
{evidence.map((item) => (
- <div
+ <button
+ aria-pressed={item.id === activeEvidenceId}
className={cx(styles.thumb, item.id === activeEvidenceId && styles.thumbActive)}
key={item.id}
- onClick={() => setActiveEvidenceId(item.id)}
+ style={{ flexShrink: 0 }}
+ type={'button'}
+ aria-label={translate('acceptance.review.imageNumber', {
+ current: evidence.indexOf(item) + 1,
+ total: evidence.length,
+ })}
+ onClick={() => selectEvidence(evidence.indexOf(item))}
>
<img alt={''} src={item.fileUrl} />
- </div>
+ </button>
))}
</Flexbox>
);
@@ -457,12 +592,13 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
onRemove={remove}
/>
</Flexbox>
- <Button disabled={loading} onClick={close}>
+ <Button disabled={loading} style={{ minHeight: md ? undefined : 44 }} onClick={close}>
{translate('acceptance.actions.cancel')}
</Button>
<Button
disabled={!canSubmit || uploading}
loading={loading}
+ style={{ minHeight: md ? undefined : 44 }}
type={'primary'}
onClick={handleConfirm}
>
@@ -472,28 +608,106 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
</Flexbox>
);
+ const imageStage = activeEvidence && (
+ <div
+ className={styles.viewport}
+ ref={viewportRef}
+ style={{
+ touchAction: !md && !drawing && zoom === 1 ? 'pan-y pinch-zoom' : undefined,
+ }}
+ onTouchEnd={(event) => {
+ const start = swipeStart.current;
+ swipeStart.current = null;
+ const touch = event.changedTouches[0];
+ if (!start || !touch) return;
+ const dx = touch.clientX - start.x;
+ const dy = touch.clientY - start.y;
+ if (Math.abs(dx) > 60 && Math.abs(dx) > Math.abs(dy) * 1.5)
+ selectEvidence(activeIndex + (dx < 0 ? 1 : -1));
+ }}
+ onTouchStart={(event) => {
+ const touch = event.touches[0];
+ swipeStart.current =
+ !md && !drawing && zoom === 1 && event.touches.length === 1
+ ? { x: touch.clientX, y: touch.clientY }
+ : null;
+ }}
+ >
+ <div className={styles.viewportInner}>
+ <AnnotationCanvas
+ annotations={activeAnnotations}
+ drawing={md || drawing}
+ imageWidth={viewportWidth ? Math.max(viewportWidth * zoom - 2, 0) : undefined}
+ src={activeEvidence!.fileUrl}
+ {...canvasHandlers}
+ />
+ </div>
+ </div>
+ );
+
+ if (!md)
+ return (
+ <MobileEvidenceReview
+ canSubmit={canSubmit && !uploading}
+ drawing={drawing}
+ failed={failed}
+ image={imageStage}
+ imageCount={evidence.length}
+ imageIndex={activeIndex}
+ loading={loading}
+ showFeedback={showFeedback}
+ zoom={zoom}
+ editor={
+ <Flexbox gap={16}>
+ {annotations.length > 0 && (
+ <>
+ <Text strong>{translate('acceptance.review.regionComments')}</Text>
+ {annotationInputs}
+ </>
+ )}
+ <Text strong>{translate('acceptance.review.supplement')}</Text>
+ <TextArea
+ aria-label={translate('acceptance.review.supplement')}
+ autoSize={{ minRows: 4, maxRows: 10 }}
+ placeholder={translate('acceptance.review.rejectPlaceholder')}
+ style={{ fontSize: 16 }}
+ value={comment}
+ onChange={(event) => setComment(event.target.value)}
+ onPaste={handlePaste}
+ />
+ <AttachmentUploadButton disabled={loading} onFiles={uploadFiles} />
+ <AttachmentStrip
+ attachments={attachments}
+ disabled={loading}
+ uploading={uploading}
+ onRemove={remove}
+ />
+ <Text fontSize={12} type={'secondary'}>
+ {translate('acceptance.review.draftSaved')}
+ </Text>
+ </Flexbox>
+ }
+ onConfirm={handleConfirm}
+ onDrawingChange={setDrawing}
+ onImageChange={selectEvidence}
+ onShowFeedback={setShowFeedback}
+ onZoom={stepZoom}
+ />
+ );
+
return (
<div className={styles.modalBody}>
{activeEvidence && (
<Flexbox flex={1} gap={12} style={{ minHeight: 0 }}>
<Flexbox gap={12} height={'100%'} style={{ minHeight: 0 }}>
- {thumbnails}
+ {md && thumbnails}
<div className={styles.fullscreenBody} style={{ position: 'relative' }}>
- <div className={styles.viewport} ref={viewportRef}>
- <div className={styles.viewportInner}>
- <AnnotationCanvas
- annotations={activeAnnotations}
- imageWidth={viewportWidth ? Math.max(viewportWidth * zoom - 2, 0) : undefined}
- src={activeEvidence.fileUrl}
- {...canvasHandlers}
- />
- </div>
- </div>
+ {imageStage}
<div className={styles.zoomBar}>
<ActionIcon
disabled={zoom <= ZOOM_STEPS[0]}
icon={ZoomOut}
- size={'small'}
+ size={md ? 'small' : { blockSize: 44, size: 20 }}
title={translate('acceptance.review.zoomOut')}
onClick={() => stepZoom(-1)}
/>
@@ -501,12 +715,19 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
<ActionIcon
disabled={zoom >= ZOOM_STEPS.at(-1)!}
icon={ZoomIn}
- size={'small'}
+ size={md ? 'small' : { blockSize: 44, size: 20 }}
title={translate('acceptance.review.zoomIn')}
onClick={() => stepZoom(1)}
/>
</div>
- <div className={styles.sidePanel}>
+ <div
+ className={styles.sidePanel}
+ style={
+ !md && !drawing && activeAnnotations.length === 0
+ ? { display: 'none' }
+ : undefined
+ }
+ >
<Flexbox gap={2}>
<Text strong fontSize={13}>
{translate('acceptance.review.regionComments')}
@@ -526,7 +747,14 @@ const CheckRejectModalContent = memo<CheckRejectModalProps>(
</Flexbox>
</Flexbox>
)}
- <div className={styles.modalFooter}>{footer}</div>
+ <div className={styles.modalFooter}>
+ {failed && (
+ <Text role={'alert'} type={'danger'}>
+ {translate('acceptance.review.submitFailed')}
+ </Text>
+ )}
+ {footer}
+ </div>
</div>
);
},
@@ -546,7 +774,9 @@ export const openCheckRejectModal = (options: CheckRejectModalProps) => {
maskClosable: true,
title: (
<Flexbox gap={2}>
- <Text strong>{modalTitle.title}</Text>
+ <Text strong style={{ overflowWrap: 'anywhere', whiteSpace: 'normal' }}>
+ {modalTitle.title}
+ </Text>
{modalTitle.description && (
<Text fontSize={12} type={'secondary'}>
{modalTitle.description}
diff --git a/src/features/Acceptance/Viewer/DecisionBar.test.ts b/src/features/Acceptance/Viewer/DecisionBar.test.ts
index e6c64f1bb25..c764fd48d57 100644
--- a/src/features/Acceptance/Viewer/DecisionBar.test.ts
+++ b/src/features/Acceptance/Viewer/DecisionBar.test.ts
@@ -1,13 +1,18 @@
-import { describe, expect, it } from 'vitest';
+import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { createElement } from 'react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import verify from '../../../../packages/locales/src/default/verify';
+import DecisionBar from './DecisionBar';
+
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+afterEach(cleanup);
describe('DecisionBar copy', () => {
it('keeps the copy prompt action and uses Fix for rerunning the repair', () => {
// Regression (#18843): the rerun handoff was collapsed into copy-only.
- // Embedded drafts into the composer; standalone dispatches to the origin
- // conversation — both hang off these keys.
- expect(verify['acceptance.bar.copyReview']).toBe('Copy review prompt');
+ // Embedded drafts into the composer; standalone copies the repair prompt — both hang off these keys.
+ expect(verify['acceptance.bar.copyReview']).toBe('Copy repair prompt');
expect(verify['acceptance.bar.rerun']).toBe('Fix');
expect(verify['acceptance.bar.rerunDrafted']).toBe(
'Drafted into your composer — review and send it.',
@@ -17,3 +22,45 @@ describe('DecisionBar copy', () => {
);
});
});
+
+const props = {
+ acceptedCount: 0,
+ feedbackCount: 1,
+ ignoredCount: 0,
+ needsFixCount: 1,
+ onAccept: vi.fn(),
+ onAddComment: vi.fn(),
+ onCopyReview: vi.fn(),
+ onOpenFeedback: vi.fn(),
+ onRejectComment: vi.fn(),
+ onRerun: vi.fn(),
+ pending: false,
+ rerunAvailable: true,
+ rerunPending: false,
+ state: 'settled' as const,
+ statusText: 'Needs a fix',
+ totalCount: 1,
+};
+
+it('standalone only copies repair instructions even when an origin can rerun', () => {
+ render(createElement(DecisionBar, { ...props, embedded: false }));
+ expect(screen.queryByRole('button', { name: 'acceptance.bar.rerun' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'acceptance.bar.copyReview' }));
+ expect(props.onCopyReview).toHaveBeenCalledOnce();
+ expect(props.onRerun).not.toHaveBeenCalled();
+});
+
+it('the portal hands the repair to its conversation', () => {
+ render(createElement(DecisionBar, { ...props, embedded: true }));
+ expect(screen.queryByRole('button', { name: 'acceptance.bar.copyReview' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'acceptance.bar.rerun' }));
+ expect(props.onRerun).toHaveBeenCalledOnce();
+});
+
+it('keeps the repair prompt available after an aggregate rejection', () => {
+ render(
+ createElement(DecisionBar, { ...props, embedded: false, feedbackCount: 0, state: 'rejected' }),
+ );
+ expect(screen.getByRole('button', { name: 'acceptance.bar.copyReview' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'acceptance.bar.rerun' })).toBeNull();
+});
diff --git a/src/features/Acceptance/Viewer/DecisionBar.tsx b/src/features/Acceptance/Viewer/DecisionBar.tsx
index de09aa7a502..6315db69057 100644
--- a/src/features/Acceptance/Viewer/DecisionBar.tsx
+++ b/src/features/Acceptance/Viewer/DecisionBar.tsx
@@ -2,7 +2,7 @@
import { Flexbox, Icon } from '@lobehub/ui';
import { Button, Text } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
+import { createStaticStyles, cssVar, useResponsive } from 'antd-style';
import {
BadgeCheck,
CircleAlert,
@@ -34,6 +34,27 @@ const styles = createStaticStyles(({ css }) => ({
background: ${cssVar.colorBgElevated};
box-shadow: ${cssVar.boxShadowTertiary};
+
+ @media (width <= 767px) {
+ inset-block-end: max(8px, env(safe-area-inset-bottom));
+ flex-wrap: wrap;
+ gap: 8px;
+ padding: 12px;
+
+ > button {
+ min-height: 44px;
+ }
+
+ > .acceptance-decision-actions {
+ flex-wrap: wrap;
+ width: 100%;
+ }
+
+ .acceptance-decision-actions > button {
+ flex: 1;
+ min-height: 44px;
+ }
+ }
`,
// The completion mark springs in the instant review finishes — the felt beat
// the abrupt ring→disc swap never had, landing at the decision bar where the
@@ -46,7 +67,7 @@ const styles = createStaticStyles(({ css }) => ({
}
55% {
- transform: scale(1.18);
+ transform: scale(1);
}
100% {
@@ -55,7 +76,11 @@ const styles = createStaticStyles(({ css }) => ({
}
}
- animation: acceptance-decision-complete-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
+ animation: acceptance-decision-complete-pop 0.2s ease-out both;
+
+ @media (prefers-reduced-motion: reduce) {
+ animation: none;
+ }
`,
}));
@@ -147,7 +172,7 @@ interface DecisionBarProps {
/** Open the aggregate reject dialog (comment required). */
onRejectComment: () => void;
/** Start the repair round: embedded, drafts the prompt into the composer
- beside the bar; standalone, dispatches it to the origin conversation. */
+ beside the bar. Standalone pages only copy the repair prompt. */
onRerun: () => void;
pending: boolean;
/** A live round that is a dispatched repair — coloured as an in-progress task
@@ -168,8 +193,7 @@ interface DecisionBarProps {
* clearing-list opener, and the closing actions. What the actions are follows
* the review state — feedback queued for the next round turns the bar into a
* repair handoff (打回重跑: embedded drafts the prompt into the composer
- * beside the bar, standalone dispatches to the origin conversation, with copy
- * as the standalone-only manual fallback);
+ * beside the bar; standalone copies the repair prompt);
* a clean review offers reject-with-comment and accept, with accept gaining
* primary weight only once every check is signed off.
*/
@@ -196,6 +220,7 @@ const DecisionBar = memo<DecisionBarProps>(
totalCount,
}) => {
const { t } = useTranslation('verify');
+ const { md = true } = useResponsive();
const stateMeta = {
accepted: { color: cssVar.colorSuccess, icon: BadgeCheck },
@@ -264,7 +289,9 @@ const DecisionBar = memo<DecisionBarProps>(
)}
<Flexbox gap={2} style={{ flex: '0 1 auto', minWidth: 0 }}>
<Text ellipsis strong style={{ fontSize: 14 }}>
- {statusText}
+ {!md && state === 'settled'
+ ? t('acceptance.bar.mobileProgress', { done: decidedCount, total: totalCount })
+ : statusText}
</Text>
{subText && (
<Text ellipsis fontSize={12} type={'secondary'}>
@@ -288,77 +315,87 @@ const DecisionBar = memo<DecisionBarProps>(
</Button>
)}
- <div style={{ flex: 1, minWidth: 8 }} />
-
- {/* A dispatched send-back (repairing) keeps the copy entry alive —
+ <Flexbox
+ horizontal
+ className={'acceptance-decision-actions'}
+ gap={8}
+ style={{ marginInlineStart: 'auto' }}
+ >
+ {/* A dispatched send-back (repairing) keeps the copy entry alive —
the reviewer may still hand the prompt to another agent. Embedded,
the composer beside it already receives the draft. */}
- {state === 'live' && hasFeedback && !embedded && (
- <Button disabled={pending} style={{ flex: 'none' }} type={'fill'} onClick={onCopyReview}>
- {t('acceptance.bar.copyReview')}
- </Button>
- )}
+ {state === 'live' && hasFeedback && !embedded && (
+ <Button
+ disabled={pending}
+ style={{ flex: 'none' }}
+ type={'fill'}
+ onClick={onCopyReview}
+ >
+ {t('acceptance.bar.copyReview')}
+ </Button>
+ )}
- {state === 'settled' &&
- (hasFeedback ? (
- // Feedback is queued — the delivery isn't being accepted now; the
- // bar's job is getting the repair round started.
- <>
- {!embedded && (
+ {(state === 'settled' || state === 'rejected') &&
+ (hasFeedback || state === 'rejected' ? (
+ // Feedback is queued — the delivery isn't being accepted now; the
+ // bar's job is getting the repair round started.
+ <>
+ {!embedded && (
+ <Button
+ disabled={pending}
+ style={{ flex: 'none' }}
+ type={'primary'}
+ onClick={onCopyReview}
+ >
+ {t('acceptance.bar.copyReview')}
+ </Button>
+ )}
+ {/* Last words before the repair leaves — a global note the next
+ round reads, for what the queued per-check feedback missed. */}
<Button
disabled={pending}
+ icon={<Icon icon={MessageSquarePlus} />}
style={{ flex: 'none' }}
type={'fill'}
- onClick={onCopyReview}
+ onClick={onAddComment}
>
- {t('acceptance.bar.copyReview')}
+ {t('acceptance.bar.addComment')}
</Button>
- )}
- {/* Last words before the repair leaves — a global note the next
- round reads, for what the queued per-check feedback missed. */}
- <Button
- disabled={pending}
- icon={<Icon icon={MessageSquarePlus} />}
- style={{ flex: 'none' }}
- type={'fill'}
- onClick={onAddComment}
- >
- {t('acceptance.bar.addComment')}
- </Button>
- {rerunAvailable && (
+ {embedded && rerunAvailable && (
+ <Button
+ disabled={pending}
+ loading={rerunPending}
+ style={{ flex: 'none' }}
+ type={'primary'}
+ onClick={onRerun}
+ >
+ {t('acceptance.bar.rerun')}
+ </Button>
+ )}
+ </>
+ ) : (
+ // Clean review — accept carries primary weight only once every
+ // check is signed off; before that it stays a quiet option.
+ <>
<Button
disabled={pending}
- loading={rerunPending}
style={{ flex: 'none' }}
- type={'primary'}
- onClick={onRerun}
+ type={'text'}
+ onClick={onRejectComment}
>
- {t('acceptance.bar.rerun')}
+ {t('acceptance.bar.rejectComment')}
</Button>
- )}
- </>
- ) : (
- // Clean review — accept carries primary weight only once every
- // check is signed off; before that it stays a quiet option.
- <>
- <Button
- disabled={pending}
- style={{ flex: 'none' }}
- type={'text'}
- onClick={onRejectComment}
- >
- {t('acceptance.bar.rejectComment')}
- </Button>
- <Button
- disabled={pending}
- style={{ flex: 'none' }}
- type={allConfirmed ? 'primary' : 'fill'}
- onClick={onAccept}
- >
- {t('acceptance.actions.accept')}
- </Button>
- </>
- ))}
+ <Button
+ disabled={pending}
+ style={{ flex: 'none' }}
+ type={allConfirmed ? 'primary' : 'fill'}
+ onClick={onAccept}
+ >
+ {t('acceptance.actions.accept')}
+ </Button>
+ </>
+ ))}
+ </Flexbox>
</div>
);
},
diff --git a/src/features/Acceptance/Viewer/FeedbackDrawer.tsx b/src/features/Acceptance/Viewer/FeedbackDrawer.tsx
index c44fe267de7..795425add7b 100644
--- a/src/features/Acceptance/Viewer/FeedbackDrawer.tsx
+++ b/src/features/Acceptance/Viewer/FeedbackDrawer.tsx
@@ -98,10 +98,22 @@ const EntryRow = memo<{
<Flexbox
className={cx(styles.row, entry.checkId && styles.clickable)}
gap={8}
+ role={entry.checkId ? 'button' : undefined}
style={entry.stale ? { opacity: 0.55 } : undefined}
+ tabIndex={entry.checkId ? 0 : undefined}
onClick={entry.checkId ? () => onJumpToCheck(entry.checkId!) : undefined}
+ onKeyDown={(event) => {
+ if (
+ event.target === event.currentTarget &&
+ entry.checkId &&
+ (event.key === 'Enter' || event.key === ' ')
+ ) {
+ event.preventDefault();
+ onJumpToCheck(entry.checkId);
+ }
+ }}
>
- <Flexbox horizontal align={'center'} gap={6}>
+ <Flexbox horizontal align={'center'} gap={6} wrap={'wrap'}>
{isCheck ? (
<>
<span className={styles.seq}>C{entry.checkSeq}</span>
diff --git a/src/features/Acceptance/Viewer/MobileEvidenceReview.tsx b/src/features/Acceptance/Viewer/MobileEvidenceReview.tsx
new file mode 100644
index 00000000000..897390504ea
--- /dev/null
+++ b/src/features/Acceptance/Viewer/MobileEvidenceReview.tsx
@@ -0,0 +1,166 @@
+'use client';
+
+import { Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Button, Text } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { ArrowLeft, ChevronLeft, ChevronRight, ZoomIn, ZoomOut } from 'lucide-react';
+import type { ReactNode } from 'react';
+import { useTranslation } from 'react-i18next';
+
+const styles = createStaticStyles(({ css }) => ({
+ body: css`
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ gap: 8px;
+
+ min-width: 0;
+ min-height: 0;
+ `,
+ editor: css`
+ overflow-y: auto;
+ overscroll-behavior: contain;
+ flex: 1;
+
+ min-height: 0;
+ padding-block: 8px 16px;
+
+ textarea {
+ font-size: 16px;
+ }
+ `,
+ footer: css`
+ display: flex;
+ flex: none;
+ gap: 8px;
+
+ padding-block-start: 8px;
+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+
+ > button {
+ flex: 1;
+ min-height: 44px;
+ }
+ `,
+}));
+
+interface MobileEvidenceReviewProps {
+ canSubmit: boolean;
+ drawing: boolean;
+ editor: ReactNode;
+ failed: boolean;
+ image: ReactNode;
+ imageCount: number;
+ imageIndex: number;
+ loading: boolean;
+ onConfirm: () => void;
+ onDrawingChange: (value: boolean) => void;
+ onImageChange: (index: number) => void;
+ onShowFeedback: (value: boolean) => void;
+ onZoom: (direction: 1 | -1) => void;
+ showFeedback: boolean;
+ zoom: number;
+}
+
+/** Phone review has one task at a time: inspect/mark the image, then write feedback. */
+export const MobileEvidenceReview = ({
+ canSubmit,
+ drawing,
+ failed,
+ editor,
+ image,
+ imageCount,
+ imageIndex,
+ loading,
+ onConfirm,
+ onDrawingChange,
+ onImageChange,
+ onShowFeedback,
+ onZoom,
+ showFeedback,
+ zoom,
+}: MobileEvidenceReviewProps) => {
+ const { t } = useTranslation('verify');
+ return (
+ <div className={styles.body}>
+ {showFeedback ? (
+ <>
+ {imageCount > 0 && (
+ <Button
+ icon={<Icon icon={ArrowLeft} />}
+ style={{ alignSelf: 'flex-start', minHeight: 44 }}
+ type={'text'}
+ onClick={() => onShowFeedback(false)}
+ >
+ {t('acceptance.review.backToImages')}
+ </Button>
+ )}
+ <div className={styles.editor}>{editor}</div>
+ {failed && (
+ <Text role={'alert'} type={'danger'}>
+ {t('acceptance.review.submitFailed')}
+ </Text>
+ )}
+ <div className={styles.footer}>
+ <Button disabled={!canSubmit} loading={loading} type={'primary'} onClick={onConfirm}>
+ {t('acceptance.review.confirmReject')}
+ </Button>
+ </div>
+ </>
+ ) : (
+ <>
+ <Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>
+ <ActionIcon
+ aria-label={t('acceptance.review.previousImage')}
+ disabled={imageIndex <= 0}
+ icon={ChevronLeft}
+ size={{ blockSize: 44, size: 20 }}
+ onClick={() => onImageChange(imageIndex - 1)}
+ />
+ <Text aria-live={'polite'} style={{ flex: 1, textAlign: 'center' }}>
+ {t('acceptance.review.imageNumber', { current: imageIndex + 1, total: imageCount })}
+ </Text>
+ <ActionIcon
+ aria-label={t('acceptance.review.nextImage')}
+ disabled={imageIndex >= imageCount - 1}
+ icon={ChevronRight}
+ size={{ blockSize: 44, size: 20 }}
+ onClick={() => onImageChange(imageIndex + 1)}
+ />
+ </Flexbox>
+ {image}
+ <Flexbox horizontal align={'center'} gap={8} style={{ flex: 'none' }}>
+ <Text fontSize={12} style={{ flex: 1 }} type={'secondary'}>
+ {t(
+ drawing ? 'acceptance.review.mobileDrawHint' : 'acceptance.review.mobileBrowseHint',
+ )}
+ </Text>
+ <ActionIcon
+ aria-label={t('acceptance.review.zoomOut')}
+ disabled={zoom <= 0.5}
+ icon={ZoomOut}
+ size={{ blockSize: 44, size: 20 }}
+ onClick={() => onZoom(-1)}
+ />
+ <Text fontSize={12}>{Math.round(zoom * 100)}%</Text>
+ <ActionIcon
+ aria-label={t('acceptance.review.zoomIn')}
+ disabled={zoom >= 4}
+ icon={ZoomIn}
+ size={{ blockSize: 44, size: 20 }}
+ onClick={() => onZoom(1)}
+ />
+ </Flexbox>
+ <div className={styles.footer}>
+ <Button aria-pressed={drawing} onClick={() => onDrawingChange(!drawing)}>
+ {t(drawing ? 'acceptance.review.browseImage' : 'acceptance.review.drawRegion')}
+ </Button>
+ <Button type={'primary'} onClick={() => onShowFeedback(true)}>
+ {t('acceptance.review.writeFeedback')}
+ </Button>
+ </div>
+ </>
+ )}
+ </div>
+ );
+};
diff --git a/src/features/Acceptance/Viewer/attachments.test.tsx b/src/features/Acceptance/Viewer/attachments.test.tsx
index 27cdea49744..27bfbe06e85 100644
--- a/src/features/Acceptance/Viewer/attachments.test.tsx
+++ b/src/features/Acceptance/Viewer/attachments.test.tsx
@@ -1,8 +1,8 @@
-import { cleanup, render, screen } from '@testing-library/react';
+import { act, cleanup, render, renderHook, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { AttachmentThumbs } from './attachments';
+import { AttachmentStrip, AttachmentThumbs, useFeedbackAttachments } from './attachments';
vi.mock('@/store/file', () => ({ useFileStore: () => vi.fn() }));
@@ -43,3 +43,17 @@ describe('AttachmentThumbs', () => {
expect(onRowClick).toHaveBeenCalledTimes(1);
});
});
+
+it('restores uploaded attachments with the feedback draft and removes them', () => {
+ const { result } = renderHook(() => useFeedbackAttachments(6, attachments));
+ expect(result.current.fileIds).toEqual(['att-1']);
+ act(() => result.current.remove('att-1'));
+ expect(result.current.fileIds).toEqual([]);
+});
+
+it('exposes attachment removal without hover', async () => {
+ const onRemove = vi.fn();
+ render(<AttachmentStrip attachments={attachments} onRemove={onRemove} />);
+ await userEvent.click(screen.getByRole('button'));
+ expect(onRemove).toHaveBeenCalledWith('att-1');
+});
diff --git a/src/features/Acceptance/Viewer/attachments.tsx b/src/features/Acceptance/Viewer/attachments.tsx
index c94afecb3a6..e9d2833d4e9 100644
--- a/src/features/Acceptance/Viewer/attachments.tsx
+++ b/src/features/Acceptance/Viewer/attachments.tsx
@@ -28,25 +28,30 @@ const styles = createStaticStyles(({ css }) => ({
position: absolute;
z-index: 2;
- inset-block-start: -6px;
- inset-inline-end: -6px;
+ inset-block-start: 0;
+ inset-inline-end: 0;
display: flex;
align-items: center;
justify-content: center;
- width: 18px;
- height: 18px;
+ width: 28px;
+ height: 28px;
padding: 0;
border: none;
border-radius: 50%;
color: #fff;
- opacity: 0;
+ opacity: 1;
background: ${cssVar.colorError};
transition: opacity 0.15s;
+
+ @media (pointer: coarse), (width <= 767px) {
+ width: 44px;
+ height: 44px;
+ }
`,
thumb: css`
position: relative;
@@ -96,11 +101,11 @@ const pickImages = (files: File[]): File[] =>
* attachment is a real file row the reject/group-feedback write references by
* id (the same flywheel evidence uses), never a base64 blob on the note.
*/
-export const useFeedbackAttachments = (max = 6) => {
+export const useFeedbackAttachments = (max = 6, initialAttachments: PendingAttachment[] = []) => {
const { t } = useTranslation('verify');
const uploadWithProgress = useFileStore((s) => s.uploadWithProgress);
- const [attachments, setAttachments] = useState<PendingAttachment[]>([]);
+ const [attachments, setAttachments] = useState<PendingAttachment[]>(initialAttachments);
const [uploadingCount, setUploadingCount] = useState(0);
const uploadFiles = useCallback(
@@ -180,6 +185,7 @@ interface AttachmentStripProps {
/** The draft thumbnails in a compose surface — each removable, plus a spinner tile while uploading. */
export const AttachmentStrip = memo<AttachmentStripProps>(
({ attachments, disabled, onRemove, uploading }) => {
+ const { t } = useTranslation('verify');
if (attachments.length === 0 && !uploading) return null;
return (
<Flexbox horizontal gap={8} wrap={'wrap'}>
@@ -188,6 +194,7 @@ export const AttachmentStrip = memo<AttachmentStripProps>(
<Image alt={attachment.name ?? ''} preview={false} src={attachment.url} />
{!disabled && (
<button
+ aria-label={t('acceptance.review.removeAttachment')}
className={cx('acceptance-attach-remove', styles.remove)}
type={'button'}
onClick={() => onRemove(attachment.id)}
@@ -231,10 +238,9 @@ export const AttachmentUploadButton = memo<AttachmentUploadButtonProps>(({ disab
}}
>
<Button
- outdent
disabled={disabled}
icon={<Icon icon={ImagePlus} />}
- size={'small'}
+ style={{ minHeight: 44, alignSelf: 'flex-start' }}
type={'text'}
>
{t('acceptance.review.attach')}
diff --git a/src/features/Acceptance/Viewer/index.tsx b/src/features/Acceptance/Viewer/index.tsx
index 48ad3ab6d77..6a02833ae1a 100644
--- a/src/features/Acceptance/Viewer/index.tsx
+++ b/src/features/Acceptance/Viewer/index.tsx
@@ -23,7 +23,9 @@ import AcceptanceStatusControl from './AcceptanceStatusControl';
import type { AcceptanceTabKey } from './AcceptanceTabs';
import AcceptanceTabs from './AcceptanceTabs';
import { acceptanceScrollLayout } from './layout';
+import { checksForTurn } from './turnChecks';
import { useAcceptanceBundle } from './useAcceptanceBundle';
+import { useAcceptanceTurn } from './useAcceptanceTurn';
const CONTENT_MAX_WIDTH = 920;
@@ -33,6 +35,10 @@ const styles = createStaticStyles(({ css }) => ({
max-width: ${CONTENT_MAX_WIDTH}px;
margin-inline: auto;
padding-inline: 24px;
+
+ @media (width <= 767px) {
+ padding-inline: 16px;
+ }
`,
contentFrame: css`
overflow: ${acceptanceScrollLayout.frameOverflow};
@@ -66,12 +72,14 @@ interface AcceptancePageProps {
* then whichever face of the delivery the tabs select.
*/
const AcceptanceBody = ({ onDraftToComposer }: Pick<AcceptancePageProps, 'onDraftToComposer'>) => {
- const { acceptanceId } = useAcceptanceScope();
+ const { acceptanceId, embedded } = useAcceptanceScope();
+ const { turn } = useAcceptanceTurn(embedded);
const { data } = useAcceptanceBundle(acceptanceId);
const [tab, setTab] = useState<AcceptanceTabKey>('checks');
+ const checks = data ? checksForTurn(data, turn) : [];
const resourceCount = new Set(
- (data?.checks ?? []).flatMap((check) =>
+ checks.flatMap((check) =>
(check.evidence ?? [])
.filter((evidence) => evidence.fileUrl || evidence.documentId)
.map((evidence) => evidence.fileId ?? evidence.documentId ?? evidence.id),
@@ -95,7 +103,7 @@ const AcceptanceBody = ({ onDraftToComposer }: Pick<AcceptancePageProps, 'onDraf
<Flexbox style={{ paddingBlockStart: 16 }}>
<AcceptanceTabs
active={tab}
- checkCount={data?.checks.length ?? 0}
+ checkCount={checks.length}
resourceCount={resourceCount}
onChange={setTab}
/>
diff --git a/src/features/Acceptance/Viewer/turnChecks.test.ts b/src/features/Acceptance/Viewer/turnChecks.test.ts
new file mode 100644
index 00000000000..b2d384135b3
--- /dev/null
+++ b/src/features/Acceptance/Viewer/turnChecks.test.ts
@@ -0,0 +1,43 @@
+import { describe, expect, it } from 'vitest';
+
+import type { AcceptanceBundle } from '@/services/verify';
+
+import { checksForTurn } from './turnChecks';
+
+const bundle = {
+ rounds: [{ run: { roundIndex: 1, plan: [{ id: 'check', name: 'Original check' }] } }],
+ checks: [
+ {
+ id: 'check',
+ title: 'Latest',
+ resultRound: 2,
+ reviews: [],
+ state: 'passed',
+ evidence: [{ id: 'new-image' }],
+ result: { id: 'new-result' },
+ timeline: [
+ {
+ roundIndex: 1,
+ state: 'failed',
+ title: 'Original check',
+ evidence: [{ id: 'old-image' }],
+ },
+ ],
+ },
+ ],
+} as unknown as AcceptanceBundle;
+
+describe('round evidence selection', () => {
+ it('shows the selected round evidence and never pairs it with the latest outcome', () => {
+ const [check] = checksForTurn(bundle, 1);
+ expect(check.title).toBe('Original check');
+ expect(check.state).toBe('failed');
+ expect(check.evidence).toEqual([{ id: 'old-image' }]);
+ expect(check.result).toBeUndefined();
+ expect(bundle.checks[0].title).toBe('Latest');
+ });
+ it('keeps the aggregate and does not invent results for absent rounds', () => {
+ expect(checksForTurn(bundle, null)).toBe(bundle.checks);
+ expect(checksForTurn(bundle, 3)).toEqual([]);
+ });
+});
diff --git a/src/features/Acceptance/Viewer/turnChecks.ts b/src/features/Acceptance/Viewer/turnChecks.ts
new file mode 100644
index 00000000000..b0a360c8f4d
--- /dev/null
+++ b/src/features/Acceptance/Viewer/turnChecks.ts
@@ -0,0 +1,31 @@
+import type { AcceptanceBundle } from '@/services/verify';
+
+/** A round link displays that round's evidence, never the latest replacement. */
+export const checksForTurn = (
+ data: AcceptanceBundle,
+ turn: number | null,
+): AcceptanceBundle['checks'] => {
+ if (turn === null) return data.checks;
+ return data.checks.flatMap((check) => {
+ const step = check.timeline.find((entry) => entry.roundIndex === turn);
+ if (!step) return [];
+ if (check.resultRound === turn) return [check];
+ const review = check.reviews.findLast((item) => item.roundIndex === turn);
+ return [
+ {
+ ...check,
+ evidence: step.evidence,
+ planItem: data.rounds
+ .find((round) => round.run.roundIndex === turn)
+ ?.run.plan?.find((item) => item.id === check.id),
+ prediction: null,
+ result: undefined,
+ resultRound: turn,
+ state: step.state,
+ title: step.title,
+ reviews: check.reviews.filter((review) => review.roundIndex <= turn),
+ userReview: review ? { ...review, stale: false } : undefined,
+ },
+ ];
+ });
+};
diff --git a/src/features/Acceptance/Viewer/useAcceptanceRailState.test.ts b/src/features/Acceptance/Viewer/useAcceptanceRailState.test.ts
index a6f7a692b8a..5fd39079664 100644
--- a/src/features/Acceptance/Viewer/useAcceptanceRailState.test.ts
+++ b/src/features/Acceptance/Viewer/useAcceptanceRailState.test.ts
@@ -1,6 +1,7 @@
/** @vitest-environment happy-dom */
import { act, renderHook } from '@testing-library/react';
-import { createElement, type ReactNode } from 'react';
+import type { ReactNode } from 'react';
+import { createElement } from 'react';
import { describe, expect, it } from 'vitest';
import { OriginConversationProvider } from './originConversation';
@@ -10,19 +11,45 @@ const TopicPanel = () => null;
const wrapper = ({ children }: { children: ReactNode }) =>
createElement(OriginConversationProvider, { TopicPanel, children });
-describe('useAcceptanceRailState', () => {
- it('reopens the source conversation after collapsing the rail', () => {
+describe('acceptance rail navigation', () => {
+ it('never opens a drawer while the responsive breakpoint is resolving', () => {
+ const renders: boolean[] = [];
+ const { rerender } = renderHook(
+ ({ narrow }) => {
+ const state = useAcceptanceRailState({ focused: false, isNarrowViewport: narrow });
+ renders.push(state.expand);
+ return state;
+ },
+ { initialProps: { narrow: false }, wrapper },
+ );
+
+ rerender({ narrow: true });
+ // Even a single open frame can leave a modal backdrop after its enter
+ // animation is immediately interrupted on mobile.
+ expect(renders.every((open) => !open)).toBe(true);
+ });
+
+ it('opens on request and closes when entering a focused check', () => {
+ const { result, rerender } = renderHook(
+ ({ focused }) => useAcceptanceRailState({ focused, isNarrowViewport: true }),
+ { initialProps: { focused: false }, wrapper },
+ );
+ act(() => result.current.onExpandChange(true));
+ expect(result.current.expand).toBe(true);
+ rerender({ focused: true });
+ expect(result.current.expand).toBe(false);
+ });
+
+ it('can reopen the source conversation after dismissing its drawer', () => {
const { result } = renderHook(
- () => useAcceptanceRailState({ focused: false, isNarrowViewport: false }),
+ () => useAcceptanceRailState({ focused: false, isNarrowViewport: true }),
{ wrapper },
);
act(() => result.current.originConversation?.openTopicDrawer('topic-1'));
expect(result.current.expand).toBe(true);
-
act(() => result.current.onExpandChange(false));
expect(result.current.expand).toBe(false);
expect(result.current.originConversation?.isOpen).toBe(false);
-
act(() => result.current.originConversation?.openTopicDrawer('topic-1'));
expect(result.current.expand).toBe(true);
});
diff --git a/src/features/Acceptance/Viewer/useAcceptanceTurn.test.ts b/src/features/Acceptance/Viewer/useAcceptanceTurn.test.ts
new file mode 100644
index 00000000000..62fe86bd3f5
--- /dev/null
+++ b/src/features/Acceptance/Viewer/useAcceptanceTurn.test.ts
@@ -0,0 +1,48 @@
+/** @vitest-environment happy-dom */
+import { act, renderHook } from '@testing-library/react';
+import type { ReactNode } from 'react';
+import { createElement } from 'react';
+import { MemoryRouter, useLocation } from 'react-router';
+import { describe, expect, it } from 'vitest';
+
+import { readAcceptanceTurn, useAcceptanceTurn } from './useAcceptanceTurn';
+
+describe('Acceptance round links', () => {
+ it('maps a shared r link to the Acceptance turn and preserves unrelated query state', () => {
+ const { result } = renderHook(
+ () => ({ ...useAcceptanceTurn(), search: useLocation().search }),
+ {
+ wrapper: ({ children }: { children: ReactNode }) =>
+ createElement(MemoryRouter, {
+ initialEntries: ['/acceptance/id?r=2&filter=all'],
+ children,
+ }),
+ },
+ );
+ expect(result.current.turn).toBe(2);
+ expect(result.current.search).toBe('?filter=all&turn=2');
+ act(() => result.current.setTurn(1));
+ expect(result.current.search).toBe('?turn=1');
+ act(() => result.current.setTurn(null));
+ expect(result.current.search).toBe('');
+ });
+ it('keeps embedded round selection local to its host', () => {
+ const { result } = renderHook(
+ () => ({ ...useAcceptanceTurn(true), search: useLocation().search }),
+ {
+ wrapper: ({ children }: { children: ReactNode }) =>
+ createElement(MemoryRouter, { initialEntries: ['/chat?r=7'], children }),
+ },
+ );
+ expect(result.current.turn).toBeNull();
+ act(() => result.current.setTurn(2));
+ expect(result.current.turn).toBe(2);
+ expect(result.current.search).toBe('?r=7');
+ });
+ it('does not mistake an explicit report request for a turn link', () => {
+ expect(readAcceptanceTurn(new URLSearchParams('report=2'))).toBeNull();
+ expect(readAcceptanceTurn(new URLSearchParams('turn=3&r=2'))).toBe(3);
+ for (const value of ['0', '-1', '1.5', 'NaN', '9007199254740992'])
+ expect(readAcceptanceTurn(new URLSearchParams(`r=${value}`))).toBeNull();
+ });
+});
diff --git a/src/features/Acceptance/Viewer/useAcceptanceTurn.ts b/src/features/Acceptance/Viewer/useAcceptanceTurn.ts
new file mode 100644
index 00000000000..cb758134fd9
--- /dev/null
+++ b/src/features/Acceptance/Viewer/useAcceptanceTurn.ts
@@ -0,0 +1,40 @@
+import { useEffect, useState } from 'react';
+import { useSearchParams } from 'react-router';
+
+export const readAcceptanceTurn = (params: URLSearchParams) => {
+ const raw = params.get('turn') ?? params.get('r');
+ return raw && /^[1-9]\d*$/.test(raw) && Number.isSafeInteger(Number(raw)) ? Number(raw) : null;
+};
+
+export const useAcceptanceTurn = (embedded = false) => {
+ const [params, setParams] = useSearchParams();
+ const [localTurn, setLocalTurn] = useState<number | null>(null);
+ const turn = embedded ? localTurn : readAcceptanceTurn(params);
+ useEffect(() => {
+ if (embedded || !params.has('r')) return;
+ setParams(
+ (previous) => {
+ const next = new URLSearchParams(previous);
+ if (turn !== null) next.set('turn', String(turn));
+ next.delete('r');
+ return next;
+ },
+ { replace: true },
+ );
+ }, [embedded, params, setParams, turn]);
+ const setTurn = (value: number | null) => {
+ if (embedded) {
+ setLocalTurn(value);
+ return;
+ }
+ setParams((previous) => {
+ const next = new URLSearchParams(previous);
+ next.delete('r');
+ next.delete('filter');
+ if (value === null) next.delete('turn');
+ else next.set('turn', String(value));
+ return next;
+ });
+ };
+ return { setTurn, turn };
+};
diff --git a/src/features/Acceptance/Viewer/useAnnotationGesture.test.ts b/src/features/Acceptance/Viewer/useAnnotationGesture.test.ts
new file mode 100644
index 00000000000..f5653d2dccf
--- /dev/null
+++ b/src/features/Acceptance/Viewer/useAnnotationGesture.test.ts
@@ -0,0 +1,115 @@
+/** @vitest-environment happy-dom */
+import { act, renderHook } from '@testing-library/react';
+import type { PointerEvent } from 'react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { useAnnotationGesture } from './useAnnotationGesture';
+
+const pointer = (x: number, y: number) =>
+ ({
+ clientX: x,
+ clientY: y,
+ pointerId: 7,
+ pointerType: 'touch',
+ currentTarget: { setPointerCapture: vi.fn() },
+ preventDefault: vi.fn(),
+ stopPropagation: vi.fn(),
+ }) as unknown as PointerEvent<HTMLDivElement>;
+
+const setup = (drawing = true, width = 200, height = 400) => {
+ const onDraw = vi.fn();
+ const onUpdate = vi.fn();
+ const hook = renderHook(() => useAnnotationGesture({ drawing, onDraw, onUpdate }));
+ const image = document.createElement('img');
+ vi.spyOn(image, 'getBoundingClientRect').mockReturnValue({
+ x: 10,
+ y: 20,
+ left: 10,
+ top: 20,
+ width,
+ height,
+ right: 10 + width,
+ bottom: 20 + height,
+ toJSON: () => ({}),
+ });
+ hook.result.current.imageRef.current = image;
+ return { ...hook, onDraw, onUpdate };
+};
+
+describe('touch annotation gestures', () => {
+ afterEach(() => vi.restoreAllMocks());
+
+ it.each([
+ [360, 12000],
+ [12000, 360],
+ [6400, 3600],
+ ])('keeps small visible regions on a %s × %s displayed image', (width, height) => {
+ const { result, onDraw } = setup(true, width, height);
+ act(() => result.current.handlers.onPointerDown(pointer(30, 40)));
+ act(() => result.current.handlers.onPointerUp(pointer(34, 44)));
+ expect(onDraw).toHaveBeenCalledOnce();
+ const rect = onDraw.mock.calls[0][0];
+ expect(rect.width * width).toBeCloseTo(4);
+ expect(rect.height * height).toBeCloseTo(4);
+ });
+
+ it.each([
+ [0, 0],
+ [2, 2],
+ [2, 20],
+ [20, 2],
+ ])('ignores a click or a region with a sub-threshold screen dimension (%s, %s)', (dx, dy) => {
+ const { result, onDraw } = setup(true, 100, 100);
+ act(() => result.current.handlers.onPointerDown(pointer(30, 40)));
+ act(() => result.current.handlers.onPointerUp(pointer(30 + dx, 40 + dy)));
+ expect(onDraw).not.toHaveBeenCalled();
+ });
+
+ it('resizes to a fixed screen minimum on a zoomed image', () => {
+ const { result, onUpdate } = setup(true, 6400, 3600);
+ const origin = { x: 0.1, y: 0.1, width: 0.2, height: 0.2 };
+ act(() => result.current.startEdit(pointer(1930, 1100), 0, origin, 'resize'));
+ act(() => result.current.handlers.onPointerMove(pointer(651, 381)));
+ const rect = onUpdate.mock.calls[0][1];
+ expect(rect.width * 6400).toBeCloseTo(3);
+ expect(rect.height * 3600).toBeCloseTo(3);
+ });
+
+ it('keeps the resize minimum inside the image boundary', () => {
+ const { result, onUpdate } = setup(true, 200, 400);
+ const origin = { x: 0.995, y: 0.9975, width: 0.005, height: 0.0025 };
+ act(() => result.current.startEdit(pointer(210, 420), 0, origin, 'resize'));
+ act(() => result.current.handlers.onPointerMove(pointer(209, 419)));
+ const rect = onUpdate.mock.calls[0][1];
+ expect(rect.x + rect.width).toBeLessThanOrEqual(1);
+ expect(rect.y + rect.height).toBeLessThanOrEqual(1);
+ });
+
+ it('captures touch and commits a normalized region on pointer up', () => {
+ const { result, onDraw } = setup();
+ const start = pointer(30, 60);
+ act(() => result.current.handlers.onPointerDown(start));
+ act(() => result.current.handlers.onPointerMove(pointer(110, 220)));
+ expect(start.currentTarget.setPointerCapture).toHaveBeenCalledWith(7);
+ expect(result.current.draft).toEqual({ x: 0.1, y: 0.1, width: 0.4, height: 0.4 });
+ act(() => result.current.handlers.onPointerUp(pointer(110, 220)));
+ expect(onDraw).toHaveBeenCalledWith({ x: 0.1, y: 0.1, width: 0.4, height: 0.4 });
+ expect(result.current.draft).toBeNull();
+ });
+ it('does not turn a cancelled touch into a region', () => {
+ const { result, onDraw } = setup();
+ act(() => result.current.handlers.onPointerDown(pointer(30, 60)));
+ act(() => result.current.handlers.onPointerCancel());
+ act(() => result.current.handlers.onPointerUp(pointer(110, 220)));
+ expect(onDraw).not.toHaveBeenCalled();
+ });
+ it('lets browsing gestures scroll without drawing or capturing them', () => {
+ const { result, onDraw } = setup(false);
+ const start = pointer(30, 60);
+ act(() => result.current.handlers.onPointerDown(start));
+ act(() => result.current.handlers.onPointerUp(pointer(110, 220)));
+ expect(start.preventDefault).not.toHaveBeenCalled();
+ expect(start.currentTarget.setPointerCapture).not.toHaveBeenCalled();
+ expect(onDraw).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/features/Acceptance/Viewer/useAnnotationGesture.ts b/src/features/Acceptance/Viewer/useAnnotationGesture.ts
new file mode 100644
index 00000000000..9b429e2d8d7
--- /dev/null
+++ b/src/features/Acceptance/Viewer/useAnnotationGesture.ts
@@ -0,0 +1,118 @@
+import type { AcceptanceReviewAnnotation } from '@lobechat/types';
+import type { PointerEvent } from 'react';
+import { useRef, useState } from 'react';
+
+type Rect = AcceptanceReviewAnnotation['rect'];
+/** An in-flight pointer gesture: drawing a new region, or moving/resizing one. */
+type Gesture =
+ | { kind: 'draw'; start: { x: number; y: number } }
+ | { index: number; kind: 'move'; origin: Rect; start: { x: number; y: number } }
+ | { index: number; kind: 'resize'; origin: Rect };
+
+// Keep the minimum in displayed CSS pixels, independent of aspect ratio and zoom.
+const MIN_REGION_PX = 3;
+
+const clamp01 = (value: number) => Math.min(Math.max(value, 0), 1);
+
+export const useAnnotationGesture = ({
+ drawing,
+ onDraw,
+ onUpdate,
+}: {
+ drawing: boolean;
+ onDraw: (rect: Rect) => void;
+ onUpdate: (index: number, rect: Rect) => void;
+}) => {
+ const imageRef = useRef<HTMLImageElement>(null);
+ const [draft, setDraft] = useState<Rect | null>(null);
+ const gestureRef = useRef<Gesture | null>(null);
+
+ // Normalize against the image's own box — the frame may not equal it.
+ const normalize = (event: PointerEvent) => {
+ const box = imageRef.current?.getBoundingClientRect();
+ if (!box || box.width === 0 || box.height === 0) return null;
+ return {
+ x: clamp01((event.clientX - box.left) / box.width),
+ y: clamp01((event.clientY - box.top) / box.height),
+ };
+ };
+
+ const toRect = (a: { x: number; y: number }, b: { x: number; y: number }): Rect => ({
+ height: Math.abs(a.y - b.y),
+ width: Math.abs(a.x - b.x),
+ x: Math.min(a.x, b.x),
+ y: Math.min(a.y, b.y),
+ });
+
+ const endGesture = (event: PointerEvent) => {
+ const gesture = gestureRef.current;
+ gestureRef.current = null;
+ setDraft(null);
+ if (gesture?.kind !== 'draw') return;
+ const point = normalize(event);
+ if (!point) return;
+ const rect = toRect(gesture.start, point);
+ // Ignore accidental clicks — a region needs real area to comment on.
+ const box = imageRef.current?.getBoundingClientRect();
+ if (!box || rect.width * box.width < MIN_REGION_PX || rect.height * box.height < MIN_REGION_PX)
+ return;
+ onDraw(rect);
+ };
+
+ const startEdit = (
+ event: PointerEvent<HTMLElement>,
+ index: number,
+ origin: Rect,
+ kind: 'move' | 'resize',
+ ) => {
+ if (!drawing) return;
+ event.preventDefault();
+ event.stopPropagation();
+ event.currentTarget.setPointerCapture(event.pointerId);
+ const start = normalize(event);
+ if (start) gestureRef.current = { index, kind, origin, start };
+ };
+ const handlers = {
+ onPointerCancel: () => {
+ gestureRef.current = null;
+ setDraft(null);
+ },
+ onPointerUp: endGesture,
+ onPointerDown: (event: PointerEvent<HTMLDivElement>) => {
+ if (!drawing) return;
+ event.currentTarget.setPointerCapture(event.pointerId);
+ event.preventDefault();
+ const start = normalize(event);
+ if (start) gestureRef.current = { kind: 'draw', start };
+ },
+ onPointerMove: (event: PointerEvent<HTMLDivElement>) => {
+ const gesture = gestureRef.current;
+ if (!gesture) return;
+ const point = normalize(event);
+ if (!point) return;
+ if (gesture.kind === 'draw') {
+ setDraft(toRect(gesture.start, point));
+ return;
+ }
+ const { index, origin } = gesture;
+ if (gesture.kind === 'move') {
+ onUpdate(index, {
+ ...origin,
+ x: Math.min(Math.max(origin.x + (point.x - gesture.start.x), 0), 1 - origin.width),
+ y: Math.min(Math.max(origin.y + (point.y - gesture.start.y), 0), 1 - origin.height),
+ });
+ return;
+ }
+ // resize — the origin's top-left corner stays anchored.
+ const box = imageRef.current?.getBoundingClientRect();
+ if (!box || box.width === 0 || box.height === 0) return;
+ onUpdate(index, {
+ height: Math.min(Math.max(point.y - origin.y, MIN_REGION_PX / box.height), 1 - origin.y),
+ width: Math.min(Math.max(point.x - origin.x, MIN_REGION_PX / box.width), 1 - origin.x),
+ x: origin.x,
+ y: origin.y,
+ });
+ },
+ };
+ return { draft, handlers, imageRef, startEdit };
+};
diff --git a/src/features/Acceptance/Viewer/useReviewSubmit.test.ts b/src/features/Acceptance/Viewer/useReviewSubmit.test.ts
new file mode 100644
index 00000000000..181433b5cda
--- /dev/null
+++ b/src/features/Acceptance/Viewer/useReviewSubmit.test.ts
@@ -0,0 +1,46 @@
+import { act, renderHook } from '@testing-library/react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { useReviewSubmit } from './useReviewSubmit';
+
+afterEach(() => vi.restoreAllMocks());
+
+describe('feedback submission recovery', () => {
+ it('keeps a visible failure until the user retries successfully', async () => {
+ const { result } = renderHook(useReviewSubmit);
+ await act(async () => {
+ await result.current.submit(async () => false);
+ });
+ expect(result.current.failed).toBe(true);
+ expect(result.current.loading).toBe(false);
+ await act(async () => {
+ await result.current.submit(async () => true);
+ });
+ expect(result.current.failed).toBe(false);
+ expect(result.current.loading).toBe(false);
+ });
+
+ it('recovers from thrown errors and suppresses concurrent submissions', async () => {
+ vi.spyOn(console, 'error').mockImplementation(() => {});
+ const { result } = renderHook(useReviewSubmit);
+ const duplicate = vi.fn(async () => true);
+ let reject!: (reason: Error) => void;
+ const request = new Promise<boolean>((_, fail) => {
+ reject = fail;
+ });
+ let first!: Promise<boolean>;
+ act(() => {
+ first = result.current.submit(() => request);
+ });
+ await act(async () => {
+ await result.current.submit(duplicate);
+ });
+ expect(duplicate).not.toHaveBeenCalled();
+ await act(async () => {
+ reject(new Error('offline'));
+ await first;
+ });
+ expect(result.current.failed).toBe(true);
+ expect(result.current.loading).toBe(false);
+ });
+});
diff --git a/src/features/Acceptance/Viewer/useReviewSubmit.ts b/src/features/Acceptance/Viewer/useReviewSubmit.ts
new file mode 100644
index 00000000000..ef5aa03f7b6
--- /dev/null
+++ b/src/features/Acceptance/Viewer/useReviewSubmit.ts
@@ -0,0 +1,27 @@
+import { useRef, useState } from 'react';
+
+/** Keep failed feedback editable and prevent duplicate submissions before React rerenders. */
+export const useReviewSubmit = () => {
+ const busy = useRef(false);
+ const [loading, setLoading] = useState(false);
+ const [failed, setFailed] = useState(false);
+ const submit = async (action: () => Promise<boolean>) => {
+ if (busy.current) return false;
+ busy.current = true;
+ setLoading(true);
+ setFailed(false);
+ try {
+ const saved = await action();
+ setFailed(!saved);
+ return saved;
+ } catch (cause) {
+ console.error('[acceptance:feedback]', cause);
+ setFailed(true);
+ return false;
+ } finally {
+ busy.current = false;
+ setLoading(false);
+ }
+ };
+ return { failed, loading, submit };
+};