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。

fix(desktop): verify queue edit projections

DavidShen5cd36025efb3
diff --git a/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts b/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts
index c7965386b9..36fe2c35d8 100644
--- a/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts
+++ b/apps/desktop/src/renderer/__tests__/pendingQueueDefer.test.ts
@@ -463,6 +463,32 @@ describe('renderer input queue facade', () => {
);
});
+ it('rejects a queue edit when the projection keeps stale mentions', async () => {
+ const sid = 'stale-mentions-' + Math.random().toString(36).slice(2, 8);
+ const item = queued('q-stale-mentions', 'keep @src/app.ts');
+ item.mentions = [{ type: 'file', name: 'app.ts', path: 'src/app.ts' }];
+
+ makerChatStore.initGlobalListeners();
+ projectionHandler?.(projection(sid, { pendingQueue: [item] }));
+ input.updateContent.mockImplementationOnce(async () =>
+ projection(sid, { pendingQueue: [item] }),
+ );
+
+ const saved = await makerChatStore.updateQueueItemContent(sid, item.clientId, {
+ content: {
+ text: item.text,
+ mentions: [],
+ hasQuotes: false,
+ agentReferences: [],
+ pastedTextRanges: [],
+ slashCommandRanges: [],
+ },
+ files: [],
+ });
+
+ expect(saved).toBe(false);
+ });
+
it('falls back to update-text when an old device-link target lacks update-content', async () => {
const sid = `legacy-content-${Math.random().toString(36).slice(2, 8)}`;
const item = queued('q-legacy-content', 'old text');
diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.ts
index 2100a8863b..245c4fbf49 100644
--- a/apps/desktop/src/renderer/lib/makerChatStore.ts
+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts
@@ -13629,7 +13629,6 @@ function queuedContentProjectionMatches(
replacement: QueuedMessage,
): boolean {
if (!accepted || accepted.text !== replacement.text) return false;
- if (accepted.persistedContent === replacement.persistedContent) return true;
const stableFiles = (files: QueuedMessage['files']) =>
(files ?? []).map(({ path: _, url: __, pathOrigin: ___, ...file }) => file);
return (