🤯 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
💄 style(dashboard): show widget approval stages, and let "don't ask again" cover the waiting batch (#21936)
Arvin Xu528ffe89cfe8
diff --git a/.agents/ux/lobe-design-rules.md b/.agents/ux/lobe-design-rules.mdindex 6ab7c14dd82..38b79664e06 100644--- a/.agents/ux/lobe-design-rules.md+++ b/.agents/ux/lobe-design-rules.md@@ -113,3 +113,15 @@ An unreleased feature's settings, search results and settings summary counts useEnforcement: `src/features/SettingsSearch/items.test.ts` covers the channel decision search entry with the flag off and on. The service-model form filters the channel row before deriving its groups and counts.Source: user correction about the unreleased Channel feature (2026-10-28).++## LOBE-UX-016 — A stage path is `Steps`, and its current step is the blue live dot++Show where a flow stands (draft → dry run → publish, select → fill) with `Steps` from `@lobehub/ui`, not a hand-rolled row of labels and chevrons: `Steps` owns the connectors and spacing that make the path readable. Mark the current step with `Badge status="processing"` (the blue `colorInfo` dot with its pulse), not `colorPrimary`, which renders near-black in LobeHub's theme and reads as plain text. Done steps keep a check; upcoming steps are a quiet dot. Leave room above the path when it sits right under a tab bar or divider. Copy under the stage title uses `colorTextDescription`.++Source: reviewer correction on widget approval cards, lobehub#21936 acceptance round 1 (2026-10-30).++## LOBE-UX-017 — A strip of tabs is `Tabs`, with plain labels that tell each tab apart++Switching between items in one space (the approval bar's pending calls) uses `@lobehub/ui` `Tabs` (`size="small"`), not a hand-styled underline row. Do not decorate tab labels with emoji (no `🔧`). When two tabs would read the same (two dry runs of one tool), number them ("试运行组件 1", "试运行组件 2"). Read a reviewer's circled region against the exact screenshot coordinates before acting: in this case, two rounds of feedback on the tab strip were misread as feedback on the stage path below it.++Source: reviewer correction on the approval tab bar, lobehub#21936 acceptance round 2 (2026-10-30).diff --git a/locales/en-US/dashboard.json b/locales/en-US/dashboard.jsonindex c7095393d7b..8a6273ef94e 100644--- a/locales/en-US/dashboard.json+++ b/locales/en-US/dashboard.json@@ -63,7 +63,7 @@"detail.versionDraft": "draft v{{version}}","detail.versionNone": "Not published","detail.versionPublished": "v{{version}} live",- "dryRun.intro": "The agent wants to run this draft once to preview its output. It runs in a sandbox with the access below; nothing goes live and no dashboard changes.",+ "dryRun.intro": "The agent wants to run this draft once in a sandbox to see its real output. Nothing goes live and no dashboard changes; it gets only the access listed below.","dryRun.rememberFailed": "Approved, but this access couldn't be remembered. You'll be asked again next time.","error.hideDetails": "Hide details","error.showDetails": "Show details",@@ -101,6 +101,7 @@"project.widgetsEmpty": "No widgets yet. Ask an agent in a conversation of this project to build a monitoring widget and it will show up here.","project.widgets_one": "Widgets ({{count}})","project.widgets_other": "Widgets ({{count}})",+ "publish.dryRunPassed": "v{{version}} passed its dry run {{time}}","publish.env": "Credentials","publish.envNone": "None","publish.intro": "Once published, this script runs on its schedule with the listed credentials and its result shows on dashboards.",@@ -120,6 +121,12 @@"review.sampleName": "Name","review.sampleTag": "Sample","review.sampleValue": "Value",+ "review.stage.draft": "Draft",+ "review.stage.dryRun": "Dry run",+ "review.stage.label": "Widget approval stage",+ "review.stage.publish": "Publish",+ "review.title.dryRun": "Dry-run approval · {{title}} · v{{version}}",+ "review.title.publish": "Publish approval · {{title}} · v{{version}}","review.versionMissing": "This version is no longer available, so it can't be reviewed. Reject the request and ask the agent to try again.","run.empty": "This widget has not run yet.","run.error": "Error",diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.jsonindex afc88469fc4..6b989956313 100644--- a/locales/en-US/plugin.json+++ b/locales/en-US/plugin.json@@ -1,6 +1,9 @@{"arguments.moreParams": "{{count}} params in total","arguments.title": "Arguments",+ "builtins.builtin-dashboard.approve.dryRunWidget": "Approve dry run",+ "builtins.builtin-dashboard.approve.requestPublish": "Approve publishing",+ "builtins.builtin-dashboard.approveRemember.dryRunWidget": "Approve dry run, and don't ask again for the same access","builtins.builtin-dashboard.apiName.addWidgetToDashboard": "Add widget to dashboard","builtins.builtin-dashboard.apiName.createDashboard": "Create dashboard","builtins.builtin-dashboard.apiName.createWidgetDraft": "Create widget draft",diff --git a/locales/zh-CN/dashboard.json b/locales/zh-CN/dashboard.jsonindex 40b4941a851..3a8eece5cf6 100644--- a/locales/zh-CN/dashboard.json+++ b/locales/zh-CN/dashboard.json@@ -63,7 +63,7 @@"detail.versionDraft": "草稿 v{{version}}","detail.versionNone": "未发布","detail.versionPublished": "v{{version}} 生效中",- "dryRun.intro": "智能体想先试运行一次此草稿以预览输出。它会在沙箱中以下方列出的权限运行;不会上线,也不会改动任何看板。",+ "dryRun.intro": "智能体想先在沙箱里试运行一次此草稿,看看真实输出;不会上线,也不会改动任何看板,只能使用下方列出的权限。","dryRun.rememberFailed": "已批准,但没能记住这项授权,下次仍会询问。","error.hideDetails": "隐藏详情","error.showDetails": "显示详情",@@ -101,6 +101,7 @@"project.widgetsEmpty": "还没有组件。在此项目的对话中让智能体创建监控组件,它会出现在这里。","project.widgets_one": "组件({{count}})","project.widgets_other": "组件({{count}})",+ "publish.dryRunPassed": "v{{version}} 已试运行成功 · {{time}}","publish.env": "凭证","publish.envNone": "无","publish.intro": "发布后,该脚本将使用下列凭证按计划运行,结果会显示在看板上。",@@ -120,6 +121,12 @@"review.sampleName": "名称","review.sampleTag": "示例","review.sampleValue": "数值",+ "review.stage.draft": "草稿",+ "review.stage.dryRun": "试运行",+ "review.stage.label": "组件审批阶段",+ "review.stage.publish": "发布",+ "review.title.dryRun": "试运行审批 · {{title}} · v{{version}}",+ "review.title.publish": "发布审批 · {{title}} · v{{version}}","review.versionMissing": "这个版本已不可用,无法审阅。请拒绝该请求,并让智能体重新尝试。","run.empty": "这个组件还没有运行过。","run.error": "错误",diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.jsonindex aa1fd9d2e46..e9f9785d22d 100644--- a/locales/zh-CN/plugin.json+++ b/locales/zh-CN/plugin.json@@ -1,6 +1,9 @@{"arguments.moreParams": "等 {{count}} 个参数","arguments.title": "参数列表",+ "builtins.builtin-dashboard.approve.dryRunWidget": "批准试运行",+ "builtins.builtin-dashboard.approve.requestPublish": "批准发布",+ "builtins.builtin-dashboard.approveRemember.dryRunWidget": "批准试运行,且相同权限不再询问","builtins.builtin-dashboard.apiName.addWidgetToDashboard": "添加组件到看板","builtins.builtin-dashboard.apiName.createDashboard": "创建看板","builtins.builtin-dashboard.apiName.createWidgetDraft": "创建组件草稿",diff --git a/packages/locales/src/default/dashboard.ts b/packages/locales/src/default/dashboard.tsindex 31c43ea5014..591df342633 100644--- a/packages/locales/src/default/dashboard.ts+++ b/packages/locales/src/default/dashboard.ts@@ -56,7 +56,7 @@ export default {'detail.versionNone': 'Not published','detail.versionPublished': 'v{{version}} live','dryRun.intro':- 'The agent wants to run this draft once to preview its output. It runs in a sandbox with the access below; nothing goes live and no dashboard changes.',+ 'The agent wants to run this draft once in a sandbox to see its real output. Nothing goes live and no dashboard changes; it gets only the access listed below.','error.hideDetails': 'Hide details','error.showDetails': 'Show details','form.descriptionLabel': 'Description',@@ -93,6 +93,7 @@ export default {'Output of the dry run this conversation produced. It does not change the live widget.','detail.tab.diff': 'Changes','portal.title': 'Widget',+ 'publish.dryRunPassed': 'v{{version}} passed its dry run {{time}}','publish.env': 'Credentials','publish.envNone': 'None','publish.intro':@@ -110,6 +111,12 @@ export default {"for reference, v{{version}}'s last result; approving runs this draft to make its own",'review.expectedSameVersion': "from this version's last dry run",'review.loadFailed': "Couldn't load the review, so approval is on hold",+ 'review.stage.draft': 'Draft',+ 'review.stage.dryRun': 'Dry run',+ 'review.stage.label': 'Widget approval stage',+ 'review.stage.publish': 'Publish',+ 'review.title.dryRun': 'Dry-run approval · {{title}} · v{{version}}',+ 'review.title.publish': 'Publish approval · {{title}} · v{{version}}','review.versionMissing':"This version is no longer available, so it can't be reviewed. Reject the request and ask the agent to try again.",'run.empty': 'This widget has not run yet.',diff --git a/packages/locales/src/default/plugin.ts b/packages/locales/src/default/plugin.tsindex a4eb65afea9..f7cff1c2469 100644--- a/packages/locales/src/default/plugin.ts+++ b/packages/locales/src/default/plugin.ts@@ -570,6 +570,9 @@ export default {'builtins.lobe-canvas.apiName.readCanvasGuide': 'Read canvas guide','builtins.lobe-canvas.apiName.updateCanvas': 'Update canvas','builtins.lobe-canvas.title': 'Canvas',+ 'builtins.builtin-dashboard.approve.dryRunWidget': 'Approve dry run',+ 'builtins.builtin-dashboard.approve.requestPublish': 'Approve publishing',+ 'builtins.builtin-dashboard.approveRemember.dryRunWidget': "Approve dry run, and don't ask again for the same access",'builtins.builtin-dashboard.apiName.addWidgetToDashboard': 'Add widget to dashboard','builtins.builtin-dashboard.apiName.createDashboard': 'Create dashboard','builtins.builtin-dashboard.apiName.createWidgetDraft': 'Create widget draft',diff --git a/src/features/Conversation/InterventionBar/InterventionTabBar.tsx b/src/features/Conversation/InterventionBar/InterventionTabBar.tsxindex f5985a5cc56..6021d882ea6 100644--- a/src/features/Conversation/InterventionBar/InterventionTabBar.tsx+++ b/src/features/Conversation/InterventionBar/InterventionTabBar.tsx@@ -1,10 +1,11 @@-import { Button, cx, Tooltip } from '@lobehub/ui';+import { Button, Tabs, Tooltip } from '@lobehub/ui';import { CheckCheck } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';import { type PendingIntervention } from '../store/slices/data/pendingInterventions';import { styles } from './style';+import { interventionTabLabelKey, numberDuplicateLabels } from './tabLabel';interface InterventionTabBarProps {activeIndex: number;@@ -24,19 +25,22 @@ interface InterventionTabBarProps {const InterventionTabBar = memo<InterventionTabBarProps>(({ interventions, activeIndex, approveAll, onTabChange }) => {- const { t } = useTranslation('chat');+ const { t } = useTranslation(['chat', 'plugin']);+ const labels = numberDuplicateLabels(+ interventions.map((item) => {+ const labelKey = interventionTabLabelKey(item);+ return labelKey ? t(labelKey, { defaultValue: item.apiName, ns: 'plugin' }) : item.apiName;+ }),+ );return (<div className={styles.tabBar}>- {interventions.map((item, index) => (- <div- className={cx(styles.tab, index === activeIndex && styles.tabActive)}- key={item.toolCallId}- onClick={() => onTabChange(index)}- >- 🔧 {item.apiName}- </div>- ))}+ <Tabs+ activeKey={String(activeIndex)}+ items={labels.map((label, index) => ({ key: String(index), label }))}+ size={'small'}+ onChange={(key) => onTabChange(Number(key))}+ /><div className={styles.tabTrailing}><span className={styles.tabCounter}>{activeIndex + 1} / {interventions.length}diff --git a/src/features/Conversation/InterventionBar/style.ts b/src/features/Conversation/InterventionBar/style.tsindex 911d8681c21..3bff3ef302d 100644--- a/src/features/Conversation/InterventionBar/style.ts+++ b/src/features/Conversation/InterventionBar/style.ts@@ -29,35 +29,14 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({min-height: 0;padding-block: 0 8px;`,- tab: css`- cursor: pointer;-- padding-block: 5px;- padding-inline: 10px;- border-block-end: 2px solid transparent;-- font-size: 12px;- color: ${cssVar.colorTextSecondary};- white-space: nowrap;-- transition:- border-color 0.2s,- color 0.2s,- background 0.2s;-- &:hover {- color: ${cssVar.colorText};- }- `,- tabActive: css`- border-block-end-color: ${cssVar.colorPrimary};- color: ${cssVar.colorPrimary};- background: ${cssVar.colorPrimaryBg};- `,tabBar: css`overflow-x: auto;display: flex;+ gap: 8px;align-items: center;++ padding-block: 6px;+ padding-inline: 4px;border-block-end: 1px solid ${cssVar.colorBorderSecondary};`,tabCounter: css`diff --git a/src/features/Conversation/InterventionBar/tabLabel.test.ts b/src/features/Conversation/InterventionBar/tabLabel.test.tsnew file mode 100644index 00000000000..29f47f3b68b--- /dev/null+++ b/src/features/Conversation/InterventionBar/tabLabel.test.ts@@ -0,0 +1,37 @@+import { describe, expect, it } from 'vitest';++import { interventionTabLabelKey, numberDuplicateLabels } from './tabLabel';++describe('interventionTabLabelKey', () => {+ it('names builtin calls by their localized action, not the raw API name', () => {+ expect(+ interventionTabLabelKey({ apiName: 'dryRunWidget', identifier: 'builtin-dashboard' }),+ ).toBe('builtins.builtin-dashboard.apiName.dryRunWidget');+ expect(+ interventionTabLabelKey({ apiName: 'requestPublish', identifier: 'builtin-dashboard' }),+ ).toBe('builtins.builtin-dashboard.apiName.requestPublish');+ });++ it('keeps the API name for tools that are not builtin', () => {+ expect(interventionTabLabelKey({ apiName: 'fetchThing', identifier: 'some-mcp' })).toBe(+ undefined,+ );+ });+});++describe('numberDuplicateLabels', () => {+ it('numbers labels that repeat so their tabs can be told apart', () => {+ expect(numberDuplicateLabels(['Dry-run widget', 'Dry-run widget', 'Publish widget'])).toEqual([+ 'Dry-run widget 1',+ 'Dry-run widget 2',+ 'Publish widget',+ ]);+ });++ it('leaves unique labels untouched', () => {+ expect(numberDuplicateLabels(['Search', 'Publish widget'])).toEqual([+ 'Search',+ 'Publish widget',+ ]);+ });+});diff --git a/src/features/Conversation/InterventionBar/tabLabel.ts b/src/features/Conversation/InterventionBar/tabLabel.tsnew file mode 100644index 00000000000..657bebca307--- /dev/null+++ b/src/features/Conversation/InterventionBar/tabLabel.ts@@ -0,0 +1,35 @@+import { builtinToolIdentifiers } from '@lobechat/builtin-tools/identifiers';++/**+ * The `plugin` key naming a pending call's tab the way its card names it: two+ * steps of one flow (a widget's dry run, then its publish) must not read as+ * one raw API name repeated. Tools that are not builtin have none and keep+ * their API name.+ */+export const interventionTabLabelKey = ({+ apiName,+ identifier,+}: {+ apiName: string;+ identifier: string;+}) =>+ builtinToolIdentifiers.includes(identifier)+ ? `builtins.${identifier}.apiName.${apiName}`+ : undefined;++/**+ * Tell apart tabs that would read the same: two calls of one action (two+ * widget dry runs) get "Dry-run widget 1" / "Dry-run widget 2"; a label that+ * appears once stays as is.+ */+export const numberDuplicateLabels = (labels: string[]) => {+ const total = new Map<string, number>();+ for (const label of labels) total.set(label, (total.get(label) ?? 0) + 1);+ const seen = new Map<string, number>();+ return labels.map((label) => {+ if ((total.get(label) ?? 0) < 2) return label;+ const index = (seen.get(label) ?? 0) + 1;+ seen.set(label, index);+ return `${label} ${index}`;+ });+};diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsxindex a2aa0858680..cdea5f24307 100644--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx@@ -1,11 +1,13 @@import { registerPendingHotkeyCard } from '@lobechat/shared-tool-ui/pending-hotkeys';-import type { BuiltinRememberApproval } from '@lobechat/types';+import type { BuiltinRememberApproval, DynamicInterventionResolver } from '@lobechat/types';+import { safeParseJSON } from '@lobechat/utils';import { Button, createStaticStyles, cx, Flexbox } from '@lobehub/ui';import { CircleStop, CornerDownLeft } from 'lucide-react';import type { KeyboardEvent as ReactKeyboardEvent } from 'react';import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';+import { clientInterventionAudits } from '@/store/chat/slices/agentRun/actions/transports/client/interventionAudits';import { useToolStore } from '@/store/tool';import { toolSelectors } from '@/store/tool/selectors';@@ -13,14 +15,25 @@ import { useConversationResourceAccess } from '../../../../../hooks/useConversatimport { useConversationStore } from '../../../../../store';import {type ApprovalChoice,+ approveChoiceLabelKeys,canRememberViaAllowList,+ dynamicAuditType,getApprovalChoices,isChoiceSubmitBlocked,+ isCoveredByRemember,resolveRememberAction,} from './approvalGate';import { type ApprovalMode } from './index';import { isSubmitShortcutBlockedByTarget } from './submitShortcutGuard';+/** The audit this client runs for a tool's dynamic approval, to re-check calls after a remember. */+const rememberAuditFor = (config: unknown) => {+ const type = dynamicAuditType(config);+ return type+ ? (clientInterventionAudits as Record<string, DynamicInterventionResolver>)[type]+ : undefined;+};+interface ApprovalActionsProps {apiName: string;approvalMode: ApprovalMode;@@ -159,7 +172,7 @@ const ApprovalActions = memo<ApprovalActionsProps>(rememberOption,toolArgs,}) => {- const { t } = useTranslation('chat');+ const { t } = useTranslation(['chat', 'plugin']);const [choice, setChoice] = useState<Choice>('approve');const [reason, setReason] = useState('');const [loading, setLoading] = useState(false);@@ -199,12 +212,17 @@ const ApprovalActions = memo<ApprovalActionsProps>(const effectiveChoice: Choice = choices.includes(choice) ? choice : 'approve';const rememberAction = resolveRememberAction({ toolRemember: hasToolRemember });- const [approveToolCall, rejectAndContinueToolCall, stopPendingApprovalForCard] =- useConversationStore((s) => [- s.approveToolCall,- s.rejectAndContinueToolCall,- s.stopPendingApprovalForCard,- ]);+ const [+ approveToolCall,+ approveToolCallAndCovered,+ rejectAndContinueToolCall,+ stopPendingApprovalForCard,+ ] = useConversationStore((s) => [+ s.approveToolCall,+ s.approveToolCallAndCovered,+ s.rejectAndContinueToolCall,+ s.stopPendingApprovalForCard,+ ]);const [stopping, setStopping] = useState(false);/**@@ -244,12 +262,24 @@ const ApprovalActions = memo<ApprovalActionsProps>(// after this approval already sees it.if (remember && rememberAction === 'tool') await rememberOption?.onRemember();const editedArguments = await onBeforeApprove?.();- await approveToolCall(messageId, assistantGroupId ?? '', {- editedArguments,- ...(remember && rememberAction === 'allow-list'- ? { rememberToolKey: `${identifier}/${apiName}` }- : {}),- });+ if (remember) {+ const audit = rememberAuditFor(interventionConfig);+ await approveToolCallAndCovered(messageId, assistantGroupId ?? '', {+ editedArguments,+ isCovered: (sibling) =>+ isCoveredByRemember({+ audit,+ config: interventionConfig,+ rememberAction,+ toolArgs: safeParseJSON(sibling.requestArgs) ?? {},+ }),+ ...(rememberAction === 'allow-list'+ ? { rememberToolKey: `${identifier}/${apiName}` }+ : {}),+ });+ } else {+ await approveToolCall(messageId, assistantGroupId ?? '', { editedArguments });+ }}} finally {setLoading(false);@@ -257,10 +287,12 @@ const ApprovalActions = memo<ApprovalActionsProps>(}, [apiName,approveToolCall,+ approveToolCallAndCovered,assistantGroupId,canUseResource,effectiveChoice,identifier,+ interventionConfig,isMessageCreating,loading,messageId,@@ -363,9 +395,9 @@ const ApprovalActions = memo<ApprovalActionsProps>(const rejectNumber = choices.indexOf('reject') + 1;- const approveLabel: Record<'approve' | 'approve-remember', string> = {- 'approve': t('tool.intervention.optionApprove'),- 'approve-remember': t('tool.intervention.optionApproveRemember'),+ const approveLabelFor = (c: 'approve' | 'approve-remember') => {+ const keys = approveChoiceLabelKeys({ apiName, choice: c, identifier });+ return t(keys.tool, { defaultValue: t(keys.shared), ns: 'plugin' });};// View-only members see the pending intervention but get no approval@@ -416,7 +448,7 @@ const ApprovalActions = memo<ApprovalActionsProps>(onClick={() => setChoice(c)}><span className={styles.number}>{index + 1}.</span>- <span className={styles.optionLabel}>{approveLabel[c]}</span>+ <span className={styles.optionLabel}>{approveLabelFor(c)}</span></div>);})}diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.test.ts b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.test.tsindex 1d9585f3844..0ec16153785 100644--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.test.ts+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.test.ts@@ -1,9 +1,12 @@import { describe, expect, it } from 'vitest';import {+ approveChoiceLabelKeys,canRememberViaAllowList,+ dynamicAuditType,getApprovalChoices,isChoiceSubmitBlocked,+ isCoveredByRemember,resolveRememberAction,} from './approvalGate';@@ -86,3 +89,79 @@ describe('canRememberViaAllowList', () => {);});});++describe('approveChoiceLabelKeys', () => {+ it('lets each tool name its own approval so consecutive steps of one flow read differently', () => {+ const dryRun = approveChoiceLabelKeys({+ apiName: 'dryRunWidget',+ choice: 'approve',+ identifier: 'builtin-dashboard',+ });+ const publish = approveChoiceLabelKeys({+ apiName: 'requestPublish',+ choice: 'approve',+ identifier: 'builtin-dashboard',+ });+ expect(dryRun.tool).toBe('builtins.builtin-dashboard.approve.dryRunWidget');+ expect(publish.tool).toBe('builtins.builtin-dashboard.approve.requestPublish');+ expect(dryRun.shared).toBe('tool.intervention.optionApprove');+ });++ it('keys the remember choice apart from the plain approve', () => {+ expect(+ approveChoiceLabelKeys({+ apiName: 'dryRunWidget',+ choice: 'approve-remember',+ identifier: 'builtin-dashboard',+ }),+ ).toEqual({+ shared: 'tool.intervention.optionApproveRemember',+ tool: 'builtins.builtin-dashboard.approveRemember.dryRunWidget',+ });+ });+});++describe('dynamicAuditType', () => {+ it('reads the audit type of a dynamic config only', () => {+ expect(dynamicAuditType({ dynamic: { type: 'dashboardDryRunAudit' } })).toBe(+ 'dashboardDryRunAudit',+ );+ expect(dynamicAuditType('always')).toBeUndefined();+ expect(dynamicAuditType(undefined)).toBeUndefined();+ });+});++describe('isCoveredByRemember', () => {+ it("re-runs the tool's audit: covered once the remembered access clears it", async () => {+ await expect(+ isCoveredByRemember({ audit: async () => false, rememberAction: 'tool', toolArgs: {} }),+ ).resolves.toBe(true);+ await expect(+ isCoveredByRemember({ audit: async () => true, rememberAction: 'tool', toolArgs: {} }),+ ).resolves.toBe(false);+ });++ it('keeps asking when the tool has no audit or the audit fails', async () => {+ await expect(isCoveredByRemember({ rememberAction: 'tool', toolArgs: {} })).resolves.toBe(+ false,+ );+ await expect(+ isCoveredByRemember({+ audit: async () => {+ throw new Error('offline');+ },+ rememberAction: 'tool',+ toolArgs: {},+ }),+ ).resolves.toBe(false);+ });++ it('covers allow-listed siblings unless they must always ask', async () => {+ await expect(+ isCoveredByRemember({ config: 'required', rememberAction: 'allow-list', toolArgs: {} }),+ ).resolves.toBe(true);+ await expect(+ isCoveredByRemember({ config: 'always', rememberAction: 'allow-list', toolArgs: {} }),+ ).resolves.toBe(false);+ });+});diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.ts b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.tsindex e487b78233e..30e5f2cb700 100644--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.ts+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/approvalGate.ts@@ -73,3 +73,65 @@ export const resolveRememberAction = ({}: {toolRemember: boolean;}): 'allow-list' | 'tool' => (toolRemember ? 'tool' : 'allow-list');++const APPROVE_LABEL_KEY = {+ 'approve': ['approve', 'tool.intervention.optionApprove'],+ 'approve-remember': ['approveRemember', 'tool.intervention.optionApproveRemember'],+} as const;++/**+ * The keys wording an approve choice: a builtin tool may name what approving+ * its call does (`plugin` key, e.g. "Approve dry run" vs "Approve+ * publishing"), so consecutive steps of one flow do not read as the same+ * approval; the shared `chat` wording is the fallback for every other tool.+ */+export const approveChoiceLabelKeys = ({+ apiName,+ choice,+ identifier,+}: {+ apiName: string;+ choice: Exclude<ApprovalChoice, 'reject'>;+ identifier: string;+}) => {+ const [toolKey, shared] = APPROVE_LABEL_KEY[choice];+ return { shared, tool: `builtins.${identifier}.${toolKey}.${apiName}` };+};++/** The dynamic audit type of an intervention config, when it has one. */+export const dynamicAuditType = (config: unknown): string | undefined => {+ if (!config || typeof config !== 'object' || Array.isArray(config)) return undefined;+ const dynamic = (config as { dynamic?: { type?: unknown } }).dynamic;+ return typeof dynamic?.type === 'string' ? dynamic.type : undefined;+};++/**+ * Whether a sibling call of the same tool, still waiting in the same parallel+ * batch, no longer needs approval once "approve, and don't ask again" took+ * effect. Siblings were audited when the model emitted them, before the+ * remember existed, so without this the user is asked again for the very+ * thing they just said not to ask about.+ *+ * Allow-list: the sibling is covered unless it must always ask. Tool's own+ * remember: the tool's audit is re-run with the remembered access; with no+ * audit, or when it fails, the sibling still asks (fails closed).+ */+export const isCoveredByRemember = async ({+ audit,+ config,+ rememberAction,+ toolArgs,+}: {+ audit?: (toolArgs: Record<string, unknown>) => boolean | Promise<boolean>;+ config?: unknown;+ rememberAction: 'allow-list' | 'tool';+ toolArgs: Record<string, unknown>;+}) => {+ if (rememberAction === 'allow-list') return canRememberViaAllowList({ config, toolArgs });+ if (!audit) return false;+ try {+ return !(await audit(toolArgs));+ } catch {+ return false;+ }+};diff --git a/src/features/Conversation/store/slices/tool/action.test.ts b/src/features/Conversation/store/slices/tool/action.test.tsindex 97c52aa42f0..806da99f7af 100644--- a/src/features/Conversation/store/slices/tool/action.test.ts+++ b/src/features/Conversation/store/slices/tool/action.test.ts@@ -3,12 +3,16 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { type ConversationContext, type ConversationHooks } from '../../../types';import { createStore } from '../../index';+import type { PendingIntervention } from '../data/pendingInterventions';+import { dataSelectors } from '../data/selectors';// Mock dependenciesconst mockApproveToolCalling = vi.fn();const mockRejectToolCalling = vi.fn();const mockRejectAndContinueToolCalling = vi.fn();const mockSubmitHeteroIntervention = vi.fn();+const mockApproveAllToolCalls = vi.fn();+const mockAddToolToAllowList = vi.fn();vi.mock('@/store/chat', () => ({useChatStore: {@@ -17,6 +21,7 @@ vi.mock('@/store/chat', () => ({messagesMap: {},operations: {},approveToolCalling: mockApproveToolCalling,+ approveAllToolCalls: mockApproveAllToolCalls,rejectToolCalling: mockRejectToolCalling,rejectAndContinueToolCalling: mockRejectAndContinueToolCalling,submitHeteroIntervention: mockSubmitHeteroIntervention,@@ -35,6 +40,10 @@ vi.mock('@/store/chat', () => ({},}));+vi.mock('@/store/user', () => ({+ useUserStore: { getState: () => ({ addToolToAllowList: mockAddToolToAllowList }) },+}));+vi.mock('@/store/chat/selectors', () => ({displayMessageSelectors: {lastDisplayMessageId: vi.fn(() => 'last-msg-id'),@@ -550,4 +559,86 @@ describe('Tool Actions', () => {);});});++ describe('approveToolCallAndCovered', () => {+ const context: ConversationContext = { agentId: 'agent', topicId: 'topic' };+ const pending = (+ toolMessageId: string,+ apiName = 'dryRunWidget',+ batchId = 'batch-1',+ ): PendingIntervention =>+ ({+ apiName,+ batchId,+ identifier: 'builtin-dashboard',+ operationId: 'op-1',+ requestArgs: JSON.stringify({ versionId: toolMessageId }),+ toolCallId: `call-${toolMessageId}`,+ toolMessageId,+ }) as PendingIntervention;++ const withPending = (items: PendingIntervention[]) =>+ vi.spyOn(dataSelectors, 'pendingInterventions').mockReturnValue(items);++ it('approves siblings the remember now covers together with the card, in one batch', async () => {+ withPending([pending('tool-a'), pending('tool-b'), pending('tool-c', 'requestPublish')]);+ const store = createStore({ context });+ const isCovered = vi.fn(async () => true);++ await act(async () => {+ await store.getState().approveToolCallAndCovered('tool-a', 'group-1', { isCovered });+ });++ // Only the same tool's calls are re-checked; another API in the batch still asks.+ expect(isCovered).toHaveBeenCalledTimes(1);+ expect(mockApproveAllToolCalls).toHaveBeenCalledWith(['tool-a', 'tool-b'], context);+ expect(mockApproveToolCalling).not.toHaveBeenCalled();+ });++ it('approves the card alone when no sibling is covered', async () => {+ withPending([pending('tool-a'), pending('tool-b')]);+ const store = createStore({ context });++ await act(async () => {+ await store.getState().approveToolCallAndCovered('tool-a', 'group-1', {+ isCovered: async () => false,+ rememberToolKey: 'builtin-dashboard/dryRunWidget',+ });+ });++ expect(mockApproveAllToolCalls).not.toHaveBeenCalled();+ expect(mockApproveToolCalling).toHaveBeenCalledWith('tool-a', 'group-1', context, {+ editedArguments: undefined,+ rememberToolKey: 'builtin-dashboard/dryRunWidget',+ });+ });++ it('writes the allow-list itself when siblings ride along on the batch approval', async () => {+ withPending([pending('tool-a'), pending('tool-b')]);+ const store = createStore({ context });++ await act(async () => {+ await store.getState().approveToolCallAndCovered('tool-a', 'group-1', {+ isCovered: async () => true,+ rememberToolKey: 'builtin-dashboard/dryRunWidget',+ });+ });++ expect(mockAddToolToAllowList).toHaveBeenCalledWith('builtin-dashboard/dryRunWidget');+ expect(mockApproveAllToolCalls).toHaveBeenCalledWith(['tool-a', 'tool-b'], context);+ });++ it('never reaches into another batch', async () => {+ withPending([pending('tool-a'), pending('tool-b', 'dryRunWidget', 'batch-2')]);+ const store = createStore({ context });+ const isCovered = vi.fn(async () => true);++ await act(async () => {+ await store.getState().approveToolCallAndCovered('tool-a', 'group-1', { isCovered });+ });++ expect(isCovered).not.toHaveBeenCalled();+ expect(mockApproveToolCalling).toHaveBeenCalled();+ });+ });});diff --git a/src/features/Conversation/store/slices/tool/action.ts b/src/features/Conversation/store/slices/tool/action.tsindex f0c1f407617..ee32d025e0a 100644--- a/src/features/Conversation/store/slices/tool/action.ts+++ b/src/features/Conversation/store/slices/tool/action.ts@@ -1,9 +1,10 @@import type { AgentInterventionSourceAction } from '@/services/aiAgent';import { useChatStore } from '@/store/chat';import { type StoreSetter } from '@/store/types';+import { useUserStore } from '@/store/user';import { type Store as ConversationStore } from '../../action';-import { getInterventionBatch } from '../data/pendingInterventions';+import { getInterventionBatch, type PendingIntervention } from '../data/pendingInterventions';import { dataSelectors } from '../data/selectors';/**@@ -65,6 +66,58 @@ export class ToolActionImpl {}};+ /**+ * "Approve, and don't ask again for similar actions" from one card, once its+ * remember step has taken effect.+ *+ * The other calls of the same tool in this card's parallel batch were+ * audited when the model emitted them, before the remember existed, so they+ * would still ask. Those `isCovered` now clears are approved together with+ * this card in one batch approval: the run continues once, and the user is+ * not asked again for what they just said not to ask about. A card with+ * staged argument edits approves alone, as the batch approval carries none.+ */+ approveToolCallAndCovered = async (+ toolMessageId: string,+ assistantGroupId: string,+ {+ editedArguments,+ isCovered,+ rememberToolKey,+ }: {+ editedArguments?: Record<string, unknown>;+ isCovered: (sibling: PendingIntervention) => Promise<boolean>;+ rememberToolKey?: string;+ },+ ): Promise<void> => {+ const pending = dataSelectors.pendingInterventions(this.#get());+ const active = pending.find((item) => item.toolMessageId === toolMessageId);+ const siblings = editedArguments+ ? []+ : getInterventionBatch(pending, active).filter(+ (item) =>+ item.toolMessageId !== toolMessageId &&+ item.identifier === active?.identifier &&+ item.apiName === active?.apiName,+ );+ const covered: string[] = [];+ for (const sibling of siblings) {+ if (await isCovered(sibling)) covered.push(sibling.toolMessageId);+ }++ if (covered.length === 0) {+ await this.approveToolCall(toolMessageId, assistantGroupId, {+ editedArguments,+ ...(rememberToolKey ? { rememberToolKey } : {}),+ });+ return;+ }++ // The batch approval approves once; the allow-list entry is written here.+ if (rememberToolKey) await useUserStore.getState().addToolToAllowList(rememberToolKey);+ await this.approveAllToolCalls([toolMessageId, ...covered]);+ };+/*** Approve every pending tool of a parallel batch in one action.*diff --git a/src/features/Dashboard/WidgetPreview/DryRunReview.tsx b/src/features/Dashboard/WidgetPreview/DryRunReview.tsxindex df6e297f45d..5d0c8d3eedd 100644--- a/src/features/Dashboard/WidgetPreview/DryRunReview.tsx+++ b/src/features/Dashboard/WidgetPreview/DryRunReview.tsx@@ -22,6 +22,7 @@ import {reviewStyles,ReviewUnavailable,} from './ReviewFacts';+import ReviewStage, { ReviewStageNote } from './ReviewStage';import { useWidgetReview } from './useWidgetReview';interface ExpectedPreviewProps {@@ -152,14 +153,12 @@ const DryRunReview = memo<DryRunReviewProps>(return (<Flexbox data-widget-dry-run-review={widgetId} gap={12}>- <Text weight={600}>{`${widget.title} · v${target.version}`}</Text>+ <ReviewStage stage={'dryRun'} title={widget.title} version={target.version}>+ <ReviewStageNote>{t('dryRun.intro')}</ReviewStageNote>+ </ReviewStage><ExpectedPreview target={target} versions={versions} widget={widget} />- {/* The intro introduces the access facts it sits above. */}- <Text fontSize={12} type={'secondary'}>- {t('dryRun.intro')}- </Text><Flexbox className={reviewStyles.section} gap={6}><Fact label={t('chat.definition')}><Text fontSize={12}>{widget.description || t('chat.noDefinition')}</Text>diff --git a/src/features/Dashboard/WidgetPreview/PublishReview.tsx b/src/features/Dashboard/WidgetPreview/PublishReview.tsxindex 59b373672fe..c8528b23672 100644--- a/src/features/Dashboard/WidgetPreview/PublishReview.tsx+++ b/src/features/Dashboard/WidgetPreview/PublishReview.tsx@@ -1,6 +1,8 @@'use client';-import { Alert, Flexbox, Skeleton, Text } from '@lobehub/ui';+import { Alert, cssVar, Flexbox, Icon, Skeleton, Text } from '@lobehub/ui';+import dayjs from 'dayjs';+import { CircleCheckIcon } from 'lucide-react';import { memo } from 'react';import { useTranslation } from 'react-i18next';@@ -16,6 +18,7 @@ import {reviewStyles,ReviewUnavailable,} from './ReviewFacts';+import ReviewStage, { ReviewStageNote } from './ReviewStage';import { useWidgetReview } from './useWidgetReview';interface PublishReviewProps {@@ -71,10 +74,21 @@ const PublishReview = memo<PublishReviewProps>(return (<Flexbox data-widget-publish-review={widgetId} gap={12}>- <Flexbox gap={4}>- <Text weight={600}>{`${widget.title} · v${target.version}`}</Text>+ <ReviewStage stage={'publish'} title={widget.title} version={target.version}>{summary && <Text fontSize={13}>{summary}</Text>}- </Flexbox>+ {/* Says the dry run is behind it, so this does not read as approving it again. */}+ {run && (+ <Flexbox horizontal align={'center'} gap={4}>+ <Icon color={cssVar.colorSuccess} icon={CircleCheckIcon} size={12} />+ <ReviewStageNote>+ {t('publish.dryRunPassed', {+ time: dayjs(run.finishedAt ?? run.startedAt).fromNow(),+ version: target.version,+ })}+ </ReviewStageNote>+ </Flexbox>+ )}+ </ReviewStage>{run ? (<ReviewSection title={t('review.expected')}>diff --git a/src/features/Dashboard/WidgetPreview/ReviewStage.tsx b/src/features/Dashboard/WidgetPreview/ReviewStage.tsxnew file mode 100644index 00000000000..266103dc0ff--- /dev/null+++ b/src/features/Dashboard/WidgetPreview/ReviewStage.tsx@@ -0,0 +1,92 @@+'use client';++import { Badge, Flexbox, Icon, Steps, Text } from '@lobehub/ui';+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';+import { CheckIcon } from 'lucide-react';+import { memo, type ReactNode } from 'react';+import { useTranslation } from 'react-i18next';++import { type ReviewStageStep, type ReviewStepState, reviewStepStates } from './reviewSteps';++const styles = stylex.create({+ check: {+ color: cssVar.colorSuccess,+ display: 'inline-flex',+ },+ description: {+ color: cssVar.colorTextDescription,+ },+ root: {+ paddingBlockStart: 8,+ },+});++// The step markers are status dots, not numbered circles: drop the circle so+// the current step reads as the blue live dot the rest of the app uses.+const INDICATOR_STYLE = {+ backgroundColor: 'transparent',+ borderWidth: 0,+ height: 14,+ width: 14,+};+const TITLE_STYLE = { fontSize: 13 };++const StepMarker = ({ state }: { state: ReviewStepState }) => {+ if (state === 'done') {+ return (+ <span {...stylex.props(styles.check)}>+ <Icon icon={CheckIcon} size={14} />+ </span>+ );+ }+ return <Badge status={state === 'current' ? 'processing' : 'default'} />;+};++interface ReviewStageProps {+ /** Under the title: what approving this stage does, or how the previous one went. */+ children?: ReactNode;+ stage: ReviewStageStep;+ title: string;+ version: number;+}++/**+ * A widget asks for approval twice — to dry-run a draft, then to publish it —+ * and both cards review the same widget and version. Without the path and the+ * stage in the heading the second reads as a repeat of the first.+ */+const ReviewStage = memo<ReviewStageProps>(({ children, stage, title, version }) => {+ const { t } = useTranslation('dashboard');+ const steps = reviewStepStates(stage);++ return (+ <Flexbox gap={12} {...stylex.props(styles.root)}>+ <Steps+ aria-label={t('review.stage.label')}+ current={steps.findIndex(({ state }) => state === 'current')}+ styles={{ indicator: INDICATOR_STYLE, title: TITLE_STYLE }}+ items={steps.map(({ state, step }) => ({+ icon: <StepMarker state={state} />,+ key: step,+ title: t(`review.stage.${step}`),+ }))}+ />+ <Flexbox gap={4}>+ <Text weight={600}>{t(`review.title.${stage}`, { title, version })}</Text>+ {children}+ </Flexbox>+ </Flexbox>+ );+});++ReviewStage.displayName = 'DashboardReviewStage';++/** Copy under a review title: the description tone, quieter than the title. */+export const ReviewStageNote = ({ children }: { children: ReactNode }) => (+ <Text fontSize={12} {...stylex.props(styles.description)}>+ {children}+ </Text>+);++export default ReviewStage;diff --git a/src/features/Dashboard/WidgetPreview/reviewSteps.test.ts b/src/features/Dashboard/WidgetPreview/reviewSteps.test.tsnew file mode 100644index 00000000000..3ff65740ca6--- /dev/null+++ b/src/features/Dashboard/WidgetPreview/reviewSteps.test.ts@@ -0,0 +1,21 @@+import { describe, expect, it } from 'vitest';++import { reviewStepStates } from './reviewSteps';++describe('reviewStepStates', () => {+ it('puts a dry-run approval after the draft and before publishing', () => {+ expect(reviewStepStates('dryRun')).toEqual([+ { state: 'done', step: 'draft' },+ { state: 'current', step: 'dryRun' },+ { state: 'upcoming', step: 'publish' },+ ]);+ });++ it('shows the dry run as behind a publish approval, so it does not read as a repeat', () => {+ expect(reviewStepStates('publish')).toEqual([+ { state: 'done', step: 'draft' },+ { state: 'done', step: 'dryRun' },+ { state: 'current', step: 'publish' },+ ]);+ });+});diff --git a/src/features/Dashboard/WidgetPreview/reviewSteps.ts b/src/features/Dashboard/WidgetPreview/reviewSteps.tsnew file mode 100644index 00000000000..d55bcd41ea7--- /dev/null+++ b/src/features/Dashboard/WidgetPreview/reviewSteps.ts@@ -0,0 +1,22 @@+/** A widget's path from authoring to live; each step after the draft asks for approval. */+export const REVIEW_STEPS = ['draft', 'dryRun', 'publish'] as const;++export type ReviewStep = (typeof REVIEW_STEPS)[number];++/** The approval a review card asks for; drafting itself never asks. */+export type ReviewStageStep = Exclude<ReviewStep, 'draft'>;++export type ReviewStepState = 'current' | 'done' | 'upcoming';++/** Every step of the path with where it stands while `stage` is being approved. */+export const reviewStepStates = (stage: ReviewStageStep) => {+ const currentIndex = REVIEW_STEPS.indexOf(stage);+ return REVIEW_STEPS.map((step, index) => ({+ state: (index < currentIndex+ ? 'done'+ : index === currentIndex+ ? 'current'+ : 'upcoming') as ReviewStepState,+ step,+ }));+};