Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(remote): retain local user bubbles in history view
Dashedfcb814d50a
diff --git a/apps/desktop/src/renderer/components/chat/MessageStream.tsx b/apps/desktop/src/renderer/components/chat/MessageStream.tsxindex f700053024..f182ccf6e1 100644--- a/apps/desktop/src/renderer/components/chat/MessageStream.tsx+++ b/apps/desktop/src/renderer/components/chat/MessageStream.tsx@@ -2739,6 +2739,7 @@ export function MessageStream({const items = renderHistoryView<HistoryChatMessage, RenderItem>({view: historyView, snapshot: historySnapshot, liveMessages, streaming: isSessionStreaming,isLive: (row) => row.isStreaming === true,+ isLocalUser: (row) => row.role === 'user' && (row.isPendingPersist === true || !!row.blockedByGhost),build: (rows) => {const chunk = buildRenderItems([...rows], taskUpdates, ghostCardSnapshot, {historyWindowIncomplete: true, workingDir,diff --git a/packages/maker-shared/src/__tests__/historyView.test.ts b/packages/maker-shared/src/__tests__/historyView.test.tsindex c435626f70..e79e59cc36 100644--- a/packages/maker-shared/src/__tests__/historyView.test.ts+++ b/packages/maker-shared/src/__tests__/historyView.test.ts@@ -256,6 +256,31 @@ describe('shared history view lifecycle', () => {expect(rendered).toEqual(['c1']);});+ it('preserves current local user bubbles, source authority and store order despite clock skew', async () => {+ type Message = HistoryMessageSource & { isPendingPersist?: boolean; blockedByGhost?: boolean };+ const source = [row(1, 'user', 'kept'), row(10, 'assistant', 'answer'), row(11, 'user', 'persisted rewrite')];+ const view = new HistoryViewController<Message>({+ page: async () => ({ version: 1, items: projectHistoryView(source, false), hasMore: false, nextCursor: null }),+ details: async () => ({ version: 1, messages: [], hasMore: false, nextCursor: null }),+ expanded: async () => undefined,+ });+ await view.refresh();+ const blocked = { ...row(2, 'user', 'blocked'), blockedByGhost: true };+ const pending = { ...row(3, 'user', 'pending'), isPendingPersist: true };+ const render = (liveMessages: Message[]) => renderHistoryView({+ view, snapshot: view.getSnapshot(), liveMessages, streaming: false,+ isLive: () => false,+ isLocalUser: (message) => message.isPendingPersist === true || !!message.blockedByGhost,+ build: (rows) => rows.map((message) => message.content), structure: ungroupedStructure,+ });+ expect(render([source[0], blocked, source[1],+ { ...source[2], content: 'stale optimistic body', isPendingPersist: true }, pending,+ row(12, 'user', 'rewound durable user'), row(13, 'assistant', 'rewound answer')]))+ .toEqual(['kept', 'blocked', 'answer', 'persisted rewrite', 'pending']);+ // Clearing the existing store removes local bubbles; no renderer-owned cache revives them.+ expect(render(source)).toEqual(['kept', 'answer', 'persisted rewrite']);+ });+it.each([false, true])('uses refreshed work details after collapse despite stale streaming rows (active=%s)', async (active) => {let thinking = { ...row(1, 'thinking', 'partial'), isStreaming: true };const prose = row(2, 'assistant', 'answer');diff --git a/packages/maker-shared/src/historyViewRender.ts b/packages/maker-shared/src/historyViewRender.tsindex bf312d8f97..06a213844c 100644--- a/packages/maker-shared/src/historyViewRender.ts+++ b/packages/maker-shared/src/historyViewRender.ts@@ -9,6 +9,7 @@ export function renderHistoryView<T extends HistoryMessageSource, TItem>(optionsbuild(messages: readonly T[], streaming: boolean): TItem[];streaming: boolean;isLive?(message: T): boolean;+ isLocalUser?(message: T): boolean;structure: {placeholder(summary: HistoryWorkSummary): T;children(item: TItem): readonly TItem[] | undefined;@@ -62,6 +63,21 @@ export function renderHistoryView<T extends HistoryMessageSource, TItem>(optionsif (options.isLive?.(row) && !seen.has(row.clientId) && (row.role === 'assistant' || row.role === 'user')&& Date.parse(row.createdAt) >= endMs) rows.push(row);}+ // Local pending/blocked user bubbles belong to the current UI store, not+ // persisted history. Keep their store order without trusting device clocks.+ const renderedIds = new Set(rows.map((row) => row.clientId));+ let beforeClientId: string | undefined;+ for (let index = options.liveMessages.length - 1; index >= 0; index--) {+ const row = options.liveMessages[index];+ if (renderedIds.has(row.clientId)) {+ beforeClientId = row.clientId;+ } else if (row.role === 'user' && options.isLocalUser?.(row)) {+ const before = beforeClientId === undefined ? -1 : rows.findIndex((item) => item.clientId === beforeClientId);+ rows.splice(before < 0 ? rows.length : before, 0, row);+ renderedIds.add(row.clientId);+ beforeClientId = row.clientId;+ }+ }const bind = (item: TItem): TItem => {const children = structure.children(item);if (!children) return item;