Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 远程跟进确认后换新动作票;同账号代次修复不丢确认
zqchrisd4c59a233cec
diff --git a/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx b/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsxindex 9bf7a05aa9..f35159fa07 100644--- a/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx+++ b/apps/desktop/src/renderer/features/bots/BotFollowUpInvitation.tsx@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';import { Button } from '@/components/ui/button';import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';-import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';+import { getDataOwnerGeneration, isDataOwnerGenerationCurrent, isDataOwnerIdCurrent } from '@/contexts/dataOwnerGeneration';import { toast } from '@/lib/toast';import { setBotSchedulerBotId, useBotAutonomySettings } from './botStore';@@ -67,7 +67,8 @@ export function BotFollowUpInvitationCard({ pending, onChoose, consent }: {confirmText: t('bots.autonomy.invitation.start'),cancelText: t('bots.autonomy.invitation.notNow'),}, controller.signal);- if (accepted && mounted.current && isDataOwnerGenerationCurrent(owner)) await onChoose(true);+ // 同一账号内的代次修复不卸载卡片,确认仍有效;换了账号才丢弃。+ if (accepted && mounted.current && isDataOwnerIdCurrent(owner)) await onChoose(true);} finally {asking.current = false;if (dialog.current === controller) dialog.current = null;diff --git a/apps/desktop/src/renderer/features/bots/RemoteBotFollowUpInvitation.tsx b/apps/desktop/src/renderer/features/bots/RemoteBotFollowUpInvitation.tsxindex 4bd96accdf..0c2cbb3e36 100644--- a/apps/desktop/src/renderer/features/bots/RemoteBotFollowUpInvitation.tsx+++ b/apps/desktop/src/renderer/features/bots/RemoteBotFollowUpInvitation.tsx@@ -25,13 +25,26 @@ export function RemoteBotFollowUpInvitation({ deviceId, botId }: { deviceId: strconst panel = data?.panels.find(item => item.id === 'follow-up');if (!data || !panel?.invitationAvailable || !panel.action || !panel.dismissAction) return null;const choose = async (enable: boolean) => {- const actionId = (enable ? panel.action : panel.dismissAction)?.id;- if (saving.current || !actionId) return;+ if (saving.current || !(enable ? panel.action : panel.dismissAction)) return;saving.current = true; setPending(true);const owner = getDataOwnerGeneration();try {+ let target = { data, panel };+ if (enable) {+ // 确认框可能开了很久,Host 的动作票会过期:确认后按未变的 revision 换一张新票再提交。+ const fresh = await readRemoteBotSettings(deviceId, `settings:${botId}/follow-up`, i18n.language);+ if (!alive.current || !isDataOwnerGenerationCurrent(owner)) return;+ const freshPanel = fresh.panels.find(item => item.id === 'follow-up');+ if (fresh.resource.revision !== data.resource.revision || !freshPanel?.invitationAvailable || !freshPanel.action) {+ setData(fresh);+ return;+ }+ target = { data: fresh, panel: freshPanel };+ }+ const actionId = (enable ? target.panel.action : target.panel.dismissAction)?.id;+ if (!actionId) return;await window.electronAPI.deviceLink.invoke(deviceId, REMOTE_RESOURCE_INVOKE_CHANNEL, [{- client: settingsClient(i18n.language), collectionId: 'teammates', resourceRef: data.resource.ref,+ client: settingsClient(i18n.language), collectionId: 'teammates', resourceRef: target.data.resource.ref,actionId, input: enable ? { enabled: true } : {},}]);if (alive.current && isDataOwnerGenerationCurrent(owner)) setData(null);diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsxindex 7c35e6ed05..94fe00cfcc 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/botAutonomySettings.test.tsx@@ -183,6 +183,17 @@ it('asks once for a double click and drops a confirmation that returns after thedataOwnerTesting.reset();});+it('still saves a confirmation across a same-account generation repair', async () => {+ render(<BotFollowUpInvitation botId="cindy-default" engaged />);+ let answer!: (value: boolean) => void;+ m.confirm.mockImplementationOnce(() => new Promise<boolean>((done) => { answer = done; }));+ fireEvent.click(await screen.findByRole('button', { name: 'bots.autonomy.invitation.start' }));+ setDataOwnerGeneration(null);+ await act(async () => answer(true));+ expect(host.setSettings).toHaveBeenCalledWith({ schedulerBotId: 'cindy-default' });+ dataOwnerTesting.reset();+});+it('closes a pending confirmation when the invitation goes away', async () => {const { unmount } = render(<BotFollowUpInvitation botId="cindy-default" engaged />);m.confirm.mockImplementationOnce(() => new Promise<boolean>(() => {}));@@ -233,5 +244,7 @@ it.each([true, false])('remote invitation uses the host-bound choice, enable=%s'expect(invoke).toHaveBeenLastCalledWith('host-computer', 'maker:remote-resources:invoke', [expect.objectContaining({resourceRef: ref, actionId: enable ? 'opaque-enable' : 'opaque-dismiss', input: enable ? { enabled: true } : {},})]);+ // Starting re-reads the Host after confirmation so an expired ticket is renewed; declining uses the shown one.+ expect(invoke.mock.calls.filter(([, channel]) => String(channel).endsWith(':get'))).toHaveLength(enable ? 2 : 1);expect(host.setSettings).not.toHaveBeenCalled();});