Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(chat): 完成后将紧邻最终答复的进度文字收入折叠
Dashb6d92e2c167e
diff --git a/apps/desktop/src/renderer/__tests__/workGroupBlockLivePreview.test.tsx b/apps/desktop/src/renderer/__tests__/workGroupBlockLivePreview.test.tsxindex e12ed01650..2971e7b29f 100644--- a/apps/desktop/src/renderer/__tests__/workGroupBlockLivePreview.test.tsx+++ b/apps/desktop/src/renderer/__tests__/workGroupBlockLivePreview.test.tsx@@ -191,24 +191,30 @@ describe('failed sampling work-group disclosure (#6351)', () => {message('intro', 'assistant', 'Accepted introduction'),message('final', 'assistant', 'Successful welcome', { turnCompleted: true })];view.rerender(samplingTimeline(completed, false));- // The same failed group retains its explicit audit expansion. Accepted- // multi-message prose is outside it and remains visible when it closes.- expect(screen.getByTestId('work-f1').textContent).toContain('First failed welcome');- expect(screen.getByTestId('work-f1').textContent).not.toContain('Successful welcome');- fireEvent.click(screen.getByTestId('work-f1').querySelector('button')!);+ // Explicit commentary joins the completed summary; the inner failed group+ // retains its audit expansion when that new outer summary is opened.+ const completedWork = screen.getByTestId(ending === 'same-turn success' ? 'work-summary-f1' : 'work-f1');+ if (ending === 'same-turn success') fireEvent.click(completedWork.querySelector('button')!);+ expect(completedWork.textContent).toContain('First failed welcome');+ expect(completedWork.textContent).not.toContain('Successful welcome');+ fireEvent.click(completedWork.querySelector('button')!);expect(screen.queryByText('First failed welcome')).toBeNull();expect(screen.queryByText('Second failed welcome')).toBeNull();- expect(screen.getByText('Accepted commentary')).toBeTruthy();+ expect(screen.queryByText('Accepted commentary')).toBeNull();expect(screen.getByText('Accepted introduction')).toBeTruthy();expect(screen.getByText('Successful welcome')).toBeTruthy();if (ending === 'stopped then manual recovery') {expect(screen.getByText('Reply stopped')).toBeTruthy();expect(screen.getByText('Continue')).toBeTruthy();}- fireEvent.click(screen.getByTestId('work-f1').querySelector('button')!);+ fireEvent.click(completedWork.querySelector('button')!);expect(screen.getByText('First failed welcome')).toBeTruthy();expect(screen.getByText('Second failed welcome')).toBeTruthy();expect(screen.getByText('Successful welcome')).toBeTruthy();+ if (ending === 'stopped then manual recovery') {+ fireEvent.click(screen.getByTestId('work-summary-commentary').querySelector('button')!);+ }+ expect(screen.getByText('Accepted commentary')).toBeTruthy();});it('keeps equal failed prose on each side of steering independently auditable', () => {@@ -222,15 +228,18 @@ describe('failed sampling work-group disclosure (#6351)', () => {], false));expect(screen.queryAllByText('Repeated failed welcome')).toHaveLength(0);expect(screen.getByText('Include the new direction')).toBeTruthy();- expect(screen.getByText('Accepted commentary')).toBeTruthy();+ expect(screen.queryByText('Accepted commentary')).toBeNull();expect(screen.getByText('Successful steered welcome')).toBeTruthy();const first = screen.getByTestId('work-f1');- const second = screen.getByTestId('work-f2');+ const second = screen.getByTestId('work-summary-f2');+ fireEvent.click(second.querySelector('button')!);+ expect(screen.getByText('Accepted commentary')).toBeTruthy();fireEvent.click(first.querySelector('button')!);expect(screen.getAllByText('Repeated failed welcome')).toHaveLength(1);expect(first.textContent).toContain('Repeated failed welcome');expect(second.textContent).not.toContain('Repeated failed welcome');- fireEvent.click(second.querySelector('button')!);+ // The summary's second disclosure is the independently retained failed sample.+ fireEvent.click(second.querySelectorAll('button')[1]);expect(screen.getAllByText('Repeated failed welcome')).toHaveLength(2);fireEvent.click(first.querySelector('button')!);expect(screen.getAllByText('Repeated failed welcome')).toHaveLength(1);diff --git a/apps/desktop/src/renderer/components/chat/messageWorkGroups.ts b/apps/desktop/src/renderer/components/chat/messageWorkGroups.tsindex 57807ca2cb..b86c96cb81 100644--- a/apps/desktop/src/renderer/components/chat/messageWorkGroups.ts+++ b/apps/desktop/src/renderer/components/chat/messageWorkGroups.ts@@ -531,6 +531,7 @@ export function groupWorkRuns(items: RenderItem[], isSessionStreaming: boolean):isUserBoundary: (item) => item.type === 'message' && item.message.role === 'user' && !isSteerUserRow(item.message),isContinuationBoundary: (item) => item.type === 'message' && isContinuationMessage(item.message),isAnswer: isAssistantAnswerCandidate,+ canPrependToAnswer: (item) => item.type !== 'message' || item.message.assistantPhase !== 'commentary',isSealedAnswer: (item) => item.type === 'message' && isCompletedAssistantMessage(item.message),isCompactBoundary: isCompactBoundaryItem,isActivity: isWorkActivityItem,diff --git a/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts b/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.tsindex 09765a1583..b67afa8907 100644--- a/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts+++ b/apps/desktop/src/renderer/features/bots/__tests__/botConversationPresentation.test.ts@@ -339,7 +339,12 @@ describe('provider final streaming', () => {expect(proseIds(project([...prefix, final], true))).toEqual(['process', 'answer']);expect(proseIds(project([...prefix, { ...final, message: { ...final.message, isStreaming: false } }], true))).toEqual(['process', 'answer']);}- expect(proseIds(project([...prefix, message('answer', 'assistant', 'Answer', { assistantPhase: 'final_answer', turnCompleted: true })], false))).toEqual(['process', 'answer']);+ for (const streaming of [false, true]) {+ const completed = project([...prefix, message('answer', 'assistant', 'Answer', { assistantPhase: 'final_answer', turnCompleted: true })], streaming);+ expect(proseIds(completed)).toEqual(['answer']);+ expect(allKeys(completed)).toContain('msg-process');+ expect(completed.find(item => item.type === 'work_group')).toMatchObject({ isStreaming: false });+ }});});diff --git a/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts b/apps/desktop/src/renderer/features/bots/botConversationPresentation.tsindex e67e734833..c309bd2291 100644--- a/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts+++ b/apps/desktop/src/renderer/features/bots/botConversationPresentation.ts@@ -155,7 +155,8 @@ function projectWindow(let sealedRun = false;for (let index = expanded.length - 1; index >= 0; index -= 1) {const item = expanded[index];- if (!isProse(item) || !item.message.content.trim() || item.message.failedSamplingAttempt) {+ if (!isProse(item) || !item.message.content.trim() || item.message.failedSamplingAttempt+ || item.message.assistantPhase === 'commentary') {sealedRun = false;continue;}diff --git a/apps/mobile/src/__tests__/companionConversationPresentation.test.ts b/apps/mobile/src/__tests__/companionConversationPresentation.test.tsindex 16eaa564e8..49f45959b7 100644--- a/apps/mobile/src/__tests__/companionConversationPresentation.test.ts+++ b/apps/mobile/src/__tests__/companionConversationPresentation.test.ts@@ -80,6 +80,19 @@ it('keeps all contiguous blocks of a sealed final answer', () => {const text = items.filter(item => item.type === 'message').map(item => item.message.body);expect(text).toEqual(['Help', 'Part one', 'Part two']);});+// #7081 review: no tool/thinking boundary exists between progress and the final.+// Unit: real normalize → shared grouping → companion projection, including a late running status.+it.each([false, true])('folds commentary before a directly adjacent sealed answer (running=%s)', (running) => {+ const progress = row('a1', 'assistant', 'Checking', { assistantPhase: 'commentary' });+ const final = row('a2', 'assistant', 'Done', { assistantPhase: 'final_answer', turnCompleted: true });+ expect(bodies([base[0], progress, { ...final, agentMeta: { assistantPhase: 'final_answer', isStreaming: true } }], true)+ .filter(item => item.type === 'message').map(item => item.message.body)).toEqual(['Help', 'Checking', 'Done']);+ const complete = bodies([base[0], progress, final], running);+ expect(complete.filter(item => item.type === 'message').map(item => item.message.body)).toEqual(['Help', 'Done']);+ const work = complete.find(item => item.type === 'work_group');+ expect(work).toMatchObject({ isStreaming: false });+ expect(JSON.stringify(work)).toContain('Checking');+});it('keeps every sealed reply block after a continuation even when the main timeline folds earlier seals', () => {const items = bodies([...base,row('a4', 'assistant', 'First block'), row('a5', 'assistant', 'First reply', { turnCompleted: true }),diff --git a/apps/mobile/src/__tests__/mobileHistoryRender.test.ts b/apps/mobile/src/__tests__/mobileHistoryRender.test.tsindex 084469f636..0422339eda 100644--- a/apps/mobile/src/__tests__/mobileHistoryRender.test.ts+++ b/apps/mobile/src/__tests__/mobileHistoryRender.test.ts@@ -35,6 +35,19 @@ function harness(rows: RemoteMessage[], streaming = false, lazyDetails = false)}describe('remote history preserves original folding', () => {+ // #7081: the host outline must agree with raw grouping when progress directly precedes the final.+ it.each([false, true])('folds adjacent companion commentary after history takeover (lazy=%s)', async (lazy) => {+ const rows = [row(0, 'user', 'Work'),+ { ...row(1, 'assistant', 'Checking'), agentMeta: { assistantPhase: 'commentary' } },+ { ...row(2, 'assistant', 'Done'), agentMeta: { assistantPhase: 'final_answer', turnCompleted: true } }];+ const { view, render } = harness(rows, false, lazy);+ await view.refresh();+ const loaded = companionConversationItems(render());+ expect(loaded.filter(item => item.type === 'message').map(item => item.message.body)).toEqual(['Work', 'Done']);+ expect(outline(loaded)).toEqual(outline(companionConversationItems(buildMobileMessageRenderItems(rows))));+ expect(JSON.stringify(loaded.find(item => item.type === 'work_group'))).toContain('Checking');+ view.setActive(false);+ });// Unit: a child inherits the transcript for the model but only its new turns// belong on screen. Exercise real rendering with both eager and lazy work.it.each([false, true])('hides inherited work and messages in a side chat (lazy=%s)', async (lazy) => {diff --git a/apps/mobile/src/session/companionConversationPresentation.ts b/apps/mobile/src/session/companionConversationPresentation.tsindex 2ac8049838..502a744def 100644--- a/apps/mobile/src/session/companionConversationPresentation.ts+++ b/apps/mobile/src/session/companionConversationPresentation.ts@@ -47,7 +47,8 @@ export function companionConversationItems(items: readonly MobileMessageRenderItlet sealedRun = false;let nextAssistantAt: number | null = null;for (const item of expandWorkGroups(items).reverse()) {- if (item.type !== 'message' || item.message.kind !== 'assistant' || item.message.failedSamplingAttempt || !item.message.body.trim() || item.message.systemCardType) {+ if (item.type !== 'message' || item.message.kind !== 'assistant' || item.message.failedSamplingAttempt || !item.message.body.trim() || item.message.systemCardType+ || item.message.source.agentMeta?.assistantPhase === 'commentary') {sealedRun = false;nextAssistantAt = null;} else {diff --git a/packages/maker-shared/src/historyViewProjection.ts b/packages/maker-shared/src/historyViewProjection.tsindex a1905e6938..d0463823ad 100644--- a/packages/maker-shared/src/historyViewProjection.ts+++ b/packages/maker-shared/src/historyViewProjection.ts@@ -271,6 +271,8 @@ function projectHistorySourceView<T extends HistoryMessageSource>(isAnswer: (item) => item.type === 'source' && item.row.role === 'assistant'&& typeof item.row.content === 'string' && !!item.row.content.trim(),isSealedAnswer: (item) => item.type === 'source' && completesHistoryTurn(item.row),+ canPrependToAnswer: (item) => item.type !== 'source'+ || (item.row.agentMeta as Record<string, unknown> | null | undefined)?.assistantPhase !== 'commentary',isCompactBoundary: (item) => item.type === 'source' && item.row.role === 'system',isActivity: (item): item is SourceItem<T> => item.type === 'source' && item.activity,isArchivable: (item): item is SourceItem<T> => item.type === 'source' && item.archivable,diff --git a/packages/maker-shared/src/messageRender.ts b/packages/maker-shared/src/messageRender.tsindex 17c8eb1e99..a311900e4a 100644--- a/packages/maker-shared/src/messageRender.ts+++ b/packages/maker-shared/src/messageRender.ts@@ -1531,6 +1531,7 @@ function groupMessageWorkRuns<TMessage extends MessageRenderNormalizedMessage>(isUserBoundary: (item) => item.type === 'message' && item.message.kind === 'user' && !isSteerUserRow(item.message.source),isContinuationBoundary: (item) => item.type === 'message' && isContinuationMessage(item.message.source),isAnswer: isAssistantAnswerCandidate,+ canPrependToAnswer: (item) => item.type !== 'message' || item.message.source.agentMeta?.assistantPhase !== 'commentary',isSealedAnswer: (item) => item.type === 'message' && isCompletedAssistantMessage(item.message),isCompactBoundary: isCompactBoundaryItem,isActivity: isWorkActivityItem,diff --git a/packages/maker-shared/src/workRunGrouping.ts b/packages/maker-shared/src/workRunGrouping.tsindex 03b3337f5d..8dcb9c3b8f 100644--- a/packages/maker-shared/src/workRunGrouping.ts+++ b/packages/maker-shared/src/workRunGrouping.ts@@ -6,6 +6,8 @@ export interface WorkRunGroupingAdapter<TItem, TChild extends TItem> {/** A recovery closes the interrupted attempt without requiring a final answer. */isContinuationBoundary?(item: TItem): boolean;isAnswer(item: TItem): boolean;+ /** Explicit progress cannot be prepended to an adjacent final answer run. */+ canPrependToAnswer?(item: TItem): boolean;isSealedAnswer(item: TItem): boolean;isCompactBoundary(item: TItem): boolean;isActivity(item: TItem): item is TChild;@@ -201,7 +203,8 @@ function groupAnsweredTurn<TItem, TChild extends TItem>(while (answerStart > lastActivity + 1 &&answerStart > segmentStart &&- adapter.isAnswer(items[answerStart - 1])+ adapter.isAnswer(items[answerStart - 1]) &&+ adapter.canPrependToAnswer?.(items[answerStart - 1]) !== false) {answerStart--;}@@ -235,7 +238,8 @@ function groupAnsweredTurn<TItem, TChild extends TItem>(if (lastActivity >= 0) {while (answerStart > lastActivity + 1 &&- adapter.isAnswer(items[answerStart - 1])+ adapter.isAnswer(items[answerStart - 1]) &&+ adapter.canPrependToAnswer?.(items[answerStart - 1]) !== false)answerStart--;}