Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(device-link): 收敛列表正文推送与缓存合并边界
Dash1898ae197410
diff --git a/apps/desktop/src/main/device-link/__tests__/dispatchMakerEventBatch.test.ts b/apps/desktop/src/main/device-link/__tests__/dispatchMakerEventBatch.test.tsindex 6a6aa4cbe2..9f5e8461e0 100644--- a/apps/desktop/src/main/device-link/__tests__/dispatchMakerEventBatch.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/dispatchMakerEventBatch.test.ts@@ -137,6 +137,23 @@ afterEach(() => {});describe('[1] 能力协商', () => {+ it('projects done to lifecycle fields for list subscribers while retaining full detail events', async () => {+ const h = mkClient();+ __testing.setActiveClient(h.client as never);+ const capabilities = [CONTROLLER_CAPABILITY_SESSION_LIST_MESSAGES_V1, CONTROLLER_CAPABILITY_MAKER_EVENT_BATCH_V1];+ subscriptions.subscribe('list', ['sessions'], 'list', capabilities);+ subscriptions.subscribe('detail', ['sessions', 'session:s1'], 'detail', capabilities);+ const payload = { sessionId: 's1', resolvedContent: 'tool-body', event: { type: 'done', source: 'codex',+ turnContinuationId: 2, turnScope: 'background', data: { raw: { items: ['tool-body'] }, result: 'tool-body',+ plan: ['tool-body'], cancelled: true, silentStop: true } } };+ __testing.forwardPush('maker:event', payload);+ await vi.advanceTimersByTimeAsync(WINDOW_MS);+ const list = h.sent.find(push => push.dst === 'list')!.payload as MakerEventBatchPayload;+ expect(list.events).toEqual([{ sessionId: 's1', listMessage: true, event: { type: 'done', source: 'codex',+ turnContinuationId: 2, turnScope: 'background', data: { cancelled: true, silentStop: true } } }]);+ expect((h.sent.find(push => push.dst === 'detail')!.payload as MakerEventBatchPayload).events).toEqual([payload]);+ });+it('prefetches full prose for new list subscribers only, without duplicate delivery or tools', async () => {const h = mkClient();__testing.setActiveClient(h.client as never);@@ -582,6 +599,21 @@ describe('[10] 收敛检查点:主动发送闸门的全部入口与边界(review});describe('[11] 重连恢复的顺序(review 第三轮)', () => {+ it('replays a reply completed while the relay was offline to sessions-only subscribers', () => {+ const h = mkClient();+ __testing.setActiveClient(h.client as never);+ const capabilities = [CONTROLLER_CAPABILITY_SESSION_LIST_MESSAGES_V1];+ subscriptions.subscribe('phone', ['sessions'], 'phone', capabilities);+ h.client.getStatus.mockReturnValue('connecting');+ const message = { id: 'final', clientId: 'final', role: 'assistant', content: 'completed offline' };+ __testing.forwardPush('local-db:messages:created', { sessionId: 's1', message });+ expect(h.sent).toEqual([]);+ h.client.getStatus.mockReturnValue('online');+ __testing.handleSubscriptionFrame('phone', { channel: DL_SUBSCRIBE_CHANNEL, args: [{ topics: ['sessions'], capabilities }] });+ expect(h.sent).toHaveLength(1);+ expect(h.sent[0]).toMatchObject({ channel: 'local-db:messages:created', payload: { listMessage: true, message } });+ });+it('订阅重放 drain 离线积压之前先排空断线前的事件批', () => {// 断线期间同会话的新事件/终态进 offlinePushQueue,旧批留在内存等重试;// 不先收口就会让新帧先于断线前的文本送达,重现「终态后冒出文本」。@@ -726,6 +758,20 @@ describe('running session recovery on slow links', () => {type: 'text', data: { text: 'whole prefix', isFinal: false, isFullText: true },} };+ it('keeps oversized recovery text on demand for list-only subscribers', async () => {+ const h = mkClient();+ __testing.setActiveClient(h.client as never);+ const oversized = { ...snapshot, event: { ...snapshot.event, data: { ...snapshot.event.data, text: 'x'.repeat(200_001) } } };+ setSessionTextSnapshotReader(() => oversized);+ subscriptions.subscribe('list', ['sessions', 'session:s1'], 'list', [...capabilities, CONTROLLER_CAPABILITY_SESSION_LIST_MESSAGES_V1]);+ __testing.handleSubscriptionFrame('list', { channel: DL_UNSUBSCRIBE_CHANNEL, args: [{ topics: ['session:s1'] }] });+ await vi.advanceTimersByTimeAsync(250);+ expect(h.sent[0]).toMatchObject({ channel: SESSION_SYNC_CHANNEL, payload: { sessionId: 's1', listMessage: true, resyncRequired: true } });+ expect(JSON.stringify(h.sent[0])).not.toContain('xxx');+ __testing.handleSubscriptionFrame('detail', { channel: DL_SUBSCRIBE_CHANNEL, args: [{ topics: ['session:s1'], capabilities }] });+ expect(h.sent.at(-1)).toMatchObject({ channel: SESSION_SYNC_CHANNEL, payload: oversized });+ });+it('repairs the prefix when leaving chat and continues list text until the list is unsubscribed', async () => {const h = mkClient();__testing.setActiveClient(h.client as never);diff --git a/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.ts b/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.tsindex c4eb6ee507..ab0153ca7d 100644--- a/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.ts@@ -334,6 +334,34 @@ describe('normalizeDeviceSessions', () => {});describe('readMessages / writeMessages', () => {+ it('merges list arrivals under the page-write lock, preserving history and clear barriers', async () => {+ const c = rawCache();+ const token = await c.readMessagesWithInvalidation('dev', 'session');+ const rows = [row('old', '2026-01-01T00:00:00Z')];+ const snapshot: HistoryViewSnapshot<typeof rows[number]> = {+ items: projectHistoryView(rows, false), details: new Map(), expanded: new Set(),+ nextCursor: 'older', hasMore: true, ready: true, loading: false, error: null,+ };+ const history = encodeRemoteHistory(snapshot);+ const one = row('one', '2026-01-02T00:00:00Z');+ const two = row('two', '2026-01-03T00:00:00Z');+ await Promise.all([+ c.writeMessages('dev', 'session', [], token.invalidation, token.ownerRoot, token.accountCounter, history),+ c.writeMessages('dev', 'session', [one], token.invalidation, token.ownerRoot, token.accountCounter, undefined, true),+ c.writeMessages('dev', 'session', [two], token.invalidation, token.ownerRoot, token.accountCounter, undefined, true),+ ]);+ const cached = await c.readMessagesWithInvalidation('dev', 'session');+ expect(cached.messages).toEqual([one, two]);+ expect(decodeRemoteHistory(cached.historyView)?.items).toEqual(snapshot.items);+ // An additive prefetch exceeding the file budget cannot delete usable history.+ await c.writeMessages('dev', 'session', [row('huge', '2026-01-04', { content: 'x'.repeat(MAX_MESSAGE_FILE_BYTES) })],+ token.invalidation, token.ownerRoot, token.accountCounter, undefined, true);+ expect(await c.readMessagesWithInvalidation('dev', 'session')).toEqual(cached);+ await c.writeMessages('dev', 'session', []);+ await c.writeMessages('dev', 'session', [one], token.invalidation, token.ownerRoot, token.accountCounter, undefined, true);+ expect((await c.readMessagesWithInvalidation('dev', 'session')).messages).toEqual([]);+ });+it('round-trips structured history in the existing guarded file and strips live/media data', async () => {const c = rawCache();const rows = [row('one', '2026-01-01T00:00:00Z', { isStreaming: true, images: [{ base64: 'secret-bytes', url: 'data:image/png;base64,secret' }], retryFiles: ['private'] })];diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.tsindex b21f58af67..9a89272ffc 100644--- a/apps/desktop/src/main/device-link/dispatch.ts+++ b/apps/desktop/src/main/device-link/dispatch.ts@@ -13,6 +13,7 @@ import {mapMessageBodies,messageRecord,MESSAGE_BODY_FORMAT,+ MAX_LIST_MESSAGE_CHARS,} from '@cindy/device-link';import { requestFilePeer, stopFilePeers } from './filePeer';import { requestTaskMigration } from '../task-migration/service';@@ -1936,8 +1937,23 @@ function receivesSessionText(dst: string, sessionId: string): boolean {}function listMessagePayload(dst: string, sessionId: string, payload: unknown): unknown {- return receivesListMessages(dst) && !subscriptions.controllerHasTopic(dst, `session:${sessionId}`)- ? { ...(payload as object), listMessage: true } : payload;+ if (!receivesListMessages(dst) || subscriptions.controllerHasTopic(dst, `session:${sessionId}`)) return payload;+ const value = payload as Record<string, unknown>;+ const event = messageRecord(value.event) ? value.event : undefined;+ const data = messageRecord(event?.data) ? event.data : undefined;+ // Snapshot repair must use the same bound as ordinary list text pushes.+ if (event?.type === 'text' && typeof data?.text === 'string' && data.text.length > MAX_LIST_MESSAGE_CHARS) {+ return { sessionId, listMessage: true, resyncRequired: true };+ }+ // SDK done payloads can contain the entire turn, including tools and thinking.+ // List subscribers need only the lifecycle boundary, including continuation claims.+ if (event?.type === 'done') return {+ sessionId, listMessage: true,+ event: { type: 'done', source: event.source, turnScope: event.turnScope,+ turnContinuationId: event.turnContinuationId,+ data: { silentStop: data?.silentStop === true, cancelled: data?.cancelled === true } },+ };+ return { ...value, listMessage: true };}function forwardPush(channel: string, payload: unknown, ownerStamp?: PushOwnerStamp): void {@@ -2045,7 +2061,8 @@ function forwardPush(channel: string, payload: unknown, ownerStamp?: PushOwnerStofflinePushQueue.enqueue(dst, {channel,payload: payloadFor(dst),- topic: sharedMetadata ? sharedTaskTopic : topic,+ topic: sharedMetadata ? sharedTaskTopic : listMessage && receivesListMessages(dst)+ && !subscriptions.controllerHasTopic(dst, `session:${historySessionId}`) ? 'sessions' : topic,...(ownerStamp ? { ownerStamp } : {}),});}diff --git a/apps/desktop/src/main/device-link/ipc.ts b/apps/desktop/src/main/device-link/ipc.tsindex 5dade749ee..4dc318159b 100644--- a/apps/desktop/src/main/device-link/ipc.ts+++ b/apps/desktop/src/main/device-link/ipc.ts@@ -1169,6 +1169,7 @@ export async function handleMirrorCachePutMessages(expectedOwnerToken?: unknown,expectedAccountCounter?: unknown,historyView?: unknown,+ mergeListMessage?: unknown,): Promise<{ ok: true; invalidation?: number }> {const device = requireCacheId(deviceId, 'deviceId');const session = requireCacheId(sessionId, 'sessionId');@@ -1199,6 +1200,8 @@ export async function handleMirrorCachePutMessages(? expectedAccountCounter: undefined;try {+ const historyArgs: [historyView?: string, mergeListMessage?: boolean] = mergeListMessage === true+ ? [historyView as string | undefined, true] : historyView !== undefined ? [historyView as string] : [];const result = await cache.writeMessages(device,session,@@ -1206,7 +1209,7 @@ export async function handleMirrorCachePutMessages(expected,expectedOwner,expectedAccount,- ...(historyView !== undefined ? [historyView as string] : []),+ ...historyArgs,);return { ok: true, invalidation: result.invalidation };} catch (err) {@@ -1605,6 +1608,7 @@ export function registerDeviceLinkIpc(deps: DeviceLinkIpcDeps = defaultDeps()):expectedOwnerToken?: unknown;expectedAccountCounter?: unknown;historyView?: unknown;+ mergeListMessage?: unknown;};return handleMirrorCachePutMessages(getMirrorCache(),@@ -1616,6 +1620,7 @@ export function registerDeviceLinkIpc(deps: DeviceLinkIpcDeps = defaultDeps()):p.expectedOwnerToken,p.expectedAccountCounter,p.historyView,+ p.mergeListMessage,);});ipcMain.handle(DEVICE_LINK_INVOKE.MIRROR_CACHE_GET_SESSION_LIST, (e) => {diff --git a/apps/desktop/src/main/device-link/mirrorCacheStore.ts b/apps/desktop/src/main/device-link/mirrorCacheStore.tsindex 84afe098a8..87be2e5288 100644--- a/apps/desktop/src/main/device-link/mirrorCacheStore.ts+++ b/apps/desktop/src/main/device-link/mirrorCacheStore.ts@@ -430,6 +430,7 @@ export interface MirrorCache {expectedOwnerRoot?: string,expectedAccountCounter?: number,historyView?: string,+ mergeListMessage?: boolean,): Promise<{ invalidation: number }>;/*** 读某 (设备, 会话) 的最近一页,并带回当前作废计数与账号代际(供写入侧比对)。@@ -1027,6 +1028,7 @@ export function createMirrorCache(resolveRoot: () => string): MirrorCache {expectedOwnerRoot,expectedAccountCounter,historyView,+ mergeListMessage,) {if (!deviceId.trim() || !sessionId.trim()) return { invalidation: -1 };// root 在**发起时**快照,不能在出错时再 resolve:owner 会在进程生命周期内变(登出 /@@ -1051,13 +1053,17 @@ export function createMirrorCache(resolveRoot: () => string): MirrorCache {return withCacheFileLock(rootAtStart, async (held) => {const dir = path.join(rootAtStart, MESSAGES_DIR);const file = path.join(dir, messageFileName(deviceId, sessionId));- const normalized = normalizeMessages(messages);+ let normalized = normalizeMessages(messages);const history = decodeRemoteHistory(historyView);// Sanitize the whole projection, including images outside message.content.- const sanitizedHistory = history ? JSON.stringify(stripInlineMedia(JSON.parse(encodeRemoteHistory(history)), 0)) : undefined;+ let sanitizedHistory = history ? JSON.stringify(stripInlineMedia(JSON.parse(encodeRemoteHistory(history)), 0)) : undefined;if (historyView !== undefined && (!sanitizedHistory || !decodeRemoteHistory(sanitizedHistory))) {return { invalidation: numericCounter(await readClearCounter(rootAtStart, sessionKey)) };}+ // An invalid list update is never an authoritative empty-page clear.+ if (mergeListMessage && (normalized.length !== 1 || historyView !== undefined)) {+ return { invalidation: numericCounter(await readClearCounter(rootAtStart, sessionKey)) };+ }// 空列表 = 清掉这条缓存(被控端 /clear、rewind 或删完最后一条时,残留会在// 下次冷开 hydrate 出已经不存在的正文)。if (normalized.length === 0 && sanitizedHistory === undefined) {@@ -1145,6 +1151,15 @@ export function createMirrorCache(resolveRoot: () => string): MirrorCache {}return true;};+ if (mergeListMessage) {+ if (!(await canCommitNonEmpty())) return { invalidation: -1 };+ const previous = await readJson(file);+ const message = normalized[0];+ const rows = isRecord(previous) && Array.isArray(previous.messages) ? normalizeMessages(previous.messages) : [];+ normalized = normalizeMessages([...rows.filter(row => row.id !== message.id+ && (!message.clientId || row.clientId !== message.clientId)), message]);+ if (isRecord(previous) && decodeRemoteHistory(previous.historyView)) sanitizedHistory = previous.historyView as string;+ }const body = sanitizedHistory === undefined ? JSON.stringify(normalized) : JSON.stringify([normalized, sanitizedHistory]);const payload: StoredMessages = {version: 1,@@ -1154,6 +1169,8 @@ export function createMirrorCache(resolveRoot: () => string): MirrorCache {};const serialized = JSON.stringify(payload);if (Buffer.byteLength(serialized, 'utf8') > MAX_MESSAGE_FILE_BYTES) {+ // Prefetch is additive: if it cannot fit, retain the usable history.+ if (mergeListMessage) return { invalidation: numericCounter(await readClearCounter(rootAtStart, sessionKey)) };// 单会话超限:新页写不下 —— 但旧正本此刻可能是 rewind / 删消息**之前**的窗口,// 而同一个超限页每次对账都会走到这里,永远不会有第二次机会更新它。所以**作废**// 旧缓存,而不是留一份会骗人的旧页(review: codex P1)。diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.tsindex 8e3e417395..37d8f9a40a 100644--- a/apps/desktop/src/preload/preload.ts+++ b/apps/desktop/src/preload/preload.ts@@ -4675,6 +4675,7 @@ contextBridge.exposeInMainWorld('electronAPI', {expectedOwnerToken?: string,expectedAccountCounter?: number,historyView?: string,+ mergeListMessage?: boolean,): Promise<{ ok: true; invalidation?: number }> =>ipcRenderer.invoke('device-link:mirror-cache:messages:put', {deviceId,@@ -4684,6 +4685,7 @@ contextBridge.exposeInMainWorld('electronAPI', {expectedOwnerToken,expectedAccountCounter,historyView,+ mergeListMessage,}),/** 读侧边栏远程会话列表快照 */getSessionList: (): Promise<{diff --git a/apps/desktop/src/preload/sidebarWindowPreload.ts b/apps/desktop/src/preload/sidebarWindowPreload.tsindex 9883def524..65d56310fc 100644--- a/apps/desktop/src/preload/sidebarWindowPreload.ts+++ b/apps/desktop/src/preload/sidebarWindowPreload.ts@@ -170,6 +170,7 @@ contextBridge.exposeInMainWorld('electronAPI', {expectedOwnerToken?: string,expectedAccountCounter?: number,historyView?: string,+ mergeListMessage?: boolean,): Promise<unknown> =>ipcRenderer.invoke(DEVICE_LINK_INVOKE.MIRROR_CACHE_PUT_MESSAGES, {deviceId,@@ -179,6 +180,7 @@ contextBridge.exposeInMainWorld('electronAPI', {expectedOwnerToken,expectedAccountCounter,historyView,+ mergeListMessage,}),getSessionList: (): Promise<unknown> =>ipcRenderer.invoke(DEVICE_LINK_INVOKE.MIRROR_CACHE_GET_SESSION_LIST),diff --git a/apps/desktop/src/renderer/__tests__/remoteMirrorCache.test.ts b/apps/desktop/src/renderer/__tests__/remoteMirrorCache.test.tsindex d1f668303c..cf9ce98942 100644--- a/apps/desktop/src/renderer/__tests__/remoteMirrorCache.test.ts+++ b/apps/desktop/src/renderer/__tests__/remoteMirrorCache.test.ts@@ -168,6 +168,8 @@ const putMessages = vi.fn<expectedInvalidation?: number,expectedOwnerToken?: string,expectedAccountCounter?: number,+ historyView?: string,+ mergeListMessage?: boolean,) => Promise<{ ok: true }>>(async () => ({ ok: true as const }));@@ -295,8 +297,33 @@ describe('冷缓存 hydrate', () => {const latest = dbMessage(s, 'new', '完整正文'.repeat(2000), '2026-10-10T00:01:00.000Z');cachedMessages.set(`${DEVICE_ID}::${s}`, [earlier as unknown as Record<string, unknown>]);persistListMessage(DEVICE_ID, s, latest);- await vi.waitFor(() => expectPut(DEVICE_ID, s, [earlier, latest]));+ await vi.waitFor(() => expectPut(DEVICE_ID, s, [latest]));expect(putMessages.mock.calls[0].slice(3, 6)).toEqual([7, cachedOwnerToken, 0]);+ expect(putMessages.mock.calls[0].slice(6)).toEqual([undefined, true]);+ });++ it('reclaims never-opened list messages through the existing idle budget', async () => {+ vi.useFakeTimers();+ const s = sid();+ try {+ setDataOwnerGeneration('owner-a', 1);+ registerRemote(s);+ let push!: Parameters<typeof window.electronAPI.deviceLink.onRemotePush>[0];+ window.electronAPI.deviceLink.onRemotePush = vi.fn(callback => { push = callback; return () => {}; });+ makerChatStore.initGlobalListeners();+ makerChatStore.__activeViewTest.setSoftEvictionBudget({ messages: 0, characters: 0 });+ const row = dbMessage(s, 'prefetched', 'full body', '2026-10-10T00:00:00.000Z');+ push({ deviceId: DEVICE_ID, channel: 'local-db:messages:created', payload: { sessionId: s, listMessage: true, message: row } });+ expect(makerChatStore.__activeViewTest.getLastViewedAt(s)).toBeDefined();+ expect(makerChatStore.getSnapshot(s).messages).toHaveLength(1);+ await vi.advanceTimersByTimeAsync(30_000);+ expect(makerChatStore.getSnapshot(s).messages).toHaveLength(0);+ } finally {+ makerChatStore.__activeViewTest.setSoftEvictionBudget(null);+ makerChatStore.purgeSession(s);+ makerChatStore.__teardownGlobalListeners();+ vi.useRealTimers();+ }});it('restores the structured view through the actual offline session entry', async () => {diff --git a/apps/desktop/src/renderer/features/device-link/mirrorCacheClient.ts b/apps/desktop/src/renderer/features/device-link/mirrorCacheClient.tsindex cda7e96a8f..d98f398cea 100644--- a/apps/desktop/src/renderer/features/device-link/mirrorCacheClient.ts+++ b/apps/desktop/src/renderer/features/device-link/mirrorCacheClient.ts@@ -145,24 +145,18 @@ export async function readCachedMessages(deviceId: string, sessionId: string, onreturn read;}-const listMessageWrites = new Map<string, Promise<void>>();-/** List pushes merge into the same protected disk window used when opening a task. */export function persistListMessage(deviceId: string, sessionId: string, message: Message): void {- const owner = getDataOwnerGeneration();- const token = sessionCacheInvalidationToken(sessionId);- const key = JSON.stringify([deviceId, sessionId]);- const current = () => isDataOwnerGenerationCurrent(owner) && token === sessionCacheInvalidationToken(sessionId);- const pending = (listMessageWrites.get(key) ?? Promise.resolve()).then(async () => {- if (!current()) return;- const rows = await readCachedMessages(deviceId, sessionId);- if (!current()) return;- await persistCachedMessages(deviceId, sessionId,- [...rows.filter(row => row.id !== message.id && (!message.clientId || row.clientId !== message.clientId)), message],- invalidationAtRequestStart(deviceId, sessionId), ownerTokenAtRequestStart(sessionId), accountCounterAtRequestStart(sessionId));- }).catch(error => log.debug('persist list message failed', error));- listMessageWrites.set(key, pending);- void pending.finally(() => { if (listMessageWrites.get(key) === pending) listMessageWrites.delete(key); });+ // Never-opened sessions have no protected read to establish their owner token yet.+ // Start the existing read path; the token helpers below wait for it with their usual timeout.+ const pending = pendingProtectedRead.get(sessionId);+ if (!knownOwnerToken.has(sessionId) && (!pending || !isDataOwnerGenerationCurrent(pending.owner))) {+ void readCachedMessages(deviceId, sessionId);+ }+ // Merge inside Main's existing lock, alongside page writes and clears.+ void persistCachedMessages(deviceId, sessionId, [message],+ invalidationAtRequestStart(deviceId, sessionId), ownerTokenAtRequestStart(sessionId),+ accountCounterAtRequestStart(sessionId), undefined, true);}/** 写某 (设备, 会话) 的最近一页 server rows(空数组 = 清掉该条缓存)。失败静默。 */@@ -254,9 +248,12 @@ export function persistCachedMessages(expectedOwnerToken?: string | Promise<string | undefined>,expectedAccountCounter?: number | Promise<number | undefined>,historyView?: string,+ mergeListMessage?: boolean,): Promise<number | undefined> {const api = bridge();if (!api || !deviceId || !sessionId) return Promise.resolve(undefined);+ const historyArgs: [historyView?: string, mergeListMessage?: boolean] = mergeListMessage+ ? [historyView, true] : historyView !== undefined ? [historyView] : [];const owner = getDataOwnerGeneration();const localToken = sessionCacheInvalidationToken(sessionId);const dispatch = (@@ -273,7 +270,7 @@ export function persistCachedMessages(expected,ownerToken,accountCounter,- ...(historyView !== undefined ? [historyView] : []),+ ...historyArgs,).then((result) => {if (!isDataOwnerGenerationCurrent(owner) || localToken !== sessionCacheInvalidationToken(sessionId)) return undefined;diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 060e06b265..04dd22e386 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -8941,6 +8941,10 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {inboundEvent.data?.isFinal === false &&inboundEvent.data?.isFullText !== true;const listMessage = (push.payload as { listMessage?: unknown } | null)?.listMessage === true;+ if (listMessage && inboundSid && !_activeViewSessions.has(inboundSid)) {+ if (!_lastViewedAt.has(inboundSid)) _lastViewedAt.set(inboundSid, Date.now());+ _ensureSoftEvictionTimer();+ }if (push.deviceId && inboundSid && isDurableMessagePush && !isOrdinaryStreamingTextDelta && !listMessage) {scheduleRemoteMessageRepair(inboundSid);}diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.tsindex 6cda44f283..498926b558 100644--- a/apps/desktop/src/renderer/vite-env.d.ts+++ b/apps/desktop/src/renderer/vite-env.d.ts@@ -4069,6 +4069,7 @@ interface ElectronAPI {expectedOwnerToken?: string,expectedAccountCounter?: number,historyView?: string,+ mergeListMessage?: boolean,) => Promise<{ ok: true; invalidation?: number }>;getSessionList: () => Promise<{devices: Array<{diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex b9b2f29f38..1e87daf5cc 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -18,6 +18,9 @@带 `listMessage: true`,不建立活跃控制意图,也不因正文到达自动拉取整段历史。工具正文、思考、附件及超过 200,000 字符的异常长消息仍按需读取;列表显示行数不变。共享任务访客和供应商分享不扩展订阅范围。旧控制端未声明能力时保持原来的路由。+列表收尾只携带生命周期字段,不转发 SDK 整轮工具/思考结果;快照补偿同样受正文长度上限+约束,超限时只标记历史待核对。列表离线补发按 `sessions` topic 回放。桌面预收正文在现有+缓存写锁内合并并保留结构化历史,从未打开的任务同样计入现有内存回收预算。`messages:list` / `messages:view` 的 options 可选携带 `messageBodies: { version: 1, known }`,known 是消息 ID 与主机提供的 SHA-256 正文指纹对。支持的主机在授权、净化之后返回