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。

perf(plugins): omit task plan payloads from task listing

Dashf1832ff7c631
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskStoreBudget.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskStoreBudget.test.ts
index eb8c55ee5d..2f7e3cbe5f 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskStoreBudget.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/pluginTaskStoreBudget.test.ts
@@ -23,3 +23,27 @@ it('rejects persisted oversized receipts with SQLite selection, including UTF-16
expect(sqlite.prepare('SELECT count(*) AS n FROM plugin_task_requests').get()).toEqual({ n: 3 });
} finally { sqlite.close(); }
});
+
+it('omits creation payloads in SQL while preserving pagination, ownership and run receipts', async () => {
+ const sqlite = new Database(':memory:');
+ const queries: string[] = [];
+ try {
+ sqlite.exec(`CREATE TABLE plugin_task_requests(id TEXT PRIMARY KEY, plugin_id TEXT,
+ operation TEXT, target_id TEXT, request_key TEXT, fingerprint TEXT, payload TEXT,
+ revision INTEGER, created_at INTEGER)`);
+ const db = drizzle(sqlite, { logger: { logQuery(query) { queries.push(query); } } });
+ const store = createPluginTaskStore({ drizzle: db } as unknown as DbClient);
+ const insert = sqlite.prepare('INSERT INTO plugin_task_requests VALUES (?, ?, ?, ?, ?, ?, ?, 0, 1)');
+ const large = 'x'.repeat(PLUGIN_TASK_RECEIPT_MAX_JSON_CHARS);
+ for (const id of ['a', 'b', 'c']) insert.run(id, 'p', 'create', id, id, 'h', large);
+ insert.run('other', 'other-plugin', 'create', 'other', 'other', 'h', large);
+ insert.run('run', 'p', 'send', 'b', 'run', 'h', '{"status":"completed"}');
+ const page = await store.list('p', 'create', null, '', 2);
+ expect(page.map(row => [row.id, row.payload])).toEqual([['a', ''], ['b', '']]);
+ expect(queries.at(-1)?.split(' from ')[0]).not.toContain('"payload"');
+ expect((await store.list('p', 'create', null, 'b', 2)).map(row => row.id)).toEqual(['c']);
+ expect((await store.list('p', 'send', 'b', '', 2))[0]?.payload).toBe('{"status":"completed"}');
+ expect(await store.list('p', 'send', 'a', '', 2)).toEqual([]);
+ expect((await store.get('a'))?.payload).toBe(large);
+ } finally { sqlite.close(); }
+});
diff --git a/apps/desktop/src/main/maker-ipc/pluginTaskStore.ts b/apps/desktop/src/main/maker-ipc/pluginTaskStore.ts
index 5abd42fe6b..31398238e6 100644
--- a/apps/desktop/src/main/maker-ipc/pluginTaskStore.ts
+++ b/apps/desktop/src/main/maker-ipc/pluginTaskStore.ts
@@ -45,7 +45,13 @@ export function createPluginTaskStore(db: DbClient): PluginTaskStore {
.from(table).where(and(scope, eq(table.id, after))).limit(1) : [];
if (after && !cursor) throw new PluginTaskError('INVALID_REQUEST', 'Invalid task cursor');
return db.drizzle
- .select()
+ .select({
+ ...getTableColumns(table),
+ // Task listing only needs receipt IDs to read session views. Keep
+ // large creation plans inside SQLite; run listing still reconciles
+ // send payloads and therefore must retain them.
+ payload: operation === 'create' ? sql<string>`''` : table.payload,
+ })
.from(table)
.where(
and(