Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(desktop): 伙伴群聊发送后立即乐观显示自己的消息
Dash322a67b93991
diff --git a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsxindex ba078e50de..0be6c44dcd 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx@@ -13,6 +13,9 @@ import type { ReactNode } from 'react';* 附件(§3.1):托盘状态(`useAttachments`)由页面持有,文件拖到页面任意位置都进托盘,* 与普通任务的整区拖入一致;用户消息上的图片与文件复用普通聊天用户气泡的图片视图与* 附件 chip。+ *+ * 自己刚发的消息先由发件箱(botGroupOutbox.ts)接在时间线末尾显示,main 读到它后由+ * 真实消息替换;没发出去的显示「没发出去」与重试、编辑。*/import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type DragEvent } from 'react';import { ArrowLeft, CircleAlert, RefreshCcw, Settings2, Sparkles } from 'lucide-react';@@ -94,6 +97,19 @@ import {openBotGroupPlan,} from './botGroupPresentation';import { botGroupApi, editBotGroupPlanStep, runBotGroupPlanAction, useBotGroupSummary } from './botGroupStore';+import {+ beginBotGroupTimelineRead,+ discardBotGroupOutbox,+ editBotGroupSend,+ getBotGroupOutboxClaims,+ getBotGroupOutboxPreviews,+ mergeBotGroupLocalAttachments,+ noteBotGroupTimeline,+ projectBotGroupOutbox,+ retryBotGroupSend,+ useBotGroupOutbox,+ type BotGroupOutboxEntry,+} from './botGroupOutbox';import { botGroupReadKey, markBotRead } from './botReadState';import { collectBotMessageTimeGroups, formatBotMessageGroupTime } from './botConversationTimeline';@@ -107,6 +123,8 @@ type GroupViewState =/** Plans referenced by the older pages; the latest read wins on overlap. */olderPlans: BotGroupPlanView[];olderHasMore: boolean;+ /** Outbox read token of the read that produced `group` (see beginBotGroupTimelineRead). */+ readToken: number;}| { kind: 'missing' }| { kind: 'error' };@@ -189,6 +207,7 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {if (isCurrent()) setState({ kind: groupId ? 'error' : 'missing' });return;}+ const readToken = beginBotGroupTimelineRead();try {const displayed = stateRef.current;const sourceMessageIds = [...new Set([...(displayed.kind === 'ready' && displayed.group.id === groupId@@ -199,13 +218,14 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {readOwner.current = owner;setState((previous) =>previous.kind === 'ready'- ? { ...previous, group: result.group }+ ? { ...previous, group: result.group, readToken }: {kind: 'ready',group: result.group,older: [],olderPlans: [],olderHasMore: result.group.hasMoreBefore,+ readToken,},);} else if (result.errorCode === 'NOT_FOUND') {@@ -227,6 +247,7 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {requestVersion += 1;// Unsent attachments go with the group (staged copies included).discardDraft(botGroupAttachmentScope(groupId));+ discardBotGroupOutbox(groupId);setState({ kind: 'missing' });return;}@@ -248,6 +269,21 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {() => (state.kind === 'ready' ? projectBotGroupExecutionFailures(mergeBotGroupMessages(state.older, state.group.messages), state.group.executionFailures) : []),[state],);+ // Settle receipts only once the read that shows them is on screen, so a pending bubble+ // never disappears a frame before its real message appears.+ useLayoutEffect(() => {+ if (state.kind === 'ready') noteBotGroupTimeline(groupId, state.group.messages, state.readToken);+ }, [groupId, state]);+ const outbox = useBotGroupOutbox(groupId);+ const { pending: pendingSends, localAttachments } = useMemo(+ () => projectBotGroupOutbox(outbox, messages, getBotGroupOutboxClaims(groupId), getBotGroupOutboxPreviews(groupId)),+ [groupId, messages, outbox],+ );+ // A receipt the timeline does not show yet: read again so the real message takes its place.+ const unreadReceipts = pendingSends.flatMap((entry) => (entry.status === 'sent' && entry.messageId ? [entry.messageId] : [])).join(',');+ useEffect(() => {+ if (unreadReceipts) loadRef.current();+ }, [unreadReceipts]);const acknowledge = useCallback(() => {if (!isDataOwnerGenerationCurrent(readOwner.current) || !stickToBottomRef.current || document.visibilityState !== 'visible' || !document.hasFocus()) return;const at = messages.reduce((latest, message) => message.kind === 'message' && (message.authorKind === 'bot' || message.isSelf === false)@@ -375,7 +411,7 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {return;}if (stickToBottomRef.current) element.scrollTop = element.scrollHeight;- }, [lastSequence, speakingKey, messages.length, hasControlledBanner, controlledBannerCollapsed]);+ }, [lastSequence, speakingKey, messages.length, pendingSends.length, hasControlledBanner, controlledBannerCollapsed]);// Markdown, code blocks and avatars finish layout after the first paint; keep a reader// who is at the bottom pinned there while the content grows.@@ -573,9 +609,10 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {const openPlan = openBotGroupPlan({ openPlan: group.openPlan, plans });const followUp = botGroupPlanFollowUp(openPlan);const continueId = continuableRoundEndId(messages, group.round);- const timeGroups = collectBotMessageTimeGroups(- messages.map((message) => ({ clientId: message.id, createdAt: message.createdAt })),- );+ const timeGroups = collectBotMessageTimeGroups([+ ...messages.map((message) => ({ clientId: message.id, createdAt: message.createdAt })),+ ...pendingSends.map((entry) => ({ clientId: outboxKey(entry), createdAt: entry.createdAt })),+ ]);const mentionLabels = [t('bots.groupChat.mention.all'), ...group.members.flatMap((member) => [member.name, member.nickname || member.displayName || member.name])];const running = group.round.status === 'running';const speakers = running@@ -639,7 +676,7 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {</Button></div>) : null}- {messages.length === 0 && !running ? (+ {messages.length === 0 && pendingSends.length === 0 && !running ? (<div className="py-12 text-center"><p className="text-13 font-medium text-[var(--text-secondary)]">{t('bots.groupChat.timeline.emptyTitle')}@@ -649,8 +686,13 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {</p></div>) : null}- {messages.map((message) => {- const groupTime = timeGroups.get(message.id);+ {messages.map((timelineMessage) => {+ const groupTime = timeGroups.get(timelineMessage.id);+ // My own message just confirmed: keep the local attachment previews until the server copies are usable.+ const local = localAttachments.get(timelineMessage.id);+ const message = local && timelineMessage.isSelf !== false+ ? { ...timelineMessage, attachments: mergeBotGroupLocalAttachments(timelineMessage.attachments, local) }+ : timelineMessage;return (<div key={message.id} className="flex flex-col gap-4">{groupTime !== undefined ? (@@ -709,6 +751,19 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {</div>);})}+ {pendingSends.map((entry) => {+ const groupTime = timeGroups.get(outboxKey(entry));+ return (+ <div key={outboxKey(entry)} className="flex flex-col gap-4">+ {groupTime !== undefined ? (+ <p className="select-none text-center text-12 text-[var(--text-tertiary)]">+ {formatBotMessageGroupTime(groupTime, i18n.language)}+ </p>+ ) : null}+ <BotGroupOutboxItem entry={entry} mentionLabels={mentionLabels} />+ </div>+ );+ })}{openPlan && followUp ? (<BotGroupPlanFollowUpRowfollowUp={followUp}@@ -746,9 +801,8 @@ function BotGroupChatContent({ groupId }: { groupId: string }) {attachments={attachmentState}attachmentScope={attachmentScope}dragOver={dragOver}- onSent={() => {+ onSending={() => {stickToBottomRef.current = true;- loadRef.current();}}/>}{group.migrationPending && <p role="status" className="px-4 py-2 text-13 text-[var(--text-secondary)]">{t('bots.groupChat.migrationPending')}</p>}@@ -861,34 +915,13 @@ function BotGroupTimelineItem({return <p className="text-center text-12 text-[var(--text-tertiary)]">{text}</p>;}if (message.kind === 'message' && message.authorKind === 'user' && message.isSelf !== false) {- // An attachment-only message shows just its attachments, without an empty bubble.- const hasText = message.content.trim().length > 0;return (<article {...{ [SHARE_SESSION_ATTR]: shareScope, [SHARE_MESSAGE_ATTR]: message.id }}className={`relative flex justify-end ${sharing ? 'ml-10' : ''}`}>{sharing && <ShareMessageCheckbox clientId={message.id} />}- <div className="flex min-w-0 max-w-[72%] flex-col items-end gap-2">- <BotGroupUserAttachments attachments={message.attachments} />- {hasText ? (- <div- className={`max-w-full whitespace-pre-wrap break-words rounded-xl border border-[var(--msg-user-border)] bg-[var(--msg-user-bg)] px-3.5 py-2.5 text-[var(--msg-user-text)] ${CHAT_BODY_CLASS}`}- >- {splitBotGroupMentionSegments(message.content, mentionLabels).map((segment, index) =>- segment.mention ? (- <span- key={index}- className="rounded-full bg-[var(--surface-chip)] px-1.5 font-medium"- >- {segment.text}- </span>- ) : (- <span key={index}>{segment.text}</span>- ),- )}- </div>- ) : null}+ <BotGroupSelfBubble content={message.content} attachments={message.attachments} mentionLabels={mentionLabels}>{actions}- </div>+ </BotGroupSelfBubble></article>);}@@ -942,6 +975,111 @@ function BotGroupTimelineItem({);}+/** The current user's own message: attachments, then the text bubble, then what goes under it. */+function BotGroupSelfBubble({+ content,+ attachments,+ mentionLabels,+ children,+}: {+ content: string;+ attachments: readonly BotGroupAttachment[];+ mentionLabels: readonly string[];+ children?: ReactNode;+}) {+ // An attachment-only message shows just its attachments, without an empty bubble.+ const hasText = content.trim().length > 0;+ return (+ <div className="flex min-w-0 max-w-[72%] flex-col items-end gap-2">+ <BotGroupUserAttachments attachments={attachments} />+ {hasText ? (+ <div+ className={`max-w-full whitespace-pre-wrap break-words rounded-xl border border-[var(--msg-user-border)] bg-[var(--msg-user-bg)] px-3.5 py-2.5 text-[var(--msg-user-text)] ${CHAT_BODY_CLASS}`}+ >+ {splitBotGroupMentionSegments(content, mentionLabels).map((segment, index) =>+ segment.mention ? (+ <span+ key={index}+ className="rounded-full bg-[var(--surface-chip)] px-1.5 font-medium"+ >+ {segment.text}+ </span>+ ) : (+ <span key={index}>{segment.text}</span>+ ),+ )}+ </div>+ ) : null}+ {children}+ </div>+ );+}++function outboxKey(entry: BotGroupOutboxEntry): string {+ return `outbox:${entry.input.clientId}`;+}++/** Wait this long before saying 发送中, so a quick send never flashes a status. */+const BOT_GROUP_SENDING_HINT_DELAY_MS = 600;++/**+ * A message the user just sent, shown before main has it in the timeline. Not yet a+ * timeline message: no share checkbox, reply or reactions until the real one replaces it.+ */+function BotGroupOutboxItem({+ entry,+ mentionLabels,+}: {+ entry: BotGroupOutboxEntry;+ mentionLabels: readonly string[];+}) {+ const { t } = useTranslation();+ const sending = entry.status === 'sending';+ const [slow, setSlow] = useState(false);+ useEffect(() => {+ if (!sending) {+ setSlow(false);+ return;+ }+ const timer = window.setTimeout(() => setSlow(true), BOT_GROUP_SENDING_HINT_DELAY_MS);+ return () => window.clearTimeout(timer);+ }, [sending]);+ return (+ <article data-testid="bot-group-outbox" data-status={entry.status} className="relative flex justify-end">+ <BotGroupSelfBubble content={entry.input.text} attachments={entry.attachments} mentionLabels={mentionLabels}>+ {sending && slow ? (+ <p role="status" className="select-none text-12 leading-[1.33] text-[var(--text-tertiary)]">+ {t('bots.groupChat.outbox.sending')}+ </p>+ ) : null}+ {entry.status === 'failed' ? (+ <div role="alert" className="flex flex-wrap items-center justify-end gap-2">+ <span className="flex select-none items-center gap-1 text-12 leading-[1.33] text-[var(--text-danger)]">+ <CircleAlert size={13} aria-hidden className="shrink-0" />+ {t('bots.groupChat.outbox.failed')}+ </span>+ <Button+ variant="secondary"+ size="sm"+ compact+ type="button"+ onClick={() => {+ if (!editBotGroupSend(entry.input.groupId, entry.input.clientId)) toast.warning(t('bots.groupChat.outbox.editBlocked'));+ }}+ >+ {t('bots.groupChat.outbox.edit')}+ </Button>+ <Button variant="secondary" size="sm" compact type="button" onClick={() => retryBotGroupSend(entry.input.groupId, entry.input.clientId)}>+ <RefreshCcw size={13} />+ {t('bots.retry')}+ </Button>+ </div>+ ) : null}+ </BotGroupSelfBubble>+ </article>+ );+}+/*** A user message's images and files, drawn like a task's user bubble: each image as the* same attached-image view (click for the lightbox, right-click to copy or reveal), filesdiff --git a/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx b/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsxindex 7496b0a1b9..3753e676a7 100644--- a/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx+++ b/apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx@@ -8,16 +8,22 @@* 中输入框为空时,发送按钮变成停止;有文字时照常发送——插话本身就会作废当前一轮* (docs/product-rules/bot-group-chat.md §4.4)。*+ * 发送即交给群聊发件箱(botGroupOutbox.ts):消息立即出现在时间线上,输入框与托盘马上+ * 空出来,可以接着写下一条;提交按发出顺序在后台进行。没发出去时,输入框空着就把正文、+ * 点名、「分工」标签和附件原样放回,再按发送沿用同一个 clientId;输入框已有新内容时+ * 消息留在时间线上,可以重试或编辑。+ ** 「+」菜单里的「安排分工」(§7.2)给输入框加上「分工」标签:带标签发出的消息一定交给* 负责人出安排(`division: true`),发出后标签清掉。安排进行中或等继续时不能再安排新的,* 菜单项置灰并说明原因。占位文字跟随未结束的安排,告诉用户这时说的话会交给谁。** 附件(§3.1)与普通聊天同一套:托盘状态来自页面持有的 `useAttachments`(整页拖入也能* 加),缩略图与拒收提示复用 ComposerAttachments;「+」→「添加文件、图片或视频…」、粘贴- * 文件或截图都进托盘。有附件时可以不写字。发送前烧录图片标注,发出去之后才从托盘移走- * 这一批;没发出去就原样留着。+ * 文件或截图都进托盘。有附件时可以不写字。发送时这一批随消息离开托盘+ * (不删除文件),发件箱提交前烧录图片标注;没发出去就随消息放回。*/import {+ useEffect,useId,useLayoutEffect,useMemo,@@ -47,10 +53,8 @@ import {useMenuPanel,withMenuLabels,} from '@/components/ui/menu-row';-import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';import { MENU_ITEM_CLASS } from '@/features/cc-agent/sidebar/menuStyles';import type { UseAttachmentsReturn } from '@/hooks/useAttachments';-import { isAnnotationBurnInError, materializeAnnotatedAttachmentsForSend } from '@/lib/annotationBurnIn';import type { AttachedFile } from '@/lib/fileTypes';import { toast } from '@/lib/toast';import { cn } from '@/lib/utils';@@ -60,7 +64,7 @@ import {type BotGroupMemberView,} from '../../../shared/botGroupChat';import { BotAvatar } from './BotAvatar';-import { botGroupAttachmentSignature, toBotGroupAttachmentInputs } from './botGroupAttachments';+import { botGroupAttachmentSignature } from './botGroupAttachments';import {filterBotGroupMentionCandidates,findBotGroupMentionQuery,@@ -69,8 +73,8 @@ import {retainBotGroupTrackedMentions,type BotGroupTrackedMention,} from './botGroupMentions';+import { botGroupSendSignature, enqueueBotGroupSend, registerBotGroupComposer } from './botGroupOutbox';import {- botGroupErrorKey,isActiveBotGroupMember,isBotGroupDivisionBlocked,type BotGroupComposerPlanState,@@ -116,7 +120,7 @@ export function BotGroupComposer({attachments: attachmentState,attachmentScope,dragOver = false,- onSent,+ onSending,}: {groupId: string;members: readonly BotGroupMemberView[];@@ -128,8 +132,8 @@ export function BotGroupComposer({attachmentScope: string;/** Files are being dragged over the page: the card shows the same drop hint as a task's. */dragOver?: boolean;- /** Called after main accepted the message, so the view can re-read at once. */- onSent: () => void;+ /** Called when a message enters the outbox, so the view can follow it to the bottom. */+ onSending: () => void;}) {const { t } = useTranslation();const listboxId = useId();@@ -140,8 +144,6 @@ export function BotGroupComposer({const [dismissedStart, setDismissedStart] = useState<number | null>(null);const [tracked, setTracked] = useState<BotGroupTrackedMention[]>([]);const [stopping, setStopping] = useState(false);- /** A send is in flight: its attachments stay in the tray but cannot change. */- const [sending, setSending] = useState(false);/** 「分工」 tag from 「+」→「安排分工」: this message goes to the organizer for a plan. */const [division, setDivision] = useState(false);const [menuOpen, setMenuOpen] = useState(false);@@ -163,16 +165,11 @@ export function BotGroupComposer({attachmentsRef.current = attachmentState.attachments;const focusInputOnMenuCloseRef = useRef(false);const pendingCaretRef = useRef<number | null>(null);- const sendingRef = useRef(false);const stoppingRef = useRef(false);- /** Idempotency key for the text, targets and attachments currently being (re)sent. */- const attemptRef = useRef<{- text: string;- clientId: string;- division: boolean;- attachments: string;- mentionSignature: string;- } | null>(null);+ const divisionRef = useRef(division);+ divisionRef.current = division;+ /** The failed send last put back into the input: an unchanged resend reuses its clientId. */+ const attemptRef = useRef<{ clientId: string; signature: string } | null>(null);const activeMembers = useMemo(() => members.filter(isActiveBotGroupMember), [members]);const allLabel = t('bots.groupChat.mention.all');@@ -237,97 +234,64 @@ export function BotGroupComposer({textareaRef.current?.focus();};- const send = async () => {- if (!canSend || sendingRef.current) return;- const api = botGroupApi();- if (!api) {+ // A message that did not go out comes back only into an empty input: never over new+ // text, a new tag or files added meanwhile. Pressing send again reuses its clientId.+ const restoreAttachments = attachmentState.restoreFiles;+ useEffect(+ () =>+ registerBotGroupComposer(groupId, {+ restore: (entry) => {+ if (textRef.current || attachmentsRef.current.length > 0 || divisionRef.current) return false;+ attemptRef.current = { clientId: entry.input.clientId, signature: entry.signature };+ textRef.current = entry.draft;+ setText(entry.draft);+ setTracked([...entry.tracked]);+ const restoredDivision = entry.input.division === true;+ divisionRef.current = restoredDivision;+ if (restoredDivision) setDivision(true);+ if (entry.files.length > 0) attachmentsRef.current = restoreAttachments(entry.files);+ return true;+ },+ notifyFailed: (errorKey) => toast.error(t(errorKey)),+ }),+ [groupId, restoreAttachments, t],+ );++ const send = () => {+ // A second Enter before the cleared input has rendered must not send the same draft twice.+ if (!canSend || textRef.current !== text || attachmentsRef.current !== attachmentState.attachments) return;+ if (!botGroupApi()) {toast.error(t('bots.groupChat.composer.sendFailed'));return;}const files: readonly AttachedFile[] = attachmentState.attachments;- const signature = botGroupAttachmentSignature(files);- // The tag changes what main does with the text, so it is part of the idempotency key;- // so are the attachments that go with it.const mentions = resolveBotGroupMentions(text, {members,allLabels: [allLabel],tracked,});- const mentionSignature = JSON.stringify([mentions.all, mentions.botIds]);- const attempt =- attemptRef.current?.text === trimmed &&- attemptRef.current.division === division &&- attemptRef.current.attachments === signature &&- attemptRef.current.mentionSignature === mentionSignature- ? attemptRef.current- : { text: trimmed, clientId: crypto.randomUUID(), division, attachments: signature, mentionSignature };- attemptRef.current = attempt;- const draft = text;- sendingRef.current = true;- setSending(true);- // Clear at once like any chat; a failed send puts the draft back if the- // user has not started typing something else meanwhile. Attachments stay in- // the tray until main has them.+ // Every field main gets is part of the attempt's identity (the tag changes what main does+ // with the text), and so are the attachments that go with it.+ const fields = { groupId, text: trimmed, mentions, ...(division ? { division: true } : {}) };+ const signature = botGroupSendSignature({ ...fields, clientId: '' }, botGroupAttachmentSignature(files));+ const clientId = attemptRef.current?.signature === signature ? attemptRef.current.clientId : crypto.randomUUID();+ // The outbox owns this attempt now; a failure hands it back through `restore`.+ attemptRef.current = null;+ enqueueBotGroupSend({ input: { ...fields, clientId }, signature, draft: text, tracked, files, attachmentScope });+ // Clear at once like any chat, so the next message can be written while this one+ // goes out. The batch leaves the tray without deleting its files: the message has them.+ textRef.current = '';setText('');setCaret(0);setTracked([]);setDismissedStart(null);setDivision(false);- const owner = getDataOwnerGeneration();- const restore = () => {- // The tag comes back only with its own draft, never onto newly typed text.- if (!textRef.current) {- if (attempt.division) setDivision(true);- setTracked(tracked);- }- setText((current) => (current ? current : draft));- };- try {- // Drawn annotations are burned in first, as in a task; a failure keeps everything for a retry.- const prepared =- files.length > 0- ? ((await materializeAnnotatedAttachmentsForSend(files, attachmentScope, { burnFailure: 'abort' })) ?? [])- : [];- const result = await api.sendBotGroupMessage({- groupId,- text: attempt.text,- mentions,- clientId: attempt.clientId,- ...(attempt.division ? { division: true } : {}),- ...(prepared.length > 0 ? { attachments: toBotGroupAttachmentInputs(prepared) } : {}),- });- if (!isDataOwnerGenerationCurrent(owner)) return;- if (!result.ok) {- restore();- toast.error(- t(- result.errorCode === 'INVALID_PARAMS' && prepared.length > 0- ? 'bots.groupChat.composer.attachmentsFailed'- : botGroupErrorKey(result.errorCode, 'bots.groupChat.composer.sendFailed'),- ),- );- return;- }- attemptRef.current = null;- if (files.length > 0) {- // Main now holds these files; take only this batch out of the tray (never delete- // them) and keep anything added while the message was on its way.- const sentIds = new Set(files.map((file) => file.id));- const remaining = attachmentsRef.current.filter((file) => !sentIds.has(file.id));- attachmentState.clearFiles();- attachmentState.restoreFiles(remaining);- }- onSent();- } catch (error) {- if (!isDataOwnerGenerationCurrent(owner)) return;- restore();- toast.error(- t(isAnnotationBurnInError(error) ? 'chat.media.annotateBurnFailedNotSent' : 'bots.groupChat.composer.sendFailed'),- );- } finally {- sendingRef.current = false;- setSending(false);+ divisionRef.current = false;+ if (files.length > 0) {+ attachmentState.clearFiles();+ attachmentsRef.current = [];}+ onSending();};/** Files copied in a file manager attach by path; a screenshot or copied image attaches as an image. */@@ -394,8 +358,6 @@ export function BotGroupComposer({? t('bots.groupChat.composer.placeholderPlanWaiting', { name: planState.botName }): t('bots.groupChat.composer.placeholder');- const noop = () => undefined;-return (<div className="shrink-0 px-5 pb-4 pt-2"><div className="relative mx-auto w-full max-w-[760px]">@@ -491,8 +453,8 @@ export function BotGroupComposer({{attachmentCount > 0 ? (<ThumbnailStripattachments={attachmentState.attachments}- onRemove={sending ? noop : attachmentState.removeFile}- onUpdate={sending ? noop : attachmentState.updateFile}+ onRemove={attachmentState.removeFile}+ onUpdate={attachmentState.updateFile}/>) : null}<textarea@@ -549,7 +511,7 @@ export function BotGroupComposer({}if (event.key === 'Enter' && !event.shiftKey) {event.preventDefault();- void send();+ send();return;}// Backspace at the very start of an empty input takes the 「分工」 tag off.@@ -645,7 +607,7 @@ export function BotGroupComposer({disabled={showStop ? stopping : !canSend}isStreaming={showStop}ariaLabel={actionLabel}- onClick={() => void (showStop ? stop() : send())}+ onClick={() => (showStop ? void stop() : send())}/></Tip></div>diff --git a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsxindex 61aa6f5bec..848fddc1c0 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupChatView.test.tsx@@ -13,6 +13,7 @@ import { FeatureSidebarSlotProvider, useFeatureContentHeader } from '../../featuimport { markBotRead, getBotLastReadAt, botGroupReadKey, resetBotReadStateForTests } from '../botReadState';import { botGroupAttachmentScope } from '../botGroupAttachments';import { getBotGroupListSnapshot, refreshBotGroups, resetBotGroupStoreForTests } from '../botGroupStore';+import { resetBotGroupOutboxForTests } from '../botGroupOutbox';import { BotGroupChatView } from '../BotGroupChatView';import { ControlledBanner, __resetControlledBannerForTests } from '../../remote-device/ControlledBanner';import type {@@ -258,6 +259,7 @@ beforeEach(() => {mocks.cacheImageFromBuffer.mockReset().mockResolvedValue({ url: 'cindy-media://blobs/pasted.png', filename: 'pasted.png' });mocks.cacheImageFromPath.mockReset().mockResolvedValue({ url: 'cindy-media://blobs/photo.png', filename: 'photo.png' });resetBotReadStateForTests();+ resetBotGroupOutboxForTests();mocks.groupId = 'g1';__resetControlledBannerForTests();mocks.controlledPush = null;@@ -1184,6 +1186,202 @@ describe('BotGroupChatView', () => {expect(await screen.findByText('bots.groupChat.unavailableTitle')).toBeTruthy();});+ describe('乐观显示', () => {+ /** A send main has not answered yet; the test decides when and how. */+ function pendingSend() {+ let resolve!: (result: unknown) => void;+ const promise = new Promise((res) => {+ resolve = res;+ });+ mocks.sendBotGroupMessage.mockImplementationOnce(() => promise);+ return { resolve: (result: unknown) => act(async () => { resolve(result); await promise; }) };+ }+ const outboxItems = () => screen.queryAllByTestId('bot-group-outbox');+ const withSelf = (id: string, sequence: number, content: string) =>+ detail({ messages: [...detail().messages, msg({ id, sequence, content })] });+ const pushMessages = (groupId = 'g1') =>+ act(() => mocks.pushes.forEach((push) => push({ groupId, change: 'messages' })));++ it('shows the message as soon as it is sent and swaps in the real one without a duplicate', async () => {+ const send = pendingSend();+ renderView();+ const input = (await screen.findByRole('textbox')) as HTMLTextAreaElement;+ fireEvent.change(input, { target: { value: '@咪咪 慢一点', selectionStart: 7 } });+ fireEvent.keyDown(input, { key: 'Enter' });++ expect(input.value).toBe('');+ expect(outboxItems()).toHaveLength(1);+ expect(outboxItems()[0]!.textContent).toContain('慢一点');+ // The mention keeps its chip in the pending bubble too.+ expect(within(outboxItems()[0]!).getByText('@咪咪')).toBeTruthy();+ expect(within(outboxItems()[0]!).queryByRole('status')).toBeNull();+ expect(await screen.findByText('bots.groupChat.outbox.sending', {}, { timeout: 2000 })).toBeTruthy();+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1));++ mocks.getBotGroup.mockResolvedValue({ ok: true, group: withSelf('u2', 5, '@咪咪 慢一点') });+ await send.resolve({ ok: true, messageId: 'u2' });+ pushMessages();+ await waitFor(() => expect(outboxItems()).toHaveLength(0));+ expect(screen.getAllByText('慢一点')).toHaveLength(1);+ expect(screen.queryByText('bots.groupChat.outbox.sending')).toBeNull();+ });++ it('does not show the message twice when a push re-read lands before the receipt', async () => {+ const send = pendingSend();+ renderView();+ const input = (await screen.findByRole('textbox')) as HTMLTextAreaElement;+ fireEvent.change(input, { target: { value: '早到的推送' } });+ fireEvent.keyDown(input, { key: 'Enter' });+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1));++ mocks.getBotGroup.mockResolvedValue({ ok: true, group: withSelf('u2', 5, '早到的推送') });+ pushMessages();+ await waitFor(() => expect(mocks.getBotGroup).toHaveBeenCalledTimes(2));+ await waitFor(() => expect(outboxItems()).toHaveLength(0));+ expect(screen.getAllByText('早到的推送')).toHaveLength(1);++ await send.resolve({ ok: true, messageId: 'u2' });+ pushMessages();+ await waitFor(() => expect(mocks.getBotGroup).toHaveBeenCalledTimes(3));+ expect(screen.getAllByText('早到的推送')).toHaveLength(1);+ expect(outboxItems()).toHaveLength(0);+ });++ it('takes the next message while the first is still out, and sends them in order', async () => {+ const first = pendingSend();+ renderView();+ const input = (await screen.findByRole('textbox')) as HTMLTextAreaElement;+ fireEvent.change(input, { target: { value: '同一句' } });+ fireEvent.keyDown(input, { key: 'Enter' });+ fireEvent.change(input, { target: { value: '同一句' } });+ fireEvent.keyDown(input, { key: 'Enter' });++ expect(outboxItems().map((item) => item.textContent)).toEqual(['同一句', '同一句']);+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1));+ mocks.sendBotGroupMessage.mockResolvedValueOnce({ ok: true, messageId: 'u3' });+ await first.resolve({ ok: true, messageId: 'u2' });+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(2));+ const [firstSend, secondSend] = mocks.sendBotGroupMessage.mock.calls.map(([call]) => call as Record<string, unknown>);+ // Same text, two messages: each keeps its own identity.+ expect(firstSend!.clientId).not.toBe(secondSend!.clientId);++ mocks.getBotGroup.mockResolvedValue({+ ok: true,+ group: detail({ messages: [...detail().messages, msg({ id: 'u2', sequence: 5, content: '同一句' }), msg({ id: 'u3', sequence: 6, content: '同一句' })] }),+ });+ pushMessages();+ await waitFor(() => expect(outboxItems()).toHaveLength(0));+ expect(screen.getAllByText('同一句')).toHaveLength(2);+ });++ it('keeps a failed message in place while new text is in the input; 重试 reuses its clientId and 编辑 waits for an empty input', async () => {+ const send = pendingSend();+ renderView();+ const input = (await screen.findByRole('textbox')) as HTMLTextAreaElement;+ fireEvent.change(input, { target: { value: '第一条' } });+ fireEvent.keyDown(input, { key: 'Enter' });+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1));+ fireEvent.change(input, { target: { value: '正在写的' } });+ await send.resolve({ ok: false, errorCode: 'INTERNAL', message: '' });++ expect(mocks.toastError).toHaveBeenCalledWith('bots.groupChat.composer.sendFailed');+ expect(input.value).toBe('正在写的');+ const failed = await screen.findByTestId('bot-group-outbox');+ expect(failed.getAttribute('data-status')).toBe('failed');+ expect(within(failed).getByText('bots.groupChat.outbox.failed')).toBeTruthy();+ // Nothing goes out again on its own.+ expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1);++ fireEvent.click(within(failed).getByRole('button', { name: 'bots.groupChat.outbox.edit' }));+ expect(mocks.toastWarning).toHaveBeenCalledWith('bots.groupChat.outbox.editBlocked');+ expect(input.value).toBe('正在写的');++ mocks.sendBotGroupMessage.mockResolvedValueOnce({ ok: false, errorCode: 'INTERNAL', message: '' });+ fireEvent.click(within(failed).getByRole('button', { name: /bots\.retry/ }));+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(2));+ const [firstAttempt, retry] = mocks.sendBotGroupMessage.mock.calls.map(([call]) => call as Record<string, unknown>);+ expect(retry!.clientId).toBe(firstAttempt!.clientId);+ await waitFor(() => expect(screen.getByTestId('bot-group-outbox').getAttribute('data-status')).toBe('failed'));++ fireEvent.change(input, { target: { value: '' } });+ fireEvent.click(screen.getByRole('button', { name: 'bots.groupChat.outbox.edit' }));+ expect(input.value).toBe('第一条');+ expect(outboxItems()).toHaveLength(0);+ mocks.sendBotGroupMessage.mockResolvedValueOnce({ ok: true, messageId: 'u2' });+ fireEvent.keyDown(input, { key: 'Enter' });+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(3));+ expect(lastSend().clientId).toBe(firstAttempt!.clientId);+ });++ it('keeps the local image on screen while the server copy of a confirmed message is still loading', async () => {+ const send = pendingSend();+ renderView();+ await screen.findByRole('textbox');+ pickFiles([diskFile('photo.png', 'image/png')]);+ await screen.findByAltText('photo.png');+ fireEvent.click(screen.getByRole('button', { name: 'bots.send' }));+ // Out of the tray and into the pending bubble at once.+ expect(within(outboxItems()[0]!).getByAltText('photo.png')).toBeTruthy();+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1));++ const image = { id: 's1', name: 'photo.png', category: 'image' as const, mimeType: 'image/png', size: 7 };+ mocks.getBotGroup.mockResolvedValue({+ ok: true,+ group: detail({ messages: [...detail().messages, msg({ id: 'u2', sequence: 5, attachments: [{ ...image, url: null, path: null }] })] }),+ });+ await send.resolve({ ok: true, messageId: 'u2' });+ pushMessages();+ await waitFor(() => expect(outboxItems()).toHaveLength(0));+ expect(screen.getAllByAltText('photo.png')).toHaveLength(1);+ expect(screen.getByAltText('photo.png').getAttribute('src')).toContain('photo.png');++ mocks.getBotGroup.mockResolvedValue({+ ok: true,+ group: detail({ messages: [...detail().messages, msg({ id: 'u2', sequence: 5, attachments: [{ ...image, url: 'cindy-media://blobs/server.png', path: null }] })] }),+ });+ pushMessages();+ await waitFor(() => expect(screen.getByAltText('photo.png').getAttribute('src')).toContain('server.png'));+ expect(screen.getAllByAltText('photo.png')).toHaveLength(1);+ });++ it('keeps a late receipt out of the next group and shows the message when coming back', async () => {+ const send = pendingSend();+ const view = renderView();+ const input = (await screen.findByRole('textbox')) as HTMLTextAreaElement;+ fireEvent.change(input, { target: { value: '离开前发的' } });+ fireEvent.keyDown(input, { key: 'Enter' });+ await waitFor(() => expect(mocks.sendBotGroupMessage).toHaveBeenCalledTimes(1));++ mocks.groupId = 'g2';+ mocks.getBotGroup.mockResolvedValue({ ok: true, group: detail({ id: 'g2', name: '另一个群' }) });+ view.rerender(+ <Tooltip.Provider>+ <FeatureSidebarSlotProvider isCollapsed={false}>+ <HeaderSlot />+ <BotGroupChatView />+ </FeatureSidebarSlotProvider>+ </Tooltip.Provider>,+ );+ await screen.findByText('另一个群');+ await send.resolve({ ok: true, messageId: 'u2' });+ expect(outboxItems()).toHaveLength(0);+ expect(screen.queryByText('离开前发的')).toBeNull();++ mocks.groupId = 'g1';+ mocks.getBotGroup.mockResolvedValue({ ok: true, group: withSelf('u2', 5, '离开前发的') });+ view.rerender(+ <Tooltip.Provider>+ <FeatureSidebarSlotProvider isCollapsed={false}>+ <HeaderSlot />+ <BotGroupChatView />+ </FeatureSidebarSlotProvider>+ </Tooltip.Provider>,+ );+ await waitFor(() => expect(screen.getAllByText('离开前发的')).toHaveLength(1));+ expect(outboxItems()).toHaveLength(0);+ });+ });+describe('分工', () => {it('shows the organizer’s plan card and starts or skips the open plan', async () => {mocks.getBotGroup.mockResolvedValue({ ok: true, group: withPlan(plan()) });diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botGroupOutbox.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botGroupOutbox.test.tsnew file mode 100644index 0000000000..b0335c9444--- /dev/null+++ b/apps/desktop/src/renderer/features/bots/__tests__/botGroupOutbox.test.ts@@ -0,0 +1,418 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import type { AttachedFile } from '@/lib/fileTypes';+import type {+ BotGroupAttachment,+ BotGroupMessageView,+ BotGroupSendInput,+ BotGroupSendResult,+} from '../../../../shared/botGroupChat';+import {+ beginBotGroupTimelineRead,+ botGroupSendSignature,+ discardBotGroupOutbox,+ editBotGroupSend,+ enqueueBotGroupSend,+ getBotGroupOutbox,+ getBotGroupOutboxClaims,+ noteBotGroupTimeline,+ registerBotGroupComposer,+ resetBotGroupOutboxForTests,+ getBotGroupOutboxPreviews,+ mergeBotGroupLocalAttachments,+ projectBotGroupOutbox,+ retryBotGroupSend,+ type BotGroupOutboxDraft,+ type BotGroupOutboxSendInput,+} from '../botGroupOutbox';++const mocks = vi.hoisted(() => ({+ owner: 1,+ send: vi.fn<(input: BotGroupSendInput) => Promise<BotGroupSendResult>>(),+}));++vi.mock('@/contexts/dataOwnerGeneration', () => ({+ getDataOwnerGeneration: () => mocks.owner,+ isDataOwnerGenerationCurrent: (owner: number) => owner === mocks.owner,+}));+vi.mock('../botGroupStore', () => ({+ botGroupApi: () => ({ sendBotGroupMessage: mocks.send }),+}));+vi.mock('@/lib/annotationBurnIn', () => ({+ isAnnotationBurnInError: () => false,+ materializeAnnotatedAttachmentsForSend: async (files: readonly AttachedFile[]) => [...files],+}));++/** A send main has not answered yet; the test decides when and how. */+function deferred() {+ let resolve!: (result: BotGroupSendResult) => void;+ let reject!: (error: unknown) => void;+ const promise = new Promise<BotGroupSendResult>((res, rej) => {+ resolve = res;+ reject = rej;+ });+ return { promise, resolve, reject };+}++/** A draft as the composer builds it; `input` fields and draft fields override separately. */+function draft(+ input: Partial<BotGroupOutboxSendInput> = {},+ overrides: Partial<Omit<BotGroupOutboxDraft, 'input'>> = {},+): BotGroupOutboxDraft {+ const full: BotGroupOutboxSendInput = {+ groupId: 'g1',+ clientId: 'c1',+ text: '你好',+ mentions: { all: false, botIds: [] },+ ...input,+ };+ return {+ input: full,+ signature: botGroupSendSignature(full, '[]'),+ draft: full.text,+ tracked: [],+ files: [],+ attachmentScope: `bot-group:${full.groupId}`,+ ...overrides,+ };+}++function msg(overrides: Partial<BotGroupMessageView>): BotGroupMessageView {+ return {+ id: 'm',+ sequence: 1,+ kind: 'message',+ authorKind: 'user',+ authorBotId: null,+ authorName: '',+ content: '',+ mentions: { all: false, botIds: [] },+ noticeCode: null,+ planId: null,+ files: [],+ attachments: [],+ createdAt: 1,+ isSelf: true,+ ...overrides,+ };+}++const flush = () => new Promise<void>((resolve) => setTimeout(resolve, 0));++function visible(groupId: string, messages: BotGroupMessageView[]) {+ return project(groupId, messages).pending.map((entry) => `${entry.input.clientId}:${entry.status}`);+}++function project(groupId: string, messages: BotGroupMessageView[]) {+ return projectBotGroupOutbox(+ getBotGroupOutbox(groupId),+ messages,+ getBotGroupOutboxClaims(groupId),+ getBotGroupOutboxPreviews(groupId),+ );+}++beforeEach(() => {+ mocks.owner = 1;+ mocks.send.mockReset();+ resetBotGroupOutboxForTests();+});++afterEach(() => {+ resetBotGroupOutboxForTests();+});++describe('botGroupOutbox', () => {+ it('shows a message at once and submits a group’s sends one after another', async () => {+ const first = deferred();+ const second = deferred();+ mocks.send.mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);+ noteBotGroupTimeline('g1', [msg({ id: 'old', sequence: 3 })], beginBotGroupTimelineRead());++ enqueueBotGroupSend(draft({ clientId: 'c1', text: '一' }));+ enqueueBotGroupSend(draft({ clientId: 'c2', text: '二' }));+ expect(visible('g1', [])).toEqual(['c1:sending', 'c2:sending']);+ await flush();+ // The second waits for the first, so the server sees them in the order they were sent.+ expect(mocks.send).toHaveBeenCalledTimes(1);+ expect(mocks.send.mock.calls[0]![0]).toMatchObject({ groupId: 'g1', clientId: 'c1', text: '一' });++ first.resolve({ ok: true, messageId: 'm1' });+ await flush();+ expect(mocks.send).toHaveBeenCalledTimes(2);+ expect(mocks.send.mock.calls[1]![0]).toMatchObject({ clientId: 'c2', text: '二' });+ expect(visible('g1', [])).toEqual(['c1:sent', 'c2:sending']);+ });++ it('swaps a receipt for the real message whether the receipt or the re-read comes first, and ignores repeats', async () => {+ const pending = deferred();+ mocks.send.mockReturnValueOnce(pending.promise);+ noteBotGroupTimeline('g1', [msg({ id: 'old', sequence: 3, content: '你好' })], beginBotGroupTimelineRead());+ enqueueBotGroupSend(draft());+ await flush();++ // A push re-read lands before main answers: the copy after the baseline stands in for it,+ // while the earlier message with the same text does not.+ const real = msg({ id: 'm9', sequence: 4, content: '你好' });+ const reread = [msg({ id: 'old', sequence: 3, content: '你好' }), real];+ noteBotGroupTimeline('g1', reread, beginBotGroupTimelineRead());+ expect(visible('g1', [msg({ id: 'old', sequence: 3, content: '你好' })])).toEqual(['c1:sending']);+ expect(visible('g1', reread)).toEqual([]);++ pending.resolve({ ok: true, messageId: 'm9' });+ await flush();+ expect(visible('g1', reread)).toEqual([]);+ // The same receipt id read again (a duplicate push) settles the entry for good.+ const read = beginBotGroupTimelineRead();+ noteBotGroupTimeline('g1', reread, read);+ noteBotGroupTimeline('g1', reread, read);+ expect(getBotGroupOutbox('g1')).toEqual([]);+ });++ it('never lets a re-read hide a message that is not the one in flight', async () => {+ const first = deferred();+ const second = deferred();+ mocks.send.mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);+ noteBotGroupTimeline('g1', [], beginBotGroupTimelineRead());+ enqueueBotGroupSend(draft({ clientId: 'c1', text: '好' }));+ enqueueBotGroupSend(draft({ clientId: 'c2', text: '好' }));+ await flush();+ first.resolve({ ok: true, messageId: 'm1' });+ await flush();++ // m1 belongs to c1's receipt; c2 (same text, now in flight) must stay visible.+ const timeline = [msg({ id: 'm1', sequence: 1, content: '好' })];+ noteBotGroupTimeline('g1', timeline, beginBotGroupTimelineRead());+ expect(visible('g1', timeline)).toEqual(['c2:sending']);+ // A queued message is never matched, nor a message from someone else.+ expect(visible('g1', [...timeline, msg({ id: 'x', sequence: 2, content: '好', isSelf: false })])).toEqual(['c2:sending']);++ second.resolve({ ok: true, messageId: 'm2' });+ await flush();+ expect(visible('g1', timeline)).toEqual(['c2:sent']);+ noteBotGroupTimeline('g1', [...timeline, msg({ id: 'm2', sequence: 2, content: '好' })], beginBotGroupTimelineRead());+ expect(getBotGroupOutbox('g1')).toEqual([]);+ });++ it('settles a receipt that a later read no longer shows on its page', async () => {+ const pending = deferred();+ mocks.send.mockReturnValueOnce(pending.promise);+ enqueueBotGroupSend(draft());+ await flush();+ const early = beginBotGroupTimelineRead();+ pending.resolve({ ok: true, messageId: 'm1' });+ await flush();+ // A read that started before the receipt cannot speak for it.+ noteBotGroupTimeline('g1', [], early);+ expect(getBotGroupOutbox('g1').map((entry) => entry.status)).toEqual(['sent']);+ // One that started after it can: the message is in history even when pushed off the page.+ noteBotGroupTimeline('g1', [msg({ id: 'later', sequence: 50, isSelf: false })], beginBotGroupTimelineRead());+ expect(getBotGroupOutbox('g1')).toEqual([]);+ });++ it('hands a failure back to an empty composer, otherwise keeps it for 重试 with the same clientId', async () => {+ const restore = vi.fn(() => false);+ const notifyFailed = vi.fn();+ registerBotGroupComposer('g1', { restore, notifyFailed });+ mocks.send.mockResolvedValueOnce({ ok: false, errorCode: 'INTERNAL', message: '' });+ enqueueBotGroupSend(draft({ clientId: 'keep' }));+ await flush();+ expect(restore).toHaveBeenCalledTimes(1);+ expect(notifyFailed).toHaveBeenCalledWith('bots.groupChat.composer.sendFailed');+ expect(getBotGroupOutbox('g1').map((entry) => entry.status)).toEqual(['failed']);+ // Nothing is sent again on its own.+ await flush();+ expect(mocks.send).toHaveBeenCalledTimes(1);++ mocks.send.mockRejectedValueOnce(new Error('timeout')).mockResolvedValueOnce({ ok: true, messageId: 'm1' });+ retryBotGroupSend('g1', 'keep');+ await flush();+ expect(getBotGroupOutbox('g1').map((entry) => entry.status)).toEqual(['failed']);+ retryBotGroupSend('g1', 'keep');+ await flush();+ expect(mocks.send.mock.calls.map(([input]) => input.clientId)).toEqual(['keep', 'keep', 'keep']);+ expect(getBotGroupOutbox('g1').map((entry) => entry.status)).toEqual(['sent']);++ // An empty composer takes the next failure back; the bubble goes away.+ restore.mockReturnValue(true);+ mocks.send.mockResolvedValueOnce({ ok: false, errorCode: 'MENTION_UNAVAILABLE', message: '' });+ enqueueBotGroupSend(draft({ clientId: 'back' }));+ await flush();+ expect(restore).toHaveBeenLastCalledWith(+ expect.objectContaining({ input: expect.objectContaining({ clientId: 'back' }), status: 'failed' }),+ );+ expect(notifyFailed).toHaveBeenLastCalledWith('bots.groupChat.errors.mentionUnavailable');+ expect(getBotGroupOutbox('g1').map((entry) => entry.input.clientId)).toEqual(['keep']);+ });++ it('edits a failed message only into a composer that accepts it', async () => {+ const restore = vi.fn(() => false);+ registerBotGroupComposer('g1', { restore, notifyFailed: vi.fn() });+ mocks.send.mockResolvedValueOnce({ ok: false, errorCode: 'INTERNAL', message: '' });+ enqueueBotGroupSend(draft());+ await flush();+ expect(editBotGroupSend('g1', 'c1')).toBe(false);+ expect(getBotGroupOutbox('g1')).toHaveLength(1);+ restore.mockReturnValue(true);+ expect(editBotGroupSend('g1', 'c1')).toBe(true);+ expect(getBotGroupOutbox('g1')).toEqual([]);+ });++ it('keeps groups apart: another group’s composer never takes a failure', async () => {+ const otherRestore = vi.fn(() => true);+ registerBotGroupComposer('g2', { restore: otherRestore, notifyFailed: vi.fn() });+ const g1 = deferred();+ mocks.send.mockReturnValueOnce(g1.promise).mockResolvedValueOnce({ ok: true, messageId: 'g2-m' });+ enqueueBotGroupSend(draft({ groupId: 'g1', clientId: 'a' }));+ enqueueBotGroupSend(draft({ groupId: 'g2', clientId: 'b' }));+ await flush();+ // Groups do not queue behind each other.+ expect(mocks.send).toHaveBeenCalledTimes(2);+ g1.resolve({ ok: false, errorCode: 'INTERNAL', message: '' });+ await flush();+ expect(otherRestore).not.toHaveBeenCalled();+ expect(visible('g1', [])).toEqual(['a:failed']);+ expect(visible('g2', [])).toEqual(['b:sent']);+ });++ it('drops late answers after the account changes or the group is deleted', async () => {+ const late = deferred();+ mocks.send.mockReturnValueOnce(late.promise);+ enqueueBotGroupSend(draft());+ await flush();+ mocks.owner = 2;+ late.resolve({ ok: true, messageId: 'm1' });+ await flush();+ expect(getBotGroupOutbox('g1')).toEqual([]);++ const gone = deferred();+ mocks.send.mockReturnValueOnce(gone.promise);+ enqueueBotGroupSend(draft({ clientId: 'c2' }));+ await flush();+ discardBotGroupOutbox('g1');+ gone.resolve({ ok: false, errorCode: 'INTERNAL', message: '' });+ await flush();+ expect(getBotGroupOutbox('g1')).toEqual([]);+ });++ it('keeps the attachments with the message and sends them in the existing shape', async () => {+ mocks.send.mockResolvedValueOnce({ ok: true, messageId: 'm1' });+ const file = {+ id: 'f1',+ name: 'report.pdf',+ path: '/tmp/report.pdf',+ ext: '.pdf',+ size: 7,+ category: 'pdf',+ mimeType: 'application/pdf',+ type: 'file',+ } as unknown as AttachedFile;+ enqueueBotGroupSend(draft({ text: '' }, { files: [file] }));+ expect(getBotGroupOutbox('g1')[0]!.attachments).toEqual([+ expect.objectContaining({ id: 'f1', name: 'report.pdf', category: 'pdf', path: '/tmp/report.pdf' }),+ ]);+ await flush();+ expect(mocks.send.mock.calls[0]![0].attachments).toEqual([+ expect.objectContaining({ name: 'report.pdf', path: '/tmp/report.pdf', category: 'pdf' }),+ ]);+ });++ it('sends the whole input it was given, first time and on 重试, without dropping fields it does not know', async () => {+ // A field a later composer feature adds (here a stand-in) must survive the outbox untouched.+ const extra = { replyTo: { messageId: 'root-1' } } as unknown as Partial<BotGroupOutboxSendInput>;+ mocks.send+ .mockResolvedValueOnce({ ok: false, errorCode: 'INTERNAL', message: '' })+ .mockResolvedValueOnce({ ok: true, messageId: 'm1' });+ enqueueBotGroupSend(draft({ division: true, mentions: { all: true, botIds: ['a'] }, ...extra }));+ await flush();+ retryBotGroupSend('g1', 'c1');+ await flush();+ const expected = {+ groupId: 'g1',+ clientId: 'c1',+ text: '你好',+ mentions: { all: true, botIds: ['a'] },+ division: true,+ replyTo: { messageId: 'root-1' },+ };+ expect(mocks.send.mock.calls.map(([input]) => input)).toEqual([expected, expected]);+ });++ it('ties a clientId to every send field except itself, plus the attachments', () => {+ const base = draft().input;+ const same = botGroupSendSignature({ ...base, clientId: 'other' }, '[]');+ expect(same).toBe(botGroupSendSignature(base, '[]'));+ for (const changed of [+ { ...base, text: '别的' },+ { ...base, mentions: { all: false, botIds: ['a'] } },+ { ...base, division: true },+ { ...base, replyTo: 'x' } as unknown as BotGroupOutboxSendInput,+ ]) {+ expect(botGroupSendSignature(changed, '[]')).not.toBe(same);+ }+ expect(botGroupSendSignature(base, '[["f1"]]')).not.toBe(same);+ });++ describe('attachments of a confirmed message', () => {+ const local = (id: string, name: string): BotGroupAttachment => ({+ id, name, category: 'image', mimeType: 'image/png', size: 1, url: `cindy-media://blobs/${id}.png`, path: '/tmp/' + name,+ });+ /** A server copy not downloaded yet keeps id and name only. */+ const placeholder = (id: string, name: string): BotGroupAttachment => ({+ id, name, category: 'image', mimeType: 'image/png', size: 1, url: null, path: null,+ });+ const usable = (id: string, name: string): BotGroupAttachment => ({ ...placeholder(id, name), url: `cindy-media://blobs/${id}.png` });++ it('keeps each local preview until its server copy is usable, under the server id, in send order', () => {+ const mine = [local('l1', 'a.png'), local('l2', 'b.png')];+ expect(mergeBotGroupLocalAttachments([placeholder('s2', 'b.png'), placeholder('s1', 'a.png')], mine)).toEqual([+ { ...mine[0], id: 's1' },+ { ...mine[1], id: 's2' },+ ]);+ expect(mergeBotGroupLocalAttachments([usable('s1', 'a.png'), placeholder('s2', 'b.png')], mine)).toEqual([+ usable('s1', 'a.png'),+ { ...mine[1], id: 's2' },+ ]);+ // Older servers leave a copy out until it downloads: never show it missing or twice.+ expect(mergeBotGroupLocalAttachments([usable('s2', 'b.png')], mine)).toEqual([mine[0], usable('s2', 'b.png')]);+ // A burned-in image may come back renamed; equal counts pair the rest in order.+ expect(mergeBotGroupLocalAttachments([usable('s1', 'a-annotated.png'), usable('s2', 'b.png')], mine)).toEqual([+ usable('s1', 'a-annotated.png'),+ usable('s2', 'b.png'),+ ]);+ });++ it('carries the previews from the pending bubble onto the real message, then lets them go', async () => {+ mocks.send.mockResolvedValueOnce({ ok: true, messageId: 'm1' });+ const file = { id: 'l1', name: 'a.png', path: '/tmp/a.png', size: 1, category: 'image', mimeType: 'image/png',+ url: 'cindy-media://blobs/l1.png', type: 'image' } as unknown as AttachedFile;+ enqueueBotGroupSend(draft({ text: '' }, { files: [file] }));+ await flush();+ const shownLocal = getBotGroupOutbox('g1')[0]!.attachments;++ const loading = [msg({ id: 'm1', sequence: 1, attachments: [placeholder('s1', 'a.png')] })];+ expect(project('g1', loading)).toEqual({ pending: [], localAttachments: new Map([['m1', shownLocal]]) });+ noteBotGroupTimeline('g1', loading, beginBotGroupTimelineRead());+ // The entry is settled, the preview stays with the message.+ expect(getBotGroupOutbox('g1')).toEqual([]);+ expect(project('g1', loading).localAttachments.get('m1')).toEqual(shownLocal);++ noteBotGroupTimeline('g1', [msg({ id: 'm1', sequence: 1, attachments: [usable('s1', 'a.png')] })], beginBotGroupTimelineRead());+ expect(getBotGroupOutboxPreviews('g1').size).toBe(0);+ });++ it('lays the previews over the copy a re-read shows before the receipt', async () => {+ const pending = deferred();+ mocks.send.mockReturnValueOnce(pending.promise);+ noteBotGroupTimeline('g1', [], beginBotGroupTimelineRead());+ const file = { id: 'l1', name: 'a.png', path: '/tmp/a.png', size: 1, category: 'image', mimeType: 'image/png',+ url: 'cindy-media://blobs/l1.png', type: 'image' } as unknown as AttachedFile;+ enqueueBotGroupSend(draft({ text: '看图' }, { files: [file] }));+ await flush();+ const copy = msg({ id: 'm1', sequence: 1, content: '看图', attachments: [placeholder('s1', 'a.png')] });+ const projected = project('g1', [copy]);+ expect(projected.pending).toEqual([]);+ expect(projected.localAttachments.get('m1')).toEqual(getBotGroupOutbox('g1')[0]!.attachments);+ });+ });+});diff --git a/apps/desktop/src/renderer/features/bots/botGroupOutbox.ts b/apps/desktop/src/renderer/features/bots/botGroupOutbox.tsnew file mode 100644index 0000000000..53665388bf--- /dev/null+++ b/apps/desktop/src/renderer/features/bots/botGroupOutbox.ts@@ -0,0 +1,432 @@+/**+ * 群聊发件箱:用户点发送后立即在时间线末尾显示自己的消息,不等 main / 服务器回执。+ *+ * 只是 renderer 内存里的展示状态,不持久化,也不替代 main 的幂等与服务器的权威时间线:+ * - 每条消息保存 composer 交来的完整发送输入(`BotGroupSendInput`,附件除外——附件在+ * 提交时才烧录标注并序列化),提交与重试都原样发出,这里不挑字段;新增发送字段只需+ * composer 放进 `input`,显示、回执与重试自动带上。+ * - `input.clientId` 是身份,失败重试沿用同一个 clientId,main 与服务器据此去重,+ * 所以这里绝不自动重发。+ * - 同一个群的提交按发出顺序一条一条交给 main,保持用户看到的先后。+ * - 回执带回的 `messageId` 是替换依据:时间线读到这条消息就收起临时气泡;回执之后开始的+ * 一次重读即使没读到(被挤出最新一页),也说明它已进历史,同样收起。+ * - 推送重读可能先于回执到达。此时只对正在提交的那一条(同群同时最多一条)做显示上的+ * 去重:基线之后出现、未被任何回执认领、正文与附件数一致的自己的消息视为它,回执到达后+ * 仍以 messageId 为准。+ * - 附件:临时消息从输入的附件生成列表。真实消息到了而服务器副本还没下载好(没有 url / path,+ * 或旧版干脆还没出现在列表里)时,按同一 messageId 把本地预览接到真实消息上,直到副本可用,+ * 不让已看见的图片先退成缺失再出现(见 `mergeBotGroupLocalAttachments`)。+ * - 失败时交还输入框(输入框空着才交还,见 `registerBotGroupComposer`),否则留在时间线上+ * 显示没发出去,可重试或编辑。+ * - 切换账号整体清空,旧账号的迟到回执一律丢弃;群被删除时丢弃该群的条目。+ */+import { useCallback, useSyncExternalStore } from 'react';++import { getDataOwnerGeneration, isDataOwnerGenerationCurrent } from '@/contexts/dataOwnerGeneration';+import { isAnnotationBurnInError, materializeAnnotatedAttachmentsForSend } from '@/lib/annotationBurnIn';+import type { AttachedFile } from '@/lib/fileTypes';+import type {+ BotGroupAttachment,+ BotGroupMessageView,+ BotGroupSendInput,+ BotGroupSendResult,+} from '../../../shared/botGroupChat';+import { toBotGroupAttachmentInputs } from './botGroupAttachments';+import type { BotGroupTrackedMention } from './botGroupMentions';+import { botGroupErrorKey } from './botGroupPresentation';+import { botGroupApi } from './botGroupStore';++export type BotGroupOutboxStatus = 'sending' | 'sent' | 'failed';++/** The send as main receives it; attachments are prepared from `files` at submission. */+export type BotGroupOutboxSendInput = Omit<BotGroupSendInput, 'attachments'>;++/** What the composer hands over when the user presses send. */+export interface BotGroupOutboxDraft {+ /** Sent unchanged on every (re)try; `groupId` and `clientId` identify the entry. */+ input: BotGroupOutboxSendInput;+ /** Same-attempt identity from `botGroupSendSignature`: a changed field means a new clientId. */+ signature: string;+ /** The composer text as typed, put back on failure. */+ draft: string;+ /** Composer-only state put back with the draft (which typed @ picked which teammate). */+ tracked: readonly BotGroupTrackedMention[];+ files: readonly AttachedFile[];+ /** Scope for burning drawn annotations into images (see botGroupAttachmentScope). */+ attachmentScope: string;+}++/**+ * Identity of one send attempt: every field of the input except the clientId, plus the+ * attachments. A failed send may reuse its clientId only while this is unchanged.+ */+export function botGroupSendSignature(input: BotGroupOutboxSendInput, attachmentSignature: string): string {+ return JSON.stringify([{ ...input, clientId: undefined }, attachmentSignature]);+}++export interface BotGroupOutboxEntry extends BotGroupOutboxDraft {+ status: BotGroupOutboxStatus;+ createdAt: number;+ /** The attachments as the timeline shows them. */+ attachments: readonly BotGroupAttachment[];+ /** From the receipt. */+ messageId?: string;+ /** Order of the receipt against timeline reads (see `beginBotGroupTimelineRead`). */+ receiptTick?: number;+ /** Highest timeline sequence known when this entry's request started; set only while in flight. */+ baseline?: number;+ /** i18n key explaining a failure. */+ errorKey?: string;+}++/** The mounted composer of a group: takes a failed message back into the input when it is empty. */+export interface BotGroupComposerHandle {+ restore: (entry: BotGroupOutboxEntry) => boolean;+ notifyFailed: (errorKey: string) => void;+}++interface GroupOutbox {+ entries: readonly BotGroupOutboxEntry[];+ chain: Promise<void>;+ /** Recent receipt ids: a re-read can never mistake them for the message still in flight. */+ claimed: string[];+ latestSequence: number;+ /** Local attachment previews of confirmed messages, by messageId, until the server copy is usable. */+ previews: ReadonlyMap<string, readonly BotGroupAttachment[]>;+}++const CLAIMED_LIMIT = 64;+const PREVIEW_LIMIT = 32;+const NO_PREVIEWS: ReadonlyMap<string, readonly BotGroupAttachment[]> = new Map();+const EMPTY: readonly BotGroupOutboxEntry[] = [];++let owner = getDataOwnerGeneration();+let generation = 0;+let tick = 0;+const groups = new Map<string, GroupOutbox>();+const composers = new Map<string, BotGroupComposerHandle>();+const listeners = new Set<() => void>();++function emit(): void {+ for (const listener of listeners) listener();+}++function ensureOwner(): void {+ if (isDataOwnerGenerationCurrent(owner)) return;+ owner = getDataOwnerGeneration();+ generation += 1;+ groups.clear();+}++function groupOf(groupId: string): GroupOutbox {+ ensureOwner();+ let group = groups.get(groupId);+ if (!group) {+ group = { entries: EMPTY, chain: Promise.resolve(), claimed: [], latestSequence: 0, previews: NO_PREVIEWS };+ groups.set(groupId, group);+ }+ return group;+}++function update(groupId: string, clientId: string, patch: Partial<BotGroupOutboxEntry>): BotGroupOutboxEntry | null {+ const group = groups.get(groupId);+ const index = group?.entries.findIndex((entry) => entry.input.clientId === clientId) ?? -1;+ if (!group || index < 0) return null;+ const next = { ...group.entries[index]!, ...patch };+ group.entries = group.entries.map((entry, at) => (at === index ? next : entry));+ emit();+ return next;+}++function remove(groupId: string, clientId: string): void {+ const group = groups.get(groupId);+ if (!group || !group.entries.some((entry) => entry.input.clientId === clientId)) return;+ group.entries = group.entries.filter((entry) => entry.input.clientId !== clientId);+ emit();+}++function displayAttachments(files: readonly AttachedFile[]): BotGroupAttachment[] {+ return toBotGroupAttachmentInputs(files).map((file) => ({+ id: file.id,+ name: file.name,+ category: file.category,+ mimeType: file.mimeType,+ size: file.size ?? 0,+ url: file.url ?? null,+ path: file.path || null,+ ...(file.annotated ? { annotated: true } : {}),+ }));+}++/** Show the message at once and queue it behind the group's earlier sends. */+export function enqueueBotGroupSend(draft: BotGroupOutboxDraft): void {+ const { groupId, clientId } = draft.input;+ const group = groupOf(groupId);+ const entry: BotGroupOutboxEntry = {+ ...draft,+ input: { ...draft.input },+ files: [...draft.files],+ tracked: [...draft.tracked],+ attachments: displayAttachments(draft.files),+ status: 'sending',+ createdAt: Date.now(),+ };+ group.entries = [...group.entries.filter((existing) => existing.input.clientId !== clientId), entry];+ emit();+ schedule(groupId, clientId);+}++/** 重试 on a message that did not go out: the same clientId, so main returns any copy it already has. */+export function retryBotGroupSend(groupId: string, clientId: string): void {+ ensureOwner();+ const entry = groups.get(groupId)?.entries.find((candidate) => candidate.input.clientId === clientId);+ if (!entry || entry.status !== 'failed') return;+ update(groupId, clientId, { status: 'sending', errorKey: undefined });+ schedule(groupId, clientId);+}++/** 编辑: hand a message that did not go out back to the composer. False when the input is busy. */+export function editBotGroupSend(groupId: string, clientId: string): boolean {+ ensureOwner();+ const entry = groups.get(groupId)?.entries.find((candidate) => candidate.input.clientId === clientId);+ const composer = composers.get(groupId);+ if (!entry || entry.status !== 'failed' || !composer?.restore(entry)) return false;+ remove(groupId, clientId);+ return true;+}++function schedule(groupId: string, clientId: string): void {+ const group = groupOf(groupId);+ const requestGeneration = generation;+ group.chain = group.chain.then(() => submit(groupId, clientId, requestGeneration)).catch(() => undefined);+}++async function submit(groupId: string, clientId: string, requestGeneration: number): Promise<void> {+ const isCurrent = () => requestGeneration === generation && isDataOwnerGenerationCurrent(owner);+ if (!isCurrent()) return;+ const group = groups.get(groupId);+ const entry = group?.entries.find((candidate) => candidate.input.clientId === clientId);+ if (!group || !entry || entry.status !== 'sending') return;+ update(groupId, clientId, { baseline: group.latestSequence });+ const api = botGroupApi();+ let errorKey = 'bots.groupChat.composer.sendFailed';+ try {+ if (!api) throw new Error('HOST_NOT_READY');+ // Drawn annotations are burned in first, as in a task; a failure keeps everything for a retry.+ const prepared =+ entry.files.length > 0+ ? ((await materializeAnnotatedAttachmentsForSend(entry.files, entry.attachmentScope, { burnFailure: 'abort' })) ?? [])+ : [];+ const result: BotGroupSendResult = await api.sendBotGroupMessage({+ ...entry.input,+ ...(prepared.length > 0 ? { attachments: toBotGroupAttachmentInputs(prepared) } : {}),+ });+ if (!isCurrent()) return;+ if (result.ok) {+ group.claimed = [...group.claimed, result.messageId].slice(-CLAIMED_LIMIT);+ update(groupId, clientId, { status: 'sent', messageId: result.messageId, receiptTick: ++tick, baseline: undefined });+ return;+ }+ errorKey =+ result.errorCode === 'INVALID_PARAMS' && prepared.length > 0+ ? 'bots.groupChat.composer.attachmentsFailed'+ : botGroupErrorKey(result.errorCode, 'bots.groupChat.composer.sendFailed');+ } catch (error) {+ if (!isCurrent()) return;+ if (isAnnotationBurnInError(error)) errorKey = 'chat.media.annotateBurnFailedNotSent';+ }+ const failed = update(groupId, clientId, { status: 'failed', errorKey, baseline: undefined });+ if (!failed) return;+ const composer = composers.get(groupId);+ if (composer?.restore(failed)) remove(groupId, clientId);+ composer?.notifyFailed(errorKey);+}++/** Mark the start of a timeline read; pass the token to `noteBotGroupTimeline` when it lands. */+export function beginBotGroupTimelineRead(): number {+ return ++tick;+}++/**+ * A timeline read for this group succeeded. Receipts it contains, or that came back before+ * the read started, are settled: the server timeline now speaks for them.+ */+export function noteBotGroupTimeline(groupId: string, messages: readonly BotGroupMessageView[], readToken: number): void {+ const group = groupOf(groupId);+ group.latestSequence = messages.reduce((latest, message) => Math.max(latest, message.sequence), group.latestSequence);+ const byId = new Map(messages.map((message) => [message.id, message]));+ const settled = (entry: BotGroupOutboxEntry) =>+ entry.status === 'sent' &&+ ((entry.messageId !== undefined && byId.has(entry.messageId)) || (entry.receiptTick ?? Infinity) < readToken);+ const previews = new Map(group.previews);+ let changed = false;+ // A settled message keeps its local previews until the timeline has a usable copy of each.+ for (const entry of group.entries) {+ if (settled(entry) && entry.messageId && entry.attachments.length > 0) previews.set(entry.messageId, entry.attachments);+ }+ for (const [messageId, local] of previews) {+ const message = byId.get(messageId);+ if (message && botGroupLocalAttachmentsSettled(message.attachments, local)) previews.delete(messageId);+ }+ while (previews.size > PREVIEW_LIMIT) previews.delete(previews.keys().next().value!);+ if (previews.size !== group.previews.size || [...previews].some(([id, value]) => group.previews.get(id) !== value)) {+ group.previews = previews;+ changed = true;+ }+ if (group.entries.some(settled)) {+ group.entries = group.entries.filter((entry) => !settled(entry));+ changed = true;+ }+ if (changed) emit();+}++/** A server attachment that can be shown: an image with its address or a file on this computer. */+function isUsable(attachment: BotGroupAttachment): boolean {+ return Boolean(attachment.url || attachment.path);+}++/**+ * Pair the server's attachments of a message with the local ones it was sent with: by name+ * first, then in order when the remaining counts agree (a burned-in image can be renamed).+ * Returns, for each local attachment, the server copy it matches (or undefined), plus the+ * server attachments nothing local matched.+ */+function pairLocalAttachments(server: readonly BotGroupAttachment[], local: readonly BotGroupAttachment[]) {+ const used = new Set<number>();+ const pairs: Array<BotGroupAttachment | undefined> = local.map((file) => {+ const index = server.findIndex((candidate, at) => !used.has(at) && candidate.name === file.name);+ if (index < 0) return undefined;+ used.add(index);+ return server[index];+ });+ const rest = server.flatMap((candidate, at) => (used.has(at) ? [] : [at]));+ const unpaired = pairs.flatMap((pair, at) => (pair ? [] : [at]));+ if (rest.length === unpaired.length) {+ unpaired.forEach((at, order) => {+ used.add(rest[order]!);+ pairs[at] = server[rest[order]!];+ });+ }+ return { pairs, extra: server.filter((_, at) => !used.has(at)) };+}++/**+ * What a confirmed message shows: each attachment's server copy once it is usable, the local+ * preview until then (under the server's id when known), in the order the user sent them.+ */+export function mergeBotGroupLocalAttachments(+ server: readonly BotGroupAttachment[],+ local: readonly BotGroupAttachment[],+): BotGroupAttachment[] {+ const { pairs, extra } = pairLocalAttachments(server, local);+ return [+ ...local.map((file, at) => {+ const echo = pairs[at];+ if (!echo) return file;+ return isUsable(echo) ? echo : { ...file, id: echo.id };+ }),+ ...extra,+ ];+}++/** Every local attachment has a usable server copy: the preview is no longer needed. */+function botGroupLocalAttachmentsSettled(+ server: readonly BotGroupAttachment[],+ local: readonly BotGroupAttachment[],+): boolean {+ return pairLocalAttachments(server, local).pairs.every((echo) => echo !== undefined && isUsable(echo));+}++/** The group was deleted: nothing of it is left to send or show. */+export function discardBotGroupOutbox(groupId: string): void {+ ensureOwner();+ if (!groups.delete(groupId)) return;+ emit();+}++export function registerBotGroupComposer(groupId: string, handle: BotGroupComposerHandle): () => void {+ composers.set(groupId, handle);+ return () => {+ if (composers.get(groupId) === handle) composers.delete(groupId);+ };+}++export interface BotGroupOutboxProjection {+ /** Entries still shown under the timeline. */+ pending: BotGroupOutboxEntry[];+ /** Local attachment previews to lay over timeline messages, by message id. */+ localAttachments: ReadonlyMap<string, readonly BotGroupAttachment[]>;+}++/**+ * Split the outbox against the timeline. A receipt already in the timeline is no longer+ * pending; so is the one request in flight once a re-read shows an unclaimed copy of it (see+ * above). Either way the real message keeps the local attachment previews until usable.+ */+export function projectBotGroupOutbox(+ entries: readonly BotGroupOutboxEntry[],+ messages: readonly BotGroupMessageView[],+ claimed: readonly string[],+ previews: ReadonlyMap<string, readonly BotGroupAttachment[]> = NO_PREVIEWS,+): BotGroupOutboxProjection {+ const localAttachments = new Map(previews);+ if (entries.length === 0) return { pending: [], localAttachments };+ const ids = new Set(messages.map((message) => message.id));+ const claimedIds = new Set(claimed);+ const pending = entries.filter((entry) => {+ if (entry.status === 'sent') {+ if (!(entry.messageId && ids.has(entry.messageId))) return true;+ if (entry.attachments.length > 0) localAttachments.set(entry.messageId, entry.attachments);+ return false;+ }+ if (entry.status !== 'sending' || entry.baseline === undefined) return true;+ const baseline = entry.baseline;+ const copy = messages.find(+ (message) =>+ message.kind === 'message' &&+ message.authorKind === 'user' &&+ message.isSelf !== false &&+ message.sequence > baseline &&+ !claimedIds.has(message.id) &&+ message.content.trim() === entry.input.text &&+ message.attachments.length === entry.files.length,+ );+ if (!copy) return true;+ if (entry.attachments.length > 0) localAttachments.set(copy.id, entry.attachments);+ return false;+ });+ return { pending, localAttachments };+}++function subscribe(listener: () => void): () => void {+ listeners.add(listener);+ return () => listeners.delete(listener);+}++export function getBotGroupOutbox(groupId: string): readonly BotGroupOutboxEntry[] {+ ensureOwner();+ return groups.get(groupId)?.entries ?? EMPTY;+}++export function getBotGroupOutboxClaims(groupId: string): readonly string[] {+ ensureOwner();+ return groups.get(groupId)?.claimed ?? [];+}++export function getBotGroupOutboxPreviews(groupId: string): ReadonlyMap<string, readonly BotGroupAttachment[]> {+ ensureOwner();+ return groups.get(groupId)?.previews ?? NO_PREVIEWS;+}++export function useBotGroupOutbox(groupId: string): readonly BotGroupOutboxEntry[] {+ const read = useCallback(() => getBotGroupOutbox(groupId), [groupId]);+ return useSyncExternalStore(subscribe, read, read);+}++/** Test-only reset of the module state. */+export function resetBotGroupOutboxForTests(): void {+ generation += 1;+ owner = getDataOwnerGeneration();+ groups.clear();+ composers.clear();+}diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 0a701ece80..b7ec7ca665 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -8998,6 +8998,12 @@"attachmentsFailed": "Attachments not sent. Check that the files still exist, or remove them and try again.","folderNotSupported": "Folders can’t be attached. Choose the files inside instead."},+ "outbox": {+ "sending": "Sending…",+ "failed": "Not sent",+ "edit": "Edit",+ "editBlocked": "Send or clear what’s in the input first, then edit this message."+ },"timeline": {"loadEarlier": "Show Earlier Messages","loadEarlierFailed": "Couldn’t load earlier messages. Try again.",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 4defb76fe4..10c086fec6 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -8961,6 +8961,12 @@"attachmentsFailed": "添付ファイルを送信できませんでした。ファイルが残っているか確認するか、削除してから再試行してください","folderNotSupported": "フォルダーは添付できません。中のファイルを選んでください"},+ "outbox": {+ "sending": "送信中…",+ "failed": "送信できませんでした",+ "edit": "編集",+ "editBlocked": "入力欄に内容があります。送信するか消してから、このメッセージを編集してください"+ },"timeline": {"loadEarlier": "以前のメッセージを表示","loadEarlierFailed": "以前のメッセージを読み込めませんでした。もう一度お試しください",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex dffa9692e3..51cfa3a248 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -8961,6 +8961,12 @@"attachmentsFailed": "첨부 파일을 보내지 못했습니다. 파일이 아직 있는지 확인하거나, 제거한 후 다시 시도하세요","folderNotSupported": "폴더는 첨부할 수 없습니다. 폴더 안의 파일을 선택하세요"},+ "outbox": {+ "sending": "보내는 중…",+ "failed": "보내지 못했습니다",+ "edit": "편집",+ "editBlocked": "입력란에 내용이 있습니다. 먼저 보내거나 지운 다음 이 메시지를 편집하세요"+ },"timeline": {"loadEarlier": "이전 메시지 보기","loadEarlierFailed": "이전 메시지를 불러오지 못했습니다. 다시 시도하세요",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 33aef31025..d7177c5eaf 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -8961,6 +8961,12 @@"attachmentsFailed": "附件没能发出去,请检查文件是否还在,或移除后重试","folderNotSupported": "文件夹不能作为附件,请选择其中的文件"},+ "outbox": {+ "sending": "发送中…",+ "failed": "没发出去",+ "edit": "编辑",+ "editBlocked": "输入框里还有内容,先发出或清空,再编辑这条消息"+ },"timeline": {"loadEarlier": "查看更早的消息","loadEarlierFailed": "更早的消息没能加载,请再试一次",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex daf6ba3c90..3d0f0ac26b 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -8961,6 +8961,12 @@"attachmentsFailed": "附件沒能送出,請檢查檔案是否還在,或移除後重試","folderNotSupported": "資料夾不能作為附件,請選擇其中的檔案"},+ "outbox": {+ "sending": "傳送中…",+ "failed": "沒有送出",+ "edit": "編輯",+ "editBlocked": "輸入框裡還有內容,先送出或清空,再編輯這則訊息"+ },"timeline": {"loadEarlier": "查看更早的訊息","loadEarlierFailed": "更早的訊息沒能載入,請再試一次",diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.mdindex 57195682ad..22a04ac2e7 100644--- a/docs/design-rules/design-inventory.md+++ b/docs/design-rules/design-inventory.md@@ -18,7 +18,7 @@| `desktop.auth.add-account` | desktop | 添加账号 | hash `/add-account`(ProtectedRoute → AddAccountLoginPage) | AddAccountLoginPage | apps/desktop/src/renderer/components/login/AddAccountLoginPage.tsx, apps/desktop/src/renderer/components/login/LoginBrandStage.tsx, apps/desktop/src/renderer/components/login/LoginCaptchaOverlay.tsx, apps/desktop/src/renderer/components/login/LoginControls.tsx, apps/desktop/src/renderer/components/login/LoginPage.tsx, apps/desktop/src/renderer/components/login/loginDesignTokens.ts | 59 | 0 | 20 || `desktop.auth.legacy-migration` | desktop | 首登数据迁移弹窗 | App 顶层挂载 LegacyMigrationDialog(仅主窗;main 检测到旧版 userData 经 `legacy-migration:state` 驱动) | LegacyMigrationDialog | apps/desktop/src/renderer/components/auth/LegacyMigrationDialog.tsx | 8 | 0 | 2 || `desktop.auth.login` | desktop | 登录页 | hash `/login`(GuestRoute → LoginPage) | LoginBrandStage, LoginCaptchaOverlay, LoginControls, LoginPage | apps/desktop/src/renderer/components/login/LoginBrandStage.tsx, apps/desktop/src/renderer/components/login/LoginCaptchaOverlay.tsx, apps/desktop/src/renderer/components/login/LoginControls.tsx, apps/desktop/src/renderer/components/login/LoginPage.tsx, apps/desktop/src/renderer/components/login/loginDesignTokens.ts | 59 | 0 | 20 |-| `desktop.bots` | desktop | 伙伴(列表 / 对话 / 设置 / 历史 / 伙伴私聊 / 群聊) | hash `/bots`、`/bots/list`、`/bots/:botId`、`/bots/roster` 及伙伴当前/历史任务、伙伴私聊、伙伴群聊路由(BotsFeatureLayout) | BotBasicProfileFields, BotCollaborationCard, BotDirectMessageView, BotGroupChatView, BotGroupCreateDialog, BotGroupSettingsDrawer, BotHistorySessionView, BotLifecycleSettings, BotModelChainEditor, BotRosterView, BotSessionView, BotSettingsDrawer, BotsHomeView, BotsListView, RemoteBotSessionView | apps/desktop/src/renderer/components/chat/AgentActionRow.tsx, apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsx, apps/desktop/src/renderer/components/chat/AgentOnOtherDeviceContext.tsx, apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx, apps/desktop/src/renderer/components/chat/AgentTaskLiveDetails.tsx, apps/desktop/src/renderer/components/chat/AnnotationStrokesSvg.tsx, apps/desktop/src/renderer/components/chat/AskUserQuestionBubble.tsx, apps/desktop/src/renderer/components/chat/AssistantMessage.tsx, apps/desktop/src/renderer/components/chat/AutomationOriginBadge.tsx, apps/desktop/src/renderer/components/chat/ChatAudioCard.tsx, apps/desktop/src/renderer/components/chat/ChatDisplaySnapshotContext.tsx, apps/desktop/src/renderer/components/chat/ChatImageView.tsx, apps/desktop/src/renderer/components/chat/ChatLoadingImage.tsx, apps/desktop/src/renderer/components/chat/ChatSessionFileContext.tsx, apps/desktop/src/renderer/components/chat/ChatSoundEffectCard.tsx, apps/desktop/src/renderer/components/chat/ChatVideoView.tsx, apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx, apps/desktop/src/renderer/components/chat/CopyAsImageBlock.tsx, apps/desktop/src/renderer/components/chat/CredentialSwitchWaitBanner.tsx, apps/desktop/src/renderer/components/chat/DiffView.tsx, apps/desktop/src/renderer/components/chat/ErrorBanner.tsx, apps/desktop/src/renderer/components/chat/ErrorMessageCard.tsx, apps/desktop/src/renderer/components/chat/GeneratedFilesCard.tsx, apps/desktop/src/renderer/components/chat/GhostCardHostPrompts.tsx, apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx, apps/desktop/src/renderer/components/chat/GhostToolCard.tsx, apps/desktop/src/renderer/components/chat/HookTaskCard.tsx, apps/desktop/src/renderer/components/chat/ImageGalleryContext.tsx, apps/desktop/src/renderer/components/chat/ImageHoverPreview.tsx, apps/desktop/src/renderer/components/chat/ImageLightbox.tsx, apps/desktop/src/renderer/components/chat/ImageMissingPlaceholder.tsx, apps/desktop/src/renderer/components/chat/InlineReferenceChip.tsx, apps/desktop/src/renderer/components/chat/InterruptedTurnBanner.tsx, apps/desktop/src/renderer/components/chat/JumpToBottomChip.tsx, apps/desktop/src/renderer/components/chat/MarkdownDiffBlock.tsx, apps/desktop/src/renderer/components/chat/MarkdownMermaidBlock.tsx, apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx, apps/desktop/src/renderer/components/chat/MermaidLightbox.tsx, apps/desktop/src/renderer/components/chat/MessageActionBar.tsx, apps/desktop/src/renderer/components/chat/MessageNavRail.tsx, apps/desktop/src/renderer/components/chat/MessageSourceLabels.tsx, apps/desktop/src/renderer/components/chat/MessageStream.tsx, apps/desktop/src/renderer/components/chat/MessageViewport.tsx, apps/desktop/src/renderer/components/chat/ModelLightbox.tsx, apps/desktop/src/renderer/components/chat/NewMessageIndicator.tsx, apps/desktop/src/renderer/components/chat/PlanReviewBubble.tsx, apps/desktop/src/renderer/components/chat/PrevMessageJumpChip.tsx, apps/desktop/src/renderer/components/chat/ProjectLinkChip.tsx, apps/desktop/src/renderer/components/chat/QuoteChip.tsx, apps/desktop/src/renderer/components/chat/RewindPreviewDialog.tsx, apps/desktop/src/renderer/components/chat/SelectionQuoteButton.tsx, apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx, apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx, apps/desktop/src/renderer/components/chat/SessionHandoffCard.tsx, apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx, apps/desktop/src/renderer/components/chat/ShareMessageCheckbox.tsx, apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx, apps/desktop/src/renderer/components/chat/SlackIcon.tsx, apps/desktop/src/renderer/components/chat/StreamFadeSpan.tsx, apps/desktop/src/renderer/components/chat/StreamingMarkdownChunk.tsx, apps/desktop/src/renderer/components/chat/SystemCard.tsx, apps/desktop/src/renderer/components/chat/TextLightbox.tsx, apps/desktop/src/renderer/components/chat/ThinkingCard.tsx, apps/desktop/src/renderer/components/chat/ThinkingText.tsx, apps/desktop/src/renderer/components/chat/TodoListCard.tsx, apps/desktop/src/renderer/components/chat/ToolCallCard.tsx, apps/desktop/src/renderer/components/chat/ToolPayloadLightbox.tsx, apps/desktop/src/renderer/components/chat/TopRightChipStack.tsx, apps/desktop/src/renderer/components/chat/TurnChangesCard.tsx, apps/desktop/src/renderer/components/chat/UnreadFailedScheduleBanner.tsx, apps/desktop/src/renderer/components/chat/UpgradeBanner.tsx, apps/desktop/src/renderer/components/chat/UserAttachmentChip.tsx, apps/desktop/src/renderer/components/chat/UserMessage.tsx, apps/desktop/src/renderer/components/chat/UserMessageEditBox.tsx, apps/desktop/src/renderer/components/chat/UserMessageUrlLink.tsx, apps/desktop/src/renderer/components/chat/VideoLightbox.tsx, apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx, apps/desktop/src/renderer/components/chat/WorktreeRestoreBanner.tsx, apps/desktop/src/renderer/components/chat/XIcon.tsx, apps/desktop/src/renderer/components/chat/activityRowChrome.ts, apps/desktop/src/renderer/components/chat/animateFocusScroll.ts, apps/desktop/src/renderer/components/chat/autoFollowIntent.ts, apps/desktop/src/renderer/components/chat/chatChrome.ts, apps/desktop/src/renderer/components/chat/errorReasonI18n.ts, apps/desktop/src/renderer/components/chat/generatedFilesProjection.ts, apps/desktop/src/renderer/components/chat/imageDisplaySize.ts, apps/desktop/src/renderer/components/chat/lightboxAnnotations.ts, apps/desktop/src/renderer/components/chat/lightboxGestures.ts, apps/desktop/src/renderer/components/chat/markdownImageTargets.ts, apps/desktop/src/renderer/components/chat/markdownMedia.ts, apps/desktop/src/renderer/components/chat/messageNavRailModel.ts, apps/desktop/src/renderer/components/chat/messageNavRailWheel.ts, apps/desktop/src/renderer/components/chat/messageNavigationProjection.ts, apps/desktop/src/renderer/components/chat/messageProjectionCache.ts, apps/desktop/src/renderer/components/chat/messageStreamIndicatorPosition.ts, apps/desktop/src/renderer/components/chat/messageViewportCompensation.ts, apps/desktop/src/renderer/components/chat/messageViewportGeometry.ts, apps/desktop/src/renderer/components/chat/messageWorkGroups.ts, apps/desktop/src/renderer/components/chat/observeProgrammaticScroll.ts, apps/desktop/src/renderer/components/chat/rehypeFencedCodeMarker.ts, apps/desktop/src/renderer/components/chat/rehypeHighlightShared.ts, apps/desktop/src/renderer/components/chat/rehypeMathBlockMarker.ts, apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.ts, apps/desktop/src/renderer/components/chat/remarkHtmlImages.ts, apps/desktop/src/renderer/components/chat/remarkLocalPathLinks.ts, apps/desktop/src/renderer/components/chat/remarkPreserveRawLocalDestinations.ts, apps/desktop/src/renderer/components/chat/remarkSessionLinks.ts, apps/desktop/src/renderer/components/chat/remarkStrictInlineMath.ts, apps/desktop/src/renderer/components/chat/remarkTruncateCjkUrls.ts, apps/desktop/src/renderer/components/chat/repairStreamingMarkdown.ts, apps/desktop/src/renderer/components/chat/scrollAnchoringDetect.ts, apps/desktop/src/renderer/components/chat/shareSelectionStore.ts, apps/desktop/src/renderer/components/chat/streamingMarkdownBlocks.tsx, apps/desktop/src/renderer/components/chat/streamingMarkdownChunks.ts, apps/desktop/src/renderer/components/chat/streamingMessageProjection.ts, apps/desktop/src/renderer/components/chat/toolLoopI18n.ts, apps/desktop/src/renderer/components/chat/unreadCount.ts, apps/desktop/src/renderer/components/chat/useAutomaticHistoryLoadBudget.ts, apps/desktop/src/renderer/components/chat/useCopyAsImage.tsx, apps/desktop/src/renderer/components/chat/useDeleteMessage.ts, apps/desktop/src/renderer/components/chat/useFileChipContextMenu.tsx, apps/desktop/src/renderer/components/chat/useForkAtMessage.ts, apps/desktop/src/renderer/components/chat/useImageClipboard.ts, apps/desktop/src/renderer/components/chat/useImageLoadFailure.ts, apps/desktop/src/renderer/components/chat/useMessageViewport.ts, apps/desktop/src/renderer/components/chat/useNavigationKeyListener.ts, apps/desktop/src/renderer/components/chat/useOpenWithMenu.tsx, apps/desktop/src/renderer/components/chat/usePrevUserMessageInView.ts, apps/desktop/src/renderer/components/chat/useTurnChangeSets.ts, apps/desktop/src/renderer/components/chat/userMessageCollapse.ts, apps/desktop/src/renderer/components/chat/userMessageDisplayText.ts, apps/desktop/src/renderer/components/chat/userMessageLinkify.ts, apps/desktop/src/renderer/components/chat/viewportFillDetect.ts, apps/desktop/src/renderer/components/new-chat/AddRemoteProjectDialog.tsx, apps/desktop/src/renderer/components/new-chat/AgentSelect.tsx, apps/desktop/src/renderer/components/new-chat/AskUserQuestionPrompt.tsx, apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx, apps/desktop/src/renderer/components/new-chat/AttachmentTypeThumb.tsx, apps/desktop/src/renderer/components/new-chat/ChatInput.tsx, apps/desktop/src/renderer/components/new-chat/CjkPunctDecoration.ts, apps/desktop/src/renderer/components/new-chat/CjkPunctuationUtils.ts, apps/desktop/src/renderer/components/new-chat/ComposerAttachments.tsx, apps/desktop/src/renderer/components/new-chat/ComposerListIndentDecoration.ts, apps/desktop/src/renderer/components/new-chat/ComposerListNodes.ts, apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx, apps/desktop/src/renderer/components/new-chat/DeviceSwitcherPill.tsx, apps/desktop/src/renderer/components/new-chat/EffortSlider.tsx, apps/desktop/src/renderer/components/new-chat/EmptyDocSelectionGuard.ts, apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx, apps/desktop/src/renderer/components/new-chat/FastModeToggle.tsx, apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx, apps/desktop/src/renderer/components/new-chat/FullAccessConfirmContent.tsx, apps/desktop/src/renderer/components/new-chat/GhostCommandDecoration.ts, apps/desktop/src/renderer/components/new-chat/GoalAdvancedLimits.tsx, apps/desktop/src/renderer/components/new-chat/GoalIndicator.tsx, apps/desktop/src/renderer/components/new-chat/HomeUsageDashboard.tsx, apps/desktop/src/renderer/components/new-chat/ListComposerTextarea.tsx, apps/desktop/src/renderer/components/new-chat/LocalModelCatalogNotice.tsx, apps/desktop/src/renderer/components/new-chat/MentionChipNode.tsx, apps/desktop/src/renderer/components/new-chat/MentionDragCaretDecoration.ts, apps/desktop/src/renderer/components/new-chat/ModelCompatibilityNotice.tsx, apps/desktop/src/renderer/components/new-chat/ModelConfigFlyout.tsx, apps/desktop/src/renderer/components/new-chat/ModelHarnessPicker.tsx, apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx, apps/desktop/src/renderer/components/new-chat/ModelSourceDetails.tsx, apps/desktop/src/renderer/components/new-chat/NewGoalDialog.tsx, apps/desktop/src/renderer/components/new-chat/PastedTextChipNode.tsx, apps/desktop/src/renderer/components/new-chat/PendingQueuePanel.tsx, apps/desktop/src/renderer/components/new-chat/PermissionPrompt.tsx, apps/desktop/src/renderer/components/new-chat/PermissionSelector.tsx, apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx, apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx, apps/desktop/src/renderer/components/new-chat/PlanModeIndicator.tsx, apps/desktop/src/renderer/components/new-chat/PlanViewerCard.tsx, apps/desktop/src/renderer/components/new-chat/PluginConnectionForm.tsx, apps/desktop/src/renderer/components/new-chat/PluginOauthDeviceCode.tsx, apps/desktop/src/renderer/components/new-chat/PluginSetupPrompt.tsx, apps/desktop/src/renderer/components/new-chat/PluginSetupRemoteDesktopButton.tsx, apps/desktop/src/renderer/components/new-chat/PluginWriteAccessRecovery.tsx, apps/desktop/src/renderer/components/new-chat/QuickStartPillMark.ts, apps/desktop/src/renderer/components/new-chat/RemoteOauthSetupCard.tsx, apps/desktop/src/renderer/components/new-chat/SendButton.tsx, apps/desktop/src/renderer/components/new-chat/SlashCommandDecoration.ts, apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx, apps/desktop/src/renderer/components/new-chat/TakeoverMask.tsx, apps/desktop/src/renderer/components/new-chat/ThinkingToggle.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedFlyoutHost.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelRail.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx, apps/desktop/src/renderer/components/new-chat/UsageDailyBars.tsx, apps/desktop/src/renderer/components/new-chat/UsageHeatmap.tsx, apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx, apps/desktop/src/renderer/components/new-chat/VoiceInputDraftDecoration.ts, apps/desktop/src/renderer/components/new-chat/WindowsSelectionReplacement.ts, apps/desktop/src/renderer/components/new-chat/WorktreeChipsRow.tsx, apps/desktop/src/renderer/components/new-chat/WorktreeCreatingOverlay.tsx, apps/desktop/src/renderer/components/new-chat/agentOptions.ts, apps/desktop/src/renderer/components/new-chat/agentSwitchConfirmation.ts, apps/desktop/src/renderer/components/new-chat/branchPick.ts, apps/desktop/src/renderer/components/new-chat/composerBlankPointerFocus.ts, apps/desktop/src/renderer/components/new-chat/composerContentSerialization.ts, apps/desktop/src/renderer/components/new-chat/composerDocState.ts, apps/desktop/src/renderer/components/new-chat/composerFrameScheduler.ts, apps/desktop/src/renderer/components/new-chat/composerHistoryProjection.ts, apps/desktop/src/renderer/components/new-chat/composerModelSelection.ts, apps/desktop/src/renderer/components/new-chat/composerPromptRecommendation.ts, apps/desktop/src/renderer/components/new-chat/composerRenderGate.ts, apps/desktop/src/renderer/components/new-chat/composerSendOwnership.ts, apps/desktop/src/renderer/components/new-chat/composerSendSnapshot.ts, apps/desktop/src/renderer/components/new-chat/effortChangeQueue.ts, apps/desktop/src/renderer/components/new-chat/extraDirsActions.ts, apps/desktop/src/renderer/components/new-chat/ghostComposerPlacement.ts, apps/desktop/src/renderer/components/new-chat/localAttachmentPicker.ts, apps/desktop/src/renderer/components/new-chat/mentionChipInsertion.ts, apps/desktop/src/renderer/components/new-chat/modelWindowErrorToast.ts, apps/desktop/src/renderer/components/new-chat/pastePipeline.ts, apps/desktop/src/renderer/components/new-chat/pathPaste.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueLocks.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueRowActivity.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueRowPresentation.ts, apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.ts, apps/desktop/src/renderer/components/new-chat/priceTierMarks.tsx, apps/desktop/src/renderer/components/new-chat/remoteBrowseAdapters.ts, apps/desktop/src/renderer/components/new-chat/remoteExistingProjects.ts, apps/desktop/src/renderer/components/new-chat/restoreComposerDocument.ts, apps/desktop/src/renderer/components/new-chat/sessionLinkPaste.ts, apps/desktop/src/renderer/components/new-chat/sourceSwitch.ts, apps/desktop/src/renderer/components/new-chat/unifiedModelSelection.ts, apps/desktop/src/renderer/components/new-chat/usagePalette.ts, apps/desktop/src/renderer/components/new-chat/useComposerSendFocusRestore.ts, apps/desktop/src/renderer/components/new-chat/useModelDiscoveryPending.ts, apps/desktop/src/renderer/components/new-chat/useProviderWeeklyQuota.ts, apps/desktop/src/renderer/components/new-chat/useUnifiedRowActions.ts, apps/desktop/src/renderer/features/bots/BotAuthorizationCard.tsx, apps/desktop/src/renderer/features/bots/BotAvatar.tsx, apps/desktop/src/renderer/features/bots/BotBasicProfileFields.tsx, apps/desktop/src/renderer/features/bots/BotCapabilitySettings.tsx, apps/desktop/src/renderer/features/bots/BotCollaborationCard.tsx, apps/desktop/src/renderer/features/bots/BotConnectionStatus.tsx, apps/desktop/src/renderer/features/bots/BotCreateMenu.tsx, apps/desktop/src/renderer/features/bots/BotDeleteDialog.tsx, apps/desktop/src/renderer/features/bots/BotDirectMessageCard.tsx, apps/desktop/src/renderer/features/bots/BotDirectMessageView.tsx, apps/desktop/src/renderer/features/bots/BotFollowMark.tsx, apps/desktop/src/renderer/features/bots/BotGenerationLabel.tsx, apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx, apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx, apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx, apps/desktop/src/renderer/features/bots/BotGroupCreateDialog.tsx, apps/desktop/src/renderer/features/bots/BotGroupPendingInteraction.tsx, apps/desktop/src/renderer/features/bots/BotGroupPlan.tsx, apps/desktop/src/renderer/features/bots/BotGroupRuntimeFailureNotice.tsx, apps/desktop/src/renderer/features/bots/BotGroupSettingsDrawer.tsx, apps/desktop/src/renderer/features/bots/BotGroupSidebarRow.tsx, apps/desktop/src/renderer/features/bots/BotHistorySessionView.tsx, apps/desktop/src/renderer/features/bots/BotImportForm.tsx, apps/desktop/src/renderer/features/bots/BotInvitationWelcome.tsx, apps/desktop/src/renderer/features/bots/BotLearningFooter.tsx, apps/desktop/src/renderer/features/bots/BotLifecycleSettings.tsx, apps/desktop/src/renderer/features/bots/BotMemorySettings.tsx, apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx, apps/desktop/src/renderer/features/bots/BotPortraitPicker.tsx, apps/desktop/src/renderer/features/bots/BotRosterView.tsx, apps/desktop/src/renderer/features/bots/BotRoutines.tsx, apps/desktop/src/renderer/features/bots/BotSessionContentHeader.tsx, apps/desktop/src/renderer/features/bots/BotSessionTaskLink.tsx, apps/desktop/src/renderer/features/bots/BotSessionTaskResultCard.tsx, apps/desktop/src/renderer/features/bots/BotSessionView.tsx, apps/desktop/src/renderer/features/bots/BotSettingsBlock.tsx, apps/desktop/src/renderer/features/bots/BotSettingsDrawer.tsx, apps/desktop/src/renderer/features/bots/BotTaskCardHeader.tsx, apps/desktop/src/renderer/features/bots/BotTaskModelEditor.tsx, apps/desktop/src/renderer/features/bots/BotTodoList.tsx, apps/desktop/src/renderer/features/bots/BotWorkbench.tsx, apps/desktop/src/renderer/features/bots/BotWorkingStatus.tsx, apps/desktop/src/renderer/features/bots/BotsFeatureLayout.tsx, apps/desktop/src/renderer/features/bots/BotsGlobalSettingsSection.tsx, apps/desktop/src/renderer/features/bots/BotsHomeView.tsx, apps/desktop/src/renderer/features/bots/BotsListView.tsx, apps/desktop/src/renderer/features/bots/BotsSidebar.tsx, apps/desktop/src/renderer/features/bots/ChatBotAccessField.tsx, apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx, apps/desktop/src/renderer/features/bots/ChatInviteDialog.tsx, apps/desktop/src/renderer/features/bots/ChatInviteHost.tsx, apps/desktop/src/renderer/features/bots/ChatServerControls.tsx, apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx, apps/desktop/src/renderer/features/bots/CindyDevicePicker.tsx, apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx, apps/desktop/src/renderer/features/bots/RemoteBotSessionView.tsx, apps/desktop/src/renderer/features/bots/RemoteBotSettings.tsx, apps/desktop/src/renderer/features/bots/WorkbenchSessionList.tsx, apps/desktop/src/renderer/features/bots/botAvatarIdentity.ts, apps/desktop/src/renderer/features/bots/botCapabilityDefaults.ts, apps/desktop/src/renderer/features/bots/botChatPresentation.ts, apps/desktop/src/renderer/features/bots/botConversationPresentation.ts, apps/desktop/src/renderer/features/bots/botConversationTimeline.ts, apps/desktop/src/renderer/features/bots/botDelegationLive.ts, apps/desktop/src/renderer/features/bots/botFollowScopes.ts, apps/desktop/src/renderer/features/bots/botGeneratedArtifacts.ts, apps/desktop/src/renderer/features/bots/botGroupAttachments.ts, apps/desktop/src/renderer/features/bots/botGroupLane.ts, apps/desktop/src/renderer/features/bots/botGroupMentions.ts, apps/desktop/src/renderer/features/bots/botGroupPresentation.ts, apps/desktop/src/renderer/features/bots/botGroupStore.ts, apps/desktop/src/renderer/features/bots/botListDisplay.ts, apps/desktop/src/renderer/features/bots/botNavigation.ts, apps/desktop/src/renderer/features/bots/botPronounContext.tsx, apps/desktop/src/renderer/features/bots/botReadState.ts, apps/desktop/src/renderer/features/bots/botRosterDisplay.ts, apps/desktop/src/renderer/features/bots/botSessionOwners.ts, apps/desktop/src/renderer/features/bots/botSettingsAutosave.ts, apps/desktop/src/renderer/features/bots/botStore.ts, apps/desktop/src/renderer/features/bots/botTodo.css, apps/desktop/src/renderer/features/bots/botWelcomeContext.ts, apps/desktop/src/renderer/features/bots/botWorkbenchProjection.ts, apps/desktop/src/renderer/features/bots/chatError.ts, apps/desktop/src/renderer/features/bots/cindyDeviceRoster.ts, apps/desktop/src/renderer/features/bots/remoteBotRoster.ts, apps/desktop/src/renderer/features/bots/remoteBotSettingsData.ts, apps/desktop/src/renderer/features/bots/useBotGeneratedFileDeliveries.ts, apps/desktop/src/renderer/features/bots/useBotIslandVisibleSession.ts, apps/desktop/src/renderer/features/bots/useBotSettingsAutosave.ts, apps/desktop/src/renderer/features/bots/useBotUnreadSync.ts, apps/desktop/src/renderer/features/bots/useRemoteBots.ts, apps/desktop/src/renderer/features/bots/useWorkbenchSessionPages.ts, apps/desktop/src/renderer/features/bots/useWorkingStatusCopy.ts, apps/desktop/src/renderer/features/cc-agent/CCAgentFeatureLayout.tsx, apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx | 277 | 38 | 474 |+| `desktop.bots` | desktop | 伙伴(列表 / 对话 / 设置 / 历史 / 伙伴私聊 / 群聊) | hash `/bots`、`/bots/list`、`/bots/:botId`、`/bots/roster` 及伙伴当前/历史任务、伙伴私聊、伙伴群聊路由(BotsFeatureLayout) | BotBasicProfileFields, BotCollaborationCard, BotDirectMessageView, BotGroupChatView, BotGroupCreateDialog, BotGroupSettingsDrawer, BotHistorySessionView, BotLifecycleSettings, BotModelChainEditor, BotRosterView, BotSessionView, BotSettingsDrawer, BotsHomeView, BotsListView, RemoteBotSessionView | apps/desktop/src/renderer/components/chat/AgentActionRow.tsx, apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsx, apps/desktop/src/renderer/components/chat/AgentOnOtherDeviceContext.tsx, apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx, apps/desktop/src/renderer/components/chat/AgentTaskLiveDetails.tsx, apps/desktop/src/renderer/components/chat/AnnotationStrokesSvg.tsx, apps/desktop/src/renderer/components/chat/AskUserQuestionBubble.tsx, apps/desktop/src/renderer/components/chat/AssistantMessage.tsx, apps/desktop/src/renderer/components/chat/AutomationOriginBadge.tsx, apps/desktop/src/renderer/components/chat/ChatAudioCard.tsx, apps/desktop/src/renderer/components/chat/ChatDisplaySnapshotContext.tsx, apps/desktop/src/renderer/components/chat/ChatImageView.tsx, apps/desktop/src/renderer/components/chat/ChatLoadingImage.tsx, apps/desktop/src/renderer/components/chat/ChatSessionFileContext.tsx, apps/desktop/src/renderer/components/chat/ChatSoundEffectCard.tsx, apps/desktop/src/renderer/components/chat/ChatVideoView.tsx, apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx, apps/desktop/src/renderer/components/chat/CopyAsImageBlock.tsx, apps/desktop/src/renderer/components/chat/CredentialSwitchWaitBanner.tsx, apps/desktop/src/renderer/components/chat/DiffView.tsx, apps/desktop/src/renderer/components/chat/ErrorBanner.tsx, apps/desktop/src/renderer/components/chat/ErrorMessageCard.tsx, apps/desktop/src/renderer/components/chat/GeneratedFilesCard.tsx, apps/desktop/src/renderer/components/chat/GhostCardHostPrompts.tsx, apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx, apps/desktop/src/renderer/components/chat/GhostToolCard.tsx, apps/desktop/src/renderer/components/chat/HookTaskCard.tsx, apps/desktop/src/renderer/components/chat/ImageGalleryContext.tsx, apps/desktop/src/renderer/components/chat/ImageHoverPreview.tsx, apps/desktop/src/renderer/components/chat/ImageLightbox.tsx, apps/desktop/src/renderer/components/chat/ImageMissingPlaceholder.tsx, apps/desktop/src/renderer/components/chat/InlineReferenceChip.tsx, apps/desktop/src/renderer/components/chat/InterruptedTurnBanner.tsx, apps/desktop/src/renderer/components/chat/JumpToBottomChip.tsx, apps/desktop/src/renderer/components/chat/MarkdownDiffBlock.tsx, apps/desktop/src/renderer/components/chat/MarkdownMermaidBlock.tsx, apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx, apps/desktop/src/renderer/components/chat/MermaidLightbox.tsx, apps/desktop/src/renderer/components/chat/MessageActionBar.tsx, apps/desktop/src/renderer/components/chat/MessageNavRail.tsx, apps/desktop/src/renderer/components/chat/MessageSourceLabels.tsx, apps/desktop/src/renderer/components/chat/MessageStream.tsx, apps/desktop/src/renderer/components/chat/MessageViewport.tsx, apps/desktop/src/renderer/components/chat/ModelLightbox.tsx, apps/desktop/src/renderer/components/chat/NewMessageIndicator.tsx, apps/desktop/src/renderer/components/chat/PlanReviewBubble.tsx, apps/desktop/src/renderer/components/chat/PrevMessageJumpChip.tsx, apps/desktop/src/renderer/components/chat/ProjectLinkChip.tsx, apps/desktop/src/renderer/components/chat/QuoteChip.tsx, apps/desktop/src/renderer/components/chat/RewindPreviewDialog.tsx, apps/desktop/src/renderer/components/chat/SelectionQuoteButton.tsx, apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx, apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx, apps/desktop/src/renderer/components/chat/SessionHandoffCard.tsx, apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx, apps/desktop/src/renderer/components/chat/ShareMessageCheckbox.tsx, apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx, apps/desktop/src/renderer/components/chat/SlackIcon.tsx, apps/desktop/src/renderer/components/chat/StreamFadeSpan.tsx, apps/desktop/src/renderer/components/chat/StreamingMarkdownChunk.tsx, apps/desktop/src/renderer/components/chat/SystemCard.tsx, apps/desktop/src/renderer/components/chat/TextLightbox.tsx, apps/desktop/src/renderer/components/chat/ThinkingCard.tsx, apps/desktop/src/renderer/components/chat/ThinkingText.tsx, apps/desktop/src/renderer/components/chat/TodoListCard.tsx, apps/desktop/src/renderer/components/chat/ToolCallCard.tsx, apps/desktop/src/renderer/components/chat/ToolPayloadLightbox.tsx, apps/desktop/src/renderer/components/chat/TopRightChipStack.tsx, apps/desktop/src/renderer/components/chat/TurnChangesCard.tsx, apps/desktop/src/renderer/components/chat/UnreadFailedScheduleBanner.tsx, apps/desktop/src/renderer/components/chat/UpgradeBanner.tsx, apps/desktop/src/renderer/components/chat/UserAttachmentChip.tsx, apps/desktop/src/renderer/components/chat/UserMessage.tsx, apps/desktop/src/renderer/components/chat/UserMessageEditBox.tsx, apps/desktop/src/renderer/components/chat/UserMessageUrlLink.tsx, apps/desktop/src/renderer/components/chat/VideoLightbox.tsx, apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx, apps/desktop/src/renderer/components/chat/WorktreeRestoreBanner.tsx, apps/desktop/src/renderer/components/chat/XIcon.tsx, apps/desktop/src/renderer/components/chat/activityRowChrome.ts, apps/desktop/src/renderer/components/chat/animateFocusScroll.ts, apps/desktop/src/renderer/components/chat/autoFollowIntent.ts, apps/desktop/src/renderer/components/chat/chatChrome.ts, apps/desktop/src/renderer/components/chat/errorReasonI18n.ts, apps/desktop/src/renderer/components/chat/generatedFilesProjection.ts, apps/desktop/src/renderer/components/chat/imageDisplaySize.ts, apps/desktop/src/renderer/components/chat/lightboxAnnotations.ts, apps/desktop/src/renderer/components/chat/lightboxGestures.ts, apps/desktop/src/renderer/components/chat/markdownImageTargets.ts, apps/desktop/src/renderer/components/chat/markdownMedia.ts, apps/desktop/src/renderer/components/chat/messageNavRailModel.ts, apps/desktop/src/renderer/components/chat/messageNavRailWheel.ts, apps/desktop/src/renderer/components/chat/messageNavigationProjection.ts, apps/desktop/src/renderer/components/chat/messageProjectionCache.ts, apps/desktop/src/renderer/components/chat/messageStreamIndicatorPosition.ts, apps/desktop/src/renderer/components/chat/messageViewportCompensation.ts, apps/desktop/src/renderer/components/chat/messageViewportGeometry.ts, apps/desktop/src/renderer/components/chat/messageWorkGroups.ts, apps/desktop/src/renderer/components/chat/observeProgrammaticScroll.ts, apps/desktop/src/renderer/components/chat/rehypeFencedCodeMarker.ts, apps/desktop/src/renderer/components/chat/rehypeHighlightShared.ts, apps/desktop/src/renderer/components/chat/rehypeMathBlockMarker.ts, apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.ts, apps/desktop/src/renderer/components/chat/remarkHtmlImages.ts, apps/desktop/src/renderer/components/chat/remarkLocalPathLinks.ts, apps/desktop/src/renderer/components/chat/remarkPreserveRawLocalDestinations.ts, apps/desktop/src/renderer/components/chat/remarkSessionLinks.ts, apps/desktop/src/renderer/components/chat/remarkStrictInlineMath.ts, apps/desktop/src/renderer/components/chat/remarkTruncateCjkUrls.ts, apps/desktop/src/renderer/components/chat/repairStreamingMarkdown.ts, apps/desktop/src/renderer/components/chat/scrollAnchoringDetect.ts, apps/desktop/src/renderer/components/chat/shareSelectionStore.ts, apps/desktop/src/renderer/components/chat/streamingMarkdownBlocks.tsx, apps/desktop/src/renderer/components/chat/streamingMarkdownChunks.ts, apps/desktop/src/renderer/components/chat/streamingMessageProjection.ts, apps/desktop/src/renderer/components/chat/toolLoopI18n.ts, apps/desktop/src/renderer/components/chat/unreadCount.ts, apps/desktop/src/renderer/components/chat/useAutomaticHistoryLoadBudget.ts, apps/desktop/src/renderer/components/chat/useCopyAsImage.tsx, apps/desktop/src/renderer/components/chat/useDeleteMessage.ts, apps/desktop/src/renderer/components/chat/useFileChipContextMenu.tsx, apps/desktop/src/renderer/components/chat/useForkAtMessage.ts, apps/desktop/src/renderer/components/chat/useImageClipboard.ts, apps/desktop/src/renderer/components/chat/useImageLoadFailure.ts, apps/desktop/src/renderer/components/chat/useMessageViewport.ts, apps/desktop/src/renderer/components/chat/useNavigationKeyListener.ts, apps/desktop/src/renderer/components/chat/useOpenWithMenu.tsx, apps/desktop/src/renderer/components/chat/usePrevUserMessageInView.ts, apps/desktop/src/renderer/components/chat/useTurnChangeSets.ts, apps/desktop/src/renderer/components/chat/userMessageCollapse.ts, apps/desktop/src/renderer/components/chat/userMessageDisplayText.ts, apps/desktop/src/renderer/components/chat/userMessageLinkify.ts, apps/desktop/src/renderer/components/chat/viewportFillDetect.ts, apps/desktop/src/renderer/components/new-chat/AddRemoteProjectDialog.tsx, apps/desktop/src/renderer/components/new-chat/AgentSelect.tsx, apps/desktop/src/renderer/components/new-chat/AskUserQuestionPrompt.tsx, apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx, apps/desktop/src/renderer/components/new-chat/AttachmentTypeThumb.tsx, apps/desktop/src/renderer/components/new-chat/ChatInput.tsx, apps/desktop/src/renderer/components/new-chat/CjkPunctDecoration.ts, apps/desktop/src/renderer/components/new-chat/CjkPunctuationUtils.ts, apps/desktop/src/renderer/components/new-chat/ComposerAttachments.tsx, apps/desktop/src/renderer/components/new-chat/ComposerListIndentDecoration.ts, apps/desktop/src/renderer/components/new-chat/ComposerListNodes.ts, apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx, apps/desktop/src/renderer/components/new-chat/DeviceSwitcherPill.tsx, apps/desktop/src/renderer/components/new-chat/EffortSlider.tsx, apps/desktop/src/renderer/components/new-chat/EmptyDocSelectionGuard.ts, apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx, apps/desktop/src/renderer/components/new-chat/FastModeToggle.tsx, apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx, apps/desktop/src/renderer/components/new-chat/FullAccessConfirmContent.tsx, apps/desktop/src/renderer/components/new-chat/GhostCommandDecoration.ts, apps/desktop/src/renderer/components/new-chat/GoalAdvancedLimits.tsx, apps/desktop/src/renderer/components/new-chat/GoalIndicator.tsx, apps/desktop/src/renderer/components/new-chat/HomeUsageDashboard.tsx, apps/desktop/src/renderer/components/new-chat/ListComposerTextarea.tsx, apps/desktop/src/renderer/components/new-chat/LocalModelCatalogNotice.tsx, apps/desktop/src/renderer/components/new-chat/MentionChipNode.tsx, apps/desktop/src/renderer/components/new-chat/MentionDragCaretDecoration.ts, apps/desktop/src/renderer/components/new-chat/ModelCompatibilityNotice.tsx, apps/desktop/src/renderer/components/new-chat/ModelConfigFlyout.tsx, apps/desktop/src/renderer/components/new-chat/ModelHarnessPicker.tsx, apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx, apps/desktop/src/renderer/components/new-chat/ModelSourceDetails.tsx, apps/desktop/src/renderer/components/new-chat/NewGoalDialog.tsx, apps/desktop/src/renderer/components/new-chat/PastedTextChipNode.tsx, apps/desktop/src/renderer/components/new-chat/PendingQueuePanel.tsx, apps/desktop/src/renderer/components/new-chat/PermissionPrompt.tsx, apps/desktop/src/renderer/components/new-chat/PermissionSelector.tsx, apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx, apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx, apps/desktop/src/renderer/components/new-chat/PlanModeIndicator.tsx, apps/desktop/src/renderer/components/new-chat/PlanViewerCard.tsx, apps/desktop/src/renderer/components/new-chat/PluginConnectionForm.tsx, apps/desktop/src/renderer/components/new-chat/PluginOauthDeviceCode.tsx, apps/desktop/src/renderer/components/new-chat/PluginSetupPrompt.tsx, apps/desktop/src/renderer/components/new-chat/PluginSetupRemoteDesktopButton.tsx, apps/desktop/src/renderer/components/new-chat/PluginWriteAccessRecovery.tsx, apps/desktop/src/renderer/components/new-chat/QuickStartPillMark.ts, apps/desktop/src/renderer/components/new-chat/RemoteOauthSetupCard.tsx, apps/desktop/src/renderer/components/new-chat/SendButton.tsx, apps/desktop/src/renderer/components/new-chat/SlashCommandDecoration.ts, apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx, apps/desktop/src/renderer/components/new-chat/TakeoverMask.tsx, apps/desktop/src/renderer/components/new-chat/ThinkingToggle.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedFlyoutHost.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelRail.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx, apps/desktop/src/renderer/components/new-chat/UsageDailyBars.tsx, apps/desktop/src/renderer/components/new-chat/UsageHeatmap.tsx, apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx, apps/desktop/src/renderer/components/new-chat/VoiceInputDraftDecoration.ts, apps/desktop/src/renderer/components/new-chat/WindowsSelectionReplacement.ts, apps/desktop/src/renderer/components/new-chat/WorktreeChipsRow.tsx, apps/desktop/src/renderer/components/new-chat/WorktreeCreatingOverlay.tsx, apps/desktop/src/renderer/components/new-chat/agentOptions.ts, apps/desktop/src/renderer/components/new-chat/agentSwitchConfirmation.ts, apps/desktop/src/renderer/components/new-chat/branchPick.ts, apps/desktop/src/renderer/components/new-chat/composerBlankPointerFocus.ts, apps/desktop/src/renderer/components/new-chat/composerContentSerialization.ts, apps/desktop/src/renderer/components/new-chat/composerDocState.ts, apps/desktop/src/renderer/components/new-chat/composerFrameScheduler.ts, apps/desktop/src/renderer/components/new-chat/composerHistoryProjection.ts, apps/desktop/src/renderer/components/new-chat/composerModelSelection.ts, apps/desktop/src/renderer/components/new-chat/composerPromptRecommendation.ts, apps/desktop/src/renderer/components/new-chat/composerRenderGate.ts, apps/desktop/src/renderer/components/new-chat/composerSendOwnership.ts, apps/desktop/src/renderer/components/new-chat/composerSendSnapshot.ts, apps/desktop/src/renderer/components/new-chat/effortChangeQueue.ts, apps/desktop/src/renderer/components/new-chat/extraDirsActions.ts, apps/desktop/src/renderer/components/new-chat/ghostComposerPlacement.ts, apps/desktop/src/renderer/components/new-chat/localAttachmentPicker.ts, apps/desktop/src/renderer/components/new-chat/mentionChipInsertion.ts, apps/desktop/src/renderer/components/new-chat/modelWindowErrorToast.ts, apps/desktop/src/renderer/components/new-chat/pastePipeline.ts, apps/desktop/src/renderer/components/new-chat/pathPaste.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueLocks.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueRowActivity.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueRowPresentation.ts, apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.ts, apps/desktop/src/renderer/components/new-chat/priceTierMarks.tsx, apps/desktop/src/renderer/components/new-chat/remoteBrowseAdapters.ts, apps/desktop/src/renderer/components/new-chat/remoteExistingProjects.ts, apps/desktop/src/renderer/components/new-chat/restoreComposerDocument.ts, apps/desktop/src/renderer/components/new-chat/sessionLinkPaste.ts, apps/desktop/src/renderer/components/new-chat/sourceSwitch.ts, apps/desktop/src/renderer/components/new-chat/unifiedModelSelection.ts, apps/desktop/src/renderer/components/new-chat/usagePalette.ts, apps/desktop/src/renderer/components/new-chat/useComposerSendFocusRestore.ts, apps/desktop/src/renderer/components/new-chat/useModelDiscoveryPending.ts, apps/desktop/src/renderer/components/new-chat/useProviderWeeklyQuota.ts, apps/desktop/src/renderer/components/new-chat/useUnifiedRowActions.ts, apps/desktop/src/renderer/features/bots/BotAuthorizationCard.tsx, apps/desktop/src/renderer/features/bots/BotAvatar.tsx, apps/desktop/src/renderer/features/bots/BotBasicProfileFields.tsx, apps/desktop/src/renderer/features/bots/BotCapabilitySettings.tsx, apps/desktop/src/renderer/features/bots/BotCollaborationCard.tsx, apps/desktop/src/renderer/features/bots/BotConnectionStatus.tsx, apps/desktop/src/renderer/features/bots/BotCreateMenu.tsx, apps/desktop/src/renderer/features/bots/BotDeleteDialog.tsx, apps/desktop/src/renderer/features/bots/BotDirectMessageCard.tsx, apps/desktop/src/renderer/features/bots/BotDirectMessageView.tsx, apps/desktop/src/renderer/features/bots/BotFollowMark.tsx, apps/desktop/src/renderer/features/bots/BotGenerationLabel.tsx, apps/desktop/src/renderer/features/bots/BotGroupAvatars.tsx, apps/desktop/src/renderer/features/bots/BotGroupChatView.tsx, apps/desktop/src/renderer/features/bots/BotGroupComposer.tsx, apps/desktop/src/renderer/features/bots/BotGroupCreateDialog.tsx, apps/desktop/src/renderer/features/bots/BotGroupPendingInteraction.tsx, apps/desktop/src/renderer/features/bots/BotGroupPlan.tsx, apps/desktop/src/renderer/features/bots/BotGroupRuntimeFailureNotice.tsx, apps/desktop/src/renderer/features/bots/BotGroupSettingsDrawer.tsx, apps/desktop/src/renderer/features/bots/BotGroupSidebarRow.tsx, apps/desktop/src/renderer/features/bots/BotHistorySessionView.tsx, apps/desktop/src/renderer/features/bots/BotImportForm.tsx, apps/desktop/src/renderer/features/bots/BotInvitationWelcome.tsx, apps/desktop/src/renderer/features/bots/BotLearningFooter.tsx, apps/desktop/src/renderer/features/bots/BotLifecycleSettings.tsx, apps/desktop/src/renderer/features/bots/BotMemorySettings.tsx, apps/desktop/src/renderer/features/bots/BotModelChainEditor.tsx, apps/desktop/src/renderer/features/bots/BotPortraitPicker.tsx, apps/desktop/src/renderer/features/bots/BotRosterView.tsx, apps/desktop/src/renderer/features/bots/BotRoutines.tsx, apps/desktop/src/renderer/features/bots/BotSessionContentHeader.tsx, apps/desktop/src/renderer/features/bots/BotSessionTaskLink.tsx, apps/desktop/src/renderer/features/bots/BotSessionTaskResultCard.tsx, apps/desktop/src/renderer/features/bots/BotSessionView.tsx, apps/desktop/src/renderer/features/bots/BotSettingsBlock.tsx, apps/desktop/src/renderer/features/bots/BotSettingsDrawer.tsx, apps/desktop/src/renderer/features/bots/BotTaskCardHeader.tsx, apps/desktop/src/renderer/features/bots/BotTaskModelEditor.tsx, apps/desktop/src/renderer/features/bots/BotTodoList.tsx, apps/desktop/src/renderer/features/bots/BotWorkbench.tsx, apps/desktop/src/renderer/features/bots/BotWorkingStatus.tsx, apps/desktop/src/renderer/features/bots/BotsFeatureLayout.tsx, apps/desktop/src/renderer/features/bots/BotsGlobalSettingsSection.tsx, apps/desktop/src/renderer/features/bots/BotsHomeView.tsx, apps/desktop/src/renderer/features/bots/BotsListView.tsx, apps/desktop/src/renderer/features/bots/BotsSidebar.tsx, apps/desktop/src/renderer/features/bots/ChatBotAccessField.tsx, apps/desktop/src/renderer/features/bots/ChatGroupSettings.tsx, apps/desktop/src/renderer/features/bots/ChatInviteDialog.tsx, apps/desktop/src/renderer/features/bots/ChatInviteHost.tsx, apps/desktop/src/renderer/features/bots/ChatServerControls.tsx, apps/desktop/src/renderer/features/bots/ChatThreadPanel.tsx, apps/desktop/src/renderer/features/bots/CindyDevicePicker.tsx, apps/desktop/src/renderer/features/bots/CindyDeviceRow.tsx, apps/desktop/src/renderer/features/bots/RemoteBotSessionView.tsx, apps/desktop/src/renderer/features/bots/RemoteBotSettings.tsx, apps/desktop/src/renderer/features/bots/WorkbenchSessionList.tsx, apps/desktop/src/renderer/features/bots/botAvatarIdentity.ts, apps/desktop/src/renderer/features/bots/botCapabilityDefaults.ts, apps/desktop/src/renderer/features/bots/botChatPresentation.ts, apps/desktop/src/renderer/features/bots/botConversationPresentation.ts, apps/desktop/src/renderer/features/bots/botConversationTimeline.ts, apps/desktop/src/renderer/features/bots/botDelegationLive.ts, apps/desktop/src/renderer/features/bots/botFollowScopes.ts, apps/desktop/src/renderer/features/bots/botGeneratedArtifacts.ts, apps/desktop/src/renderer/features/bots/botGroupAttachments.ts, apps/desktop/src/renderer/features/bots/botGroupLane.ts, apps/desktop/src/renderer/features/bots/botGroupMentions.ts, apps/desktop/src/renderer/features/bots/botGroupOutbox.ts, apps/desktop/src/renderer/features/bots/botGroupPresentation.ts, apps/desktop/src/renderer/features/bots/botGroupStore.ts, apps/desktop/src/renderer/features/bots/botListDisplay.ts, apps/desktop/src/renderer/features/bots/botNavigation.ts, apps/desktop/src/renderer/features/bots/botPronounContext.tsx, apps/desktop/src/renderer/features/bots/botReadState.ts, apps/desktop/src/renderer/features/bots/botRosterDisplay.ts, apps/desktop/src/renderer/features/bots/botSessionOwners.ts, apps/desktop/src/renderer/features/bots/botSettingsAutosave.ts, apps/desktop/src/renderer/features/bots/botStore.ts, apps/desktop/src/renderer/features/bots/botTodo.css, apps/desktop/src/renderer/features/bots/botWelcomeContext.ts, apps/desktop/src/renderer/features/bots/botWorkbenchProjection.ts, apps/desktop/src/renderer/features/bots/chatError.ts, apps/desktop/src/renderer/features/bots/cindyDeviceRoster.ts, apps/desktop/src/renderer/features/bots/remoteBotRoster.ts, apps/desktop/src/renderer/features/bots/remoteBotSettingsData.ts, apps/desktop/src/renderer/features/bots/useBotGeneratedFileDeliveries.ts, apps/desktop/src/renderer/features/bots/useBotIslandVisibleSession.ts, apps/desktop/src/renderer/features/bots/useBotSettingsAutosave.ts, apps/desktop/src/renderer/features/bots/useBotUnreadSync.ts, apps/desktop/src/renderer/features/bots/useRemoteBots.ts, apps/desktop/src/renderer/features/bots/useWorkbenchSessionPages.ts, apps/desktop/src/renderer/features/bots/useWorkingStatusCopy.ts, apps/desktop/src/renderer/features/cc-agent/CCAgentFeatureLayout.tsx, apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx | 277 | 38 | 474 || `desktop.chat.files` | desktop | 工作目录文件浏览 | hash `/cc-agent/files/:sessionId`(WorkdirBrowseRoute) | FileBodyView, FileTreeView, WorkdirBrowseRoute | apps/desktop/src/renderer/features/cc-agent/workdir-browse/DocSearchBar.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/DrawioPreview.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/FileBodyView.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/FileFilterInput.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/FileTabsBar.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/FileTreeView.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/FilterResultList.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/ImagePreview.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/OpenInSystemActions.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/PdfPreview.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/SessionTabsBar.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/UnrenderablePlaceholder.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/WorkdirBrowseRoute.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/WorkdirBrowseSidebar.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useChatRailCollapsed.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useChatRailResize.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useConfirmSwitchAwayIfDirty.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useDelayedFlag.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useFileContent.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useFileTree.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useOpenTabs.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useProjectFileList.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/hooks/useRevealFileInTree.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/activeFileBodyHandle.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/docModeSwitchProjects.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/drawioExt.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/expandedStore.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/fileContentCache.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/fileIcon.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/fileMeta.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/fileScrollStore.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/fileSelectionParams.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/filterFiles.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/imageExt.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/markdownAutosave.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/openTabsStore.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/pdfExt.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/lib/selectedFileStore.ts, apps/desktop/src/renderer/features/cc-agent/workdir-browse/search/SearchInput.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/search/SearchPanel.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/search/SearchResults.tsx, apps/desktop/src/renderer/features/cc-agent/workdir-browse/search/hooks/useProjectSearch.ts | 17 | 7 | 45 || `desktop.chat.new-draft` | desktop | 新建任务草稿页 | hash `/cc-agent/new`(NewMakerDraftRoute) | NewMakerDraftRoute | apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx | 15 | 0 | 3 || `desktop.chat.orca-workflow` | desktop | Orca 协同工作台 | hash `/cc-agent/orca/:sessionId`(OrcaWorkflowRoute) | CCAgentSessionView, OrcaSplitView, OrcaWorkerPanel, OrcaWorkflowRoute | apps/desktop/src/renderer/components/chat/AgentActionRow.tsx, apps/desktop/src/renderer/components/chat/AgentActionsBlock.tsx, apps/desktop/src/renderer/components/chat/AgentOnOtherDeviceContext.tsx, apps/desktop/src/renderer/components/chat/AgentTaskCard.tsx, apps/desktop/src/renderer/components/chat/AgentTaskLiveDetails.tsx, apps/desktop/src/renderer/components/chat/AnnotationStrokesSvg.tsx, apps/desktop/src/renderer/components/chat/AskUserQuestionBubble.tsx, apps/desktop/src/renderer/components/chat/AssistantMessage.tsx, apps/desktop/src/renderer/components/chat/AutomationOriginBadge.tsx, apps/desktop/src/renderer/components/chat/ChatAudioCard.tsx, apps/desktop/src/renderer/components/chat/ChatDisplaySnapshotContext.tsx, apps/desktop/src/renderer/components/chat/ChatImageView.tsx, apps/desktop/src/renderer/components/chat/ChatLoadingImage.tsx, apps/desktop/src/renderer/components/chat/ChatSessionFileContext.tsx, apps/desktop/src/renderer/components/chat/ChatSoundEffectCard.tsx, apps/desktop/src/renderer/components/chat/ChatVideoView.tsx, apps/desktop/src/renderer/components/chat/CindyMakeDoctorCard.tsx, apps/desktop/src/renderer/components/chat/CopyAsImageBlock.tsx, apps/desktop/src/renderer/components/chat/CredentialSwitchWaitBanner.tsx, apps/desktop/src/renderer/components/chat/DiffView.tsx, apps/desktop/src/renderer/components/chat/ErrorBanner.tsx, apps/desktop/src/renderer/components/chat/ErrorMessageCard.tsx, apps/desktop/src/renderer/components/chat/GeneratedFilesCard.tsx, apps/desktop/src/renderer/components/chat/GhostCardHostPrompts.tsx, apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx, apps/desktop/src/renderer/components/chat/GhostToolCard.tsx, apps/desktop/src/renderer/components/chat/HookTaskCard.tsx, apps/desktop/src/renderer/components/chat/ImageGalleryContext.tsx, apps/desktop/src/renderer/components/chat/ImageHoverPreview.tsx, apps/desktop/src/renderer/components/chat/ImageLightbox.tsx, apps/desktop/src/renderer/components/chat/ImageMissingPlaceholder.tsx, apps/desktop/src/renderer/components/chat/InlineReferenceChip.tsx, apps/desktop/src/renderer/components/chat/InterruptedTurnBanner.tsx, apps/desktop/src/renderer/components/chat/JumpToBottomChip.tsx, apps/desktop/src/renderer/components/chat/MarkdownDiffBlock.tsx, apps/desktop/src/renderer/components/chat/MarkdownMermaidBlock.tsx, apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx, apps/desktop/src/renderer/components/chat/MermaidLightbox.tsx, apps/desktop/src/renderer/components/chat/MessageActionBar.tsx, apps/desktop/src/renderer/components/chat/MessageNavRail.tsx, apps/desktop/src/renderer/components/chat/MessageSourceLabels.tsx, apps/desktop/src/renderer/components/chat/MessageStream.tsx, apps/desktop/src/renderer/components/chat/MessageViewport.tsx, apps/desktop/src/renderer/components/chat/ModelLightbox.tsx, apps/desktop/src/renderer/components/chat/NewMessageIndicator.tsx, apps/desktop/src/renderer/components/chat/PlanReviewBubble.tsx, apps/desktop/src/renderer/components/chat/PrevMessageJumpChip.tsx, apps/desktop/src/renderer/components/chat/ProjectLinkChip.tsx, apps/desktop/src/renderer/components/chat/QuoteChip.tsx, apps/desktop/src/renderer/components/chat/RewindPreviewDialog.tsx, apps/desktop/src/renderer/components/chat/SelectionQuoteButton.tsx, apps/desktop/src/renderer/components/chat/SentAgentReferenceChip.tsx, apps/desktop/src/renderer/components/chat/SentInlineAtomBody.tsx, apps/desktop/src/renderer/components/chat/SessionHandoffCard.tsx, apps/desktop/src/renderer/components/chat/SessionLinkChip.tsx, apps/desktop/src/renderer/components/chat/ShareMessageCheckbox.tsx, apps/desktop/src/renderer/components/chat/ShareSelectionBar.tsx, apps/desktop/src/renderer/components/chat/SlackIcon.tsx, apps/desktop/src/renderer/components/chat/StreamFadeSpan.tsx, apps/desktop/src/renderer/components/chat/StreamingMarkdownChunk.tsx, apps/desktop/src/renderer/components/chat/SystemCard.tsx, apps/desktop/src/renderer/components/chat/TextLightbox.tsx, apps/desktop/src/renderer/components/chat/ThinkingCard.tsx, apps/desktop/src/renderer/components/chat/ThinkingText.tsx, apps/desktop/src/renderer/components/chat/TodoListCard.tsx, apps/desktop/src/renderer/components/chat/ToolCallCard.tsx, apps/desktop/src/renderer/components/chat/ToolPayloadLightbox.tsx, apps/desktop/src/renderer/components/chat/TopRightChipStack.tsx, apps/desktop/src/renderer/components/chat/TurnChangesCard.tsx, apps/desktop/src/renderer/components/chat/UnreadFailedScheduleBanner.tsx, apps/desktop/src/renderer/components/chat/UpgradeBanner.tsx, apps/desktop/src/renderer/components/chat/UserAttachmentChip.tsx, apps/desktop/src/renderer/components/chat/UserMessage.tsx, apps/desktop/src/renderer/components/chat/UserMessageEditBox.tsx, apps/desktop/src/renderer/components/chat/UserMessageUrlLink.tsx, apps/desktop/src/renderer/components/chat/VideoLightbox.tsx, apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx, apps/desktop/src/renderer/components/chat/WorktreeRestoreBanner.tsx, apps/desktop/src/renderer/components/chat/XIcon.tsx, apps/desktop/src/renderer/components/chat/activityRowChrome.ts, apps/desktop/src/renderer/components/chat/animateFocusScroll.ts, apps/desktop/src/renderer/components/chat/autoFollowIntent.ts, apps/desktop/src/renderer/components/chat/chatChrome.ts, apps/desktop/src/renderer/components/chat/errorReasonI18n.ts, apps/desktop/src/renderer/components/chat/generatedFilesProjection.ts, apps/desktop/src/renderer/components/chat/imageDisplaySize.ts, apps/desktop/src/renderer/components/chat/lightboxAnnotations.ts, apps/desktop/src/renderer/components/chat/lightboxGestures.ts, apps/desktop/src/renderer/components/chat/markdownImageTargets.ts, apps/desktop/src/renderer/components/chat/markdownMedia.ts, apps/desktop/src/renderer/components/chat/messageNavRailModel.ts, apps/desktop/src/renderer/components/chat/messageNavRailWheel.ts, apps/desktop/src/renderer/components/chat/messageNavigationProjection.ts, apps/desktop/src/renderer/components/chat/messageProjectionCache.ts, apps/desktop/src/renderer/components/chat/messageStreamIndicatorPosition.ts, apps/desktop/src/renderer/components/chat/messageViewportCompensation.ts, apps/desktop/src/renderer/components/chat/messageViewportGeometry.ts, apps/desktop/src/renderer/components/chat/messageWorkGroups.ts, apps/desktop/src/renderer/components/chat/observeProgrammaticScroll.ts, apps/desktop/src/renderer/components/chat/rehypeFencedCodeMarker.ts, apps/desktop/src/renderer/components/chat/rehypeHighlightShared.ts, apps/desktop/src/renderer/components/chat/rehypeMathBlockMarker.ts, apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.ts, apps/desktop/src/renderer/components/chat/remarkHtmlImages.ts, apps/desktop/src/renderer/components/chat/remarkLocalPathLinks.ts, apps/desktop/src/renderer/components/chat/remarkPreserveRawLocalDestinations.ts, apps/desktop/src/renderer/components/chat/remarkSessionLinks.ts, apps/desktop/src/renderer/components/chat/remarkStrictInlineMath.ts, apps/desktop/src/renderer/components/chat/remarkTruncateCjkUrls.ts, apps/desktop/src/renderer/components/chat/repairStreamingMarkdown.ts, apps/desktop/src/renderer/components/chat/scrollAnchoringDetect.ts, apps/desktop/src/renderer/components/chat/shareSelectionStore.ts, apps/desktop/src/renderer/components/chat/streamingMarkdownBlocks.tsx, apps/desktop/src/renderer/components/chat/streamingMarkdownChunks.ts, apps/desktop/src/renderer/components/chat/streamingMessageProjection.ts, apps/desktop/src/renderer/components/chat/toolLoopI18n.ts, apps/desktop/src/renderer/components/chat/unreadCount.ts, apps/desktop/src/renderer/components/chat/useAutomaticHistoryLoadBudget.ts, apps/desktop/src/renderer/components/chat/useCopyAsImage.tsx, apps/desktop/src/renderer/components/chat/useDeleteMessage.ts, apps/desktop/src/renderer/components/chat/useFileChipContextMenu.tsx, apps/desktop/src/renderer/components/chat/useForkAtMessage.ts, apps/desktop/src/renderer/components/chat/useImageClipboard.ts, apps/desktop/src/renderer/components/chat/useImageLoadFailure.ts, apps/desktop/src/renderer/components/chat/useMessageViewport.ts, apps/desktop/src/renderer/components/chat/useNavigationKeyListener.ts, apps/desktop/src/renderer/components/chat/useOpenWithMenu.tsx, apps/desktop/src/renderer/components/chat/usePrevUserMessageInView.ts, apps/desktop/src/renderer/components/chat/useTurnChangeSets.ts, apps/desktop/src/renderer/components/chat/userMessageCollapse.ts, apps/desktop/src/renderer/components/chat/userMessageDisplayText.ts, apps/desktop/src/renderer/components/chat/userMessageLinkify.ts, apps/desktop/src/renderer/components/chat/viewportFillDetect.ts, apps/desktop/src/renderer/components/new-chat/AddRemoteProjectDialog.tsx, apps/desktop/src/renderer/components/new-chat/AgentSelect.tsx, apps/desktop/src/renderer/components/new-chat/AskUserQuestionPrompt.tsx, apps/desktop/src/renderer/components/new-chat/AtMentionPanel.tsx, apps/desktop/src/renderer/components/new-chat/AttachmentTypeThumb.tsx, apps/desktop/src/renderer/components/new-chat/ChatInput.tsx, apps/desktop/src/renderer/components/new-chat/CjkPunctDecoration.ts, apps/desktop/src/renderer/components/new-chat/CjkPunctuationUtils.ts, apps/desktop/src/renderer/components/new-chat/ComposerAttachments.tsx, apps/desktop/src/renderer/components/new-chat/ComposerListIndentDecoration.ts, apps/desktop/src/renderer/components/new-chat/ComposerListNodes.ts, apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx, apps/desktop/src/renderer/components/new-chat/DeviceSwitcherPill.tsx, apps/desktop/src/renderer/components/new-chat/EffortSlider.tsx, apps/desktop/src/renderer/components/new-chat/EmptyDocSelectionGuard.ts, apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx, apps/desktop/src/renderer/components/new-chat/FastModeToggle.tsx, apps/desktop/src/renderer/components/new-chat/FolderPickerPopover.tsx, apps/desktop/src/renderer/components/new-chat/FullAccessConfirmContent.tsx, apps/desktop/src/renderer/components/new-chat/GhostCommandDecoration.ts, apps/desktop/src/renderer/components/new-chat/GoalAdvancedLimits.tsx, apps/desktop/src/renderer/components/new-chat/GoalIndicator.tsx, apps/desktop/src/renderer/components/new-chat/HomeUsageDashboard.tsx, apps/desktop/src/renderer/components/new-chat/ListComposerTextarea.tsx, apps/desktop/src/renderer/components/new-chat/LocalModelCatalogNotice.tsx, apps/desktop/src/renderer/components/new-chat/MentionChipNode.tsx, apps/desktop/src/renderer/components/new-chat/MentionDragCaretDecoration.ts, apps/desktop/src/renderer/components/new-chat/ModelCompatibilityNotice.tsx, apps/desktop/src/renderer/components/new-chat/ModelConfigFlyout.tsx, apps/desktop/src/renderer/components/new-chat/ModelHarnessPicker.tsx, apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx, apps/desktop/src/renderer/components/new-chat/ModelSourceDetails.tsx, apps/desktop/src/renderer/components/new-chat/NewGoalDialog.tsx, apps/desktop/src/renderer/components/new-chat/PastedTextChipNode.tsx, apps/desktop/src/renderer/components/new-chat/PendingQueuePanel.tsx, apps/desktop/src/renderer/components/new-chat/PermissionPrompt.tsx, apps/desktop/src/renderer/components/new-chat/PermissionSelector.tsx, apps/desktop/src/renderer/components/new-chat/PinnedPlanPanel.tsx, apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx, apps/desktop/src/renderer/components/new-chat/PlanModeIndicator.tsx, apps/desktop/src/renderer/components/new-chat/PlanViewerCard.tsx, apps/desktop/src/renderer/components/new-chat/PluginConnectionForm.tsx, apps/desktop/src/renderer/components/new-chat/PluginOauthDeviceCode.tsx, apps/desktop/src/renderer/components/new-chat/PluginSetupPrompt.tsx, apps/desktop/src/renderer/components/new-chat/PluginSetupRemoteDesktopButton.tsx, apps/desktop/src/renderer/components/new-chat/PluginWriteAccessRecovery.tsx, apps/desktop/src/renderer/components/new-chat/QuickStartPillMark.ts, apps/desktop/src/renderer/components/new-chat/RemoteOauthSetupCard.tsx, apps/desktop/src/renderer/components/new-chat/SendButton.tsx, apps/desktop/src/renderer/components/new-chat/SlashCommandDecoration.ts, apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx, apps/desktop/src/renderer/components/new-chat/TakeoverMask.tsx, apps/desktop/src/renderer/components/new-chat/ThinkingToggle.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedFlyoutHost.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelPanel.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelRail.tsx, apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx, apps/desktop/src/renderer/components/new-chat/UsageDailyBars.tsx, apps/desktop/src/renderer/components/new-chat/UsageHeatmap.tsx, apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx, apps/desktop/src/renderer/components/new-chat/VoiceInputDraftDecoration.ts, apps/desktop/src/renderer/components/new-chat/WindowsSelectionReplacement.ts, apps/desktop/src/renderer/components/new-chat/WorktreeChipsRow.tsx, apps/desktop/src/renderer/components/new-chat/WorktreeCreatingOverlay.tsx, apps/desktop/src/renderer/components/new-chat/agentOptions.ts, apps/desktop/src/renderer/components/new-chat/agentSwitchConfirmation.ts, apps/desktop/src/renderer/components/new-chat/branchPick.ts, apps/desktop/src/renderer/components/new-chat/composerBlankPointerFocus.ts, apps/desktop/src/renderer/components/new-chat/composerContentSerialization.ts, apps/desktop/src/renderer/components/new-chat/composerDocState.ts, apps/desktop/src/renderer/components/new-chat/composerFrameScheduler.ts, apps/desktop/src/renderer/components/new-chat/composerHistoryProjection.ts, apps/desktop/src/renderer/components/new-chat/composerModelSelection.ts, apps/desktop/src/renderer/components/new-chat/composerPromptRecommendation.ts, apps/desktop/src/renderer/components/new-chat/composerRenderGate.ts, apps/desktop/src/renderer/components/new-chat/composerSendOwnership.ts, apps/desktop/src/renderer/components/new-chat/composerSendSnapshot.ts, apps/desktop/src/renderer/components/new-chat/effortChangeQueue.ts, apps/desktop/src/renderer/components/new-chat/extraDirsActions.ts, apps/desktop/src/renderer/components/new-chat/ghostComposerPlacement.ts, apps/desktop/src/renderer/components/new-chat/localAttachmentPicker.ts, apps/desktop/src/renderer/components/new-chat/mentionChipInsertion.ts, apps/desktop/src/renderer/components/new-chat/modelWindowErrorToast.ts, apps/desktop/src/renderer/components/new-chat/pastePipeline.ts, apps/desktop/src/renderer/components/new-chat/pathPaste.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueLocks.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueRowActivity.ts, apps/desktop/src/renderer/components/new-chat/pendingQueueRowPresentation.ts, apps/desktop/src/renderer/components/new-chat/planModeComposerCommand.ts, apps/desktop/src/renderer/components/new-chat/priceTierMarks.tsx, apps/desktop/src/renderer/components/new-chat/remoteBrowseAdapters.ts, apps/desktop/src/renderer/components/new-chat/remoteExistingProjects.ts, apps/desktop/src/renderer/components/new-chat/restoreComposerDocument.ts, apps/desktop/src/renderer/components/new-chat/sessionLinkPaste.ts, apps/desktop/src/renderer/components/new-chat/sourceSwitch.ts, apps/desktop/src/renderer/components/new-chat/unifiedModelSelection.ts, apps/desktop/src/renderer/components/new-chat/usagePalette.ts, apps/desktop/src/renderer/components/new-chat/useComposerSendFocusRestore.ts, apps/desktop/src/renderer/components/new-chat/useModelDiscoveryPending.ts, apps/desktop/src/renderer/components/new-chat/useProviderWeeklyQuota.ts, apps/desktop/src/renderer/components/new-chat/useUnifiedRowActions.ts, apps/desktop/src/renderer/features/cc-agent/CCAgentFeatureLayout.tsx, apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx, apps/desktop/src/renderer/features/cc-agent/OrcaSplitView.tsx, apps/desktop/src/renderer/features/cc-agent/OrcaWorkerPanel.tsx, apps/desktop/src/renderer/features/cc-agent/OrcaWorkflowRoute.tsx | 252 | 38 | 337 |diff --git a/docs/product-rules/bot-group-chat.md b/docs/product-rules/bot-group-chat.mdindex faf4eb9d5c..5cb017d28e 100644--- a/docs/product-rules/bot-group-chat.md+++ b/docs/product-rules/bot-group-chat.md@@ -351,6 +351,8 @@ Chris 已明确扩展到多人各带伙伴,并选择「主人按群预先授同一草稿的点名目标 ID、顺序或所有人标记变化,即使显示名字与正文没变,也必须使用新的 `clientId`。只有正文、点名目标、分工标记和附件均不变时,失败重试才复用原发送尝试。+Desktop 主群输入框发送即乐观显示:点发送后消息立即接在时间线末尾,输入框与托盘马上空出,可以接着发下一条;同一个群的提交按发出顺序逐条交给 main,慢于 0.6 秒才在气泡下显示「发送中…」。回执的 `messageId` 是替换依据:时间线读到该消息即换成真实消息,回执之后开始的重读没读到也视为已进历史;推送重读先于回执到达时,只对正在提交的那一条按「基线之后、未被回执认领、正文与附件数一致的自己的消息」做显示去重,最终仍以 `messageId` 为准。附件按输入生成临时列表;真实消息到达而服务器副本尚未可用(无 url / path,或旧版尚未列出)时,按同一 `messageId` 内先同名、再在剩余数量相等时按顺序配对,继续显示本地预览直到副本可用,不退成缺失也不重复。发送失败绝不自动重发:输入框为空(无文字、附件、分工标签)时把正文、点名、标签与附件原样放回并提示原因,再发沿用原 `clientId`;输入框已有新内容时消息留在时间线上显示「没发出去」,可「重试」(同一 `clientId`)或在输入框清空后「编辑」放回。发件箱原样保存并发出完整发送输入(附件在提交时才烧录标注并序列化),首发与重试不挑字段;除 `clientId` 外的全部字段与附件共同决定能否复用原 `clientId`,新增发送字段无需改动发件箱。发件箱只在 renderer 内存中保留,切群后仍按群隔离,切换账号清空、删群丢弃,不持久化。Thread 回复与手机端仍是等待回执后显示。实现见 `renderer/features/bots/botGroupOutbox.ts`,回归见 `botGroupOutbox.test.ts` 与 `BotGroupChatView.test.tsx`。+完成全部显式目标校验后,最终点名列表继续沿用排除当前用户自己的既有规则;主群、Thread 与手机直连均一致,不因显式列表或所有人标记改变。手机直连入口同样在发送前读取已加入成员、校验全部显式目标,再展开所有人。点名失效沿用本地化提示和草稿恢复,不把群页标为离线;重选当前成员后可以立即继续发送。回归见 `chatServerMobileEntry.test.tsx` 与 `BotGroupChatScreen.test.tsx`。