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): 修正 #329 后过时的 3 条单测断言,恢复单测门禁全绿

Lizi5c1a81cdcd66
diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts
index 00699412bb..736268498b 100644
--- a/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts
+++ b/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts
@@ -660,7 +660,8 @@ describe('远程交互接线不变式', () => {
const src = read('lib/makerChatStore.ts');
expect(src).toContain('const deviceLinkRemote = isRemoteSession(sessionId);');
expect(src).toContain('const sshRemote = Boolean(current.remoteHostId);');
- expect(src).toContain(
+ // 该三元可能被 prettier 折成多行:先把空白折叠成单空格,只锁 token 序列。
+ expect(src.replace(/\s+/g, ' ')).toContain(
'...(deviceLinkRemote ? {} : { makerMemoryEnabled: sshRemote ? false : getMakerMemoryEnabled() })',
);
});
@@ -1006,13 +1007,19 @@ describe('远程交互接线不变式', () => {
it('main RESOLVE_INTERACTION handler 解决后广播 dismissed(dismissRendererInteraction)', () => {
const src = readFileSync(resolve(__dirname, '../../main/maker-ipc/register.ts'), 'utf8');
// handler 可以只委托 helper,但 helper 必须负责 resolved 广播和权威落库。
+ // 截取窗口用下一个语法边界而非固定字符数:handler/helper 体量会随入参校验、
+ // 注释增长,固定窗口会在无行为回归时误报(#329 曾把调用挤出 1000 字符窗口)。
const handlerStart = src.indexOf('ipcMain.handle(MAKER_INVOKE.RESOLVE_INTERACTION');
expect(handlerStart).toBeGreaterThan(-1);
- const handlerBody = src.slice(handlerStart, handlerStart + 1000);
+ const handlerEnd = src.indexOf('ipcMain.handle(', handlerStart + 1);
+ const handlerBody = src.slice(handlerStart, handlerEnd === -1 ? undefined : handlerEnd);
expect(handlerBody).toContain('resolvePendingInteraction(');
const helperStart = src.indexOf('function resolvePendingInteraction');
expect(helperStart).toBeGreaterThan(-1);
- const body = src.slice(helperStart, helperStart + 1800);
+ // 顶层函数体内嵌套块都有缩进,列首 '\n}' 即 helper 自己的闭括号。
+ const helperEnd = src.indexOf('\n}', helperStart);
+ expect(helperEnd).toBeGreaterThan(-1);
+ const body = src.slice(helperStart, helperEnd);
expect(body).toContain('resolver.resolve(');
expect(body).toContain('dismissRendererInteraction(');
// F1:resolve 后被控端权威落库 ask/plan answered 状态。
diff --git a/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts b/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts
index 51be00956a..735f34d4a8 100644
--- a/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts
+++ b/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts
@@ -6,6 +6,10 @@
*/
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import {
+ GHOST_SETUP_MAX_INTERACTION_STEPS,
+ GHOST_SETUP_MAX_STEPS,
+} from '../../shared/ghost';
import type { AgentInputProjection, AgentInputQueuedMessage } from '../../shared/agentInputQueue';
import type { Message } from '@/lib/ccAgent.types';
import type { AttachedFile, MentionedResource } from '@/lib/fileTypes';
@@ -827,27 +831,43 @@ describe('makerChatStore text delta batching', () => {
expect(makerChatStore.getSnapshot(SESSION_ID).pendingPluginSetup).toBeNull();
});
- it('accepts all 64 manifest-valid setup steps and rejects a 65th', () => {
+ it('accepts manifest-max and host-reserve step counts, rejects past the transport cap', () => {
const step = pluginSetupRequest(1).steps[0];
- emitInteractionRequest({
- ...pluginSetupRequest(1),
- steps: Array.from({ length: 64 }, (_, index) => ({
+ const buildSteps = (count: number) =>
+ Array.from({ length: count }, (_, index) => ({
...step,
id: `setup-${index}`,
action: { ...step.action, id: `oauth:${index}` },
- })),
+ }));
+
+ // manifest 合法声明的步数上限(8 组 × 8 条)。
+ emitInteractionRequest({
+ ...pluginSetupRequest(1),
+ steps: buildSteps(GHOST_SETUP_MAX_STEPS),
});
- expect(makerChatStore.getSnapshot(SESSION_ID).pendingPluginSetup?.steps).toHaveLength(64);
+ expect(makerChatStore.getSnapshot(SESSION_ID).pendingPluginSetup?.steps).toHaveLength(
+ GHOST_SETUP_MAX_STEPS,
+ );
+ // Host-owned setup provider 可在 manifest 步骤之外追加 Core 步骤,
+ // Main → Renderer 的传输上限是 GHOST_SETUP_MAX_INTERACTION_STEPS
+ // (= manifest 上限 + Host 保留),打满仍须完整过界。
+ makerChatStore.purgeSession(SESSION_ID);
+ emitInteractionRequest({
+ ...pluginSetupRequest(1),
+ requestId: 'plugin-setup-transport-cap',
+ steps: buildSteps(GHOST_SETUP_MAX_INTERACTION_STEPS),
+ });
+ expect(makerChatStore.getSnapshot(SESSION_ID).pendingPluginSetup?.steps).toHaveLength(
+ GHOST_SETUP_MAX_INTERACTION_STEPS,
+ );
+
+ // 超过传输上限:整卡拒收。
makerChatStore.purgeSession(SESSION_ID);
emitInteractionRequest({
...pluginSetupRequest(1),
requestId: 'plugin-setup-oversized',
- steps: Array.from({ length: 65 }, (_, index) => ({
- ...step,
- id: `setup-${index}`,
- action: { ...step.action, id: `oauth:${index}` },
- })),
+ steps: buildSteps(GHOST_SETUP_MAX_INTERACTION_STEPS + 1),
});
expect(makerChatStore.getSnapshot(SESSION_ID).pendingPluginSetup).toBeNull();
});