🤯 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
✨ feat(acceptance): let the reject dialog copy the prompt when no agent can repair (#19936)
Arvin Xue51d12e4f2e9
diff --git a/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.ts b/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.tsindex f912b39400f..2afc5286b8d 100644--- a/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.ts+++ b/apps/server/src/routers/lambda/__tests__/acceptance.reject.test.ts@@ -155,6 +155,9 @@ describe('acceptanceRouter reject', () => {prompt: expect.stringContaining(`lh acceptance feedback ${acceptanceId} --actionable`),}),);+ // The round-level reason is not printed by `feedback --actionable`, so+ // the agent only learns it from the prompt.+ expect(mockExecAgent.mock.calls[0][0].prompt).toContain('Tab title missing');const [run] = await serverDB.select().from(verifyRuns).where(eq(verifyRuns.id, runId));expect(run.decisionDetail?.comment).toBe('Tab title missing');});diff --git a/apps/server/src/routers/lambda/_helpers/acceptanceRepairDispatch.ts b/apps/server/src/routers/lambda/_helpers/acceptanceRepairDispatch.tsindex 803f398af1f..0501f3fad63 100644--- a/apps/server/src/routers/lambda/_helpers/acceptanceRepairDispatch.ts+++ b/apps/server/src/routers/lambda/_helpers/acceptanceRepairDispatch.ts@@ -60,6 +60,7 @@ export const dispatchAcceptanceRepair = async (ctx: DispatchContext,service: AcceptanceService,acceptance: AcceptanceItem,+ rejectComment?: string,): Promise<AcceptanceRepairDispatch> => {// A Goal Task's next attempt belongs to its coordinator, which reads the// rejected round through the prompt builder and claims the task. A plain@@ -88,7 +89,7 @@ export const dispatchAcceptanceRepair = async (try {({ operationId } = await agentNotifyRouter.createCaller(ctx).notify({agentId,- content: buildAcceptanceRepairPrompt(acceptance.id),+ content: buildAcceptanceRepairPrompt(acceptance.id, rejectComment),role: 'user',topicId: topic.id,}));diff --git a/apps/server/src/routers/lambda/acceptance.ts b/apps/server/src/routers/lambda/acceptance.tsindex 0f2eccd35df..7418813980d 100644--- a/apps/server/src/routers/lambda/acceptance.ts+++ b/apps/server/src/routers/lambda/acceptance.ts@@ -1248,7 +1248,12 @@ export const acceptanceRouter = router({return { ...rejected, repairDispatch: { dispatched: false, reason: 'skipped' } };}- const repairDispatch = await dispatchAcceptanceRepair(ctx, service, acceptance);+ const repairDispatch = await dispatchAcceptanceRepair(+ ctx,+ service,+ acceptance,+ input.comment || undefined,+ );if (!repairDispatch.dispatched) return { ...rejected, repairDispatch };const current = await service.acceptanceModel.findById(acceptance.id);diff --git a/locales/en-US/verify.json b/locales/en-US/verify.jsonindex 9f579de9634..07bf4f6b4f5 100644--- a/locales/en-US/verify.json+++ b/locales/en-US/verify.json@@ -7,6 +7,7 @@"acceptance.actions.cancel": "Cancel","acceptance.actions.confirmAccept": "Confirm acceptance","acceptance.actions.confirmReject": "Reject and start the next round",+ "acceptance.actions.confirmRejectCopy": "Reject & copy prompt","acceptance.actions.more": "More actions","acceptance.actions.refresh": "Refresh","acceptance.actions.reject": "Reject delivery",@@ -225,6 +226,7 @@"acceptance.proposal.request": "Ask AI to review the pending checks","acceptance.proposal.title": "AI review · possibly unmet","acceptance.reject.description": "Send this delivery back for another repair round. Optionally add a reason to guide the fix.",+ "acceptance.reject.descriptionCopy": "No agent is attached to this delivery. Rejecting copies the repair prompt, including any reason you add — paste it to any agent to start the next round.","acceptance.reject.placeholder": "Reason (optional), e.g. add screenshot evidence for dark mode…","acceptance.reportDrawer.close": "Close the round report","acceptance.requirementEmpty": "No acceptance goal recorded for this subject yet.",diff --git a/locales/zh-CN/verify.json b/locales/zh-CN/verify.jsonindex 1f67ab0af83..ae6feff6bbd 100644--- a/locales/zh-CN/verify.json+++ b/locales/zh-CN/verify.json@@ -7,6 +7,7 @@"acceptance.actions.cancel": "取消","acceptance.actions.confirmAccept": "确认接受交付","acceptance.actions.confirmReject": "打回并发起下一轮",+ "acceptance.actions.confirmRejectCopy": "打回并复制 prompt","acceptance.actions.more": "更多操作","acceptance.actions.refresh": "刷新","acceptance.actions.reject": "打回交付",@@ -225,6 +226,7 @@"acceptance.proposal.request": "让 AI 复核待验收项","acceptance.proposal.title": "AI 复核 · 疑似未达成","acceptance.reject.description": "打回后将发起新一轮修复,完成后回到「待验收」。可补充打回原因,为修复提供参考。",+ "acceptance.reject.descriptionCopy": "这份交付没有关联 agent。打回后会复制修改 prompt(附上你填写的原因),粘贴给任意 agent 即可开始下一轮。","acceptance.reject.placeholder": "打回原因(可选),例如:深色模式需补截图证据……","acceptance.reportDrawer.close": "关闭该轮报告","acceptance.requirementEmpty": "尚未记录该对象的验收目标。",diff --git a/packages/locales/src/default/verify.ts b/packages/locales/src/default/verify.tsindex 658af115ffe..e5989e2edb2 100644--- a/packages/locales/src/default/verify.ts+++ b/packages/locales/src/default/verify.ts@@ -122,6 +122,7 @@ export default {'acceptance.actions.confirmAccept': 'Confirm acceptance','acceptance.actions.more': 'More actions','acceptance.actions.refresh': 'Refresh',+ 'acceptance.actions.confirmRejectCopy': 'Reject & copy prompt','acceptance.actions.confirmReject': 'Reject and start the next round','acceptance.actions.reject': 'Reject delivery','acceptance.banner.accepted': 'Accepted by you · {{time}}',@@ -349,6 +350,8 @@ export default {'acceptance.origin.agentFallback': 'Agent','acceptance.origin.backToRuns': 'Back to runs','acceptance.origin.openTopic': 'Open topic',+ 'acceptance.reject.descriptionCopy':+ 'No agent is attached to this delivery. Rejecting copies the repair prompt, including any reason you add — paste it to any agent to start the next round.','acceptance.reject.description':'Send this delivery back for another repair round. Optionally add a reason to guide the fix.','acceptance.reject.placeholder': 'Reason (optional), e.g. add screenshot evidence for dark mode…',diff --git a/packages/prompts/src/prompts/verify/index.test.ts b/packages/prompts/src/prompts/verify/index.test.tsindex 2d88cbe79a2..f832d1c9d27 100644--- a/packages/prompts/src/prompts/verify/index.test.ts+++ b/packages/prompts/src/prompts/verify/index.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { buildVerifierPrompt } from './index';+import { buildAcceptanceRepairPrompt, buildVerifierPrompt } from './index';const checkItem = {id: 'check-1',@@ -43,3 +43,17 @@ describe('buildVerifierPrompt', () => {expect(prompt).not.toContain('## Task documents');});});++describe('buildAcceptanceRepairPrompt', () => {+ it('carries the round-level reject reason, which feedback --actionable does not print', () => {+ const prompt = buildAcceptanceRepairPrompt('acc-1', '能否录一个视频看下?');++ expect(prompt.startsWith('The reviewer sent this delivery back with this reason:')).toBe(true);+ expect(prompt).toContain('能否录一个视频看下?');+ expect(prompt).toContain('lh acceptance feedback acc-1 --actionable');+ });++ it('stays the plain CLI handoff without a reason', () => {+ expect(buildAcceptanceRepairPrompt('acc-1')).toMatch(/^Use the LobeHub CLI/);+ });+});diff --git a/packages/prompts/src/prompts/verify/index.ts b/packages/prompts/src/prompts/verify/index.tsindex f5b36a07594..5335206d6eb 100644--- a/packages/prompts/src/prompts/verify/index.ts+++ b/packages/prompts/src/prompts/verify/index.ts@@ -89,9 +89,13 @@ Investigate whether the deliverable satisfies this check, judging against the ru* The send-back prompt for a rejected delivery. It points the agent at the CLI* as the source of truth, so neither the reviewer nor the dispatcher has to* hand-summarize evidence and feedback.+ *+ * `rejectComment` is the whole-round reason from a reject. It lives on the+ * round's decision, which `feedback --actionable` does not print, so it has to+ * travel in the prompt itself.*/-export const buildAcceptanceRepairPrompt = (acceptanceId: string) =>- `Use the LobeHub CLI to read the latest review feedback for acceptance ${acceptanceId}:+export const buildAcceptanceRepairPrompt = (acceptanceId: string, rejectComment?: string) =>+ `${rejectComment ? `The reviewer sent this delivery back with this reason:\n\n${rejectComment}\n\n` : ''}Use the LobeHub CLI to read the latest review feedback for acceptance ${acceptanceId}:lh acceptance feedback ${acceptanceId} --actionablediff --git a/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsx b/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsxindex 6df8cf89f88..36027792e44 100644--- a/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsx+++ b/src/features/Acceptance/Viewer/Review/AcceptanceDecision.tsx@@ -25,6 +25,7 @@ import { canReviewAcceptance } from '../visibility';import DecisionBar from './DecisionBar';import FeedbackDrawer, { type FeedbackListEntry } from './FeedbackDrawer';import { openAcceptModal, openGroupFeedbackModal, openRejectModal } from './modals';+import { rejectCopyOnly } from './rejectCopyOnly';interface AcceptanceDecisionProps {onDraftToComposer?: (text: string) => boolean;@@ -233,8 +234,26 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {}}onRejectComment={() =>openRejectModal({- onConfirm: (comment) =>- runAction(async () => {+ // `origin` is only visible to the record owner, so this is the+ // viewer's promise, not the server's gate — the copy path below+ // opts out of dispatch explicitly.+ dispatchAvailable: Boolean(data.origin?.topic),+ onConfirm: async (comment) => {+ if (!data.origin?.topic) {+ const rejected = await runAction(() =>+ rejectCopyOnly({+ acceptanceId: acceptance.id,+ comment,+ copy: copyToClipboard,+ reject: (options) =>+ verifyService.rejectDelivery(acceptance.id, options.comment, options),+ }),+ );+ if (rejected)+ toast.success({ placement: 'top', title: t('acceptance.bar.copied') });+ return rejected;+ }+ return runAction(async () => {// The server sends the delivery back to its authoring agent when// the rounds name one — say so, since the reject itself is quiet.const { repairDispatch } = await verifyService.rejectDelivery(@@ -246,7 +265,8 @@ const AcceptanceDecision = ({ onDraftToComposer }: AcceptanceDecisionProps) => {} else if (repairDispatch.reason === 'failed') {toast.error(repairDispatch.error ?? t('acceptance.actionError'));}- }),+ });+ },})}onRerun={async () => {diff --git a/src/features/Acceptance/Viewer/Review/DecisionBar.test.ts b/src/features/Acceptance/Viewer/Review/DecisionBar.test.tsindex 67d2820011f..b36a8a0e1d1 100644--- a/src/features/Acceptance/Viewer/Review/DecisionBar.test.ts+++ b/src/features/Acceptance/Viewer/Review/DecisionBar.test.ts@@ -82,7 +82,7 @@ it.each(['', ' ', ' Please add dark mode evidence '])(...props,feedbackCount: 0,needsFixCount: 0,- onRejectComment: () => openRejectModal({ onConfirm }),+ onRejectComment: () => openRejectModal({ dispatchAvailable: true, onConfirm }),}),);@@ -97,3 +97,26 @@ it.each(['', ' ', ' Please add dark mode evidence '])(await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());},);++it('without an authoring agent, the reject dialog copies the prompt instead of promising a round', async () => {+ // Regression: the dialog said 打回并发起下一轮 though nothing could start one.+ const onConfirm = vi.fn().mockResolvedValue(true);+ render(createElement(ModalHost));+ render(+ createElement(DecisionBar, {+ ...props,+ feedbackCount: 0,+ needsFixCount: 0,+ onRejectComment: () => openRejectModal({ dispatchAvailable: false, onConfirm }),+ }),+ );++ fireEvent.click(screen.getByRole('button', { name: 'acceptance.bar.rejectComment' }));+ fireEvent.change(await screen.findByRole('textbox'), { target: { value: '补一段录屏' } });++ expect(screen.queryByRole('button', { name: 'acceptance.actions.confirmReject' })).toBeNull();+ expect(screen.getByText('acceptance.reject.descriptionCopy')).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'acceptance.actions.confirmRejectCopy' }));++ await waitFor(() => expect(onConfirm).toHaveBeenCalledWith('补一段录屏'));+});diff --git a/src/features/Acceptance/Viewer/Review/DecisionBar.tsx b/src/features/Acceptance/Viewer/Review/DecisionBar.tsxindex 084ff214140..30568dd97ca 100644--- a/src/features/Acceptance/Viewer/Review/DecisionBar.tsx+++ b/src/features/Acceptance/Viewer/Review/DecisionBar.tsx@@ -9,8 +9,8 @@ import {ListTodo,Loader2,MessageSquarePlus,- RefreshCw,RotateCcw,+ Wrench,} from 'lucide-react';import { memo, useEffect, useRef } from 'react';import { useTranslation } from 'react-i18next';@@ -18,6 +18,20 @@ import { useTranslation } from 'react-i18next';import { acceptanceContentLayout } from '../layout';const styles = createStaticStyles(({ css }) => ({+ repairingArc: css`+ transform-origin: center;+ animation: acceptance-repairing-orbit 1.2s linear infinite;++ @keyframes acceptance-repairing-orbit {+ to {+ transform: rotate(360deg);+ }+ }++ @media (prefers-reduced-motion: reduce) {+ animation: none;+ }+ `,/* Floats over the scrolling checklist — the decision stays reachablehowever deep the review goes. */bar: css`@@ -102,6 +116,49 @@ type BarState = 'accepted' | 'live' | 'rejected' | 'settled';* At zero it reads as a dashed "not started" circle; the completed state is* rendered by the bar as the BadgeCheck disc, not here.*/+/**+ * A repair round in flight: a steady wrench — what is happening — inside a+ * travelling arc — that it is still happening. Same ring geometry as the review+ * dial, so the bar's marks read as one family instead of a spinning reload glyph.+ */+const RepairingMark = memo(() => {+ const size = 20;+ const stroke = 2;+ const radius = (size - stroke) / 2;+ const circumference = 2 * Math.PI * radius;++ return (+ <div style={{ flex: 'none', height: size, position: 'relative', width: size }}>+ <svg height={size} width={size}>+ <circle+ cx={size / 2}+ cy={size / 2}+ fill={'none'}+ r={radius}+ stroke={cssVar.colorWarningBg}+ strokeWidth={stroke}+ />+ <circle+ className={styles.repairingArc}+ cx={size / 2}+ cy={size / 2}+ fill={'none'}+ r={radius}+ stroke={cssVar.colorWarning}+ strokeDasharray={`${circumference * 0.3} ${circumference}`}+ strokeLinecap={'round'}+ strokeWidth={stroke}+ />+ </svg>+ <Flexbox align={'center'} justify={'center'} style={{ inset: 0, position: 'absolute' }}>+ <Icon color={cssVar.colorWarning} icon={Wrench} size={10} />+ </Flexbox>+ </div>+ );+});++RepairingMark.displayName = 'AcceptanceRepairingMark';+const ProgressRing = memo<{ done: number; total: number }>(({ done, total }) => {const size = 20;const stroke = 2;@@ -234,11 +291,9 @@ const DecisionBar = memo<DecisionBarProps>(const stateMeta = {accepted: { color: cssVar.colorSuccess, icon: BadgeCheck },- // A repair round is an in-progress TASK — warn-coloured refresh, matching- // the task-process cue; a plain verify stays neutral info.- live: repairing- ? { color: cssVar.colorWarning, icon: RefreshCw }- : { color: cssVar.colorInfo, icon: Loader2 },+ // A repair round renders its own RepairingMark below; a plain verify+ // stays a neutral info spinner.+ live: { color: cssVar.colorInfo, icon: Loader2 },rejected: { color: cssVar.colorError, icon: RotateCcw },settled: null,}[state];@@ -269,7 +324,9 @@ const DecisionBar = memo<DecisionBarProps>(return (<div className={styles.bar}><Flexbox horizontal align={'center'} className={styles.summary} gap={8}>- {stateMeta ? (+ {state === 'live' && repairing ? (+ <RepairingMark />+ ) : stateMeta ? (// accepted / live / rejected — a plain coloured status mark.<Iconcolor={stateMeta.color}diff --git a/src/features/Acceptance/Viewer/Review/modals.tsx b/src/features/Acceptance/Viewer/Review/modals.tsxindex 65a5c01f09c..35eefc6110c 100644--- a/src/features/Acceptance/Viewer/Review/modals.tsx+++ b/src/features/Acceptance/Viewer/Review/modals.tsx@@ -103,11 +103,14 @@ export const openAcceptModal = (options: AcceptContentProps): ModalInstance =>});interface RejectContentProps {+ /** The rounds name an authoring agent — the server sends the reject back to+ it. Without one the dialog promises no next round: it copies the prompt. */+ dispatchAvailable: boolean;/** Perform the reject with an optional reason; resolve true to close. */onConfirm: (comment: string) => Promise<boolean>;}-const RejectContent = memo<RejectContentProps>(({ onConfirm }) => {+const RejectContent = memo<RejectContentProps>(({ dispatchAvailable, onConfirm }) => {const { t: translate } = useTranslation('verify');const { close } = useModalContext();const [comment, setComment] = useState('');@@ -126,7 +129,9 @@ const RejectContent = memo<RejectContentProps>(({ onConfirm }) => {return (<Flexbox gap={16}><Text fontSize={13} type={'secondary'}>- {translate('acceptance.reject.description')}+ {translate(+ dispatchAvailable ? 'acceptance.reject.description' : 'acceptance.reject.descriptionCopy',+ )}</Text><TextAreaautoSize={{ maxRows: 6, minRows: 3 }}@@ -139,7 +144,11 @@ const RejectContent = memo<RejectContentProps>(({ onConfirm }) => {{translate('acceptance.actions.cancel')}</Button><Button loading={loading} type={'primary'} onClick={handleConfirm}>- {translate('acceptance.actions.confirmReject')}+ {translate(+ dispatchAvailable+ ? 'acceptance.actions.confirmReject'+ : 'acceptance.actions.confirmRejectCopy',+ )}</Button></Flexbox></Flexbox>diff --git a/src/features/Acceptance/Viewer/Review/rejectCopyOnly.test.ts b/src/features/Acceptance/Viewer/Review/rejectCopyOnly.test.tsnew file mode 100644index 00000000000..f69c03bb552--- /dev/null+++ b/src/features/Acceptance/Viewer/Review/rejectCopyOnly.test.ts@@ -0,0 +1,32 @@+import { describe, expect, it, vi } from 'vitest';++import { rejectCopyOnly } from './rejectCopyOnly';++describe('rejectCopyOnly', () => {+ it('records the reject without the server send-back', async () => {+ // Regression: a workspace reviewer sees no `origin` (owner-only) and gets+ // the copy path, while the server could still dispatch to the origin agent+ // — the repair would then run twice.+ const reject = vi.fn().mockResolvedValue(undefined);++ await rejectCopyOnly({ acceptanceId: 'acc-1', comment: '补一段录屏', copy: vi.fn(), reject });++ expect(reject).toHaveBeenCalledWith({ comment: '补一段录屏', dispatch: false });+ });++ it('copies the prompt, reason included, before the reject request', async () => {+ const order: string[] = [];+ const copy = vi.fn(async (text: string) => {+ order.push('copy');+ expect(text).toContain('补一段录屏');+ expect(text).toContain('lh acceptance feedback acc-1 --actionable');+ });+ const reject = vi.fn(async () => {+ order.push('reject');+ });++ await rejectCopyOnly({ acceptanceId: 'acc-1', comment: '补一段录屏', copy, reject });++ expect(order).toEqual(['copy', 'reject']);+ });+});diff --git a/src/features/Acceptance/Viewer/Review/rejectCopyOnly.ts b/src/features/Acceptance/Viewer/Review/rejectCopyOnly.tsnew file mode 100644index 00000000000..316d527970d--- /dev/null+++ b/src/features/Acceptance/Viewer/Review/rejectCopyOnly.ts@@ -0,0 +1,28 @@+import { buildAcceptanceRepairPrompt } from '@lobechat/prompts';++interface RejectCopyOnlyParams {+ acceptanceId: string;+ comment: string;+ copy: (text: string) => Promise<unknown>;+ reject: (options: { comment: string; dispatch: false }) => Promise<unknown>;+}++/**+ * The reject dialog's no-agent path: hand the repair prompt to the reviewer and+ * record the reject WITHOUT the server's send-back. The viewer only sees+ * `origin` as the record owner, so a reviewer in this path may still have a+ * dispatchable origin server-side — dispatching there would start that agent+ * while the reviewer pastes the prompt elsewhere, running the repair twice.+ *+ * The copy runs first: the clipboard write needs the click's user activation,+ * which awaiting the reject request would lose.+ */+export const rejectCopyOnly = async ({+ acceptanceId,+ comment,+ copy,+ reject,+}: RejectCopyOnlyParams) => {+ await copy(buildAcceptanceRepairPrompt(acceptanceId, comment));+ return reject({ comment, dispatch: false });+};diff --git a/src/services/verify.ts b/src/services/verify.tsindex b892650b38d..8954936159f 100644--- a/src/services/verify.ts+++ b/src/services/verify.ts@@ -240,8 +240,8 @@ export class VerifyService {acceptDelivery = (id: string, comment?: string) =>lambdaClient.acceptance.accept.mutate({ comment, id });- rejectDelivery = (id: string, comment?: string) =>- lambdaClient.acceptance.reject.mutate({ comment, id });+ rejectDelivery = (id: string, comment?: string, options?: { dispatch?: boolean }) =>+ lambdaClient.acceptance.reject.mutate({ comment, dispatch: options?.dispatch, id });/*** The user's verdict on individual union checks — accept settles a check for