Skip to content

armgit / cindy

Public Imported from GitHub
0

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

Merge branch 'group-task-home-reply-timeout' into bots-ux

Chris8adb50f04a3d
diff --cc apps/desktop/src/main/maker-ipc/botDelegationService.ts
index 0773213a8a,fb2fdc5043..e8a682a424
--- a/apps/desktop/src/main/maker-ipc/botDelegationService.ts
+++ b/apps/desktop/src/main/maker-ipc/botDelegationService.ts
@@@ -4505,7 -4477,9 +4533,10 @@@ export function createBotDelegationServ
messageSessionTask: expose(messageSessionTask),
stopSessionTask: expose(stopSessionTask),
cancelDelegation: expose((callerSessionId: string, delegationId: string) => withTaskOperation(delegationId, () => cancelDelegation(callerSessionId, delegationId))),
+ traceOwnerNote: expose(traceOwnerNote),
+ /** The owner stopping a task from its card (IPC / device-link), from any lane that shows the card. */
+ cancelDelegationFromOwner: expose((callerSessionId: string, delegationId: string) => withTaskOperation(delegationId,
+ () => cancelDelegation(callerSessionId, delegationId, undefined, { ownerUi: true }))),
cancelDelegationsForParentSession,
cancelDelegationsForBot,
settleSession,
diff --cc apps/desktop/src/main/maker-ipc/register.ts
index dfb3a33890,79aae9eef5..8728a24b9d
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@@ -12258,28 -12260,10 +12260,29 @@@ export function registerMakerIpc(maker
) {
throwIpcError('INVALID_PARAMS', 'parentSessionId + delegationId required');
}
- return delegationForRestore.cancelDelegation(parentSessionId, delegationId);
+ // The owner's own stop button: not a group tool call, so no live group execution is needed.
+ return delegationForRestore.cancelDelegationFromOwner(parentSessionId, delegationId);
},
);
+ ipcMain.handle(
+ MAKER_INVOKE.BOT_DELEGATION_NOTE_TRACE,
+ async (event, parentSessionId: unknown, delegationId: unknown, text: unknown) => {
+ // Local only: the card offers 补一句 for tasks on this computer and the channel
+ // stays out of the device-link allowlist, so the sender is always the app renderer.
+ assertTrustedAppRendererEvent(event);
+ if (
+ typeof parentSessionId !== 'string'
+ || (parentSessionId.length === 0 || parentSessionId.length > 128)
+ || typeof delegationId !== 'string'
+ || (delegationId.length === 0 || delegationId.length > 128)
+ || typeof text !== 'string'
+ || (text.trim().length === 0 || text.length > 4_000)
+ ) {
+ throwIpcError('INVALID_PARAMS', 'parentSessionId + delegationId + text required');
+ }
+ return delegationForRestore.traceOwnerNote(parentSessionId, delegationId, text);
+ },
+ );
const captureSessionOwner = () => {
const owner = getCurrentDbClientSnapshot();
return () => {
diff --cc apps/desktop/src/renderer/features/bots/BotGroupTaskCard.tsx
index 120a913fd7,0b607ad8a7..e667e76aa4
--- a/apps/desktop/src/renderer/features/bots/BotGroupTaskCard.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotGroupTaskCard.tsx
@@@ -1,25 -1,24 +1,30 @@@
/**
* An independent task a teammate started from this group (bot-group-chat.md §10).
*
- * My own teammate's task: the same background-task card as in its chat (live status,
- * result, files, 补一句), read from the delegation row on this computer. Someone else's
- * teammate: the card as it was posted — title and state — because that task runs on
- * their computer.
- * My own teammate's task, when this computer is its home: the live task link (status icon,
- * click to open), read from the delegation row here. Someone else's teammate, or mine opened on
- * another of my computers: the card as it was posted — title and state — because that task runs
- * on the companion's home computer.
++ * My own teammate's task, when this computer is its home: the same background-task card as in
++ * its chat (live status, result, files, 补一句), read from the delegation row here. Someone
++ * else's teammate, or mine opened on another of my computers: the card as it was posted —
++ * title and state — because that task runs on the companion's home computer.
*/
import { ListTodo } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import type { BotGroupTaskCardView } from '../../../shared/botGroupChat';
-import { BotSessionTaskLink } from './BotSessionTaskLink';
+import { BotTaskCard } from './BotCollaborationCard';
+ import { useBotProfiles } from './botStore';
+ import { companionRunsHere } from './companionCloudPresentation';
+ import { useCompanionCloud } from './companionCloudStore';
- export function BotGroupTaskCard({ task, owned }: { task: BotGroupTaskCardView; owned: boolean }) {
+ export function BotGroupTaskCard({ task, owned, botId }: { task: BotGroupTaskCardView; owned: boolean; botId: string | null }) {
const { t } = useTranslation();
- if (owned) {
+ const profiles = useBotProfiles();
+ const cloud = useCompanionCloud();
- const live = owned && botId !== null && companionRunsHere(cloud, profiles.map((bot) => bot.id), botId);
++ if (owned && botId !== null && companionRunsHere(cloud, profiles.map((bot) => bot.id), botId)) {
+ return (
+ <div data-testid="bot-group-task" data-state={task.state} className="my-1 max-w-[520px]">
+ <BotTaskCard card={task.meta} sessionId={task.meta.parentSessionId ?? undefined} />
+ </div>
+ );
+ }
const state = t(`bots.groupChat.task.state.${task.state}`);
return (
<div
diff --cc apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsx
index fd3367713c,0000000000..95831ea579
mode 100644,000000..100644
--- a/apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotGroupTimelineItem.tsx
@@@ -1,470 -1,0 +1,471 @@@
+/**
+ * 群聊时间线的一行(主时间线与话题面板共用),Telegram / Slack 式的紧凑排版:
+ *
+ * - 自己的消息靠右、浅色气泡;其他人(伙伴与别的人)一律靠左平铺:28px 头像 + 名字
+ * (text-13)+ 时刻(text-11),正文在下。同一作者五分钟内的连续消息合并:后续行不再带
+ * 头像和名字,时刻只在悬停时出现在左侧槽位。
+ * - 引用块在正文上方,表情回应在正文下方;消息操作栏(复制、分享、引用回复、话题、表情、
+ * 时间)悬停时浮在右上角,键盘聚焦与触屏时常显。
+ * - @ 点名在所有消息里都高亮:正文仍交给 MarkdownRenderer,高亮走 CSS Custom Highlight
+ * (不改 Markdown 的 DOM,也就不会和 React 抢节点)。
+ * - 轮次结束、分工结束与系统提示是居中的一行小字。
+ *
+ * 行用 `memo` 包住:父组件只在这条消息(或它的引用、安排快照、高亮状态)真的变了时才会
+ * 让它重绘;回调一律是父组件的稳定引用,按消息 id 调用。
+ */
+import { memo, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { formatBotTimelineClock, formatBotTimelineDate } from '@cindy/maker-shared/botTimeline';
+import { ChatImageView } from '@/components/chat/ChatImageView';
+import { MarkdownRenderer } from '@/components/chat/MarkdownRenderer';
+import { ShareMessageCheckbox } from '@/components/chat/ShareMessageCheckbox';
+import { TextLightbox } from '@/components/chat/TextLightbox';
+import { UserAttachmentChip } from '@/components/chat/UserAttachmentChip';
+import { Button } from '@/components/ui/button';
+import { SHARE_MESSAGE_ATTR, SHARE_SESSION_ATTR } from '@/lib/shareConversationImage';
+import { cn } from '@/lib/utils';
+import type {
+ BotGroupAttachment,
+ BotGroupMemberView,
+ BotGroupPlanStepView,
+ BotGroupPlanView,
+ BotGroupQuoteDisplay,
+ BotGroupQuoteView,
+} from '../../../shared/botGroupChat';
+import { isBotGroupRuntimeFailureCode } from '../../../shared/botGroupChat';
+import { BotAvatar } from './BotAvatar';
+import { splitBotGroupMessageAttachments } from './botGroupAttachments';
+import { splitBotGroupMentionSegments } from './botGroupMentions';
+import { botGroupNoticeKey } from './botGroupPresentation';
+import {
+ BotGroupHandoffFiles,
+ BotGroupOrganizerTag,
+ BotGroupPlanCard,
+ BotGroupPlanEndDivider,
+ type BotGroupPlanCardAction,
+} from './BotGroupPlan';
+import { BotGroupQuoteBlock } from './BotGroupQuote';
+import { BotGroupRuntimeFailureNotice } from './BotGroupRuntimeFailureNotice';
+import { BotGroupTaskCard } from './BotGroupTaskCard';
+import type { BotGroupTimelineMessage } from './BotGroupTimelineModel';
+import { ChatMessageHoverActions, ChatMessageReactions } from './ChatServerControls';
+
+/** Group chat body: one step smaller than a task's reading text, Slack-dense. */
+export const BOT_GROUP_BODY_CLASS = 'text-14 font-normal leading-relaxed';
+
+// ---- @ mention highlight ----------------------------------------------------------------
+
+const MENTION_HIGHLIGHT = 'bot-group-mention';
+const mentionRanges = new Map<object, Range[]>();
+let highlightSyncQueued = false;
+let highlightStyleInstalled = false;
+
+type HighlightRegistry = { set: (name: string, value: unknown) => void; delete: (name: string) => void };
+function highlightApi(): { registry: HighlightRegistry; Highlight: new (...ranges: Range[]) => unknown } | null {
+ const registry = (globalThis as { CSS?: { highlights?: HighlightRegistry } }).CSS?.highlights;
+ const Highlight = (globalThis as { Highlight?: new (...ranges: Range[]) => unknown }).Highlight;
+ return registry && typeof Highlight === 'function' ? { registry, Highlight } : null;
+}
+
+function installHighlightStyle(): void {
+ if (highlightStyleInstalled || typeof document === 'undefined') return;
+ highlightStyleInstalled = true;
+ const style = document.createElement('style');
+ style.dataset.botGroupMention = '';
+ // Same chip colors as the composer's mention chip; both modes follow the tokens.
+ style.textContent = `::highlight(${MENTION_HIGHLIGHT}) { background-color: var(--surface-chip); color: var(--text-primary); }`;
+ document.head.append(style);
+}
+
+function syncMentionHighlight(): void {
+ if (highlightSyncQueued) return;
+ highlightSyncQueued = true;
+ queueMicrotask(() => {
+ highlightSyncQueued = false;
+ const api = highlightApi();
+ if (!api) return;
+ const ranges = [...mentionRanges.values()].flat();
+ if (ranges.length === 0) api.registry.delete(MENTION_HIGHLIGHT);
+ else api.registry.set(MENTION_HIGHLIGHT, new api.Highlight(...ranges));
+ });
+}
+
+function collectMentionRanges(root: HTMLElement, labels: readonly string[]): Range[] {
+ const ranges: Range[] = [];
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
+ for (let node = walker.nextNode() as Text | null; node; node = walker.nextNode() as Text | null) {
+ if (!node.data.includes('@') || node.parentElement?.closest('pre, code')) continue;
+ let offset = 0;
+ for (const segment of splitBotGroupMentionSegments(node.data, labels)) {
+ if (segment.mention) {
+ const range = document.createRange();
+ range.setStart(node, offset);
+ range.setEnd(node, offset + segment.text.length);
+ ranges.push(range);
+ }
+ offset += segment.text.length;
+ }
+ }
+ return ranges;
+}
+
+/** Message text as Markdown, with `@名字` of known members highlighted like a chip. */
+function BotGroupMessageText({ content, mentionLabels }: { content: string; mentionLabels: readonly string[] }) {
+ const ref = useRef<HTMLDivElement>(null);
+ const labelsKey = mentionLabels.join('\u0000');
+ useLayoutEffect(() => {
+ const root = ref.current;
+ if (!root || !content.includes('@') || !highlightApi()) return;
+ installHighlightStyle();
+ const owner = {};
+ const refresh = () => {
+ mentionRanges.set(owner, collectMentionRanges(root, mentionLabels));
+ syncMentionHighlight();
+ };
+ refresh();
+ // Markdown may finish later (code highlighting, lazy blocks); follow its DOM.
+ const observer = typeof MutationObserver === 'undefined' ? null : new MutationObserver(refresh);
+ observer?.observe(root, { childList: true, subtree: true, characterData: true });
+ return () => {
+ observer?.disconnect();
+ mentionRanges.delete(owner);
+ syncMentionHighlight();
+ };
+ // labelsKey stands in for the label array.
+ }, [content, labelsKey]);
+ return (
+ <div ref={ref} className="min-w-0 break-words">
+ <MarkdownRenderer workingDir="" content={content} allowPrivilegedLinks={false} />
+ </div>
+ );
+}
+
+// ---- Pieces ----------------------------------------------------------------------------
+
+/** Quiet pill after an author name (负责人, 第 k 步, 某某的主人). */
+export function BotGroupNameTag({ children }: { children: ReactNode }) {
+ return (
+ <span className="inline-flex min-h-[18px] max-w-[12rem] shrink-0 select-none items-center truncate rounded-full bg-[var(--surface-chip)] px-1.5 py-px text-11 font-medium leading-tight text-[var(--text-secondary)]">
+ {children}
+ </span>
+ );
+}
+
+/** One line per local day; it sticks to the top while that day scrolls by. */
+export function BotGroupDateDivider({ timestamp, locale }: { timestamp: number; locale: string }) {
+ return (
+ <div data-testid="bot-group-date-divider" className="sticky top-1 z-[5] mt-4 flex select-none justify-center first:mt-0">
+ <span className="rounded-full border border-[var(--border-default)] bg-[var(--surface)] px-2.5 py-0.5 text-11 leading-4 text-[var(--text-tertiary)]">
+ {formatBotTimelineDate(timestamp, locale)}
+ </span>
+ </div>
+ );
+}
+
+/**
+ * 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), files
+ * as the same chips (text preview or the system app, right-click menu).
+ */
+export function BotGroupUserAttachments({ attachments = [], align = 'left' }: { attachments?: readonly BotGroupAttachment[]; align?: 'left' | 'right' }) {
+ const [textPreview, setTextPreview] = useState<{ path: string; name: string } | null>(null);
+ const chipRef = useRef<HTMLElement | null>(null);
+ const { images, files } = splitBotGroupMessageAttachments(attachments);
+ if (images.length === 0 && files.length === 0) return null;
+ return (
+ <>
+ {images.map((image) => (
+ <ChatImageView key={image.id} src={image.url} filename={image.name} variant="user-attached" />
+ ))}
+ {files.length > 0 ? (
+ <div className={cn('flex flex-wrap items-end gap-1.5', align === 'right' && 'justify-end')}>
+ {files.map((file) => (
+ <UserAttachmentChip
+ key={file.id}
+ file={{ name: file.name, path: file.path }}
+ onOpenTextPreview={(chip) => {
+ chipRef.current = chip;
+ setTextPreview({ path: file.path, name: file.name });
+ }}
+ />
+ ))}
+ </div>
+ ) : null}
+ {textPreview ? (
+ <TextLightbox
+ filePath={textPreview.path}
+ fileName={textPreview.name}
+ triggerRef={chipRef}
+ onClose={() => setTextPreview(null)}
+ />
+ ) : null}
+ </>
+ );
+}
+
+// ---- The row ---------------------------------------------------------------------------
+
+export interface BotGroupTimelineItemProps {
+ message: BotGroupTimelineMessage;
+ /** Same author as the row above within five minutes: no avatar or name. */
+ continued: boolean;
+ /** Author name as this reader sees it (`伙伴名 (主人昵称)` where it applies). */
+ authorName: string;
+ /** Avatar identity of the author (the organizer on a 安排卡). */
+ avatar?: { name: string; avatar: string | null; avatarUrl?: string | null; avatarColor: string | null };
+ /** Bots a human author brought into the group: 「某某的主人」. */
+ ownerOf?: string;
+ /** 「第 k 步」 on a step hand-off. */
+ stepNumber?: number;
+ members: readonly BotGroupMemberView[];
+ mentionLabels: readonly string[];
+ locale: string;
+ shareScope: string;
+ sharing: boolean;
+ /** Server group id: reactions and the toolbar's reaction picker. */
+ reactionGroupId?: string;
+ quoteDisplay?: BotGroupQuoteDisplay;
+ onLocateQuote?: (quote: BotGroupQuoteView) => void;
+ onQuote?: (messageId: string) => void;
+ onOpenThread?: (messageId: string) => void;
+ /** This client changed the message (a reaction): the timeline refreshes its copy. */
+ onChanged: (messageId: string) => void;
+ highlighted?: boolean;
+ /** Focusable only as a jump target, so a click elsewhere keeps its usual focus. */
+ focusable?: boolean;
+ /** Arrived while the reader was watching: fade in (opacity only). */
+ entering?: boolean;
+ // Round and plan pieces; the Thread panel leaves them out.
+ canContinue?: boolean;
+ continuing?: boolean;
+ onContinue?: () => void;
+ plan?: BotGroupPlanView;
+ planActionable?: boolean;
+ planReassignable?: boolean;
+ planPending?: BotGroupPlanCardAction | null;
+ /** Live start of the plan's running step (its Session's turn), for the elapsed time. */
+ planRunningSince?: number | null;
+ /** Finish time of each done step (1-based), read off its hand-off message. */
+ planDoneAt?: ReadonlyMap<number, number>;
+ onPlanAction?: (action: 'start' | 'dismiss', planId: string) => void;
+ onEditStep?: (planId: string, step: BotGroupPlanStepView, action: 'reassign' | 'remove', botId?: string) => void;
+}
+
+function Row({ message, highlighted, focusable, entering, block, children }: {
+ message: BotGroupTimelineMessage; highlighted?: boolean; focusable?: boolean; entering?: boolean;
+ /** Space above: a new author block, a merged line, or a compact system line. */
+ block: 'author' | 'continued' | 'system';
+ children: ReactNode;
+}) {
+ return (
+ <div
+ data-bot-group-message-id={message.id}
+ tabIndex={focusable ? -1 : undefined}
+ className={cn(
+ 'rounded-lg outline-none transition-colors first:mt-0',
+ block === 'continued' ? 'mt-0.5' : block === 'author' ? 'mt-3.5' : 'mt-3',
+ entering && 'animate-fade-in motion-reduce:animate-none',
+ highlighted && 'bg-[hsl(var(--search-match-bg))] ring-1 ring-[var(--border-default)]',
+ )}
+ >
+ {children}
+ </div>
+ );
+}
+
+function SystemLine({ children, testId }: { children: ReactNode; testId?: string }) {
+ return (
+ <div data-testid={testId} className="flex select-none items-center gap-3 text-12 text-[var(--text-tertiary)]">
+ <span aria-hidden className="h-px min-w-6 flex-1 bg-[var(--border-default)]" />
+ {children}
+ <span aria-hidden className="h-px min-w-6 flex-1 bg-[var(--border-default)]" />
+ </div>
+ );
+}
+
+/** A task card is live only for a member of this group whose teammate is mine; unknown authors are snapshots. */
+export function botGroupTaskOwned(authorBotId: string | null, members: readonly BotGroupMemberView[]): boolean {
+ const author = authorBotId ? members.find((member) => member.botId === authorBotId) : undefined;
+ return author !== undefined && author.isOwned !== false;
+}
+
+function BotGroupTimelineItemImpl(props: BotGroupTimelineItemProps) {
+ const { t } = useTranslation();
+ const { message, continued, authorName, members, mentionLabels, locale, shareScope, sharing } = props;
+ const rowProps = { message, highlighted: props.highlighted, focusable: props.focusable, entering: props.entering };
+
+ if (message.kind === 'round-end') {
+ return (
+ <Row {...rowProps} block="system">
+ <SystemLine>
+ <span>{t('bots.groupChat.timeline.roundEnded')}</span>
+ {props.canContinue && props.onContinue ? (
+ <Button variant="secondary" tone="quiet" size="sm" compact type="button" loading={props.continuing} onClick={props.onContinue}>
+ {t('bots.groupChat.timeline.continue')}
+ </Button>
+ ) : null}
+ </SystemLine>
+ </Row>
+ );
+ }
+ if (message.kind === 'plan-end') {
+ return (
+ <Row {...rowProps} block="system">
+ <BotGroupPlanEndDivider stepCount={props.plan ? props.plan.steps.length : null} />
+ </Row>
+ );
+ }
+ if (message.kind === 'notice' || message.authorKind === 'system') {
+ const name = message.authorName.trim() || authorName;
+ if (isBotGroupRuntimeFailureCode(message.runtimeFailureCode)) {
+ return (
+ <Row {...rowProps} block="system">
+ <BotGroupRuntimeFailureNotice name={name} code={message.runtimeFailureCode} />
+ </Row>
+ );
+ }
+ const key = botGroupNoticeKey(message.noticeCode, message.planId !== null);
+ return (
+ <Row {...rowProps} block="system">
+ <p className="select-none text-center text-12 leading-5 text-[var(--text-tertiary)]">{key ? t(key, { name }) : message.content}</p>
+ </Row>
+ );
+ }
+
+ const shareable = message.kind === 'message' && !message.pending;
+ const shareAttrs = shareable ? { [SHARE_SESSION_ATTR]: shareScope, [SHARE_MESSAGE_ATTR]: message.id } : {};
+ const hasText = message.content.trim().length > 0;
+ const quote = props.quoteDisplay ? (
+ <BotGroupQuoteBlock
+ display={props.quoteDisplay}
+ onLocate={props.onLocateQuote && message.quote ? () => props.onLocateQuote!(message.quote!) : undefined}
+ align={message.authorKind === 'user' && message.isSelf !== false ? 'right' : 'left'}
+ />
+ ) : null;
+ const actions = shareable ? (
+ <ChatMessageHoverActions
+ groupId={props.reactionGroupId}
+ shareScope={shareScope}
+ message={message}
+ align={message.authorKind === 'user' && message.isSelf !== false ? 'right' : 'left'}
+ onQuote={props.onQuote ? () => props.onQuote!(message.id) : undefined}
+ onReply={props.onOpenThread ? () => props.onOpenThread!(message.id) : undefined}
+ onChanged={props.onChanged}
+ />
+ ) : null;
+
+ if (message.kind === 'message' && message.authorKind === 'user' && message.isSelf !== false) {
+ return (
+ <Row {...rowProps} block={continued ? 'continued' : 'author'}>
+ <article
+ {...shareAttrs}
+ aria-busy={message.pending ? true : undefined}
+ className={cn('group/message relative flex min-w-0 justify-end rounded-lg py-0.5', sharing && 'ml-10')}
+ >
+ {sharing && shareable ? <ShareMessageCheckbox clientId={message.id} /> : null}
+ <div className={cn('flex min-w-0 max-w-[78%] flex-col items-end gap-1.5 transition-opacity', message.pending && 'opacity-60')}>
+ {quote}
+ <BotGroupUserAttachments attachments={message.attachments} align="right" />
+ {hasText ? (
+ <div
+ data-testid="bot-group-self-bubble"
+ className={`max-w-full rounded-xl border border-[var(--msg-user-border)] bg-[var(--msg-user-bg)] px-3 py-1.5 text-[var(--msg-user-text)] ${BOT_GROUP_BODY_CLASS}`}
+ >
+ <BotGroupMessageText content={message.content} mentionLabels={mentionLabels} />
+ </div>
+ ) : null}
+ {message.pending ? <span className="sr-only">{t('bots.groupChat.timeline.sending')}</span> : null}
+ <ChatMessageReactions groupId={props.reactionGroupId} message={message} align="right" onChanged={props.onChanged} />
+ </div>
+ {actions}
+ </article>
+ </Row>
+ );
+ }
+
+ // A server plan is signed by its human creator; present the organizer without changing authorship.
+ const isPlanCard = message.kind === 'plan';
+ const timed = Number.isFinite(message.createdAt) && message.createdAt > 0;
+ const clock = timed ? formatBotTimelineClock(message.createdAt, locale) : '';
+ const dateTime = timed ? new Date(message.createdAt).toISOString() : undefined;
+ return (
+ <Row {...rowProps} block={continued ? 'continued' : 'author'}>
+ <article
+ {...shareAttrs}
+ className={cn(
+ 'group/message relative -mx-2 flex min-w-0 items-start gap-2.5 rounded-lg px-2 py-0.5 transition-colors hover:bg-[var(--surface-hover-soft)]',
+ sharing && 'ml-8',
+ )}
+ >
+ {sharing && shareable ? <ShareMessageCheckbox clientId={message.id} /> : null}
+ <div className="flex w-7 shrink-0 justify-end">
+ {continued ? (
+ <time
+ dateTime={dateTime}
+ className="select-none pt-0.5 text-11 leading-5 tabular-nums text-[var(--text-tertiary)] opacity-0 group-hover/message:opacity-100"
+ >
+ {clock}
+ </time>
+ ) : (
+ <BotAvatar bot={props.avatar ?? { name: authorName, avatar: null, avatarColor: null }} size="sm" />
+ )}
+ </div>
+ <div className="flex min-w-0 flex-1 flex-col">
+ {!continued ? (
+ <span className="flex min-w-0 select-none items-baseline gap-1.5">
+ <span className="min-w-0 truncate text-13 font-medium leading-5 text-[var(--text-primary)]">{authorName}</span>
+ {isPlanCard ? <BotGroupOrganizerTag /> : null}
+ {props.stepNumber ? <BotGroupNameTag>{t('bots.groupChat.timeline.stepTag', { count: props.stepNumber })}</BotGroupNameTag> : null}
+ {props.ownerOf ? <BotGroupNameTag>{t('bots.groupChat.ownerOf', { name: props.ownerOf })}</BotGroupNameTag> : null}
+ {timed ? (
+ <time dateTime={dateTime} className="shrink-0 text-11 tabular-nums text-[var(--text-tertiary)]">
+ {clock}
+ </time>
+ ) : null}
+ </span>
+ ) : null}
+ {isPlanCard ? (
+ <div className="mt-1">
+ <BotGroupPlanCard
+ plan={props.plan}
+ members={members}
+ actionable={props.planActionable ?? false}
+ reassignable={props.planReassignable ?? false}
+ pending={props.planPending ?? null}
+ runningSince={props.planRunningSince ?? null}
+ doneAt={props.planDoneAt}
+ locale={locale}
+ onStart={() => { if (message.planId) props.onPlanAction?.('start', message.planId); }}
+ onDismiss={() => { if (message.planId) props.onPlanAction?.('dismiss', message.planId); }}
+ onEditStep={(step, action, botId) => { if (message.planId) props.onEditStep?.(message.planId, step, action, botId); }}
+ />
+ </div>
+ ) : (
+ <div className="flex min-w-0 flex-col gap-1">
+ {quote}
- {/* A task this teammate started from the group; mine is live, another owner's is a snapshot.
- An author no longer in the group is unknown: its task may run on another computer, so
- it stays a snapshot rather than a lookup on this one. */}
++ {/* A task this teammate started from the group; mine is live where it runs, another owner's
++ is a snapshot. An author no longer in the group is unknown: its task may run on another
++ computer, so it stays a snapshot rather than a lookup on this one. */}
+ {message.task ? (
- <BotGroupTaskCard task={message.task} owned={botGroupTaskOwned(message.authorBotId, members)} />
++ <BotGroupTaskCard task={message.task} owned={botGroupTaskOwned(message.authorBotId, members)}
++ botId={message.authorBotId} />
+ ) : null}
+ {hasText ? (
+ <div className={`min-w-0 text-[var(--msg-assistant-text)] ${BOT_GROUP_BODY_CLASS}`}>
+ <BotGroupMessageText content={message.content} mentionLabels={mentionLabels} />
+ </div>
+ ) : null}
+ <BotGroupUserAttachments attachments={message.attachments} />
+ <BotGroupHandoffFiles files={message.files ?? []} workDir={props.plan?.workDir ?? null} />
+ <ChatMessageReactions groupId={props.reactionGroupId} message={message} onChanged={props.onChanged} />
+ </div>
+ )}
+ </div>
+ {actions}
+ </article>
+ </Row>
+ );
+}
+
+export const BotGroupTimelineItem = memo(BotGroupTimelineItemImpl);
diff --cc apps/desktop/src/renderer/features/bots/__tests__/BotGroupTaskCard.test.tsx
index 83425b5a76,9e7c0e97f7..3ddbfad455
--- a/apps/desktop/src/renderer/features/bots/__tests__/BotGroupTaskCard.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/BotGroupTaskCard.test.tsx
@@@ -6,10 -11,8 +11,10 @@@ vi.mock('../companionCloudStore', () =
vi.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key: string) => key.replace('bots.groupChat.task.state.', 'state:') }),
}));
- // Another owner's task never reaches the live card; the component must not need its stores.
-// The live link reads stores of its own; the card only decides whether to show it.
-vi.mock('../BotSessionTaskLink', () => ({ BotSessionTaskLink: () => <span data-testid="live-link">live</span> }));
++// The live card reads stores of its own; this card only decides whether to show it.
+vi.mock('../BotCollaborationCard', () => ({
+ BotTaskCard: ({ sessionId }: { sessionId?: string }) => <span data-testid="live-card">live:{sessionId}</span>,
+}));
import { BotGroupTaskCard } from '../BotGroupTaskCard';
@@@ -36,9 -49,35 +51,35 @@@ describe('BotGroupTaskCard', () =>
expect(screen.getByTestId('bot-group-task').textContent).toContain('state:waiting · Which audience?');
});
- it('shows my own teammate\'s task as the live link', () => {
+ it('shows my own teammate\'s task as the live background-task card, read through the group lane', () => {
- render(<BotGroupTaskCard task={task('started')} owned />);
+ render(<BotGroupTaskCard task={task('started')} owned botId="bot-a" />);
- expect(screen.getByTestId('live-link')).toBeTruthy();
- expect(screen.getByTestId('bot-group-task').textContent).toContain('state:started');
+ expect(screen.getByTestId('live-card').textContent).toBe('live:group-lane');
+ expect(screen.getByTestId('bot-group-task').textContent).not.toContain('state:started');
});
+
+ it('shows my own teammate\'s task live on its home computer', () => {
+ stores.cloud = homedOn('this-desktop');
+ render(<BotGroupTaskCard task={task('started')} owned botId="bot-a" />);
- expect(screen.getByTestId('live-link')).toBeTruthy();
++ expect(screen.getByTestId('live-card')).toBeTruthy();
+ });
+
+ it('shows my own teammate\'s task as the snapshot on another of my computers: it runs on its home', () => {
+ // A local copy whose home is elsewhere holds neither the group lane nor the task.
+ stores.cloud = homedOn('home-desktop');
+ render(<BotGroupTaskCard task={task('started')} owned botId="bot-a" />);
- expect(screen.queryByTestId('live-link')).toBeNull();
++ expect(screen.queryByTestId('live-card')).toBeNull();
+ expect(screen.getByTestId('bot-group-task').textContent).toContain('Launch post');
+ cleanup();
+ // No copy here at all.
+ stores.cloud = EMPTY_COMPANION_CLOUD_SNAPSHOT;
+ stores.profileIds = [];
+ render(<BotGroupTaskCard task={task('started')} owned botId="bot-a" />);
- expect(screen.queryByTestId('live-link')).toBeNull();
++ expect(screen.queryByTestId('live-card')).toBeNull();
+ cleanup();
+ // A copy shadowed after its home moved away.
+ stores.profileIds = ['bot-a'];
+ stores.cloud = { ...EMPTY_COMPANION_CLOUD_SNAPSHOT, demotedBotIds: ['bot-a'] };
+ render(<BotGroupTaskCard task={task('started')} owned botId="bot-a" />);
- expect(screen.queryByTestId('live-link')).toBeNull();
++ expect(screen.queryByTestId('live-card')).toBeNull();
+ });
});