Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(group-chat): keep dissolved history read-only and preserve error copy
zqchrisbd38158cfe76
diff --cc apps/desktop/src/renderer/features/bots/BotGroupChatView.tsxindex 3d3def8502,eaa4713efb..1ef17ea4b2--- a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx@@@ -847,7 -842,7 +847,7 @@@ function BotGroupChatContent({ groupIdactions={message.kind === 'message' ? <ChatMessageActionsgroupId={group.serverBacked ? group.id : undefined} shareScope={shareScope} message={message}align={message.authorKind === 'user' && message.isSelf !== false ? 'right' : 'left'}-- onQuote={group.serverBacked && !group.archived && isBotGroupMessageQuotable(message)++ onQuote={group.serverBacked && !group.archived && !group.dissolvedAt && isBotGroupMessageQuotable(message)? () => setQuoteDraft(botGroupQuoteFromMessage(message)) : undefined}onReply={group.serverBacked ? () => {threadOpenerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;@@@ -923,7 -918,7 +923,7 @@@</div>)}{sharing ? <ShareSelectionBar sessionId={shareScope} barWidth="100%"- getContentWidth={() => contentRef.current?.querySelector('article')?.getBoundingClientRect().width ?? 760} /> : group.archived ? <p className="border-t border-[var(--border-default)] p-4 text-center text-13 text-[var(--text-tertiary)]">{t(group.dissolvedAt ? 'bots.groupChat.lifecycle.dissolved' : 'bots.groupChat.server.settings.archived')}</p> : <BotGroupComposer- getContentWidth={() => contentRef.current?.querySelector('article')?.getBoundingClientRect().width ?? 760} /> : group.archived ? <p className="border-t border-[var(--border-default)] p-4 text-center text-13 text-[var(--text-tertiary)]">{t('bots.groupChat.server.settings.archived')}</p> : <BotGroupComposer++ getContentWidth={() => contentRef.current?.querySelector('article')?.getBoundingClientRect().width ?? 760} /> : group.archived || group.dissolvedAt ? <p className="border-t border-[var(--border-default)] p-4 text-center text-13 text-[var(--text-tertiary)]">{t(group.dissolvedAt ? 'bots.groupChat.lifecycle.dissolved' : 'bots.groupChat.server.settings.archived')}</p> : <BotGroupComposergroupId={group.id}members={group.members}running={running}diff --cc apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsxindex 2c83422814,2c83422814..d952f19ed1--- a/apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx+++ b/apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx@@@ -66,6 -66,6 +66,7 @@@ export function ChatThreadPanel({ groupconst titleId = useId();const shareScope = `bot-group:${group.id}:thread:${rootId}`;const sharing = useShareSelectionActive(shareScope);++ const readOnly = Boolean(group.archived || group.dissolvedAt);const contentRef = useRef<HTMLDivElement>(null);const panelRef = useRef<HTMLElement>(null);useEffect(() => {@@@ -118,7 -118,7 +119,7 @@@return () => { request.current++; stop(); };}, [group.id, rootId]);async function send() {-- if (group.archived || sending.current || !text.trim()) return;++ if (readOnly || sending.current || !text.trim()) return;sending.current = true; setBusy(true); setError('');const owner = getDataOwnerGeneration();// A retry reuses the attempt only for the same text and the same targets (bot-group-chat.md).@@@ -157,12 -157,12 +158,12 @@@getContentWidth={() => contentRef.current?.querySelector('article')?.getBoundingClientRect().width ?? 400} /> : <div className={BOT_GROUP_COMPOSER_DOCK}><div className={BOT_GROUP_COMPOSER_COLUMN}>{error && <p role="alert" className="mb-2 px-1 text-13 leading-5 text-[var(--error-fg)]">{error}</p>}{/* Read-only also means no @ picks while sending. */}-- {busy ? null : mention.list}++ {busy || readOnly ? null : mention.list}{/* Same card as the main group's composer; a sending reply stays read-only (and focused) until main answers. */}<div className={BOT_GROUP_COMPOSER_CARD} aria-busy={busy || undefined}><textarea ref={inputRef} rows={1} aria-label={t(key('replyPlaceholder'))} placeholder={t(key('replyPlaceholder'))} value={text}{...mention.textareaProps} onChange={e => mention.onChange(e.target.value)}-- maxLength={8000} readOnly={busy} disabled={group.archived} className={BOT_GROUP_COMPOSER_INPUT} onKeyDown={e => {++ maxLength={8000} readOnly={busy} disabled={readOnly} className={BOT_GROUP_COMPOSER_INPUT} onKeyDown={e => {if (e.nativeEvent.isComposing || e.keyCode === 229 || (!busy && mention.onKeyDown(e))) return;if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); void send(); }}} />@@@ -171,7 -171,7 +172,7 @@@<div className={BOT_GROUP_COMPOSER_FOOTER_START} /><span className="inline-flex rounded-full" onMouseDown={keepBotGroupComposerInputFocus(inputRef)}><Tip text={t(key('sendReply'))}>-- <SendButton ariaLabel={t(key('sendReply'))} disabled={group.archived || busy || !text.trim()} onClick={() => void send()} />++ <SendButton ariaLabel={t(key('sendReply'))} disabled={readOnly || busy || !text.trim()} onClick={() => void send()} /></Tip></span></div>diff --cc apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsxindex b486d0df0e,7cd8105437..dc017e009a--- a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx@@@ -351,6 -343,6 +351,20 @@@ describe('BotGroupChatView', () =>expect(screen.queryByText('bots.groupChat.server.settings.archived')).toBeNull();});++ it('replaces the composer with read-only history when dissolved without being archived', async () => {++ const live = detail({ serverBacked: true, archived: false,++ messages: [msg({ content: 'Preserved dissolved history' })],++ });++ mocks.getBotGroup.mockResolvedValue({ ok: true, group: live });++ renderView();++ await screen.findByRole('textbox');++ mocks.getBotGroup.mockResolvedValue({ ok: true, group: { ...live, dissolvedAt: '2026-10-15T00:00:00.000Z' } });++ act(() => { mocks.pushes.forEach(push => push({ groupId: 'g1', change: 'updated' })); });++ await screen.findByText('bots.groupChat.lifecycle.dissolved');++ expect(screen.queryByRole('textbox')).toBeNull();++ expect(screen.getByText('Preserved dissolved history')).toBeTruthy();++ });++function mockThreadMotion(duration: string) {const style = document.createElement('style');style.textContent = `aside { --motion-base: ${duration}; --motion-ease-move: linear; }`;diff --cc apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsxindex dbee91d28f,dbee91d28f..2f2b918444--- a/apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/ChatServerControls.test.tsx@@@ -6,6 -6,6 +6,7 @@@ import { afterEach, beforeEach, describimport { ChatInviteButton, ChatMessageActions } from '../ChatServerControls';import { ChatInviteDialog } from '../ChatInviteDialog';import { ChatThreadPanel } from '../ChatThreadPanel';++import { chatErrorKey } from '../chatError';import type { BotGroupDetail, BotGroupMessageView } from '../../../../shared/botGroupChat';import { shareSelectionStore } from '@/components/chat/shareSelectionStore';import { queryShareableMessageIds, stripInteractiveElements } from '@/lib/shareConversationImage';@@@ -43,10 -43,10 +44,19 @@@ beforeEach(() =>afterEach(() => { cleanup(); shareSelectionStore.reset(); vi.unstubAllGlobals(); });describe('chat interaction controls', () => {-- it('focuses the close button when the archived thread reply input is disabled', () => {-- render(<ChatThreadPanel group={{ ...group, archived: true }} rootId="root" onClose={vi.fn()} />);++ it.each([{ archived: true }, { archived: false, dissolvedAt: '2026-10-15T00:00:00.000Z' }])('keeps terminal thread replies read-only and focuses close (%j)', async state => {++ render(<ChatThreadPanel group={{ ...group, ...state }} rootId="root" onClose={vi.fn()} />);++ await screen.findByText('Root message');expect((screen.getByRole('textbox') as HTMLTextAreaElement).disabled).toBe(true);expect(document.activeElement).toBe(screen.getByRole('button', { name: 'bots.close' }));++ fireEvent.change(screen.getByRole('textbox'), { target: { value: 'Unsent reply' } });++ fireEvent.keyDown(screen.getByRole('textbox'), { key: 'Enter' });++ expect((screen.getByRole('button', { name: k('sendReply') }) as HTMLButtonElement).disabled).toBe(true);++ expect(mocks.reply).not.toHaveBeenCalled();++ });++++ it.each(['GROUP_DISSOLVED', 'CONVERSATION_DISSOLVED'])('maps dissolution error %s to its explanation', code => {++ expect(chatErrorKey(code)).toBe('bots.groupChat.lifecycle.dissolved');});it('refits a typed thread reply when the panel width changes, not when only its height does', () => {diff --cc apps/desktop/src/renderer/features/bots/chatError.tsindex 9c9e33ee69,702836fa53..43ffbac9e9--- a/apps/desktop/src/renderer/features/bots/chatError.ts+++ b/apps/desktop/src/renderer/features/bots/chatError.ts@@@ -4,8 -4,6 +4,8 @@@ export function chatErrorKey(code: striif (code === 'INVITE_REVOKE_UNSUPPORTED') return key('revokeUnsupported');if (['INVITATION_NOT_FOUND', 'INVITATION_UNAVAILABLE', 'INVALID_INPUT'].includes(code)) return key('invalidInvite');if (code === 'MENTION_UNAVAILABLE') return 'bots.groupChat.errors.mentionUnavailable';+ if (code === 'LIFECYCLE_UNAVAILABLE') return 'bots.groupChat.lifecycle.unavailable';- if (code === 'CONVERSATION_DISSOLVED') return 'bots.groupChat.lifecycle.dissolved';++ if (['GROUP_DISSOLVED', 'CONVERSATION_DISSOLVED'].includes(code)) return 'bots.groupChat.lifecycle.dissolved';if (code === 'LAST_OWNER') return key('settings.lastOwner');if (code === 'REVISION_CONFLICT') return key('settings.conflict');if (['FORBIDDEN', 'ROLE_REQUIRED', 'OWNER_REQUIRED', 'ACTOR_NOT_OWNED', 'IDENTITY_DOMAIN_MISMATCH'].includes(code)) return key('notAllowed');diff --cc apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex 1ec3b62906,1e80fc5dba..9eedbfb50e--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@@ -540,6 -537,6 +540,21 @@@ describe('group composer', () =>});}++ it.each([true, false])('locks an existing draft when dissolved without being archived (direct server %s)', async server => {++ h.chat.server = server;++ const live = group({ openPlan: null, archived: false });++ await render(live);++ await type('Unsent draft');++ expect(h.row.editable).toBe(true);++ expect(byId('botGroup.composer.send')?.disabled).toBe(false);++ await render({ ...live, dissolvedAt: '2026-10-15T00:00:00.000Z' });++ expect(h.row.editable).toBe(false);++ expect(byId('botGroup.composer.send')?.disabled).toBe(true);++ await click('botGroup.composer.send');++ expect(h.chat.act).not.toHaveBeenCalled();++ expect(node.textContent).toContain('好的,我看看');++ });++it('offers 所有人 first, inserts a picked teammate and sends the resolved mentions', async () => {await render(group({ openPlan: null }));await type('请 @');diff --cc apps/mobile/src/session/BotGroupChatScreen.tsxindex 3fceba2ed4,04ecb29b37..688f1ecb83--- a/apps/mobile/src/session/BotGroupChatScreen.tsx+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx@@@ -369,7 -330,7 +369,7 @@@ export function BotGroupChatScreen({ deonEditStep={(planId, step, action, botId) => void editPlanStep(planId, step, action, botId)}onInteractionError={(message) => { if (message) Alert.alert(message); }} /></ScrollView>-- <BotGroupComposer members={group.members} identityFor={identityFor} deviceId={deviceId} online={chat.online && !group.archived}++ <BotGroupComposer members={group.members} identityFor={identityFor} deviceId={deviceId} online={chat.online && !group.archived && !group.dissolvedAt}running={group.round.status === 'running'} planState={botGroupComposerPlanState(openBotGroupPlan(group))}divisionSupported={!chat.server} attachmentsSupported={group.supportsAttachments === true} onSend={send} onStop={stop} /></KeyboardAvoidingView>;