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。

feat(desktop): teammate DMs use the group-chat bubble and hover toolbar

zqchrisee251c7ac39a
diff --git a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx
index d4d413b58f..2d8ff2d71c 100644
--- a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx
@@ -62,7 +62,7 @@ import { buildSessionMessageDeepLink } from '@/lib/deepLink';
import { getStickySessionDeviceId } from '@/features/device-link/stickySessionOrigin';
import { insertSessionLinkIntoComposer } from '@/lib/composerActionsBus';
import { MarkdownRenderer } from './MarkdownRenderer';
-import { MessageActionBar } from './MessageActionBar';
+import { BubbleHoverToolbar, MessageActionBar } from './MessageActionBar';
import { shareSelectionStore } from './shareSelectionStore';
import { useForkAtMessage } from './useForkAtMessage';
import { useDeleteMessage } from './useDeleteMessage';
@@ -329,18 +329,53 @@ export const AssistantMessage = memo(function AssistantMessage({
? `${currentSessionId ?? ''}\u0000${messageClientId}`
: undefined;
+ // Empty streaming starts stay chrome-free until there is something to read.
+ const botBubble = simplifiedBotConversation
+ && Boolean(content.trim() || failedSamplingAttempt || ghostRenderCard);
+
+ const actionBar = !isStreaming && showActionBar ? (
+ <MessageActionBar
+ createdAt={createdAt}
+ copyText={richAnswerText(content)}
+ copyLinkText={messageDeepLink}
+ align="left"
+ hovered={hovered}
+ simplifiedBotConversation={simplifiedBotConversation}
+ compact={botBubble}
+ onFork={!sharedGuest && canFork ? handleFork : undefined}
+ onAddToChat={messageDeepLink ? handleAddToChat : undefined}
+ onShareAsImage={handleShareAsImage}
+ onDelete={!sharedGuest && currentSessionId && messageClientId ? handleDelete : undefined}
+ turnMoney={turnMoney}
+ turnCostUsd={turnCostUsd}
+ turnCostIsEstimate={turnCostIsEstimate}
+ userTurnMoney={userTurnMoney}
+ userTurnCostUsd={userTurnCostUsd}
+ userTurnCostIsEstimate={userTurnCostIsEstimate}
+ turnUsageDetails={userTurnUsageDetails ?? turnUsageDetails}
+ />
+ ) : null;
+
return (
<div
- className="flex w-full flex-col items-start gap-1.5"
+ className={cn('flex w-full flex-col items-start gap-1.5', botBubble && 'group/message')}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
>
<div
+ {...(botBubble ? { 'data-bot-reply-bubble': '' } : {})}
className={cn(
// min-w-0: flex item 默认 min-width: auto 会被 <pre> 的固有宽度撑爆,
// 导致代码块溢出消息流右边界。加上 min-w-0 让 w-full 真正生效,
// <pre> 的 overflow-x-auto 才能正常接管横向滚动。
- 'w-full min-w-0',
+ // 伙伴私聊:回复放进与群聊同一种气泡(卡片底 + 细边框,无阴影),宽度随内容、
+ // 上限 720;组件式回答按可用宽度排版,气泡取满上限。右侧留出贴边操作栏的位置。
+ botBubble
+ ? cn(
+ 'relative min-w-0 max-w-[min(720px,calc(100%-72px))] rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-3.5 py-2.5',
+ hasRichAnswer(content) ? 'w-full' : 'w-fit',
+ )
+ : 'w-full min-w-0',
CHAT_BODY_CLASS,
'text-[var(--msg-assistant-text)]',
)}
@@ -424,6 +459,7 @@ export const AssistantMessage = memo(function AssistantMessage({
})}
</div>
)}
+ {botBubble && actionBar && <BubbleHoverToolbar side="right">{actionBar}</BubbleHoverToolbar>}
</div>
{simplifiedBotConversation && !isStreaming && content.trim() && botStarterOptions?.length
? <BotStarterOptions options={botStarterOptions} locked={starterOptionsLocked === true} /> : null}
@@ -435,28 +471,9 @@ export const AssistantMessage = memo(function AssistantMessage({
</div>
) : null}
{/* Streaming → bar not mounted at all (V1.2 验收 "流式期间不挂载");
- 非 turn 收尾正文(showActionBar=false)同样不挂,消息流保持紧凑 */}
- {!isStreaming && showActionBar && (
- <MessageActionBar
- createdAt={createdAt}
- copyText={richAnswerText(content)}
- copyLinkText={messageDeepLink}
- align="left"
- hovered={hovered}
- simplifiedBotConversation={simplifiedBotConversation}
- onFork={!sharedGuest && canFork ? handleFork : undefined}
- onAddToChat={messageDeepLink ? handleAddToChat : undefined}
- onShareAsImage={handleShareAsImage}
- onDelete={!sharedGuest && currentSessionId && messageClientId ? handleDelete : undefined}
- turnMoney={turnMoney}
- turnCostUsd={turnCostUsd}
- turnCostIsEstimate={turnCostIsEstimate}
- userTurnMoney={userTurnMoney}
- userTurnCostUsd={userTurnCostUsd}
- userTurnCostIsEstimate={userTurnCostIsEstimate}
- turnUsageDetails={userTurnUsageDetails ?? turnUsageDetails}
- />
- )}
+ 非 turn 收尾正文(showActionBar=false)同样不挂,消息流保持紧凑。
+ 伙伴私聊的气泡把操作栏挂在气泡右侧(BubbleHoverToolbar),这里不再另起一行。 */}
+ {!botBubble && actionBar}
</div>
);
});
diff --git a/apps/desktop/src/renderer/components/chat/MessageActionBar.tsx b/apps/desktop/src/renderer/components/chat/MessageActionBar.tsx
index 33fe1c8762..e7d459ce68 100644
--- a/apps/desktop/src/renderer/components/chat/MessageActionBar.tsx
+++ b/apps/desktop/src/renderer/components/chat/MessageActionBar.tsx
@@ -746,9 +746,9 @@ export function MessageActionBar({
// align='left' → [copy][share][fork][edit][more][time][cost]
// align='right' → [time][copy][share][fork][edit][more] (user)
// 伙伴对话:[copy][share][reply][more][time] / [time][copy][share][reply][edit][more]
- // 群聊(compact,贴在气泡旁):[引用回复][话题][表情][more],复制、分享与时间收进 more
+ // 贴在气泡旁(compact,群聊与伙伴私聊):[引用回复][话题][表情][编辑][more],复制、分享与时间收进 more
const items = compact
- ? align === 'left' ? [quoteBtn, replyBtn, reactionBtn, moreMenu] : [moreMenu, reactionBtn, replyBtn, quoteBtn]
+ ? align === 'left' ? [quoteBtn, replyBtn, reactionBtn, editBtn, moreMenu] : [moreMenu, editBtn, reactionBtn, replyBtn, quoteBtn]
: align === 'left'
? [
copyBtn,
@@ -787,3 +787,27 @@ export function MessageActionBar({
</div>
);
}
+
+/**
+ * The frame that hangs a compact toolbar beside its message bubble (群聊与伙伴私聊): on the bubble's
+ * outer `side`, level with its top, inside the message row so moving the pointer across the gap keeps
+ * the row hovered. It shows while the message (`group/message`) is hovered, while keyboard focus is
+ * inside, while `open` (a picker) is set, and always on touch screens. The bubble must be `relative`.
+ */
+export function BubbleHoverToolbar({ side, open = false, besideReactions = false, marker, children }: {
+ side: 'left' | 'right'; open?: boolean;
+ /** Steps past reactions hung on the bubble's outer top corner. */
+ besideReactions?: boolean;
+ /** A data attribute that names this toolbar for its caller's tests and checks. */
+ marker?: `data-${string}`;
+ children: ReactNode;
+}) {
+ const left = side === 'left';
+ return (
+ <div {...{ [SHARE_EXCLUDE_ATTR]: '' }} {...(marker ? { [marker]: '' } : {})} data-open={open ? '' : undefined}
+ className={cn('pointer-events-none absolute top-0 z-10 w-max rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] p-0.5 opacity-0 transition-opacity duration-[var(--motion-fast)] ease-[var(--motion-ease-out)] focus-within:pointer-events-auto focus-within:opacity-100 group-hover/message:pointer-events-auto group-hover/message:opacity-100 data-[open]:pointer-events-auto data-[open]:opacity-100 motion-reduce:transition-none [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100',
+ left ? 'right-full' : 'left-full', besideReactions ? (left ? 'mr-6' : 'ml-6') : (left ? 'mr-1.5' : 'ml-1.5'))}>
+ {children}
+ </div>
+ );
+}
diff --git a/apps/desktop/src/renderer/components/chat/MessageStream.tsx b/apps/desktop/src/renderer/components/chat/MessageStream.tsx
index 4773438ffb..709af76a20 100644
--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx
+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx
@@ -2912,6 +2912,7 @@ export const WorkGroupRenderItemView = memo(function WorkGroupRenderItemView({
childItems={childItems}
compact={compact}
deferred={item.deferred}
+ fitHeader={Boolean(replyColumnSpacer)}
/>
);
return (
@@ -6551,7 +6552,7 @@ export function MessageStream({
item={item}
context={workGroupRenderContext}
// 伙伴聊天与普通任务同一套工作过程:运行中露最近 5 条活动与计时,
- // 完成后收成「已工作 Xs」,不另走 compact 分支。
+ // 组头按内容宽;做完整块不再出现(simplifyBotRenderItems 丢弃完成组)。
compact={false}
replyColumnSpacer={botReplyColumnSpacer}
/>
diff --git a/apps/desktop/src/renderer/components/chat/UserMessage.tsx b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
index 8536bef785..2183ea4882 100644
--- a/apps/desktop/src/renderer/components/chat/UserMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
@@ -80,7 +80,7 @@ import { quoteSegmentsToComposerDocument } from '@/lib/composerQuoteDocument';
import { ChatImageView } from './ChatImageView';
import { TextLightbox } from './TextLightbox';
import { ToolPayloadLightbox } from './ToolPayloadLightbox';
-import { MessageActionBar } from './MessageActionBar';
+import { BubbleHoverToolbar, MessageActionBar } from './MessageActionBar';
import { shareSelectionStore } from './shareSelectionStore';
import { ErrorMessageCard } from './ErrorMessageCard';
import { useForkAtMessage, textToTiptapDoc } from './useForkAtMessage';
@@ -1251,6 +1251,12 @@ export function UserMessage({
? t('chat.userMessage.orcaFromWorkerNamed', { role: orcaWorkerRole })
: t('chat.userMessage.orcaFromWorker');
+ const attachmentsInBubble =
+ simplifiedBotConversation && !editing && !orcaCommunication && !hookSource && (hasImages || hasFiles);
+ // 伙伴私聊:操作栏挂在气泡左侧、悬停浮出(与群聊同一 BubbleHoverToolbar);没有气泡时仍在下方。
+ const bubbleActions = simplifiedBotConversation && !editing && !orcaCommunication && !hookSource
+ && Boolean(inlineQuoteCount > 0 || displayBubbleBody.trim() || ghostChipDisplay || attachmentsInBubble);
+
// Attachments belong to the user message independently of its visual shell.
const messageActions = (
<MessageActionBar
@@ -1260,6 +1266,7 @@ export function UserMessage({
align={hookSource ? 'left' : 'right'}
hovered={hovered}
simplifiedBotConversation={simplifiedBotConversation}
+ compact={bubbleActions}
onFork={!isBlocked && canFork ? handleFork : undefined}
onAddToChat={!isBlocked && messageDeepLink ? handleAddToChat : undefined}
onShareAsImage={handleShareAsImage}
@@ -1297,7 +1304,7 @@ export function UserMessage({
<div
className={cn(
'flex flex-wrap items-end gap-1.5',
- hookSource ? 'justify-start' : 'justify-end',
+ hookSource || attachmentsInBubble ? 'justify-start' : 'justify-end',
)}
>
{files.map((f, idx) => (
@@ -1327,6 +1334,7 @@ export function UserMessage({
className={cn(
'flex w-full',
orcaCommunication || hookSource ? 'justify-start' : 'justify-end',
+ bubbleActions && 'group/message',
)}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
@@ -1340,7 +1348,11 @@ export function UserMessage({
// 附件 chips 行保持右对齐不动。
editing
? 'w-full max-w-[720px] items-end'
- : 'max-w-[488px] items-end',
+ : // 伙伴私聊与群聊同一气泡上限(bot-group-chat.md §10)。
+ // 左侧留出贴边操作栏的位置。
+ simplifiedBotConversation
+ ? 'max-w-[min(720px,calc(100%-96px))] items-end'
+ : 'max-w-[488px] items-end',
)}
>
{sharedAuthorName && (
@@ -1451,8 +1463,9 @@ export function UserMessage({
</span>
</span>
)}
- {imageAttachmentNodes}
- {fileAttachmentNodes}
+ {/* 伙伴私聊:图片与文件随正文进同一个气泡(编辑态照常在上方)。 */}
+ {!attachmentsInBubble && imageAttachmentNodes}
+ {!attachmentsInBubble && fileAttachmentNodes}
{/* edit-last-message: 编辑态原地替换文本气泡 + 操作条(附件 chips 保持
只读展示在上方);非编辑态走原有渲染。 */}
{editing && sessionId && messageClientId ? (
@@ -1500,7 +1513,7 @@ export function UserMessage({
{/* 召唤标注行(chip)嵌进气泡顶部;正文永远回归文字气泡(2026-07-29
取消合并形态)。气泡在有标注、有引用或有正文任一时渲染——$指令
无余文时气泡只剩标注行。 */}
- {(inlineQuoteCount > 0 || displayBubbleBody.trim() || ghostChipDisplay) && (
+ {(inlineQuoteCount > 0 || displayBubbleBody.trim() || ghostChipDisplay || attachmentsInBubble) && (
<div
// 只剩插件标注行的气泡:分享图会剥掉标注,整泡一起去掉,不留空壳。
{...(inlineQuoteCount === 0 && !displayBubbleBody.trim()
@@ -1714,6 +1727,13 @@ export function UserMessage({
)}
</button>
)}
+ {attachmentsInBubble && (
+ <div className={cn('flex flex-col items-start gap-2', (inlineQuoteCount > 0 || displayBubbleBody.trim() || ghostChipDisplay) && 'mt-2')}>
+ {imageAttachmentNodes}
+ {fileAttachmentNodes}
+ </div>
+ )}
+ {bubbleActions && <BubbleHoverToolbar side="left">{messageActions}</BubbleHoverToolbar>}
</div>
)}
{/* ghost-summon-pill:未兑现的软提示保持低调胶囊,留在气泡下方
@@ -1738,7 +1758,7 @@ export function UserMessage({
{/* message-actions V1.2: hover-revealed bar below the bubble,
right-aligned, order [time][copy][fork][edit][undo][more]。被拦消息只保留
编辑和链接复制,fork/rewind/delete 对未发消息无意义。 */}
- {messageActions}
+ {!bubbleActions && messageActions}
</>
)}
</>
diff --git a/apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx b/apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx
index 248f3dbf64..68fe1f39a0 100644
--- a/apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx
+++ b/apps/desktop/src/renderer/components/chat/WorkGroupBlock.tsx
@@ -116,6 +116,8 @@ export interface WorkGroupBlockProps {
* the first activity — falling back to the first activity timestamp. */
startedAtMs?: number;
childItems: WorkGroupChild[];
+ /** The header hugs its text (teammate chats) instead of pinning the chevron to the far edge. */
+ fitHeader?: boolean;
}
function ToolActivityRow({ activity }: { activity: ProjectedToolActivity }) {
@@ -344,6 +346,7 @@ export function WorkGroupBlock({
isStreaming = false,
startedAtMs,
childItems,
+ fitHeader = false,
}: WorkGroupBlockProps) {
const { t } = useTranslation();
const { expanded: rememberedExpanded, setExpanded } = useExpandedBlockMemory(blockId);
@@ -480,7 +483,7 @@ export function WorkGroupBlock({
data-scroll-disclosure-header=""
disabled={!canToggle}
className={cn(
- 'flex w-full items-center gap-1.5 py-[2px]',
+ fitHeader ? 'flex w-fit max-w-full items-center gap-1.5 py-[2px]' : 'flex w-full items-center gap-1.5 py-[2px]',
'select-none',
compact && 'min-h-8 rounded-full px-2 focus-ring hover:bg-[var(--surface-hover)]',
'text-left',
@@ -499,7 +502,7 @@ export function WorkGroupBlock({
<span className="text-14 text-[var(--msg-tool-card-chevron)] truncate min-w-0 translate-y-[1px]">
{summaryText}
</span>
- <div className="flex-1" />
+ {!fitHeader && <div className="flex-1" />}
{!compact && isStreaming && startedAtMs !== undefined && (
<span className="font-mono text-12 text-[var(--msg-tool-card-chevron)]">
{formatDuration(elapsedMs, t)}
diff --git a/apps/desktop/src/renderer/components/chat/rich-answer.css b/apps/desktop/src/renderer/components/chat/rich-answer.css
index cde48d67b0..359eea3a28 100644
--- a/apps/desktop/src/renderer/components/chat/rich-answer.css
+++ b/apps/desktop/src/renderer/components/chat/rich-answer.css
@@ -218,3 +218,11 @@
border-radius: var(--rich-borderRadius, var(--radius-xl)) !important;
object-fit: contain;
}
+
+/* Inside a teammate's reply bubble (already the elevated surface), tracks and fields step down a level. */
+[data-bot-reply-bubble] .rich-answer-track {
+ background: var(--surface);
+}
+[data-bot-reply-bubble] .rich-answer-control input {
+ background: var(--surface);
+}
diff --git a/apps/desktop/src/renderer/features/bots/ChatServerControls.tsx b/apps/desktop/src/renderer/features/bots/ChatServerControls.tsx
index c821110d36..3e9c4eab4a 100644
--- a/apps/desktop/src/renderer/features/bots/ChatServerControls.tsx
+++ b/apps/desktop/src/renderer/features/bots/ChatServerControls.tsx
@@ -4,7 +4,7 @@ import { ChatInviteDialog } from './ChatInviteDialog';
import { ChatReactionButton } from './ChatReactionButton';
import { UserPlus } from 'lucide-react';
import { useTranslation } from 'react-i18next';
-import { MessageActionBar } from '@/components/chat/MessageActionBar';
+import { BubbleHoverToolbar, MessageActionBar } from '@/components/chat/MessageActionBar';
import { shareSelectionStore } from '@/components/chat/shareSelectionStore';
import { SHARE_EXCLUDE_ATTR } from '@/lib/shareConversationImage';
import { Tip } from '@/components/ui/tooltip';
@@ -110,13 +110,11 @@ function ChatMessageToolbar({ groupId, shareScope, message, align = 'left', onQu
*/
export function ChatMessageHoverActions({ besideReactions = false, ...props }: ChatMessageActionProps & { besideReactions?: boolean }) {
const [picker, setPicker] = useState(false);
- const right = props.align === 'right';
return (
- <div {...{ [SHARE_EXCLUDE_ATTR]: '' }} data-bot-group-message-actions="" data-open={picker ? '' : undefined}
- className={cn('pointer-events-none absolute top-0 z-10 w-max rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] p-0.5 opacity-0 transition-opacity duration-[var(--motion-fast)] ease-[var(--motion-ease-out)] focus-within:pointer-events-auto focus-within:opacity-100 group-hover/message:pointer-events-auto group-hover/message:opacity-100 data-[open]:pointer-events-auto data-[open]:opacity-100 motion-reduce:transition-none [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100',
- right ? 'right-full' : 'left-full', besideReactions ? (right ? 'mr-6' : 'ml-6') : (right ? 'mr-1.5' : 'ml-1.5'))}>
+ <BubbleHoverToolbar marker="data-bot-group-message-actions" side={props.align === 'right' ? 'left' : 'right'}
+ open={picker} besideReactions={besideReactions}>
<ChatMessageToolbar {...props} compact picker={picker} onPickerChange={setPicker} />
- </div>
+ </BubbleHoverToolbar>
);
}
diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts
index 7e4c0b7f37..e6e7b971c9 100644
--- a/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts
@@ -41,14 +41,20 @@ describe('teammate final-result presentation', () => {
: ending === 'retrying' ? [] : [message('error', 'error', 'Reply interrupted')]),
], ending === 'retrying');
expect(proseIds(result)).toEqual(ending === 'completed' ? ['intro', 'success'] : []);
- expect(allKeys(result)).toContain('msg-failed');
- expect(allKeys(result)).toContain('msg-failed-commentary');
+ // Failed output stays in the live work history; once the turn ends the process leaves with it.
+ if (ending === 'retrying') {
+ expect(allKeys(result)).toContain('msg-failed');
+ expect(allKeys(result)).toContain('msg-failed-commentary');
+ } else {
+ expect(allKeys(result)).not.toContain('msg-failed');
+ expect(allKeys(result)).not.toContain('msg-failed-commentary');
+ }
});
it('keeps coordination input hidden while process, explicit inputs, results and errors remain visible', () => {
const rows = [message('coordination', 'user', '[UI_ACTION_TRIGGER]File agreement', { isSyntheticTrigger: true }),
tool('audit'), message('visible-input', 'user', 'Requested status'),
message('result', 'assistant', 'Final result', { turnCompleted: true }), message('error', 'error', 'Action required')];
- expect(shape(project(rows, false))).toBe('work-audit[tools-audit], msg-visible-input, msg-result, msg-error');
+ expect(shape(project(rows, false))).toBe('msg-visible-input, msg-result, msg-error');
});
it('folds process rows into the normal work summary and keeps final answers without mutating history', () => {
@@ -57,7 +63,7 @@ describe('teammate final-result presentation', () => {
const result = project(input, false);
expect(proseIds(result)).toEqual(['final']);
// Same shape as a normal session: one outer summary with intermediate prose and inner groups.
- expect(shape(result)).toBe('msg-u, work-summary-t1[msg-a, work-t1[tools-t1], msg-b, work-t2[tools-t2]], msg-final');
+ expect(shape(result)).toBe('msg-u, msg-final');
expect(input[1]).toEqual(message('a', 'assistant'));
});
@@ -72,7 +78,7 @@ describe('teammate final-result presentation', () => {
expect(shape(continued)).toBe('msg-u, work-t1[tools-t1]');
const done = project([...work, message('b', 'assistant', 'B', { turnCompleted: true })], false);
expect(proseIds(done)).toEqual(['b']);
- expect(shape(done)).toBe('msg-u, work-summary-t1[msg-a, work-t1[tools-t1]], msg-b');
+ expect(shape(done)).toBe('msg-u, msg-b');
});
it.each(['stopped', 'failed', 'history'])('retains the last useful text with no final: %s', () => {
@@ -80,7 +86,7 @@ describe('teammate final-result presentation', () => {
message('last', 'assistant'), tool('t2'), message('err', 'error')];
const result = project(input, false);
expect(proseIds(result)).toEqual(['last']);
- expect(shape(result)).toBe('msg-u, work-t1[tools-t1], msg-last, work-t2[tools-t2], msg-err');
+ expect(shape(result)).toBe('msg-u, msg-last, msg-err');
});
it('keeps all blocks of sealed replies across continuation tools and history reloads', () => {
@@ -91,10 +97,12 @@ describe('teammate final-result presentation', () => {
for (const streaming of [true, false]) {
const result = project(input, streaming);
expect(proseIds(result)).toEqual(['first', 'second', 'third', 'fourth']);
- // An earlier background-wake reply is lifted out of the fold; the summary keeps
- // its key and the following activity group stays the same inner group.
- expect(shape(result)).toBe('msg-u, work-summary-t1[msg-progress, work-t1[tools-t1]], msg-first, '
- + 'msg-second, work-t2[tools-t2], msg-third, msg-fourth');
+ // An earlier background-wake reply is lifted out of the fold; while running the summary
+ // keeps its key and the following activity group stays the same inner group. Once the
+ // turn ends the work leaves and the replies remain.
+ expect(shape(result)).toBe(streaming
+ ? 'msg-u, work-summary-t1[msg-progress, work-t1[tools-t1]], msg-first, msg-second, work-t2[tools-t2], msg-third, msg-fourth'
+ : 'msg-u, msg-first, msg-second, msg-third, msg-fourth');
}
});
@@ -131,7 +139,7 @@ describe('teammate final-result presentation', () => {
});
const input = [message('u', 'user'), message('progress', 'assistant'), tool('t'), receipt];
expect(shape(project(input, true))).toBe('msg-u, work-t*[tools-t], msg-receipt');
- expect(shape(project(input, false))).toBe('msg-u, work-t[tools-t], msg-receipt');
+ expect(shape(project(input, false))).toBe('msg-u, msg-receipt');
});
it('retains a later explanation after partial delivery and ignores unverified file candidates', () => {
@@ -153,8 +161,8 @@ describe('teammate final-result presentation', () => {
message('u2', 'user'), message('explanation', 'assistant'), tool('failed')];
const result = simplifyBotRenderItems(groupWorkRuns(input, false), false, new Set(['files']));
expect(proseIds(result)).toEqual(['final', 'explanation']);
- expect(shape(result)).toBe('msg-u, work-summary-t[msg-progress, work-t[tools-t]], msg-final, files, '
- + 'msg-u2, msg-explanation, work-failed[tools-failed]');
+ // Both turns are over: their work leaves, the answers, files and explanation stay.
+ expect(shape(result)).toBe('msg-u, msg-final, files, msg-u2, msg-explanation');
});
it('does not extend a final seal or delivery fallback across a history gap without tools', () => {
@@ -206,34 +214,34 @@ describe('teammate final-result presentation', () => {
const input: RenderItem[] = [message('u', 'user'), message('empty', 'assistant', ' '),
{ type: 'work_group', key: 'work-nested', isStreaming: false, children: [thinking, tool('t')] },
message('answer', 'assistant')];
- expect(shape(project(input, false))).toBe('msg-u, work-nested[msg-private, tools-t], msg-answer');
+ expect(shape(project(input, false))).toBe('msg-u, msg-answer');
expect(thinking).toEqual(message('private', 'thinking', 'Not public execution'));
});
- it('passes unloaded technical history to the normal work fold without calling its expansion or retry API', () => {
+ it('drops a finished turn\'s technical history, loaded or not, without calling its expansion or retry API', () => {
const deferred = { owner: {}, key: 'range', expanded: false, loading: false, failed: false,
toggle: vi.fn(), retry: vi.fn(), setVisible: vi.fn() };
const group: RenderItem = { type: 'work_group', key: 'work-history', isStreaming: false,
children: [], deferred };
const input = [message('u', 'user'), group, message('final', 'assistant')];
const unloaded = simplifyBotRenderItems(input, false);
- expect(shape(unloaded)).toBe('msg-u, work-history[], msg-final');
- expect(unloaded[1]).toBe(group);
+ expect(shape(unloaded)).toBe('msg-u, msg-final');
+ expect(unloaded).not.toContain(group);
const loaded = { ...group, children: [message('thinking', 'thinking'), message('public', 'assistant'), tool('t')] };
const result = simplifyBotRenderItems([input[0], loaded as RenderItem, input[2]], false);
- expect(shape(result)).toBe('msg-u, work-history[msg-thinking, msg-public, tools-t], msg-final');
+ expect(shape(result)).toBe('msg-u, msg-final');
expect(deferred.toggle).not.toHaveBeenCalled();
expect(deferred.retry).not.toHaveBeenCalled();
expect(group.deferred).toBe(deferred);
});
- it('keeps deferred history controls when lifting a reply after one nested work group', () => {
+ it('keeps deferred history controls while the turn runs when lifting a reply after one nested work group', () => {
const deferred = { owner: {}, key: 'range', expanded: false, loading: false, failed: true,
previewComplete: false, toggle: vi.fn(), retry: vi.fn(), setVisible: vi.fn() };
const nested: RenderItem = { type: 'work_group', key: 'work-inner', isStreaming: false, children: [tool('t')] };
const reply = message('delivered', 'assistant', 'Here is the result', { explicitDelivery: true });
const history: RenderItem = { type: 'work_group', key: 'work-history', isStreaming: false, children: [nested, reply], deferred };
- const result = simplifyBotRenderItems([history], false);
+ const result = simplifyBotRenderItems([history], true);
expect(shape(result)).toBe('work-history[work-inner[tools-t]], msg-delivered');
const retained = result[0];
expect(retained.type === 'work_group' && retained.deferred).toBe(deferred);
@@ -242,11 +250,11 @@ describe('teammate final-result presentation', () => {
expect(deferred.retry).not.toHaveBeenCalled();
expect(history.children).toEqual([nested, reply]);
// Ordinary complete groups still unwrap the single inner group with its stable key.
- const complete = simplifyBotRenderItems([{ ...history, deferred: undefined }], false);
+ const complete = simplifyBotRenderItems([{ ...history, deferred: undefined }], true);
expect(complete).toEqual([nested, reply]);
});
- it('shows a running turn as a live work group and a finished turn as the summary with the answer outside', () => {
+ it('shows a running turn as a live work group and a finished turn as the answer alone', () => {
const at = (offset: number) => new Date(Date.parse('2026-10-15T08:00:00Z') + offset).toISOString();
const running = [message('u', 'user', 'Fix it', { createdAt: at(0) }),
message('think', 'thinking', 'Looking at refresh', { createdAt: at(1000) }),
@@ -258,9 +266,8 @@ describe('teammate final-result presentation', () => {
const finished = project([...running,
message('answer', 'assistant', 'Done', { createdAt: at(9000), turnCompleted: true })], false);
- expect(shape(finished)).toBe('msg-u, work-think[msg-think, tools-read], msg-answer');
- const doneGroup = finished[1];
- expect(doneGroup.type === 'work_group' && doneGroup.durationMs).toBe(9000);
+ // A finished turn shows only the answer; the work process leaves with the turn.
+ expect(shape(finished)).toBe('msg-u, msg-answer');
expect(proseIds(finished)).toEqual(['answer']);
});
@@ -274,8 +281,9 @@ describe('teammate final-result presentation', () => {
message('after', 'assistant', 'Continuing', { createdAt: at(6000) }),
{ type: 'work_group', key: 'work-b', isStreaming: false, children: [tool('b')] },
] };
+ // While the turn still runs its work stays visible, split around the delivered reply.
const result = simplifyBotRenderItems([message('u', 'user'), summary,
- message('final', 'assistant', 'Final', { turnCompleted: true })], false);
+ message('final', 'assistant', 'Final', { turnCompleted: true })], true);
expect(shape(result)).toBe('msg-u, work-summary-x[msg-note, work-a[tools-a]], msg-told, '
+ 'work-summary-x~msg-after[msg-after, work-b[tools-b]], msg-final');
const [first, , second] = result.slice(1);
@@ -304,7 +312,7 @@ it('nests only explicitly bound results, preserving original anchor and human me
const anchor = message('anchor', 'assistant', '', { systemCardType: 'bot-session-task' });
const final = message('final', 'assistant', 'Summary', { turnCompleted: true, botTaskResults: [card] });
const input = [anchor, receipt, message('human', 'user'), message('progress', 'assistant'), tool('t'), final];
- expect(shape(project(input, false))).toBe('msg-anchor, msg-human, work-summary-t[msg-progress, work-t[tools-t]], msg-final');
+ expect(shape(project(input, false))).toBe('msg-anchor, msg-human, msg-final');
expect(final.message.botTaskResults).toEqual([card]);
expect(allKeys(project(input.slice(0, -1), false))).toContain('msg-receipt');
expect(allKeys(project([receipt, message('unrelated', 'assistant', 'Other', { turnCompleted: true })], false))).toContain('msg-receipt');
diff --git a/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts b/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts
index 464a5762f2..a12516a862 100644
--- a/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts
+++ b/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts
@@ -31,9 +31,9 @@ function expandWorkGroups(items: readonly RenderItem[]): RenderItem[] {
/** A presentation-only projection. Never mutate messages or infer intent from prose.
* isFinal from the adapters closes a text block, not a turn (Pi/Claude can call
* another tool afterwards). Reuse the normal work-group turn seal, showing provider-marked final prose immediately while keeping
- * unclassified top-level intermediate prose hidden. Work groups (live activity and
- * the completed "worked Xs" summary), running agent tasks and workflow cards pass
- * through untouched so the bot chat shows its work exactly like a normal session.
+ * unclassified top-level intermediate prose hidden. While a turn runs its work groups
+ * show like a normal session; once the turn ends they are dropped, so a finished turn
+ * shows only what the bot said, results and errors. Agent tasks and workflow cards pass through.
* On stop/error or old history without a seal, expose the last useful
* prose so an answer or plain-text question cannot disappear permanently.
*/
@@ -199,6 +199,9 @@ function projectWindow(
// Bots never produce change cards; keep them out like before. Thinking is
// always folded into a work group by the shared grouping, never top level.
if (item.type === 'turn_changes') return;
+ // The work process shows only while its turn runs; a finished turn keeps only what
+ // the bot said, results and errors (cindy-bots-runtime.md).
+ if (!active && item.type === 'work_group') return;
if (item.type === 'message' && item.message.role === 'thinking') return;
if (item.type === 'message' && item.message.isSyntheticTrigger) return;
if (isProse(item)) {
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index f6ac409ecc..740e29256e 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -196,9 +196,11 @@ tool 副作用时自动重放。原生后台工作尚未结束时不自动关闭
伙伴界面由入口验证过的持久归属与任务 ID 决定,不随异步运行快照的缺失、刷新或重连回退为普通任务界面。历史资料尚未加载或暂时失败时也保留伙伴呈现;手机保留同一账号、设备与任务内已确认的伙伴身份。切换任务、设备或账号时不得复用旧身份。此呈现规则不替代宿主的权限与归属校验。
-**伙伴聊天显示工作过程(2026-10-15,Chris:「你这么做不如改回当年 session 的思考了」→ 直接用 session 同一套)**:伙伴的回复列与普通任务共用同一个工作过程折叠块(`WorkGroupBlock`)——运行中露出最近几步(工具名/文件/命令/思考首句)与计时,完成后折叠成「已工作 Xs」,点开可见思考与工具行;不再在渲染前删掉 thinking、tool 与 work_group。伙伴明确说给用户听的回复(provider 标为 final、群投递、显式投递或已收尾的回复)永远不藏进折叠里:工作过程在这类回复前后分段。输入框上方不再有只会说大类词的「正在处理…」状态行;运行状态走普通任务同一条 `RunningStatusBar`。工作过程与回复正文同列(头像列留空),不重复画脸。实现见 `botConversationPresentation.ts` 与 `MessageStream.tsx`。
+**伙伴聊天显示工作过程(2026-10-15,Chris:「你这么做不如改回当年 session 的思考了」→ 直接用 session 同一套)**:伙伴的回复列与普通任务共用同一个工作过程折叠块(`WorkGroupBlock`)——运行中露出最近几步(工具名/文件/命令/思考首句)与计时,组头按文字宽度,箭头紧跟计时,不再顶到最右;这一轮结束后整块工作过程不再出现,只留伙伴说的话、结果与错误(2026-10-20 Chris 裁决「做完了,去掉」,取代原先的「完成后折叠成已工作 Xs」)。运行中不在渲染前删掉 thinking、tool 与 work_group。伙伴明确说给用户听的回复(provider 标为 final、群投递、显式投递或已收尾的回复)永远不藏进折叠里:工作过程在这类回复前后分段。输入框上方不再有只会说大类词的「正在处理…」状态行;运行状态走普通任务同一条 `RunningStatusBar`。工作过程与回复正文同列(头像列留空),不重复画脸。实现见 `botConversationPresentation.ts` 与 `MessageStream.tsx`。
-手机端遵守同一展示规则:`companionConversationPresentation.ts` 保留工作组及其历史详情加载入口,
+**伙伴私聊的消息样式(2026-10-20,与群聊统一)**:伙伴的回复放进与群聊同一种气泡——卡片底色加 1px 默认边框、12px 圆角、不加阴影(DESIGN.md §6);宽度随内容,上限 720px,组件式回答在气泡内按上限宽度排版,进度轨与输入框改用 `--surface` 以免与气泡同色。用户自己的消息沿用 Cindy 用户气泡,上限同为 720px,图片与文件随正文进同一个气泡(编辑态照旧在上方)。正文与任务对话同一字号。操作栏与群聊同一种贴边紧凑栏(`BubbleHoverToolbar`):挂在气泡外侧(伙伴回复的右边、自己消息的左边),与气泡顶部齐平,悬停、键盘聚焦或触屏时出现;外露「回复」、编辑(最后一条自己的消息)与更多,复制、分享为图片、链接、删除与准确时间收进更多。为此两侧气泡上限在窄窗口下让出操作栏的宽度。手机端另行同步。
+
+手机端遵守同一展示规则(「完成后整块不再出现」与私聊气泡尚待手机端同步,目前手机仍折叠成「已工作 Xs」):`companionConversationPresentation.ts` 保留工作组及其历史详情加载入口,
`MessageRenderer.tsx` 在运行中展示最近五条活动;旧电脑未下发活动行时读取已有预览范围。
provider 的 `final_answer` 从首段正文起可见,历史视图接管、后续工具调用和完成收口均不得把它过滤掉。
本链路验收同时覆盖普通任务与伙伴入口、实时消息转历史、折叠展开及重开;不能用桌面验收代替手机验收。