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 remote-tracking branch 'upstream/main' into rich-html-answers

Chris5e3779980653
diff --cc apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts
index d393a20cc8,66177c97b1..4c3ce23df1
--- a/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts
@@@ -22,15 -22,28 +22,37 @@@ const project = (items: RenderItem[], s
simplifyBotRenderItems(groupWorkRuns(items, streaming), streaming);
describe('teammate final-result presentation', () => {
+ // Unit: a complete HTML result before a trailing tool must survive companion answer compaction.
+ it('retains a finished HTML answer before a trailing tool and closing reply', () => {
+ const html = '<html><body><button>Result</button></body></html>';
+ const rows = [message('u', 'user'), message('html', 'assistant', html), tool('notify'),
+ message('final', 'assistant', 'Done', { turnCompleted: true })];
+ expect(proseIds(project(rows, false))).toEqual(['html', 'final']);
+ expect(proseIds(project([message('u', 'user'), message('html', 'assistant', html, { isStreaming: true })], true))).toEqual([]);
+ });
+
+ // #6351: provider final_answer only closes a message, not a successful sample.
+ // Failed output remains in the expandable work history rather than being lifted
+ // beside the real answer; normal commentary is governed by the existing rules.
+ it.each(['retrying', 'completed', 'exhausted', 'stopped'] as const)(
+ 'retains failed sampling output in work history when the retry is %s', (ending) => {
+ const result = project([
+ message('u', 'user'),
+ message('failed', 'assistant', 'Opening from failed attempt', {
+ assistantPhase: 'final_answer', failedSamplingAttempt: true, turnCostUsd: 0.1,
+ }),
+ message('failed-commentary', 'assistant', 'Preparing another opening', {
+ assistantPhase: 'commentary', failedSamplingAttempt: true,
+ }),
+ ...(ending === 'completed'
+ ? [message('intro', 'assistant', 'Accepted intro'),
+ message('success', 'assistant', 'Successful opening', { assistantPhase: 'final_answer', turnCompleted: true })]
+ : 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');
+ });
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'),
diff --cc apps/desktop/src/renderer/features/bots/botConversationPresentation.ts
index 42683ff48f,f093819714..872435f122
--- a/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts
+++ b/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts
@@@ -174,10 -169,10 +174,11 @@@ function projectWindow
if (sealedRun) sealedAnswers.add(item.message);
}
const isAddressedReply = (message: ChatMessage) => Boolean(message.content.trim())
+ && !message.failedSamplingAttempt
&& !(message.assistantPhase === 'commentary' && !message.explicitDelivery)
&& (message.assistantPhase === 'final_answer' || Boolean(message.sourceGroup)
- || Boolean(message.explicitDelivery) || isCompletedAssistantMessage(message) || sealedAnswers.has(message));
+ || Boolean(message.explicitDelivery) || hasHtmlAnswer(message)
+ || isCompletedAssistantMessage(message) || sealedAnswers.has(message));
const result: RenderItem[] = [];
let turn: RenderItem[] = [];
const flushTurn = (active: boolean) => {