🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(acceptance): show non-deciders a disabled decision bar and let workspace admins decide (#21261)
Neko03a5c1d62408
diff --git a/apps/server/src/routers/lambda/__tests__/acceptance.previewUrl.test.ts b/apps/server/src/routers/lambda/__tests__/acceptance.previewUrl.test.tsindex 2f7b7f0b77e..d5a89f64ff8 100644--- a/apps/server/src/routers/lambda/__tests__/acceptance.previewUrl.test.ts+++ b/apps/server/src/routers/lambda/__tests__/acceptance.previewUrl.test.ts@@ -74,13 +74,25 @@ describe('acceptanceRouter.setPreviewUrl', () => {});});- it('hides the acceptance from someone who cannot manage it', async () => {+ it('hides a private acceptance from someone who cannot read it', async () => {+ await testDB+ .update(acceptances)+ .set({ visibility: 'private' })+ .where(eq(acceptances.id, acceptanceId));const stranger = await createTestUser(testDB);await expect(caller(stranger).setPreviewUrl({ id: acceptanceId, url: 'https://x.example.com/' }),).rejects.toMatchObject({ code: 'NOT_FOUND' });});+ it('tells a reader of a public acceptance that they cannot change it', async () => {+ const stranger = await createTestUser(testDB);+ await expect(+ caller(stranger).setPreviewUrl({ id: acceptanceId, url: 'https://x.example.com/' }),+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });+ expect((await metadataOf(latestRunId))?.previewUrl).toBeUndefined();+ });+it('needs a round to attach the preview to', async () => {const [empty] = await testDB.insert(acceptances)diff --git a/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.ts b/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.tsindex 53a4e9b2f03..9aa5f349264 100644--- a/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.ts+++ b/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.ts@@ -332,6 +332,10 @@ describe('acceptanceRouter reject', () => {});it('does not let another user return a private delivery without a reason', async () => {+ await serverDB+ .update(acceptances)+ .set({ visibility: 'private' })+ .where(eq(acceptances.id, acceptanceId));const caller = acceptanceRouter.createCaller(createTestContext(strangerId));await expect(caller.reject({ id: acceptanceId })).rejects.toMatchObject({ code: 'NOT_FOUND' });const [acceptance] = await serverDB@@ -341,6 +345,16 @@ describe('acceptanceRouter reject', () => {expect(acceptance.status).toBe('delivered');});+ it('tells a reader of a public delivery that they cannot decide it', async () => {+ const caller = acceptanceRouter.createCaller(createTestContext(strangerId));+ await expect(caller.reject({ id: acceptanceId })).rejects.toMatchObject({ code: 'FORBIDDEN' });+ const [acceptance] = await serverDB+ .select()+ .from(acceptances)+ .where(eq(acceptances.id, acceptanceId));+ expect(acceptance.status).toBe('delivered');+ });+// The list and header controls decide an acceptance without the accept /// reject procedures; the goal sign-off it carried must not stay open.describe('goal sign-off', () => {diff --git a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.ts b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.tsindex b5b232e4966..1451c68d8f4 100644--- a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.ts+++ b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.test.ts@@ -41,6 +41,23 @@ describe('canManageAcceptance', () => {expect(getMember).toHaveBeenCalledWith('ws_a', 'me');});+ it("lets an admin of the acceptance's own workspace write a teammate's delivery", async () => {+ getMember.mockResolvedValue({ role: 'admin' });++ await expect(+ canManageAcceptance({ serverDB: db, userId: 'me' }, row('teammate', 'ws_a')),+ ).resolves.toBe(true);+ expect(getMember).toHaveBeenCalledWith('ws_a', 'me');+ });++ it('does not let a viewer write a teammate delivery', async () => {+ getMember.mockResolvedValue({ role: 'viewer' });++ await expect(+ canManageAcceptance({ serverDB: db, userId: 'me' }, row('teammate', 'ws_a')),+ ).resolves.toBe(false);+ });+it('does not let an ordinary member write a teammate delivery', async () => {getMember.mockResolvedValue({ role: 'member' });@@ -77,6 +94,7 @@ describe('filterManageableAcceptances', () => {getRolesInWorkspaces.mockResolvedValue(new Map([['ws_owned', 'owner'],+ ['ws_admin', 'admin'],['ws_member', 'member'],]),);@@ -85,12 +103,18 @@ describe('filterManageableAcceptances', () => {row('me', null),row('me', 'ws_member'),row('teammate', 'ws_owned'),+ row('teammate', 'ws_admin'),row('teammate', 'ws_member'),row('teammate', null),];await expect(filterManageableAcceptances({ serverDB: db, userId: 'me' }, rows),- ).resolves.toEqual([row('me', null), row('me', 'ws_member'), row('teammate', 'ws_owned')]);+ ).resolves.toEqual([+ row('me', null),+ row('me', 'ws_member'),+ row('teammate', 'ws_owned'),+ row('teammate', 'ws_admin'),+ ]);});it('reads roles for every distinct foreign workspace in one query', async () => {diff --git a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.ts b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.tsindex 7e7c9db7d2a..012b6b971ed 100644--- a/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.ts+++ b/apps/server/src/routers/lambda/_helpers/acceptanceWriteScope.ts@@ -2,6 +2,16 @@ import { WorkspaceMemberModel } from '@/database/models/workspaceMember';import type { AcceptanceItem } from '@/database/schemas/verify';import type { LobeChatDatabase } from '@/database/type';+/**+ * Workspace roles that may decide on a teammate's acceptance. Admins run the+ * workspace day to day, so a delivery waiting on its author must not be stuck+ * until the one owner turns up; members and viewers weigh in through approvals+ * and comments instead.+ */+const DECIDER_ROLES = new Set(['owner', 'admin']);++const isDeciderRole = (role?: string | null) => Boolean(role && DECIDER_ROLES.has(role));+export interface AcceptanceScopeCtx {serverDB: LobeChatDatabase;userId?: string | null;@@ -11,7 +21,7 @@ export interface AcceptanceScopeCtx {* May this caller write to this acceptance?** The creator always may. Beyond that, an acceptance that belongs to a workspace- * may also be managed by an OWNER of **that** workspace — not of the caller's+ * may also be managed by an OWNER or ADMIN of **that** workspace — not of the caller's* currently-active one, which is frequently a different workspace or none at* all. Reading membership off the row's own workspace is what makes the rule* stable no matter where the caller happens to be standing, and it is the same@@ -29,7 +39,7 @@ export async function canManageAcceptance(acceptance.workspaceId,ctx.userId,);- return member?.role === 'owner';+ return isDeciderRole(member?.role);}/**@@ -58,6 +68,7 @@ export async function filterManageableAcceptances<return rows.filter((row) =>- row.userId === userId || (row.workspaceId ? roles.get(row.workspaceId) === 'owner' : false),+ row.userId === userId ||+ (row.workspaceId ? isDeciderRole(roles.get(row.workspaceId)) : false),);}diff --git a/apps/server/src/routers/lambda/acceptance/procedures.test.ts b/apps/server/src/routers/lambda/acceptance/procedures.test.tsnew file mode 100644index 00000000000..ac8bd56d301--- /dev/null+++ b/apps/server/src/routers/lambda/acceptance/procedures.test.ts@@ -0,0 +1,81 @@+// @vitest-environment node+import { beforeEach, describe, expect, it, vi } from 'vitest';++import { ACCEPTANCE_DECISION_FORBIDDEN, resolveAcceptanceForWrite } from './procedures';++const canManage = vi.hoisted(() => vi.fn());+const getMember = vi.hoisted(() => vi.fn());++vi.mock('../_helpers/acceptanceWriteScope', () => ({+ canManageAcceptance: (...args: unknown[]) => canManage(...args),+}));+vi.mock('@/database/models/workspaceMember', () => ({+ WorkspaceMemberModel: class {+ getMember = getMember;+ },+}));+vi.mock('@/server/services/verify', () => ({ AcceptanceService: class {} }));+vi.mock('@/business/server/trpc-middlewares/workspaceAuth', () => {+ const procedure = { use: () => procedure };+ return { requireWorkspaceRoleWhenScoped: () => ({}), wsCompatProcedure: procedure };+});+vi.mock('@/libs/trpc/lambda', () => {+ const procedure = { use: () => procedure };+ return { publicProcedure: procedure };+});+vi.mock('@/libs/trpc/lambda/middleware', () => ({ serverDatabase: {} }));++const ID = '00000000-0000-4000-8000-000000000001';+const row = {+ id: ID,+ userId: 'author',+ visibility: 'private',+ workspaceId: 'ws_a',+};+const ctx = (found: unknown) =>+ ({+ serverDB: { query: { acceptances: { findFirst: vi.fn().mockResolvedValue(found) } } },+ userId: 'me',+ }) as never;++beforeEach(() => {+ canManage.mockReset();+ getMember.mockReset();+});++describe('resolveAcceptanceForWrite', () => {+ it('resolves a row the caller may decide on', async () => {+ canManage.mockResolvedValue(true);++ await expect(resolveAcceptanceForWrite(ctx(row), ID)).resolves.toMatchObject({+ acceptance: row,+ });+ });++ it('tells a teammate who can read it that they lack the right, not that it is missing', async () => {+ canManage.mockResolvedValue(false);+ getMember.mockResolvedValue({ role: 'member' });++ await expect(resolveAcceptanceForWrite(ctx(row), ID)).rejects.toMatchObject({+ code: 'FORBIDDEN',+ message: ACCEPTANCE_DECISION_FORBIDDEN,+ });+ expect(getMember).toHaveBeenCalledWith('ws_a', 'me');+ });++ it('keeps an outsider at NOT_FOUND so existence does not leak', async () => {+ canManage.mockResolvedValue(false);+ getMember.mockResolvedValue(undefined);++ await expect(resolveAcceptanceForWrite(ctx(row), ID)).rejects.toMatchObject({+ code: 'NOT_FOUND',+ });+ });++ it('answers NOT_FOUND for a missing row', async () => {+ await expect(resolveAcceptanceForWrite(ctx(undefined), ID)).rejects.toMatchObject({+ code: 'NOT_FOUND',+ });+ expect(canManage).not.toHaveBeenCalled();+ });+});diff --git a/apps/server/src/routers/lambda/acceptance/procedures.ts b/apps/server/src/routers/lambda/acceptance/procedures.tsindex 052058a90f1..bf2a650083c 100644--- a/apps/server/src/routers/lambda/acceptance/procedures.ts+++ b/apps/server/src/routers/lambda/acceptance/procedures.ts@@ -16,6 +16,9 @@ import { AcceptanceService } from '@/server/services/verify';import { canManageAcceptance } from '../_helpers/acceptanceWriteScope';+export const ACCEPTANCE_DECISION_FORBIDDEN =+ 'Only the creator, a workspace owner or a workspace admin can change this acceptance';+/** Reads addressed purely by acceptance id — visibility is checked in the handler. */export const publicAcceptanceProcedure = publicProcedure.use(serverDatabase);@@ -61,12 +64,21 @@ export const resolveAcceptanceForWrite = async (? await ctx.serverDB.query.acceptances.findFirst({ where: eq(acceptances.id, id) }): undefined;- // An unauthorized caller gets the same answer as a missing row: the existence- // of someone else's delivery is not ours to disclose.- if (!acceptance || !(await canManageAcceptance(ctx, acceptance))) {+ if (!acceptance) {throw new TRPCError({ code: 'NOT_FOUND', message: 'Acceptance not found' });}+ if (!(await canManageAcceptance(ctx, acceptance))) {+ // A caller who cannot even read it gets the same answer as a missing row:+ // the existence of someone else's delivery is not ours to disclose. A+ // teammate already looking at it, though, is told why — "not found" about+ // a page they have open reads as a broken link, not as a missing right.+ if (!(await canReadAcceptance(ctx, acceptance))) {+ throw new TRPCError({ code: 'NOT_FOUND', message: 'Acceptance not found' });+ }+ throw new TRPCError({ code: 'FORBIDDEN', message: ACCEPTANCE_DECISION_FORBIDDEN });+ }+return {acceptance,service: new AcceptanceService(diff --git a/locales/ar/verify.json b/locales/ar/verify.jsonindex d749bcc8c03..f78c5026001 100644--- a/locales/ar/verify.json+++ b/locales/ar/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} مراجع وافق","acceptance.comments.approve": "وافق على هذا التسليم","acceptance.comments.approveAgain": "وافق على هذه الجولة",- "acceptance.comments.approveDescription": "رأيك في المراجعة. لا يغير حالة القبول - فقط المالك يقبل التسليم.","acceptance.comments.approveSummaryPlaceholder": "ملخص من سطر واحد (اختياري)","acceptance.comments.approved": "تمت الموافقة","acceptance.comments.approvedAtRound": "تمت الموافقة (الجولة {{round}})",diff --git a/locales/bg-BG/verify.json b/locales/bg-BG/verify.jsonindex 6e073860135..4cee5c95b1c 100644--- a/locales/bg-BG/verify.json+++ b/locales/bg-BG/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} рецензент(и) одобриха","acceptance.comments.approve": "Одобрете тази доставка","acceptance.comments.approveAgain": "Одобрете този кръг",- "acceptance.comments.approveDescription": "Вашето мнение за прегледа. То не променя статуса на приемане — само собственикът приема доставката.","acceptance.comments.approveSummaryPlaceholder": "Едноредово обобщение (по избор)","acceptance.comments.approved": "Одобрено","acceptance.comments.approvedAtRound": "Одобрено (кръг {{round}})",diff --git a/locales/de-DE/verify.json b/locales/de-DE/verify.jsonindex fa57b875f02..c87ea6f5903 100644--- a/locales/de-DE/verify.json+++ b/locales/de-DE/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} Prüfer haben zugestimmt","acceptance.comments.approve": "Diese Lieferung genehmigen","acceptance.comments.approveAgain": "Diese Runde erneut genehmigen",- "acceptance.comments.approveDescription": "Ihre Überprüfungsmeinung. Sie ändert nicht den Annahmestatus – nur der Eigentümer akzeptiert die Lieferung.","acceptance.comments.approveSummaryPlaceholder": "Einzeilige Zusammenfassung (optional)","acceptance.comments.approved": "Genehmigt","acceptance.comments.approvedAtRound": "Genehmigt (Runde {{round}})",diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 457f4fc2161..bddd3c0a185 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -28,6 +28,7 @@"acceptance.bar.progress": "{{done}} of {{total}} checks confirmed — {{rest}} awaiting your review","acceptance.bar.progressDone": "All {{total}} checks confirmed — ready to accept","acceptance.bar.progressZero": "{{total}} checks awaiting your review",+ "acceptance.bar.readOnlyReason": "Only the creator, a workspace owner or an admin can accept or reject this delivery. You can still approve it or comment in Discussion.","acceptance.bar.rejectComment": "Reject delivery","acceptance.bar.rerun": "Fix","acceptance.bar.rerunDrafted": "Added to your composer — review and send it.",@@ -82,7 +83,7 @@"acceptance.comments.approvalCount": "{{count}} reviewer(s) approved","acceptance.comments.approve": "Approve this delivery","acceptance.comments.approveAgain": "Approve this round",- "acceptance.comments.approveDescription": "This records your approval. It doesn’t change the acceptance status — only the owner can accept the delivery.",+ "acceptance.comments.approveDescription": "This records your approval. It doesn’t change the acceptance status — only the creator, a workspace owner or an admin can accept the delivery.","acceptance.comments.approveSummaryPlaceholder": "One-line summary (optional)","acceptance.comments.approved": "Approved","acceptance.comments.approvedAtRound": "Approved (round {{round}})",diff --git a/locales/es-ES/verify.json b/locales/es-ES/verify.jsonindex ce038540bd5..8863237e86d 100644--- a/locales/es-ES/verify.json+++ b/locales/es-ES/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} revisor(es) aprobaron","acceptance.comments.approve": "Aprobar esta entrega","acceptance.comments.approveAgain": "Aprobar esta ronda",- "acceptance.comments.approveDescription": "Tu opinión de revisión. No cambia el estado de aceptación, solo el propietario acepta la entrega.","acceptance.comments.approveSummaryPlaceholder": "Resumen en una línea (opcional)","acceptance.comments.approved": "Aprobado","acceptance.comments.approvedAtRound": "Aprobado (ronda {{round}})",diff --git a/locales/fa-IR/verify.json b/locales/fa-IR/verify.jsonindex 3815a03ede7..670f3eb45c1 100644--- a/locales/fa-IR/verify.json+++ b/locales/fa-IR/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} بازبین تایید کردهاند","acceptance.comments.approve": "این تحویل را تایید کنید","acceptance.comments.approveAgain": "این دور را دوباره تایید کنید",- "acceptance.comments.approveDescription": "نظر شما در مورد بازبینی. این وضعیت پذیرش را تغییر نمیدهد — فقط مالک تحویل را میپذیرد.","acceptance.comments.approveSummaryPlaceholder": "خلاصهای یکخطی (اختیاری)","acceptance.comments.approved": "تایید شده","acceptance.comments.approvedAtRound": "تایید شده (دور {{round}})",diff --git a/locales/fr-FR/verify.json b/locales/fr-FR/verify.jsonindex 8948e5f42e5..964fcc0c38e 100644--- a/locales/fr-FR/verify.json+++ b/locales/fr-FR/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} réviseur(s) ont approuvé","acceptance.comments.approve": "Approuver cette livraison","acceptance.comments.approveAgain": "Approuver ce tour",- "acceptance.comments.approveDescription": "Votre avis de révision. Cela ne modifie pas le statut d'acceptation — seul le propriétaire accepte la livraison.","acceptance.comments.approveSummaryPlaceholder": "Résumé en une ligne (facultatif)","acceptance.comments.approved": "Approuvé","acceptance.comments.approvedAtRound": "Approuvé (tour {{round}})",diff --git a/locales/it-IT/verify.json b/locales/it-IT/verify.jsonindex b961277f91b..8a414e4da6c 100644--- a/locales/it-IT/verify.json+++ b/locales/it-IT/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} revisore(i) hanno approvato","acceptance.comments.approve": "Approva questa consegna","acceptance.comments.approveAgain": "Approva questo turno",- "acceptance.comments.approveDescription": "La tua opinione di revisione. Non modifica lo stato di accettazione — solo il proprietario accetta la consegna.","acceptance.comments.approveSummaryPlaceholder": "Riepilogo in una riga (opzionale)","acceptance.comments.approved": "Approvato","acceptance.comments.approvedAtRound": "Approvato (turno {{round}})",diff --git a/locales/ja-JP/verify.json b/locales/ja-JP/verify.jsonindex 3aea28321dd..91a4495850d 100644--- a/locales/ja-JP/verify.json+++ b/locales/ja-JP/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} 人のレビュアーが承認しました","acceptance.comments.approve": "この納品を承認する","acceptance.comments.approveAgain": "このラウンドを再承認する",- "acceptance.comments.approveDescription": "あなたのレビュー意見です。受け入れステータスは変更されません — オーナーのみが納品を受け入れます。","acceptance.comments.approveSummaryPlaceholder": "一行の要約(オプション)","acceptance.comments.approved": "承認済み","acceptance.comments.approvedAtRound": "承認済み(ラウンド {{round}})",diff --git a/locales/ko-KR/verify.json b/locales/ko-KR/verify.jsonindex 500ccf27d5e..50829093a77 100644--- a/locales/ko-KR/verify.json+++ b/locales/ko-KR/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}}명의 검토자가 승인함","acceptance.comments.approve": "이 전달을 승인","acceptance.comments.approveAgain": "이번 라운드를 다시 승인",- "acceptance.comments.approveDescription": "귀하의 검토 의견입니다. 이는 수락 상태를 변경하지 않습니다 — 소유자만이 전달을 수락합니다.","acceptance.comments.approveSummaryPlaceholder": "한 줄 요약 (선택 사항)","acceptance.comments.approved": "승인됨","acceptance.comments.approvedAtRound": "승인됨 (라운드 {{round}})",diff --git a/locales/nl-NL/verify.json b/locales/nl-NL/verify.jsonindex 35c4e226fea..11a14d743a4 100644--- a/locales/nl-NL/verify.json+++ b/locales/nl-NL/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} beoordelaar(s) hebben goedgekeurd","acceptance.comments.approve": "Keur deze levering goed","acceptance.comments.approveAgain": "Keur deze ronde opnieuw goed",- "acceptance.comments.approveDescription": "Uw beoordelingsmening. Dit verandert de acceptatiestatus niet — alleen de eigenaar accepteert de levering.","acceptance.comments.approveSummaryPlaceholder": "Eén-regelige samenvatting (optioneel)","acceptance.comments.approved": "Goedgekeurd","acceptance.comments.approvedAtRound": "Goedgekeurd (ronde {{round}})",diff --git a/locales/pl-PL/verify.json b/locales/pl-PL/verify.jsonindex f68479cd5a2..9e31a456ec2 100644--- a/locales/pl-PL/verify.json+++ b/locales/pl-PL/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} recenzent(ów) zatwierdziło","acceptance.comments.approve": "Zatwierdź tę dostawę","acceptance.comments.approveAgain": "Zatwierdź tę rundę",- "acceptance.comments.approveDescription": "Twoja opinia recenzenta. Nie zmienia statusu akceptacji — tylko właściciel akceptuje dostawę.","acceptance.comments.approveSummaryPlaceholder": "Jednolinijkowe podsumowanie (opcjonalne)","acceptance.comments.approved": "Zatwierdzono","acceptance.comments.approvedAtRound": "Zatwierdzono (runda {{round}})",diff --git a/locales/pt-BR/verify.json b/locales/pt-BR/verify.jsonindex 0208911b24f..2ee6e68ccf6 100644--- a/locales/pt-BR/verify.json+++ b/locales/pt-BR/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} revisor(es) aprovaram","acceptance.comments.approve": "Aprovar esta entrega","acceptance.comments.approveAgain": "Aprovar esta rodada",- "acceptance.comments.approveDescription": "Sua opinião de revisão. Isso não altera o status de aceitação — apenas o proprietário aceita a entrega.","acceptance.comments.approveSummaryPlaceholder": "Resumo em uma linha (opcional)","acceptance.comments.approved": "Aprovado","acceptance.comments.approvedAtRound": "Aprovado (rodada {{round}})",diff --git a/locales/ru-RU/verify.json b/locales/ru-RU/verify.jsonindex 66defc809fd..1137a076460 100644--- a/locales/ru-RU/verify.json+++ b/locales/ru-RU/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} рецензент(ов) одобрил(и)","acceptance.comments.approve": "Одобрить эту доставку","acceptance.comments.approveAgain": "Одобрить этот раунд",- "acceptance.comments.approveDescription": "Ваше мнение о рецензии. Оно не изменяет статус принятия — только владелец принимает доставку.","acceptance.comments.approveSummaryPlaceholder": "Однострочное резюме (необязательно)","acceptance.comments.approved": "Одобрено","acceptance.comments.approvedAtRound": "Одобрено (раунд {{round}})",diff --git a/locales/tr-TR/verify.json b/locales/tr-TR/verify.jsonindex 2030bce7c66..85680da9d89 100644--- a/locales/tr-TR/verify.json+++ b/locales/tr-TR/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} inceleyici onayladı","acceptance.comments.approve": "Bu teslimatı onayla","acceptance.comments.approveAgain": "Bu turu tekrar onayla",- "acceptance.comments.approveDescription": "İnceleme görüşünüz. Kabul durumunu değiştirmez — yalnızca sahibi teslimatı kabul eder.","acceptance.comments.approveSummaryPlaceholder": "Tek satırlık özet (isteğe bağlı)","acceptance.comments.approved": "Onaylandı","acceptance.comments.approvedAtRound": "Onaylandı (tur {{round}})",diff --git a/locales/vi-VN/verify.json b/locales/vi-VN/verify.jsonindex e5acbe9440d..7a6d49a480d 100644--- a/locales/vi-VN/verify.json+++ b/locales/vi-VN/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} người đánh giá đã phê duyệt","acceptance.comments.approve": "Phê duyệt giao hàng này","acceptance.comments.approveAgain": "Phê duyệt lại vòng này",- "acceptance.comments.approveDescription": "Ý kiến đánh giá của bạn. Nó không thay đổi trạng thái chấp nhận — chỉ chủ sở hữu mới có thể chấp nhận giao hàng.","acceptance.comments.approveSummaryPlaceholder": "Tóm tắt một dòng (tùy chọn)","acceptance.comments.approved": "Đã phê duyệt","acceptance.comments.approvedAtRound": "Đã phê duyệt (vòng {{round}})",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex d5bf84c5078..54eb724f1b8 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -28,6 +28,7 @@"acceptance.bar.progress": "已完成 {{done}} / {{total}} 项验证项,剩余 {{rest}} 项等待你的验收","acceptance.bar.progressDone": "{{total}} 项验证项已全部确认,可以接受交付","acceptance.bar.progressZero": "共 {{total}} 项等待你的验收",+ "acceptance.bar.readOnlyReason": "只有发起人、工作区所有者或管理员可以接受或打回这次交付。你仍然可以在讨论中批准或留言。","acceptance.bar.rejectComment": "打回交付","acceptance.bar.rerun": "打回重跑","acceptance.bar.rerunDrafted": "已填入对话框,检查后发送。",@@ -82,7 +83,7 @@"acceptance.comments.approvalCount": "{{count}} 位评审已接受","acceptance.comments.approve": "表达接受交付","acceptance.comments.approveAgain": "表达接受本轮",- "acceptance.comments.approveDescription": "这是你的评审意见,不会改变验收状态;只有发起人能接受交付。",+ "acceptance.comments.approveDescription": "这是你的评审意见,不会改变验收状态;只有发起人、工作区所有者或管理员能接受交付。","acceptance.comments.approveSummaryPlaceholder": "一句话总结(可选)","acceptance.comments.approved": "已接受","acceptance.comments.approvedAtRound": "已接受(第 {{round}} 轮)",diff --git a/locales/zh-TW/verify.json b/locales/zh-TW/verify.jsonindex ef948b68f1f..f46f93a4909 100644--- a/locales/zh-TW/verify.json+++ b/locales/zh-TW/verify.json@@ -82,7 +82,6 @@"acceptance.comments.approvalCount": "{{count}} 位審核者已批准","acceptance.comments.approve": "批准此交付","acceptance.comments.approveAgain": "再次批准此輪",- "acceptance.comments.approveDescription": "您的審核意見。這不會改變接受狀態——只有擁有者才能接受交付。","acceptance.comments.approveSummaryPlaceholder": "一行摘要(可選)","acceptance.comments.approved": "已批准","acceptance.comments.approvedAtRound": "已批准(第 {{round}} 輪)",diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex 4958d54d0a9..0039b8a8df1 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -189,6 +189,8 @@ export default {'{{done}} of {{total}} checks confirmed — {{rest}} awaiting your review','acceptance.bar.progressDone': 'All {{total}} checks confirmed — ready to accept','acceptance.bar.progressZero': '{{total}} checks awaiting your review',+ 'acceptance.bar.readOnlyReason':+ 'Only the creator, a workspace owner or an admin can accept or reject this delivery. You can still approve it or comment in Discussion.','acceptance.bar.rejectComment': 'Reject delivery','acceptance.bar.rerun': 'Fix','acceptance.bar.rerunDrafted': 'Added to your composer — review and send it.',@@ -281,7 +283,7 @@ export default {'acceptance.comments.regionCount': '{{count}} region note(s)','acceptance.comments.approve': 'Approve this delivery','acceptance.comments.approveDescription':- 'This records your approval. It doesn’t change the acceptance status — only the owner can accept the delivery.',+ 'This records your approval. It doesn’t change the acceptance status — only the creator, a workspace owner or an admin can accept the delivery.','acceptance.comments.approveSummaryPlaceholder': 'One-line summary (optional)','acceptance.comments.withdraw': 'Withdraw approval','acceptance.comments.withdrawDescription':diff --git a/src/features/Acceptance/Viewer/Gate/GateReview.tsx b/src/features/Acceptance/Viewer/Gate/GateReview.tsxindex 182e69ae454..1a94eaa5485 100644--- a/src/features/Acceptance/Viewer/Gate/GateReview.tsx+++ b/src/features/Acceptance/Viewer/Gate/GateReview.tsx@@ -31,9 +31,10 @@ import { isAcceptanceListKey } from '@/libs/swr/keys';import { verifyService } from '@/services/verify';import { useAcceptanceScope } from '../AcceptanceScope';+import { useAcceptanceComments } from '../Comments/hooks';import { acceptanceOverviewPath } from '../routes';import { useAcceptanceBundle } from '../useAcceptanceBundle';-import { canReviewAcceptance } from '../visibility';+import { canReviewAcceptance, isReadOnlyAcceptanceDecider } from '../visibility';import { latestRound, unitArtifacts } from './dossier';import SkillDirectory from './SkillDirectory';import { usePlanFiles } from './usePlanFiles';@@ -357,7 +358,9 @@ const GateDecision = memo<{const [revising, setRevising] = useState(false);const [correction, setCorrection] = useState('');const [pending, setPending] = useState(false);- if (!data || !canReviewAcceptance(data)) return null;+ const { canApprove } = useAcceptanceComments(acceptanceId);+ const readOnly = isReadOnlyAcceptanceDecider(data, canApprove);+ if (!data || (!canReviewAcceptance(data) && !readOnly)) return null;const status = data.acceptance.status;if (status === 'accepted' || status === 'rejected')@@ -394,6 +397,22 @@ const GateDecision = memo<{? t('acceptance.gate.startBatch', { count: dossier.nextWave.length }): t('acceptance.gate.releaseWave', { count: dossier.nextWave.length, wave: dossier.wave });+ // A teammate who cannot sign the gate still sees what it asks and who signs it.+ if (readOnly)+ return (+ <Flexbox className={cx(styles.footer, !inModal && styles.footerOnPage)}>+ <Flexbox horizontal align={'center'} gap={8}>+ <Text style={{ flex: 1, minWidth: 0 }} type={'secondary'}>+ {t('acceptance.bar.readOnlyReason')}+ </Text>+ <Button disabled>{t('acceptance.gate.revise')}</Button>+ <Button disabled type={'primary'}>+ {releaseLabel}+ </Button>+ </Flexbox>+ </Flexbox>+ );+return (<Flexbox className={cx(styles.footer, !inModal && styles.footerOnPage)} gap={12}>{revising && (diff --git a/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsx b/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsxindex c28751f0c40..0b18875812b 100644--- a/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsx+++ b/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsx@@ -20,7 +20,7 @@ import { acceptanceCheckPath } from '../routes';import { useAcceptanceBundle } from '../useAcceptanceBundle';import { useAcceptanceTurn } from '../useAcceptanceTurn';import { formatAcceptanceCountsText, LIVE_ACCEPTANCE_STATUSES } from '../verdict';-import { canReviewAcceptance } from '../visibility';+import { canReviewAcceptance, isReadOnlyAcceptanceDecider } from '../visibility';import DecisionBar from './DecisionBar';import FeedbackDrawer, { type FeedbackListEntry } from './FeedbackDrawer';import { draftRepairPromptInMobile } from './mobileBridge';@@ -40,8 +40,10 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {const { turn, setTurn } = useAcceptanceTurn(embedded);const [pending, setPending] = useState(false);const [feedbackOpen, setFeedbackOpen] = useState(false);- const { approvals } = useAcceptanceComments(acceptanceId);- if (!data || !canReviewAcceptance(data) || data.acceptance.status === 'closed') return null;+ const { approvals, canApprove } = useAcceptanceComments(acceptanceId);+ const readOnly = isReadOnlyAcceptanceDecider(data, canApprove);+ if (!data || (!canReviewAcceptance(data) && !readOnly) || data.acceptance.status === 'closed')+ return null;if (flowPlanPhase(data.rounds.at(-1))) return null;@@ -194,6 +196,7 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {ignoredCount={ignoredCount}needsFixCount={needsFixCount}pending={pending}+ readOnlyReason={readOnly ? t('acceptance.bar.readOnlyReason') : undefined}repairing={acceptance.status === 'repairing'}rerunAvailable={embedded}rerunPending={false}diff --git a/src/features/Acceptance/Viewer/Review/DecisionBar.test.ts b/src/features/Acceptance/Viewer/Review/DecisionBar.test.tsindex ee34449fcd4..82bcae41e3f 100644--- a/src/features/Acceptance/Viewer/Review/DecisionBar.test.ts+++ b/src/features/Acceptance/Viewer/Review/DecisionBar.test.ts@@ -124,3 +124,56 @@ it('without an authoring agent, the reject dialog copies the prompt instead of pawait waitFor(() => expect(onConfirm).toHaveBeenCalledWith('补一段录屏'));});++describe('a teammate who cannot decide', () => {+ // Regression (T-945): a member's decision bar returned null, so the delivery+ // read as one nobody could decide. The pair stays in view, disabled, with why.+ it('sees Reject and Accept disabled, with the reason beside them', () => {+ const onAccept = vi.fn();+ const onRejectComment = vi.fn();+ render(+ createElement(DecisionBar, {+ ...props,+ feedbackCount: 0,+ needsFixCount: 0,+ onAccept,+ onRejectComment,+ readOnlyReason: 'acceptance.bar.readOnlyReason',+ }),+ );++ const reject = screen.getByRole('button', { name: 'acceptance.bar.rejectComment' });+ const accept = screen.getByRole('button', { name: 'acceptance.actions.accept' });+ expect(reject).toBeDisabled();+ expect(accept).toBeDisabled();+ expect(screen.getByText('acceptance.bar.readOnlyReason')).toBeVisible();++ fireEvent.click(reject);+ fireEvent.click(accept);+ expect(onRejectComment).not.toHaveBeenCalled();+ expect(onAccept).not.toHaveBeenCalled();+ });++ it('is not handed the repair handoff a decider gets once feedback is queued', () => {+ render(createElement(DecisionBar, { ...props, readOnlyReason: 'reason' }));++ expect(screen.queryByRole('button', { name: 'acceptance.bar.copyReview' })).toBeNull();+ expect(screen.queryByRole('button', { name: 'acceptance.bar.addComment' })).toBeNull();+ expect(screen.getByRole('button', { name: 'acceptance.actions.accept' })).toBeDisabled();+ });++ it('keeps the reason without actions while a round is still running', () => {+ render(createElement(DecisionBar, { ...props, readOnlyReason: 'reason', state: 'live' }));++ expect(screen.getByText('reason')).toBeVisible();+ expect(screen.queryByRole('button', { name: 'acceptance.actions.accept' })).toBeNull();+ });+});++it('a decider keeps live Reject and Accept without a reason line', () => {+ render(createElement(DecisionBar, { ...props, feedbackCount: 0, needsFixCount: 0 }));++ expect(screen.getByRole('button', { name: 'acceptance.bar.rejectComment' })).toBeEnabled();+ expect(screen.getByRole('button', { name: 'acceptance.actions.accept' })).toBeEnabled();+ expect(screen.queryByTestId('acceptance-decision-reason')).toBeNull();+});diff --git a/src/features/Acceptance/Viewer/Review/DecisionBar.tsx b/src/features/Acceptance/Viewer/Review/DecisionBar.tsxindex 20931388212..b5a27057087 100644--- a/src/features/Acceptance/Viewer/Review/DecisionBar.tsx+++ b/src/features/Acceptance/Viewer/Review/DecisionBar.tsx@@ -6,6 +6,7 @@ import {CircleAlert,ListTodo,Loader2,+ Lock,MessageSquarePlus,RotateCcw,Wrench,@@ -241,6 +242,9 @@ interface DecisionBarProps {beside the bar. Standalone pages only copy the repair prompt. */onRerun: () => void;pending: boolean;+ /** The viewer may weigh in but not decide: the closing actions stay on the+ bar, disabled, with this reason shown beside them. */+ readOnlyReason?: string;/** A live round that is a dispatched repair — coloured as an in-progress task(warning), not a neutral verify, to match the system's task-process cue. */repairing?: boolean;@@ -277,6 +281,7 @@ const DecisionBar = memo<DecisionBarProps>(onRejectComment,onRerun,pending,+ readOnlyReason,repairing,rerunAvailable,rerunPending,@@ -362,6 +367,19 @@ const DecisionBar = memo<DecisionBarProps>({subText}</Text>)}+ {readOnlyReason && (+ <Flexbox+ horizontal+ align={'center'}+ data-testid={'acceptance-decision-reason'}+ gap={4}+ >+ <Icon icon={Lock} size={12} style={{ flex: 'none' }} />+ <Text fontSize={12} type={'secondary'}>+ {readOnlyReason}+ </Text>+ </Flexbox>+ )}</Flexbox>{/* The clearing list — every note this round queues for the next one.@@ -379,64 +397,76 @@ const DecisionBar = memo<DecisionBarProps>(</Button>)}</Flexbox>- <Flexbox horizontal className={styles.actions} gap={8}>- {/* A dispatched send-back (repairing) keeps the copy entry alive —+ {readOnlyReason ? (+ // Not this viewer's call: the decision they are waiting on stays in+ // view, disabled, so the bar says who decides instead of vanishing.+ state === 'settled' && (+ <Flexbox horizontal className={styles.actions} gap={8}>+ <Button disabled title={readOnlyReason} type={'text'}>+ {t('acceptance.bar.rejectComment')}+ </Button>+ <Button disabled title={readOnlyReason} type={'fill'}>+ {t('acceptance.actions.accept')}+ </Button>+ </Flexbox>+ )+ ) : (+ <Flexbox horizontal className={styles.actions} gap={8}>+ {/* 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} type={'fill'} onClick={onCopyReview}>- {t('acceptance.bar.copyReview')}- </Button>- )}+ {state === 'live' && hasFeedback && !embedded && (+ <Button disabled={pending} type={'fill'} onClick={onCopyReview}>+ {t('acceptance.bar.copyReview')}+ </Button>+ )}- {(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.- <>- {/* Last words before the repair leaves — a global note the next+ {(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.+ <>+ {/* Last words before the repair leaves — a global note the nextround reads, for what the queued per-check feedback missed. */}- <Button- disabled={pending}- icon={<Icon icon={MessageSquarePlus} />}- type={'fill'}- onClick={onAddComment}- >- {t('acceptance.bar.addComment')}- </Button>- {!embedded && (- <Button disabled={pending} type={'primary'} onClick={onCopyReview}>- {t('acceptance.bar.copyReview')}+ <Button+ disabled={pending}+ icon={<Icon icon={MessageSquarePlus} />}+ type={'fill'}+ onClick={onAddComment}+ >+ {t('acceptance.bar.addComment')}+ </Button>+ {/* One commit action per host: standalone copies the repair+ prompt; embedded drafts it into the composer beside the bar. */}+ {(!embedded || rerunAvailable) && (+ <Button+ disabled={pending}+ loading={embedded && rerunPending}+ type={'primary'}+ onClick={embedded ? onRerun : onCopyReview}+ >+ {t(embedded ? 'acceptance.bar.rerun' : 'acceptance.bar.copyReview')}+ </Button>+ )}+ </>+ ) : (+ // Clean review — accept carries primary weight only once every+ // check is signed off; before that it stays a quiet option.+ <>+ <Button disabled={pending} type={'text'} onClick={onRejectComment}>+ {t('acceptance.bar.rejectComment')}</Button>- )}- {embedded && rerunAvailable && (<Buttondisabled={pending}- loading={rerunPending}- type={'primary'}- onClick={onRerun}+ type={allConfirmed ? 'primary' : 'fill'}+ onClick={onAccept}>- {t('acceptance.bar.rerun')}+ {t('acceptance.actions.accept')}</Button>- )}- </>- ) : (- // Clean review — accept carries primary weight only once every- // check is signed off; before that it stays a quiet option.- <>- <Button disabled={pending} type={'text'} onClick={onRejectComment}>- {t('acceptance.bar.rejectComment')}- </Button>- <Button- disabled={pending}- type={allConfirmed ? 'primary' : 'fill'}- onClick={onAccept}- >- {t('acceptance.actions.accept')}- </Button>- </>- ))}- </Flexbox>+ </>+ ))}+ </Flexbox>+ )}</div>);},diff --git a/src/features/Acceptance/Viewer/visibility.test.ts b/src/features/Acceptance/Viewer/visibility.test.tsindex 1d98ca04ab5..caab65f8dcd 100644--- a/src/features/Acceptance/Viewer/visibility.test.ts+++ b/src/features/Acceptance/Viewer/visibility.test.ts@@ -4,6 +4,7 @@ import {canCommentOnAcceptanceEvidence,canReviewAcceptance,canViewAcceptanceHistory,+ isReadOnlyAcceptanceDecider,resolveAcceptanceHistoryNavigation,} from './visibility';@@ -56,3 +57,18 @@ describe('canReviewAcceptance', () => {expect(canReviewAcceptance(null)).toBe(false);});});++describe('isReadOnlyAcceptanceDecider', () => {+ it('shows a disabled decision bar to a teammate who can approve but not decide', () => {+ expect(isReadOnlyAcceptanceDecider({ canReview: false }, true)).toBe(true);+ });++ it('keeps the live bar for a decider', () => {+ expect(isReadOnlyAcceptanceDecider({ canReview: true }, true)).toBe(false);+ });++ it('shows nothing to a viewer or link visitor who cannot weigh in', () => {+ expect(isReadOnlyAcceptanceDecider({ canReview: false }, false)).toBe(false);+ expect(isReadOnlyAcceptanceDecider(undefined, true)).toBe(false);+ });+});diff --git a/src/features/Acceptance/Viewer/visibility.ts b/src/features/Acceptance/Viewer/visibility.tsindex 24217960e76..f85693e483e 100644--- a/src/features/Acceptance/Viewer/visibility.ts+++ b/src/features/Acceptance/Viewer/visibility.ts@@ -11,8 +11,8 @@ export const resolveAcceptanceHistoryNavigation = (* Whether the viewer may act on the checks (accept / reject / ignore, group* feedback, proposal adjudication).*- * The server decides this — it is the creator OR an owner of the acceptance's- * workspace, exactly what the write path enforces — so the client must not+ * The server decides this — it is the creator OR an owner/admin of the+ * acceptance's workspace, exactly what the write path enforces — so the client must not* re-derive it from `isOwner`. Reading it off the bundle rather than taking it* from the host is what keeps a shared link from rendering live controls whose* every click answers "Acceptance not found"; deriving it from ownership alone@@ -21,6 +21,19 @@ export const resolveAcceptanceHistoryNavigation = (export const canReviewAcceptance = (bundle?: { canReview?: boolean; isOwner?: boolean } | null) =>Boolean(bundle?.canReview);+/**+ * Whether the decision bar is shown with its actions disabled.+ *+ * A teammate who may approve but not decide must still see that Reject and+ * Accept exist and why they cannot press them — a bar that silently vanishes+ * reads as "nobody can decide this". Viewers and link visitors, who cannot+ * weigh in at all, keep seeing no decision controls.+ */+export const isReadOnlyAcceptanceDecider = (+ bundle: { canReview?: boolean } | null | undefined,+ canApprove: boolean,+) => Boolean(bundle) && !canReviewAcceptance(bundle) && canApprove;+/** Authors give region feedback through the check's rejection action. */export const canCommentOnAcceptanceEvidence = (bundle: { isOwner: boolean } | null | undefined,