Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): 切换账号后停止批量重试贴回,跳转在减弱动效下不平滑滚动
Dashc42274ff77f5
diff --git a/apps/desktop/src/renderer/features/bots/BotGroupThreadViews.tsx b/apps/desktop/src/renderer/features/bots/BotGroupThreadViews.tsxindex d10c311dff..247e4f54dc 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupThreadViews.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupThreadViews.tsx@@ -32,7 +32,8 @@ export function findThreadMessageElement(container: HTMLElement | null, messageI/** Bring a jumped-to message into view and outline it briefly, without moving focus. */export function flashThreadTarget(target: HTMLElement) {- target.scrollIntoView?.({ block: 'center', behavior: 'smooth' });+ const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;+ target.scrollIntoView?.({ block: 'center', behavior: reduced ? 'auto' : 'smooth' });target.classList.add(...FLASH_CLASSES);window.setTimeout(() => target.classList.remove(...FLASH_CLASSES), FLASH_MS);}diff --git a/apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx b/apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsxindex 4df1d417a1..db0f28e1bd 100644--- a/apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx+++ b/apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx@@ -215,7 +215,12 @@ export function ChatThreadPanel({ group, rootId, quoteSources = group.messages,finally { postingRef.current.delete(messageId); setPosting(new Set(postingRef.current)); }}async function retryUnposted() {- for (const messageId of unposted) await postToMain(messageId, true);+ // The queue belongs to the account that started the retry; stop once it is switched.+ const owner = getDataOwnerGeneration();+ for (const messageId of unposted) {+ if (!isDataOwnerGenerationCurrent(owner)) return;+ await postToMain(messageId, true);+ }}async function send() {if (group.archived || sending.current || !text.trim()) return;diff --git a/apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsxindex aaa6417064..fee7412fc8 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsx@@ -5,13 +5,14 @@ import { Tooltip } from '@/components/ui/tooltip';import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest';import { ChatInviteButton, ChatJoinButton, ChatMessageActions } from '../ChatServerControls';import { ChatThreadPanel } from '../ChatThreadPanel';+import { flashThreadTarget } from '../BotGroupThreadViews';import type { BotGroupDetail, BotGroupMessageView } from '../../../../shared/botGroupChat';import { shareSelectionStore } from '@/components/chat/shareSelectionStore';import { queryShareableMessageIds, stripInteractiveElements } from '@/lib/shareConversationImage';const mocks = vi.hoisted(() => ({status: vi.fn(), react: vi.fn(), thread: vi.fn(), reply: vi.fn(), createInvite: vi.fn(), previewInvite: vi.fn(), acceptInvite: vi.fn(),- refresh: vi.fn(), ownerCurrent: true,+ refresh: vi.fn(), shareToMain: vi.fn(), ownerCurrent: true,}));vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }) }));vi.mock('@/components/chat/MarkdownRenderer', () => ({ MarkdownRenderer: ({ content }: { content: string }) => <div>{content}</div> }));@@ -99,6 +100,38 @@ describe('chat interaction controls', () => {expect(mocks.thread.mock.calls.at(-1)?.[0]).toMatchObject({ sourceMessageIds: [older.id, latest.id] });});+ it('stops a bulk retry of main-chat copies once the account is switched', async () => {+ mocks.reply.mockResolvedValueOnce({ ok: true, messageId: 'first' }).mockResolvedValueOnce({ ok: true, messageId: 'second' });+ mocks.shareToMain.mockResolvedValue({ ok: false, errorCode: 'SERVICE_ERROR' });+ render(<ChatThreadPanel group={group} rootId="retry-root" onClose={vi.fn()} />);+ const input = screen.getByRole('textbox', { name: k('replyPlaceholder') });+ for (const [count, text] of [[1, 'one'], [2, 'two']] as const) {+ fireEvent.click(screen.getByRole('checkbox', { name: k('thread.alsoSend') }));+ fireEvent.change(input, { target: { value: text } });+ fireEvent.click(screen.getByRole('button', { name: k('sendReply') }));+ await waitFor(() => expect(mocks.shareToMain).toHaveBeenCalledTimes(count));+ }+ const retry = await screen.findByRole('button', { name: k('thread.retryPost') });+ let finish!: (value: unknown) => void;+ mocks.shareToMain.mockClear().mockReturnValueOnce(new Promise(resolve => { finish = resolve; }))+ .mockResolvedValue({ ok: true, messageId: 'share', alreadyShared: false });+ fireEvent.click(retry);+ await waitFor(() => expect(mocks.shareToMain).toHaveBeenCalledTimes(1));+ // The account changes while the first copy is in flight: the second must not go out.+ mocks.ownerCurrent = false;+ finish({ ok: true, messageId: 'share', alreadyShared: false });+ await new Promise(resolve => setTimeout(resolve, 0));+ expect(mocks.shareToMain).toHaveBeenCalledTimes(1);+ });++ it.each([[true, 'auto'], [false, 'smooth']] as const)('jumps to a shared reply without smooth scrolling when reduced motion is %s', (reduced, behavior) => {+ vi.stubGlobal('matchMedia', (query: string) => ({ matches: reduced && query === '(prefers-reduced-motion: reduce)' }));+ const target = document.createElement('article');+ target.scrollIntoView = vi.fn();+ flashThreadTarget(target);+ expect(target.scrollIntoView).toHaveBeenCalledWith({ block: 'center', behavior });+ });+it('keeps looking for a shared reply when group pushes overtake its older-page reads', async () => {const latest = { ...message, id: 'latest', sequence: 100, content: 'Latest reply' };const target = { ...message, id: 'target', sequence: 4, content: 'Target reply' };