Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(bots): 对话内开始跟进先确认范围与额度再保存

zqchris4edc239e7cc6
diff --git a/apps/desktop/scripts/fixtures/bot-follow-up/ui-page.mjs b/apps/desktop/scripts/fixtures/bot-follow-up/ui-page.mjs
index c35cfc5e69..51167cb532 100644
--- a/apps/desktop/scripts/fixtures/bot-follow-up/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/bot-follow-up/ui-page.mjs
@@ -11,7 +11,7 @@ export default {
cases: {
'before-chat': { about: 'Opening alone never invites; an accepted message reveals the invitation' },
'remote': { about: 'Remote chat uses the same invitation with the host-owned scope and choice' },
- 'default': { about: 'One-line invitation after an accepted user message; scope and model allowance sit in the Start tooltip' },
+ 'default': { about: 'One-line invitation after an accepted user message; Start opens the settings confirmation with scope and model allowance before saving' },
'settings-off': { about: 'Off by default; explain scope before enabling' },
'settings-on': { about: 'An explicit choice is preserved; disabling is immediate' },
},
diff --git a/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx b/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx
index e927bb4192..84df2bbde0 100644
--- a/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx
@@ -2,7 +2,7 @@ import { useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
-import { Tip } from '@/components/ui/tooltip';
+import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';
import { toast } from '@/lib/toast';
import { setBotSchedulerBotId, useBotAutonomySettings } from './botStore';
@@ -38,17 +38,26 @@ export function BotFollowUpInvitationCard({ pending, onChoose, consent }: {
pending: boolean; onChoose(enable: boolean): void | Promise<void>; consent?: string;
}) {
const { t } = useTranslation();
- // 一行轻提示(大字号或窄输入框时按钮换到下一行):读什么、花额度的说明放在「开始跟进」的悬停提示里,同时作为它的可访问描述。
+ const { confirm } = useConfirmDialog();
+ // 卡片只占一行;读什么、会用模型额度在开启前的确认框里完整说明(与设置页同一确认),确认后才保存。
const scope = consent ?? t('bots.autonomy.consent');
+ const start = async () => {
+ const accepted = await confirm({
+ presentation: 'standard',
+ title: t('bots.autonomy.invitation.title'),
+ description: scope,
+ confirmText: t('bots.autonomy.invitation.start'),
+ cancelText: t('bots.autonomy.invitation.notNow'),
+ });
+ if (accepted) await onChoose(true);
+ };
return (
<section
className="flex w-full flex-wrap items-center justify-end gap-x-2 gap-y-1 rounded-xl border border-[var(--border-default)] py-1.5 pl-3 pr-1.5"
aria-label={t('bots.autonomy.invitation.title')}
>
<p className="min-w-[8rem] flex-1 text-13 leading-5 text-[var(--text-primary)]">{t('bots.autonomy.invitation.title')}</p>
- <Tip text={scope}>
- <Button variant="cta" size="sm" aria-description={scope} disabled={pending} onClick={() => void onChoose(true)}>{t('bots.autonomy.invitation.start')}</Button>
- </Tip>
+ <Button variant="cta" size="sm" disabled={pending} onClick={() => void start()}>{t('bots.autonomy.invitation.start')}</Button>
<Button variant="secondary" tone="quiet" size="sm" disabled={pending} onClick={() => void onChoose(false)}>{t('bots.autonomy.invitation.notNow')}</Button>
</section>
);
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx
index e6019d8256..d9e953aac0 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx
@@ -150,12 +150,24 @@ it.each([true, false])('invites only after engagement, then persists the choice
fireEvent.click(screen.getByRole('button', { name: enable ? 'bots.autonomy.invitation.start' : 'bots.autonomy.invitation.notNow' }));
await waitFor(() => expect(screen.queryByRole('region')).toBeNull());
expect(host.setSettings).toHaveBeenCalledWith({ schedulerBotId: enable ? 'cindy-default' : null });
+ // Starting shows scope and usage in the same confirmation as settings before saving; declining needs none.
+ if (enable) expect(m.confirm).toHaveBeenCalledWith(expect.objectContaining({ description: 'bots.autonomy.consent' }));
+ else expect(m.confirm).not.toHaveBeenCalled();
unmount();
render(<BotFollowUpInvitation botId="cindy-default" engaged />);
await waitFor(() => expect(host.getSettings).toHaveBeenCalledTimes(2));
expect(screen.queryByRole('region')).toBeNull();
});
+it('keeps the invitation and saves nothing when the confirmation is cancelled', async () => {
+ render(<BotFollowUpInvitation botId="cindy-default" engaged />);
+ m.confirm.mockResolvedValueOnce(false);
+ fireEvent.click(await screen.findByRole('button', { name: 'bots.autonomy.invitation.start' }));
+ await waitFor(() => expect(m.confirm).toHaveBeenCalledOnce());
+ expect(host.setSettings).not.toHaveBeenCalled();
+ expect(screen.getByRole('region')).toBeTruthy();
+});
+
it('keeps the invitation available when saving fails', async () => {
render(<BotFollowUpInvitation botId="cindy-default" engaged />);
const button = await screen.findByRole('button', { name: 'bots.autonomy.invitation.start' });
@@ -187,12 +199,12 @@ it.each([true, false])('remote invitation uses the host-bound choice, enable=%s'
const invoke = vi.fn(async (_device, channel) => channel.endsWith(':get') ? resource : { effects: [] });
Object.assign(window.electronAPI, { deviceLink: { invoke } });
render(<RemoteBotFollowUpInvitation deviceId="host-computer" botId="cindy-default" />);
- // The host-owned scope (not this computer's copy) describes the Start button.
- const start = await screen.findByRole('button', { name: 'bots.autonomy.invitation.start' });
- expect(start.getAttribute('aria-description')).toBe(resource.blocks[0].fallbackMarkdown);
+ await screen.findByRole('button', { name: 'bots.autonomy.invitation.start' });
expect(invoke).toHaveBeenCalledTimes(1);
fireEvent.click(screen.getByText(enable ? 'bots.autonomy.invitation.start' : 'bots.autonomy.invitation.notNow'));
await waitFor(() => expect(screen.queryByRole('region')).toBeNull());
+ // The host-owned scope (not this computer's copy) is what the confirmation shows.
+ if (enable) expect(m.confirm).toHaveBeenCalledWith(expect.objectContaining({ description: resource.blocks[0].fallbackMarkdown }));
expect(invoke).toHaveBeenLastCalledWith('host-computer', 'maker:remote-resources:invoke', [expect.objectContaining({
resourceRef: ref, actionId: enable ? 'opaque-enable' : 'opaque-dismiss', input: enable ? { enabled: true } : {},
})]);
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 41efef353b..6f5b0541e5 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -3020,6 +3020,6 @@ namespace + id 下同一插件的有界 JSON 请求;`deviceSync: true` 是独
旧票、隐藏伙伴与账号切换沿用既有拒绝规则,不新增 invoke channel 或共享访客权限。
新 Host 对旧查看端仍执行默认关闭;旧端忽略新增入口/字段,已有聊天不变。新查看端连接旧 Host
时不显示邀请,不能声称旧 Host 已执行新默认。Desktop 本机与远程 Desktop 的对话内邀请是一行轻提示,
-范围及用量(远程时取 Host 下发的文字)放在「开始跟进」的悬停提示与可访问描述里(2026-10-22 Chris 确认);
-设置页开关开启前的确认框仍完整显示。Mobile iOS/Android 复用现有设置表单与按钮并显示范围及用量;
+点「开始跟进」先弹与设置页同一确认框,完整显示范围及用量(远程时取 Host 下发的文字),确认后才保存;
+「暂不开启」直接保存。Mobile iOS/Android 复用现有设置表单与按钮并显示范围及用量;
没有原生配置、依赖、指纹或数据库迁移变化。