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.

✨ feat(acceptance): let anyone with the link join the discussion (#19420)

Arvin Xubc5c81f3198b
diff --git a/apps/server/src/routers/lambda/__tests__/acceptanceComment.access.test.ts b/apps/server/src/routers/lambda/__tests__/acceptanceComment.access.test.ts
new file mode 100644
index 00000000000..02ee9132524
--- /dev/null
+++ b/apps/server/src/routers/lambda/__tests__/acceptanceComment.access.test.ts
@@ -0,0 +1,142 @@
+// @vitest-environment node
+import { randomUUID } from 'node:crypto';
+
+import { type LobeChatDatabase } from '@lobechat/database';
+import { acceptances, verifyRuns } from '@lobechat/database/schemas';
+import { getTestDB } from '@lobechat/database/test-utils';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { acceptanceCommentRouter } from '../acceptanceComment';
+import { cleanupTestUser, createTestUser } from './integration/setup';
+
+let testDB: LobeChatDatabase;
+vi.mock('@/database/core/db-adaptor', () => ({
+ getServerDB: vi.fn(() => testDB),
+}));
+
+/**
+ * A public acceptance is handed around as a link so other people can answer the
+ * evidence in it. Reading it and remarking on it are therefore the same right;
+ * approving a round, introducing one, and closing someone else's thread are not
+ * — those speak for the delivery, and stay with its creator and their
+ * workspace.
+ */
+describe('acceptanceCommentRouter access', () => {
+ let serverDB: LobeChatDatabase;
+ let ownerId: string;
+ let visitorId: string;
+ let publicAcceptanceId: string;
+ let privateAcceptanceId: string;
+ let publicRunId: string;
+
+ beforeEach(async () => {
+ serverDB = await getTestDB();
+ testDB = serverDB;
+ ownerId = await createTestUser(serverDB);
+ visitorId = await createTestUser(serverDB);
+
+ const [open, closed] = await serverDB
+ .insert(acceptances)
+ .values([
+ {
+ subjectId: randomUUID(),
+ subjectType: 'standalone',
+ userId: ownerId,
+ visibility: 'public',
+ },
+ {
+ subjectId: randomUUID(),
+ subjectType: 'standalone',
+ userId: ownerId,
+ visibility: 'private',
+ },
+ ])
+ .returning();
+ publicAcceptanceId = open.id;
+ privateAcceptanceId = closed.id;
+
+ const [run] = await serverDB
+ .insert(verifyRuns)
+ .values({ acceptanceId: publicAcceptanceId, roundIndex: 1, userId: ownerId })
+ .returning();
+ publicRunId = run.id;
+ });
+
+ afterEach(async () => {
+ await cleanupTestUser(serverDB, visitorId);
+ await cleanupTestUser(serverDB, ownerId);
+ vi.clearAllMocks();
+ });
+
+ const caller = (userId: string) =>
+ acceptanceCommentRouter.createCaller({ jwtPayload: { userId }, userId } as any);
+
+ const comment = (userId: string, acceptanceId: string, content: string) =>
+ caller(userId).create({ acceptanceId, clientId: `c-${randomUUID()}`, content });
+
+ it('lets a visitor remark on a public acceptance', async () => {
+ const { data } = await comment(visitorId, publicAcceptanceId, 'the second screenshot is stale');
+
+ expect(data.authorUserId).toBe(visitorId);
+ });
+
+ it('lets a visitor react to a comment on a public acceptance', async () => {
+ const { data: owned } = await comment(ownerId, publicAcceptanceId, 'round 1 is up');
+
+ await expect(
+ caller(visitorId).react({ emoji: '👍', id: owned.id, on: true }),
+ ).resolves.toMatchObject({ data: { on: true } });
+ });
+
+ it('tells a visitor they may comment but not approve', async () => {
+ const list = await caller(visitorId).list({ acceptanceId: publicAcceptanceId });
+
+ expect(list).toMatchObject({ canApprove: false, canComment: true });
+ });
+
+ it('refuses a visitor an approval', async () => {
+ await expect(
+ caller(visitorId).create({
+ acceptanceId: publicAcceptanceId,
+ clientId: `c-${randomUUID()}`,
+ content: 'looks good to me',
+ contextRunId: publicRunId,
+ kind: 'approval',
+ }),
+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ });
+
+ it("refuses a visitor a round's own introduction", async () => {
+ await expect(
+ caller(visitorId).create({
+ acceptanceId: publicAcceptanceId,
+ clientId: `c-${randomUUID()}`,
+ content: 'round 2 delivered',
+ contextRunId: publicRunId,
+ kind: 'proposal',
+ }),
+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ });
+
+ it("refuses a visitor closing someone else's thread", async () => {
+ const { data: owned } = await comment(ownerId, publicAcceptanceId, 'is this expected?');
+
+ await expect(
+ caller(visitorId).setResolved({ id: owned.id, resolved: true }),
+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ });
+
+ it('lets a visitor close the thread they opened', async () => {
+ const { data: mine } = await comment(visitorId, publicAcceptanceId, 'never mind, my mistake');
+
+ const { data } = await caller(visitorId).setResolved({ id: mine.id, resolved: true });
+
+ expect(data.resolvedAt).not.toBeNull();
+ });
+
+ it('keeps a private acceptance invisible to a visitor', async () => {
+ await expect(comment(visitorId, privateAcceptanceId, 'hello?')).rejects.toMatchObject({
+ code: 'NOT_FOUND',
+ });
+ });
+});
diff --git a/apps/server/src/routers/lambda/_helpers/acceptanceCommentAccess.ts b/apps/server/src/routers/lambda/_helpers/acceptanceCommentAccess.ts
index 3ef5028cc46..5c8533e7bd1 100644
--- a/apps/server/src/routers/lambda/_helpers/acceptanceCommentAccess.ts
+++ b/apps/server/src/routers/lambda/_helpers/acceptanceCommentAccess.ts
@@ -9,7 +9,13 @@ import { isUuid } from '@/database/utils/uuid';
export interface AcceptanceCommentAccess {
acceptance: AcceptanceItem;
- /** May write comments / approvals: the creator, or a non-viewer member of the acceptance's workspace. */
+ /**
+ * May speak for the delivery itself — approve a round, or post the round's
+ * own introduction. The creator, or a non-viewer member of the acceptance's
+ * workspace.
+ */
+ canApprove: boolean;
+ /** May write comments, annotations and reactions: anyone signed in who can read it. */
canComment: boolean;
isOwner: boolean;
}
@@ -19,10 +25,14 @@ export interface AcceptanceCommentAccess {
*
* Reading follows the bundle: the creator, anyone when the acceptance is
* `public`, or a member of the acceptance's OWN workspace (not the caller's
- * active one). Writing is narrower — a public link lets a visitor read the
- * discussion, never join it — and mirrors the write procedure's member gate:
- * workspace viewers stay read-only. A personal-scope acceptance has no
- * collaborators, so only its creator can write there.
+ * active one). Remarking is as wide as reading, minus anonymity — whoever was
+ * handed the link can answer the evidence in front of them, and a shared
+ * delivery nobody outside the team may reply to is a report, not a review.
+ *
+ * Speaking FOR the delivery stays narrow. An approval and a round introduction
+ * are the delivery's own voice, so they need the creator or a workspace
+ * teammate; the acceptance decision itself is narrower still and lives on the
+ * bundle's `canReview`.
*
* Missing access reads as NOT_FOUND, like the bundle, so existence never leaks.
*/
@@ -45,6 +55,12 @@ export async function resolveAcceptanceCommentAccess(
const canRead = isOwner || acceptance.visibility === 'public' || Boolean(member);
if (!canRead) throw new TRPCError({ code: 'NOT_FOUND', message: 'Acceptance not found' });
- const canComment = isOwner || (Boolean(member) && member!.role !== 'viewer');
- return { acceptance, canComment, isOwner };
+ return {
+ acceptance,
+ canApprove: isOwner || (Boolean(member) && member!.role !== 'viewer'),
+ // Read access is already settled above, so a signed-in caller here is a
+ // caller the acceptance was shared with.
+ canComment: Boolean(userId),
+ isOwner,
+ };
}
diff --git a/apps/server/src/routers/lambda/acceptanceComment.ts b/apps/server/src/routers/lambda/acceptanceComment.ts
index d2182256260..6589810d1ef 100644
--- a/apps/server/src/routers/lambda/acceptanceComment.ts
+++ b/apps/server/src/routers/lambda/acceptanceComment.ts
@@ -353,6 +353,10 @@ export const acceptanceCommentRouter = router({
input.acceptanceId,
);
if (!access.canComment) throw new TRPCError({ code: 'FORBIDDEN', message: 'Read-only access' });
+ // An approval and a round introduction are the delivery speaking, not a
+ // reader answering it: a visitor holding the public link writes remarks.
+ if ((input.kind === 'approval' || input.kind === 'proposal') && !access.canApprove)
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Not a reviewer of this acceptance' });
await assertAuthorAgentUsable(
ctx.serverDB,
@@ -422,7 +426,7 @@ export const acceptanceCommentRouter = router({
userId: ctx.userId,
workspaceId: access.acceptance.workspaceId,
});
- return { canComment: access.canComment, items };
+ return { canApprove: access.canApprove, canComment: access.canComment, items };
}),
/**
@@ -468,9 +472,13 @@ export const acceptanceCommentRouter = router({
setResolved: writeProcedure
.input(z.object({ id: z.string().min(1), resolved: z.boolean() }))
.mutation(async ({ ctx, input }) => {
- const { comment } = await requireComment(ctx, input.id);
+ const { access, comment } = await requireComment(ctx, input.id);
if (comment.parentCommentId)
throw new TRPCError({ code: 'BAD_REQUEST', message: 'Only a thread root can be resolved' });
+ // Closing a thread is a verdict on it. Whoever opened it may close their
+ // own; everyone else's is the reviewers' call, not any reader's.
+ if (!access.canApprove && comment.authorUserId !== ctx.userId)
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Not a reviewer of this acceptance' });
const row = await ctx.acceptanceCommentModel.setResolved(
comment.id,
input.resolved,
diff --git a/locales/en-US/verify.json b/locales/en-US/verify.json
index d8d01025d3e..7323bf8cddf 100644
--- a/locales/en-US/verify.json
+++ b/locales/en-US/verify.json
@@ -110,7 +110,7 @@
"acceptance.comments.moreActions": "More actions",
"acceptance.comments.participants": "Participants",
"acceptance.comments.placeholder": "Say something about this delivery…",
- "acceptance.comments.readOnly": "You can read the discussion; join the workspace to take part.",
+ "acceptance.comments.readOnly": "You can read the discussion; sign in to take part.",
"acceptance.comments.region": "Region",
"acceptance.comments.regionCount": "{{count}} region note(s)",
"acceptance.comments.regionHint": "Drag a box on the image, then write your note.",
@@ -125,6 +125,10 @@
"acceptance.comments.roundContext": "Round {{round}}",
"acceptance.comments.roundLanded": "Round {{round}} landed",
"acceptance.comments.send": "Send",
+ "acceptance.comments.signIn": "Sign in",
+ "acceptance.comments.signInDescription": "Sign in to comment, reply, and circle what you see on a screenshot.",
+ "acceptance.comments.signInTitle": "Join the discussion",
+ "acceptance.comments.signUp": "Sign up",
"acceptance.comments.title": "Discussion",
"acceptance.comments.updateFailed": "Failed to update the comment. Please try again.",
"acceptance.comments.withdraw": "Withdraw approval",
@@ -199,6 +203,8 @@
"acceptance.ledger.pending": "Awaiting review",
"acceptance.ledger.title": "Runs",
"acceptance.ledger.viewReport": "View round report",
+ "acceptance.notFound.description": "It may have been deleted, or it was never shared with you.",
+ "acceptance.notFound.title": "No such acceptance",
"acceptance.origin.agentFallback": "Agent",
"acceptance.origin.backToRuns": "Back to runs",
"acceptance.origin.openTopic": "Open topic",
@@ -274,6 +280,7 @@
"acceptance.roundStatus.repairing": "Repairing",
"acceptance.roundStatus.uncertain": "Verify uncertain",
"acceptance.roundStatus.verifying": "In progress",
+ "acceptance.sharedNotice.commentableDescription": "You can browse every check and its evidence and join the discussion, but only the author can act on this acceptance.",
"acceptance.sharedNotice.readOnlyDescription": "You can browse every check and its evidence, but only the author can act on this acceptance.",
"acceptance.sharedNotice.reviewableDescription": "You can browse every check and its evidence, and review them on behalf of your workspace.",
"acceptance.sharedNotice.title": "Shared with you",
diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.json
index e2cae820565..c968f26ce0d 100644
--- a/locales/zh-CN/verify.json
+++ b/locales/zh-CN/verify.json
@@ -110,7 +110,7 @@
"acceptance.comments.moreActions": "更多操作",
"acceptance.comments.participants": "参与者",
"acceptance.comments.placeholder": "对整次交付说点什么…",
- "acceptance.comments.readOnly": "你可以查看讨论,加入这个 workspace 后才能参与。",
+ "acceptance.comments.readOnly": "你可以查看讨论,登录后即可参与。",
"acceptance.comments.region": "圈选",
"acceptance.comments.regionCount": "{{count}} 条圈选",
"acceptance.comments.regionHint": "在图上拖一个框,然后写下你的意见。",
@@ -125,6 +125,10 @@
"acceptance.comments.roundContext": "第 {{round}} 轮",
"acceptance.comments.roundLanded": "第 {{round}} 轮已完成",
"acceptance.comments.send": "发送",
+ "acceptance.comments.signIn": "登录",
+ "acceptance.comments.signInDescription": "登录后就能在这里评论、回复、在截图上圈出问题。",
+ "acceptance.comments.signInTitle": "加入这次讨论",
+ "acceptance.comments.signUp": "注册",
"acceptance.comments.title": "讨论",
"acceptance.comments.updateFailed": "评论更新失败,请重试。",
"acceptance.comments.withdraw": "撤回接受",
@@ -199,6 +203,8 @@
"acceptance.ledger.pending": "待验收",
"acceptance.ledger.title": "运行记录",
"acceptance.ledger.viewReport": "查看该轮报告",
+ "acceptance.notFound.description": "它可能已被删除,也可能没有分享给你。",
+ "acceptance.notFound.title": "找不到这条验收",
"acceptance.origin.agentFallback": "智能体",
"acceptance.origin.backToRuns": "返回运行记录",
"acceptance.origin.openTopic": "打开话题",
@@ -274,6 +280,7 @@
"acceptance.roundStatus.repairing": "修复中",
"acceptance.roundStatus.uncertain": "验证不确定",
"acceptance.roundStatus.verifying": "进行中",
+ "acceptance.sharedNotice.commentableDescription": "你可以查看所有检查项及其证据,也可以评论和圈选,但只有作者可以进行验收操作。",
"acceptance.sharedNotice.readOnlyDescription": "你可以查看所有检查项及其证据,但只有作者可以进行验收操作。",
"acceptance.sharedNotice.reviewableDescription": "你可以查看所有检查项及其证据,并代表你的工作区参与评审。",
"acceptance.sharedNotice.title": "来自他人的分享",
diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.ts
index 7f2820e8fa6..e92e4bccb78 100644
--- a/packages/locales/src/default/verify.ts
+++ b/packages/locales/src/default/verify.ts
@@ -179,6 +179,8 @@ export default {
'acceptance.detail.suggestion': 'Suggestion',
'acceptance.error.description': 'Check your connection and try loading this acceptance again.',
'acceptance.error.title': 'Unable to load acceptance',
+ 'acceptance.notFound.description': 'It may have been deleted, or it was never shared with you.',
+ 'acceptance.notFound.title': 'No such acceptance',
'acceptance.comments.title': 'Discussion',
'acceptance.comments.moreActions': 'More actions',
'acceptance.comments.placeholder': 'Say something about this delivery…',
@@ -200,13 +202,18 @@ export default {
'Evidence from round {{round}} — replaced in a later round',
'acceptance.comments.evidenceThisRound': 'The evidence this check shows now',
'acceptance.comments.roundLanded': 'Round {{round}} landed',
+ 'acceptance.comments.signIn': 'Sign in',
+ 'acceptance.comments.signInDescription':
+ 'Sign in to comment, reply, and circle what you see on a screenshot.',
+ 'acceptance.comments.signInTitle': 'Join the discussion',
+ 'acceptance.comments.signUp': 'Sign up',
'acceptance.comments.roundCompletedBy': '{{name}} completed round {{round}}',
'acceptance.comments.approvedBy': '{{name}} approved this delivery',
'acceptance.comments.approvedByAtRound': '{{name}} approved round {{round}}',
'acceptance.comments.historicalRegions':
'{{count}} region note(s) on evidence a later round replaced',
'acceptance.comments.empty': 'No discussion yet.',
- 'acceptance.comments.readOnly': 'You can read the discussion; join the workspace to take part.',
+ 'acceptance.comments.readOnly': 'You can read the discussion; sign in to take part.',
'acceptance.comments.region': 'Region',
'acceptance.comments.roundContext': 'Round {{round}}',
'acceptance.comments.commentEvidence': 'Comment on a region',
@@ -400,6 +407,8 @@ export default {
'acceptance.roundStatus.repairing': 'Repairing',
'acceptance.roundStatus.uncertain': 'Verify uncertain',
'acceptance.roundStatus.verifying': 'In progress',
+ 'acceptance.sharedNotice.commentableDescription':
+ 'You can browse every check and its evidence and join the discussion, but only the author can act on this acceptance.',
'acceptance.sharedNotice.readOnlyDescription':
'You can browse every check and its evidence, but only the author can act on this acceptance.',
'acceptance.sharedNotice.reviewableDescription':
diff --git a/packages/types/src/acceptanceComment.ts b/packages/types/src/acceptanceComment.ts
index 4a3ead80b2f..c876118a241 100644
--- a/packages/types/src/acceptanceComment.ts
+++ b/packages/types/src/acceptanceComment.ts
@@ -121,7 +121,9 @@ export interface AcceptanceApprovalSummary {
}
export interface AcceptanceCommentList {
- /** May the caller write comments / approvals here? */
+ /** May the caller approve a round — speak for the delivery rather than about it? */
+ canApprove: boolean;
+ /** May the caller write comments, annotations and reactions here? */
canComment: boolean;
items: AcceptanceCommentItem[];
}
diff --git a/src/features/Acceptance/Viewer/AcceptanceScope.tsx b/src/features/Acceptance/Viewer/AcceptanceScope.tsx
index 7122e371b40..62c26e3aaee 100644
--- a/src/features/Acceptance/Viewer/AcceptanceScope.tsx
+++ b/src/features/Acceptance/Viewer/AcceptanceScope.tsx
@@ -6,6 +6,7 @@ import { createContext, type ReactNode, use } from 'react';
import { useTranslation } from 'react-i18next';
import NeuralNetworkLoading from '@/components/NeuralNetworkLoading';
+import { isTrpcErrorCode } from '@/utils/trpcError';
import { useAcceptanceBundle } from './useAcceptanceBundle';
@@ -46,7 +47,7 @@ export const AcceptanceBundleGate = ({
}) => {
const { t } = useTranslation('verify');
const { acceptanceId } = useAcceptanceScope();
- const { data, isLoading, mutate } = useAcceptanceBundle(acceptanceId);
+ const { data, error, isLoading, mutate } = useAcceptanceBundle(acceptanceId);
if (isLoading && !data) {
return (
@@ -56,6 +57,23 @@ export const AcceptanceBundleGate = ({
);
}
+ /**
+ * A deleted acceptance and one that was never shared with this reader answer
+ * the same way — NOT_FOUND, so a link cannot be used to probe for what
+ * exists. Either way it will not appear by trying again, so it says so
+ * instead of blaming the network and offering a retry that cannot work.
+ */
+ if (!data && isTrpcErrorCode(error, 'NOT_FOUND')) {
+ return (
+ <Center height={height}>
+ <Empty
+ description={t('acceptance.notFound.description')}
+ title={t('acceptance.notFound.title')}
+ />
+ </Center>
+ );
+ }
+
if (!data) {
return (
<Center height={height}>
diff --git a/src/features/Acceptance/Viewer/Checks/CheckRow.tsx b/src/features/Acceptance/Viewer/Checks/CheckRow.tsx
index 2197f910cbb..1216723b024 100644
--- a/src/features/Acceptance/Viewer/Checks/CheckRow.tsx
+++ b/src/features/Acceptance/Viewer/Checks/CheckRow.tsx
@@ -187,7 +187,14 @@ export const AcceptanceCheckRow = memo<{
comment: content,
label: index + 1,
panel: (
- <CommentThread canComment={comments.canComment} thread={thread} {...commentActions} />
+ <CommentThread
+ canComment={comments.canComment}
+ // `canDelete` is only ever true on the caller's own live rows, so
+ // it doubles as "I raised this one".
+ canResolve={comments.canApprove || thread.root.canDelete}
+ thread={thread}
+ {...commentActions}
+ />
),
rect,
resolved: Boolean(thread.root.resolvedAt),
@@ -196,7 +203,7 @@ export const AcceptanceCheckRow = memo<{
});
return map.size > 0 ? map : undefined;
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [proposalOverlays, checkThreads, comments.canComment]);
+ }, [proposalOverlays, checkThreads, comments.canComment, comments.canApprove]);
const canCommentEvidence =
comments.canComment && Boolean(check.result) && hasAnnotatableEvidence(check);
const openEvidenceComment = () =>
@@ -646,6 +653,7 @@ export const AcceptanceCheckRow = memo<{
<Flexbox flex={1} style={{ minWidth: 200 }}>
<CommentThread
canComment={comments.canComment}
+ canResolve={comments.canApprove || thread.root.canDelete}
thread={thread}
{...commentActions}
/>
@@ -655,21 +663,6 @@ export const AcceptanceCheckRow = memo<{
})}
</Flexbox>
)}
- {canCommentEvidence && (
- <Button
- outdent
- icon={<Icon icon={MessageSquare} />}
- style={{ alignSelf: 'flex-start' }}
- type={'text'}
- onClick={(event) => {
- event.stopPropagation();
- openEvidenceComment();
- }}
- >
- {t('acceptance.comments.commentEvidence')}
- </Button>
- )}
-
{check.state === 'not_executed' && (
<Flexbox
horizontal
@@ -852,77 +845,100 @@ export const AcceptanceCheckRow = memo<{
onRound={onRound}
/>
)}
- {/* Confirm (plain filled) anchors the right edge; reject is the
- quiet text escape next to it. */}
- {reviewable &&
- !activeReview &&
- (detailMode ? (
- <Flexbox gap={10} style={{ marginBlockStart: 6 }}>
- <TextArea
- autoSize={{ maxRows: 8, minRows: 3 }}
- placeholder={t('acceptance.review.detailPlaceholder')}
- value={reviewComment}
- onChange={(event) => setReviewComment(event.target.value)}
- />
- <Flexbox horizontal gap={8}>
+ {/* One row closes the check: looking harder on the left, deciding on
+ the right. Circling the evidence is another way of reading what
+ was delivered rather than a verdict, so it keeps its quiet text
+ styling and the left edge — but it sits ON the same line as the
+ buttons instead of stacking a half-empty row above them. */}
+ {(canCommentEvidence || (reviewable && !activeReview && !detailMode)) && (
+ <Flexbox horizontal align={'center'} gap={8} justify={'space-between'}>
+ {canCommentEvidence ? (
+ <Button
+ outdent
+ icon={<Icon icon={MessageSquare} />}
+ type={'text'}
+ onClick={(event) => {
+ event.stopPropagation();
+ openEvidenceComment();
+ }}
+ >
+ {t('acceptance.comments.commentEvidence')}
+ </Button>
+ ) : (
+ <span />
+ )}
+ {reviewable && !activeReview && !detailMode && (
+ <Flexbox horizontal gap={4} justify={'flex-end'}>
<Button
- block
- disabled={reviewPending || !reviewComment.trim()}
- loading={rejecting}
- size={'large'}
- style={{ flex: 1 }}
- onClick={handleReject}
+ disabled={reviewPending && !ignoring}
+ loading={ignoring}
+ size={'small'}
+ type={'text'}
+ onClick={handleIgnore}
+ >
+ {t('acceptance.review.ignore')}
+ </Button>
+ <Button
+ disabled={reviewPending}
+ size={'small'}
+ type={'text'}
+ onClick={(event) => {
+ event.stopPropagation();
+ openReject();
+ }}
>
{t('acceptance.review.reject')}
</Button>
<Button
- block
disabled={reviewPending && !accepting}
icon={<Icon icon={Check} />}
loading={accepting}
- size={'large'}
- style={{ flex: 1 }}
+ size={'small'}
type={'fill'}
onClick={handleAccept}
>
{t('acceptance.review.accept')}
</Button>
</Flexbox>
- </Flexbox>
- ) : (
- <Flexbox horizontal gap={4} justify={'flex-end'}>
- <Button
- disabled={reviewPending && !ignoring}
- loading={ignoring}
- size={'small'}
- type={'text'}
- onClick={handleIgnore}
- >
- {t('acceptance.review.ignore')}
- </Button>
+ )}
+ </Flexbox>
+ )}
+ {/* The phone keeps its own stacked shape: a comment box over two
+ full-width buttons, which no single row can hold. */}
+ {reviewable && !activeReview && detailMode && (
+ <Flexbox gap={10} style={{ marginBlockStart: 6 }}>
+ <TextArea
+ autoSize={{ maxRows: 8, minRows: 3 }}
+ placeholder={t('acceptance.review.detailPlaceholder')}
+ value={reviewComment}
+ onChange={(event) => setReviewComment(event.target.value)}
+ />
+ <Flexbox horizontal gap={8}>
<Button
- disabled={reviewPending}
- size={'small'}
- type={'text'}
- onClick={(event) => {
- event.stopPropagation();
- openReject();
- }}
+ block
+ disabled={reviewPending || !reviewComment.trim()}
+ loading={rejecting}
+ size={'large'}
+ style={{ flex: 1 }}
+ onClick={handleReject}
>
{t('acceptance.review.reject')}
</Button>
<Button
+ block
disabled={reviewPending && !accepting}
icon={<Icon icon={Check} />}
loading={accepting}
- size={'small'}
+ size={'large'}
+ style={{ flex: 1 }}
type={'fill'}
onClick={handleAccept}
>
{t('acceptance.review.accept')}
</Button>
</Flexbox>
- ))}
+ </Flexbox>
+ )}
</Flexbox>
)}
</Flexbox>
diff --git a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx
index ae8ce90ba42..6c38a4179ab 100644
--- a/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx
+++ b/src/features/Acceptance/Viewer/Comments/AcceptanceDiscussion.tsx
@@ -2,7 +2,7 @@
import type { AcceptanceCommentItem } from '@lobechat/types';
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 { BadgeCheck, GitCommitHorizontal } from 'lucide-react';
import { nanoid } from 'nanoid';
@@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next';
import { useActivityTime } from '@/hooks/useActivityTime';
import { useUserStore } from '@/store/user';
-import { userProfileSelectors } from '@/store/user/selectors';
+import { authSelectors, userProfileSelectors } from '@/store/user/selectors';
import { useAcceptanceScope } from '../AcceptanceScope';
import { useAcceptanceBundle } from '../useAcceptanceBundle';
@@ -26,12 +26,52 @@ import { styles, TIMELINE_NODE } from './styles';
/** Enough room to start writing without the box dominating the column. */
const COMPOSER_MIN_HEIGHT = 80;
+/** Where a visitor lands after signing in: back on the page they were reading. */
+const authPath = (route: 'signin' | 'signup') =>
+ `/${route}?callbackUrl=${encodeURIComponent(
+ typeof window === 'undefined' ? '/' : window.location.pathname + window.location.search,
+ )}`;
+
+/**
+ * The end of a discussion a signed-out reader cannot join. A bare line of grey
+ * text states the rule and leaves them there; the way in belongs in the same
+ * place the reply box would have been, which is what GitHub does under a
+ * thread on a public repo.
+ */
+const SignInPrompt = memo(() => {
+ const { t } = useTranslation('verify');
+ return (
+ <Flexbox className={local.signInPrompt} gap={10}>
+ <Text weight={600}>{t('acceptance.comments.signInTitle')}</Text>
+ <Text fontSize={13} type={'secondary'}>
+ {t('acceptance.comments.signInDescription')}
+ </Text>
+ <Flexbox horizontal gap={8}>
+ <Button href={authPath('signin')} type={'primary'}>
+ {t('acceptance.comments.signIn')}
+ </Button>
+ <Button href={authPath('signup')}>{t('acceptance.comments.signUp')}</Button>
+ </Flexbox>
+ </Flexbox>
+ );
+});
+
+SignInPrompt.displayName = 'AcceptanceDiscussionSignInPrompt';
+
const local = createStaticStyles(({ css }) => ({
empty: css`
padding-block: 16px;
font-size: 13px;
color: ${cssVar.colorTextTertiary};
`,
+ signInPrompt: css`
+ padding-block: 16px;
+ padding-inline: 16px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
}));
/** A round landing or an approval — a dot on the rail and one line of text. */
@@ -166,6 +206,7 @@ const AcceptanceDiscussion = memo(() => {
const { t } = useTranslation('verify');
const { acceptanceId, embedded } = useAcceptanceScope();
const viewerId = useUserStore(userProfileSelectors.userId);
+ const isSignedIn = useUserStore(authSelectors.isLogin);
const { data } = useAcceptanceBundle(acceptanceId);
const { canComment, create, error, isLoading, items, react, remove, threads } =
useAcceptanceComments(acceptanceId);
@@ -264,11 +305,17 @@ const AcceptanceDiscussion = memo(() => {
/>
</Flexbox>
</Flexbox>
- ) : (
+ ) : error ? (
+ // A read that failed says nothing about permission.
+ <Text fontSize={13} type={'secondary'}>
+ {t('acceptance.comments.loadFailed')}
+ </Text>
+ ) : isSignedIn ? (
<Text fontSize={13} type={'secondary'}>
- {/* A read that failed says nothing about permission. */}
- {error ? t('acceptance.comments.loadFailed') : t('acceptance.comments.readOnly')}
+ {t('acceptance.comments.readOnly')}
</Text>
+ ) : (
+ <SignInPrompt />
)}
</Flexbox>
);
diff --git a/src/features/Acceptance/Viewer/Comments/CommentCard.tsx b/src/features/Acceptance/Viewer/Comments/CommentCard.tsx
index b3e1c80b79e..7cd9831331b 100644
--- a/src/features/Acceptance/Viewer/Comments/CommentCard.tsx
+++ b/src/features/Acceptance/Viewer/Comments/CommentCard.tsx
@@ -185,7 +185,7 @@ const CommentCard = memo<CommentCardProps>(
{/* Exhibits, under the words rather than inside them. */}
{comment.attachments.length > 0 && (
<div className={styles.attachments}>
- <AttachmentThumbs attachments={comment.attachments} />
+ <AttachmentThumbs attachments={comment.attachments} size={'comment'} />
</div>
)}
{onReact && (
diff --git a/src/features/Acceptance/Viewer/Comments/CommentReactions.tsx b/src/features/Acceptance/Viewer/Comments/CommentReactions.tsx
index 647bb6d6a0e..1e08b480b3b 100644
--- a/src/features/Acceptance/Viewer/Comments/CommentReactions.tsx
+++ b/src/features/Acceptance/Viewer/Comments/CommentReactions.tsx
@@ -176,23 +176,11 @@ const CommentReactions = memo<CommentReactionsProps>(({ onReact, reactions }) =>
</Flexbox>
);
+ // The button leads and the emoji follow: it is the one fixed thing in this
+ // row, so it stays where the reader last clicked it instead of sliding right
+ // by one chip every time somebody reacts.
return (
<Flexbox horizontal align={'center'} className={styles.bar} gap={6} wrap={'wrap'}>
- {reactions.map((reaction) => (
- <Tooltip
- key={reaction.emoji}
- title={reaction.authorNames.length > 0 ? reaction.authorNames.join('、') : reaction.emoji}
- >
- <span
- className={cx(styles.chip, reaction.mine && styles.chipMine)}
- style={onReact ? undefined : { cursor: 'default' }}
- onClick={onReact ? () => void fire(reaction.emoji, !reaction.mine) : undefined}
- >
- <span>{reaction.emoji}</span>
- <span className={styles.count}>{reaction.count}</span>
- </span>
- </Tooltip>
- ))}
{onReact && (
<Popover
content={picker}
@@ -215,6 +203,21 @@ const CommentReactions = memo<CommentReactionsProps>(({ onReact, reactions }) =>
</span>
</Popover>
)}
+ {reactions.map((reaction) => (
+ <Tooltip
+ key={reaction.emoji}
+ title={reaction.authorNames.length > 0 ? reaction.authorNames.join('、') : reaction.emoji}
+ >
+ <span
+ className={cx(styles.chip, reaction.mine && styles.chipMine)}
+ style={onReact ? undefined : { cursor: 'default' }}
+ onClick={onReact ? () => void fire(reaction.emoji, !reaction.mine) : undefined}
+ >
+ <span>{reaction.emoji}</span>
+ <span className={styles.count}>{reaction.count}</span>
+ </span>
+ </Tooltip>
+ ))}
</Flexbox>
);
});
diff --git a/src/features/Acceptance/Viewer/Comments/CommentThread.tsx b/src/features/Acceptance/Viewer/Comments/CommentThread.tsx
index a405f749091..88b3d51d1d3 100644
--- a/src/features/Acceptance/Viewer/Comments/CommentThread.tsx
+++ b/src/features/Acceptance/Viewer/Comments/CommentThread.tsx
@@ -14,6 +14,12 @@ import { styles } from './styles';
interface CommentThreadProps {
canComment: boolean;
+ /**
+ * Whether closing THIS thread is the caller's to make. Replying is open to
+ * every reader; declaring a concern handled belongs to whoever raised it and
+ * to the delivery's reviewers.
+ */
+ canResolve: boolean;
onDelete: (id: string) => Promise<void>;
onReply: (rootId: string, content: string, attachments: { fileId: string }[]) => Promise<void>;
onResolve: (rootId: string, resolved: boolean) => Promise<void>;
@@ -30,7 +36,7 @@ interface CommentThreadProps {
* carries a success colour any more.
*/
const CommentThread = memo<CommentThreadProps>(
- ({ canComment, onDelete, onReply, onResolve, thread }) => {
+ ({ canComment, canResolve, onDelete, onReply, onResolve, thread }) => {
const { t } = useTranslation('verify');
const [replying, setReplying] = useState(false);
const [resolving, setResolving] = useState(false);
@@ -107,15 +113,17 @@ const CommentThread = memo<CommentThreadProps>(
<Button outdent size={'small'} type={'text'} onClick={() => setReplying(true)}>
{t('acceptance.comments.reply')}
</Button>
- <Button
- outdent
- loading={resolving}
- size={'small'}
- type={'text'}
- onClick={() => void toggleResolved()}
- >
- {resolved ? t('acceptance.comments.reopen') : t('acceptance.comments.resolve')}
- </Button>
+ {canResolve && (
+ <Button
+ outdent
+ loading={resolving}
+ size={'small'}
+ type={'text'}
+ onClick={() => void toggleResolved()}
+ >
+ {resolved ? t('acceptance.comments.reopen') : t('acceptance.comments.resolve')}
+ </Button>
+ )}
{resolved && (
<Button outdent size={'small'} type={'text'} onClick={() => setOpenOverride(false)}>
{t('acceptance.comments.collapseThread')}
diff --git a/src/features/Acceptance/Viewer/Comments/ReviewerApprovalBar.tsx b/src/features/Acceptance/Viewer/Comments/ReviewerApprovalBar.tsx
index c4f8ea3d658..85d1ba2461e 100644
--- a/src/features/Acceptance/Viewer/Comments/ReviewerApprovalBar.tsx
+++ b/src/features/Acceptance/Viewer/Comments/ReviewerApprovalBar.tsx
@@ -29,10 +29,13 @@ const styles = createStaticStyles(({ css }) => ({
}));
/**
- * The reviewer's counterpart of the decision bar. A teammate who can comment
+ * The reviewer's counterpart of the decision bar. A teammate who can review
* but cannot close the acceptance says "fine by me" here; it lands as an
* approval row the owner reads, and the acceptance status stays untouched.
*
+ * A visitor who only holds the public link is not offered it: they can answer
+ * the evidence in the discussion, but accepting a delivery is the team's call.
+ *
* An approval is never final while the round is open: review is a moving
* opinion, so it can be withdrawn and given again at any point. Only the state
* standing when the owner decides matters, and the newest row is that state.
@@ -41,11 +44,11 @@ const ReviewerApprovalBar = memo(() => {
const { t } = useTranslation('verify');
const { acceptanceId } = useAcceptanceScope();
const { data } = useAcceptanceBundle(acceptanceId);
- const { canComment, create, items, remove } = useAcceptanceComments(acceptanceId);
+ const { canApprove, create, items, remove } = useAcceptanceComments(acceptanceId);
const [summary, setSummary] = useState('');
const [pending, setPending] = useState(false);
- if (!data || !canComment || canReviewAcceptance(data)) return null;
+ if (!data || !canApprove || canReviewAcceptance(data)) return null;
if (data.acceptance.status === 'accepted' || data.acceptance.status === 'closed') return null;
// Nothing has been delivered yet, so there is nothing to approve. Allowing it
diff --git a/src/features/Acceptance/Viewer/Comments/authorColor.test.ts b/src/features/Acceptance/Viewer/Comments/authorColor.test.ts
index d58d7e27071..c209706ae52 100644
--- a/src/features/Acceptance/Viewer/Comments/authorColor.test.ts
+++ b/src/features/Acceptance/Viewer/Comments/authorColor.test.ts
@@ -25,6 +25,12 @@ describe('acceptanceAuthorColor', () => {
for (const color of ACCEPTANCE_AUTHOR_COLORS) expect(color).toMatch(/^var\(--/);
});
+ // The bare hue token is the scale's tint step: in light mode cyan lands near
+ // #95f3d9, and a 2px box in that colour on a white screenshot cannot be seen.
+ it('uses the scale step that stays legible on the page', () => {
+ for (const color of ACCEPTANCE_AUTHOR_COLORS) expect(color).toMatch(/-10\)$/);
+ });
+
it('leaves the verdict colours to verdicts', () => {
const { cssVar } = require('antd-style');
for (const semantic of [cssVar.volcano, cssVar.green, cssVar.colorError, cssVar.colorSuccess]) {
diff --git a/src/features/Acceptance/Viewer/Comments/authorColor.ts b/src/features/Acceptance/Viewer/Comments/authorColor.ts
index 9ace54d3cad..3a0190e315e 100644
--- a/src/features/Acceptance/Viewer/Comments/authorColor.ts
+++ b/src/features/Acceptance/Viewer/Comments/authorColor.ts
@@ -10,16 +10,22 @@ import { cssVar } from 'antd-style';
* other surface. The semantic hues are deliberately absent: `volcano` is
* `colorError` and `green` is `colorSuccess`, and a person's box wearing either
* would read as a verdict on the evidence rather than as an author.
+ *
+ * Step 10, not the bare hue. The bare token is the scale's tint step, which in
+ * light mode lands somewhere around #95f3d9 for cyan — a 2px box in that colour
+ * on a white screenshot is invisible, and a mark nobody can see is a mark
+ * nobody answers. Step 10 is the scale's solid step: legible on the page in
+ * light mode, and a light tint of the same hue in dark mode.
*/
export const ACCEPTANCE_AUTHOR_COLORS = [
- cssVar.geekblue,
- cssVar.magenta,
- cssVar.gold,
- cssVar.cyan,
- cssVar.purple,
- cssVar.lime,
- cssVar.orange,
- cssVar.blue,
+ cssVar.geekblue10,
+ cssVar.magenta10,
+ cssVar.gold10,
+ cssVar.cyan10,
+ cssVar.purple10,
+ cssVar.lime10,
+ cssVar.orange10,
+ cssVar.blue10,
] as const;
/** Deterministic, order-independent: the same author keeps their colour across rounds and reloads. */
diff --git a/src/features/Acceptance/Viewer/Comments/hooks.ts b/src/features/Acceptance/Viewer/Comments/hooks.ts
index fba6a4a6b3f..8df564eceae 100644
--- a/src/features/Acceptance/Viewer/Comments/hooks.ts
+++ b/src/features/Acceptance/Viewer/Comments/hooks.ts
@@ -12,7 +12,7 @@ import {
toggleReaction,
} from './threads';
-const EMPTY: AcceptanceCommentList = { canComment: false, items: [] };
+const EMPTY: AcceptanceCommentList = { canApprove: false, canComment: false, items: [] };
/**
* The whole discussion of one acceptance, read once and shared by every
@@ -79,11 +79,12 @@ export const useAcceptanceComments = (acceptanceId: string | undefined) => {
return {
approvals,
+ canApprove: data.canApprove,
canComment: data.canComment,
/**
* A failed read is not a permission answer. Without this the page falls
- * back to `canComment: false` and tells the owner to join the workspace,
- * which is both wrong and unactionable.
+ * back to `canComment: false` and tells the owner to sign in, which is
+ * both wrong and unactionable.
*/
error: swr.error as Error | undefined,
create,
diff --git a/src/features/Acceptance/Viewer/Comments/styles.ts b/src/features/Acceptance/Viewer/Comments/styles.ts
index 6ef3c0bbcdc..8b02183f840 100644
--- a/src/features/Acceptance/Viewer/Comments/styles.ts
+++ b/src/features/Acceptance/Viewer/Comments/styles.ts
@@ -14,6 +14,8 @@ import { createStaticStyles, cssVar } from 'antd-style';
export const TIMELINE_NODE = 32;
const NODE_GUTTER = 12;
const EVENT_DOT = 20;
+/** Breathing room under each entry — spacing, never part of the rail. */
+const ENTRY_GAP = 14;
/**
* GitHub does not run the rail through the avatars. It runs it just inside the
* content column's left edge, where the opaque comment boxes cover it and only
@@ -229,9 +231,11 @@ export const styles = createStaticStyles(({ css }) => ({
*/
tailEntry: css`
/* Outranks the last-of-type truncation, which would otherwise stop the
- line 10px in and leave the composer hanging off the end. */
+ line 10px in and leave the composer hanging off the end. It stops AT the
+ composer's bottom edge: the entry's own bottom padding is spacing, and a
+ rail drawn through it is a line pointing at nothing. */
&&&::before {
- inset-block: 0;
+ inset-block: 0 ${ENTRY_GAP}px;
height: auto;
}
`,
@@ -241,7 +245,7 @@ export const styles = createStaticStyles(({ css }) => ({
*/
timelineEntry: css`
position: relative;
- padding-block-end: 14px;
+ padding-block-end: ${ENTRY_GAP}px;
&::before {
content: '';
diff --git a/src/features/Acceptance/Viewer/Evidence/attachments.tsx b/src/features/Acceptance/Viewer/Evidence/attachments.tsx
index 4531237cac4..24076bf288c 100644
--- a/src/features/Acceptance/Viewer/Evidence/attachments.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/attachments.tsx
@@ -74,6 +74,28 @@ const styles = createStaticStyles(({ css }) => ({
object-fit: cover;
}
`,
+ /**
+ * A screenshot posted INTO a remark is the remark's evidence, not a chip on a
+ * draft: at 56px "here is what I see instead" is unreadable, so in a comment
+ * the picture is shown at a size a reader can judge without opening it.
+ */
+ thumbLarge: css`
+ width: auto;
+ max-width: min(100%, 360px);
+ height: auto;
+ max-height: 220px;
+
+ img {
+ cursor: zoom-in;
+
+ width: auto;
+ max-width: min(100%, 360px);
+ height: auto;
+ max-height: 220px;
+
+ object-fit: contain;
+ }
+ `,
thumbLoading: css`
display: flex;
align-items: center;
@@ -255,10 +277,12 @@ AttachmentUploadButton.displayName = 'AcceptanceAttachmentUploadButton';
interface AttachmentThumbsProps {
attachments?: AcceptanceAttachment[];
+ /** `comment` shows the picture at reading size; the default is the 56px chip. */
+ size?: 'chip' | 'comment';
}
/** Read-only screenshots on a settled feedback card — click any to zoom (native preview). */
-export const AttachmentThumbs = memo<AttachmentThumbsProps>(({ attachments }) => {
+export const AttachmentThumbs = memo<AttachmentThumbsProps>(({ attachments, size = 'chip' }) => {
const usable = (attachments ?? []).filter((attachment) => attachment.url);
if (usable.length === 0) return null;
return (
@@ -274,7 +298,10 @@ export const AttachmentThumbs = memo<AttachmentThumbsProps>(({ attachments }) =>
}}
>
{usable.map((attachment) => (
- <div className={styles.thumb} key={attachment.id}>
+ <div
+ className={cx(styles.thumb, size === 'comment' && styles.thumbLarge)}
+ key={attachment.id}
+ >
<Image alt={attachment.name ?? ''} src={attachment.url!} />
</div>
))}
diff --git a/src/features/Acceptance/Viewer/Header/AcceptanceSharedNotice.tsx b/src/features/Acceptance/Viewer/Header/AcceptanceSharedNotice.tsx
index a333cce84ee..dbb7837e14e 100644
--- a/src/features/Acceptance/Viewer/Header/AcceptanceSharedNotice.tsx
+++ b/src/features/Acceptance/Viewer/Header/AcceptanceSharedNotice.tsx
@@ -9,20 +9,24 @@ import { useTranslation } from 'react-i18next';
import { useAuthorInfo } from '@/business/client/hooks/useAuthorInfo';
import { useAcceptanceScope } from '../AcceptanceScope';
+import { useAcceptanceComments } from '../Comments/hooks';
import { useAcceptanceBundle } from '../useAcceptanceBundle';
import { canReviewAcceptance } from '../visibility';
/**
* In-body notice for viewers who reached this acceptance through someone
* else's shared link or workspace membership: names the author when the
- * business layer can resolve them, and states whether the viewer may review
- * or is read-only — so a page missing its owner controls never looks broken.
+ * business layer can resolve them, and states what this viewer may actually do
+ * — review, join the discussion, or only read — so a page missing its owner
+ * controls never looks broken, and so it never promises a reply box that a
+ * signed-out reader does not get.
*/
const AcceptanceSharedNotice = ({ style }: { style?: CSSProperties }) => {
const { t } = useTranslation('verify');
const { acceptanceId } = useAcceptanceScope();
const { data } = useAcceptanceBundle(acceptanceId);
const author = useAuthorInfo(data?.acceptance.userId ?? undefined);
+ const { canComment } = useAcceptanceComments(acceptanceId);
if (!data || data.isOwner) return null;
@@ -36,7 +40,9 @@ const AcceptanceSharedNotice = ({ style }: { style?: CSSProperties }) => {
description={t(
canReviewAcceptance(data)
? 'acceptance.sharedNotice.reviewableDescription'
- : 'acceptance.sharedNotice.readOnlyDescription',
+ : canComment
+ ? 'acceptance.sharedNotice.commentableDescription'
+ : 'acceptance.sharedNotice.readOnlyDescription',
)}
title={
author?.fullName