Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(cindy-make): hide unconfirmed peer usage tasks
MagicLizi31a164914f5d
diff --git a/apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx b/apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsxindex 75f765fb27..d1fd2279d0 100644--- a/apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx+++ b/apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx@@ -72,7 +72,14 @@ export function buildUsageTaskRows(}const rows: UsageTaskRow[] = [];for (const task of history.tasks) {- if (!CINDY_MAKE_ENABLED && isCindyMakeSource(task.source)) continue;+ if (+ !CINDY_MAKE_ENABLED &&+ (isCindyMakeSource(task.source) ||+ (task.deviceId !== LOCAL_TASK_DEVICE &&+ (task.source === null || task.source === undefined)))+ ) {+ continue;+ }const tokens = tokensByTask.get(task.taskKey) ?? 0;if (tokens > 0) rows.push({ ...task, tokens });}diff --git a/apps/desktop/src/renderer/components/settings/usage/__tests__/usageTaskTable.test.tsx b/apps/desktop/src/renderer/components/settings/usage/__tests__/usageTaskTable.test.tsxindex 6a0ce21cfe..b91b213631 100644--- a/apps/desktop/src/renderer/components/settings/usage/__tests__/usageTaskTable.test.tsx+++ b/apps/desktop/src/renderer/components/settings/usage/__tests__/usageTaskTable.test.tsx@@ -42,6 +42,7 @@ function task(deviceId: string, sessionId: string, title = sessionId): UsageHisttitle,model: 'gpt-5.5',providerId: null,+ source: 'desktop',contextTokens: 0,contextWindow: 0,lastActiveAt: 1,@@ -86,27 +87,89 @@ describe('buildUsageTaskRows', () => {expect(buildUsageTaskRows(payload, 'all').map((r) => r.taskKey)).toContain('laptop:b');});- it.each(['local', 'laptop'])('filters Make tasks on %s before ranking without changing usage records', (deviceId) => {- const ordinary = Array.from({ length: 10 }, (_, index) => ({- ...task(deviceId, 'ordinary-' + index),- source: index % 2 === 0 ? null : undefined,- }));- const hidden = ['cindy-make', 'cindy-make-merge'].map((source) => ({- ...task(deviceId, source),+ it.each(['local', 'laptop'])(+ 'filters Make tasks on %s before ranking without changing usage records',+ (deviceId) => {+ const ordinary = Array.from({ length: 10 }, (_, index) => ({+ ...task(deviceId, 'ordinary-' + index),+ source: deviceId === 'local' ? (index % 2 === 0 ? null : undefined) : 'desktop',+ }));+ const hidden = ['cindy-make', 'cindy-make-merge'].map((source) => ({+ ...task(deviceId, source),+ source,+ }));+ const daily = [...hidden, ...ordinary].map((entry, index) => ({+ day: '2026-09-26',+ taskKey: entry.taskKey,+ tokens: 100 - index,+ }));+ const input = history(daily, [...hidden, ...ordinary]);++ expect(buildUsageTaskRows(input, 'today').map((row) => row.taskKey)).toEqual(+ ordinary.slice(0, 8).map((entry) => entry.taskKey),+ );+ expect(input.taskDaily).toEqual(daily);+ expect(input.tasks).toEqual([...hidden, ...ordinary]);+ },+ );++ it.each([+ { origin: 'legacy peer cache', source: null },+ { origin: 'older peer sync', source: undefined },+ ])('withholds source-less tasks from $origin before ranking', ({ source }) => {+ const unconfirmed = Array.from({ length: 10 }, (_, index) => ({+ ...task('laptop', 'legacy-' + index),source,}));- const daily = [...hidden, ...ordinary].map((entry, index) => ({+ const confirmed = Array.from({ length: 10 }, (_, index) =>+ task('laptop', 'confirmed-' + index),+ );+ const tasks = [...unconfirmed, ...confirmed];+ const daily = tasks.map((entry, index) => ({day: '2026-09-26',taskKey: entry.taskKey,tokens: 100 - index,}));- const input = history(daily, [...hidden, ...ordinary]);+ const input = history(daily, tasks);expect(buildUsageTaskRows(input, 'today').map((row) => row.taskKey)).toEqual(- ordinary.slice(0, 8).map((entry) => entry.taskKey),+ confirmed.slice(0, 8).map((entry) => entry.taskKey),+ );+ expect(buildUsageTaskRows(input, 'all').map((row) => row.taskKey)).toEqual(+ confirmed.slice(0, 8).map((entry) => entry.taskKey),);expect(input.taskDaily).toEqual(daily);- expect(input.tasks).toEqual([...hidden, ...ordinary]);+ expect(input.tasks).toEqual(tasks);+ });++ it.each(['desktop', 'plugin', 'cindy-make', 'cindy-make-merge'])(+ 'reconsiders retained peer tasks only after their source is confirmed as %s',+ (source) => {+ const peerTask = { ...task('laptop', 'retained'), source: null };+ const input = history(+ [{ day: '2026-09-26', taskKey: peerTask.taskKey, tokens: 100 }],+ [peerTask],+ );+ expect(buildUsageTaskRows(input, 'today')).toEqual([]);++ const refreshed = { ...input, tasks: [{ ...peerTask, source }] };+ expect(buildUsageTaskRows(refreshed, 'today').map((row) => row.taskKey)).toEqual(+ source === 'desktop' || source === 'plugin' ? [peerTask.taskKey] : [],+ );+ expect(input.tasks).toEqual([peerTask]);+ },+ );++ it.each([null, undefined])('preserves local task compatibility with source %s', (source) => {+ const localTask = { ...task('local', 'ordinary'), source };+ const input = history(+ [{ day: '2026-09-26', taskKey: localTask.taskKey, tokens: 100 }],+ [localTask],+ );++ expect(buildUsageTaskRows(input, 'today').map((row) => row.taskKey)).toEqual([+ localTask.taskKey,+ ]);});it('reports the coverage start only when the range reaches before the first record', () => {diff --git a/docs/cindy-make-upstream.md b/docs/cindy-make-upstream.mdindex cb289fe91d..cfa5195a37 100644--- a/docs/cindy-make-upstream.md+++ b/docs/cindy-make-upstream.md@@ -12,6 +12,12 @@[versionStartup](../apps/desktop/src/main/cindy-make/versionStartup.ts) 与[versionStartup.test](../apps/desktop/src/main/cindy-make/__tests__/versionStartup.test.ts)。+用量记录与总量统计继续保留;来自旧版电脑或旧同步缓存、尚未确认来源的任务不进入+「最耗 token 的任务」排名,离线时也不通过缺失来源推定为普通任务。同步获得来源后,+普通任务恢复参与排名,制作任务仍隐藏。本机任务元数据的兼容兜底不变。实现与回归见+[UsageTaskTable](../apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx) 与+[用量任务排名测试](../apps/desktop/src/renderer/components/settings/usage/__tests__/usageTaskTable.test.tsx)。+共享开关见 [cindyMakeFeature](../packages/maker-shared/src/cindyMakeFeature.ts),执行边界见 [featureGate](../apps/desktop/src/main/cindy-make/featureGate.ts) 与[回归测试](../apps/desktop/src/main/maker-ipc/__tests__/cindyMakeFeatureGate.test.ts)。