Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test(helper): align remote status fixtures with host error types
zqchrisb390a9ad73c2
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex ad345268e6..97514242c4 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -17,6 +17,7 @@ import path from 'node:path';import Database from 'better-sqlite3';import { drizzle } from 'drizzle-orm/better-sqlite3';import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';+import type { InvokeResultPayload } from '@cindy/device-link';import { messages, recentWorkdirs, sessions } from '../../schema';import type { SessionRouteLock } from '../../sessionRouteLock';@@ -925,7 +926,7 @@ describe('local-db:sessions:update handler wiring', () => {.mockRejectedValueOnce(new Error('db worker RPC queue overloaded'));try {let handlerError: unknown;- const invoke = vi.fn(async (_device: string, _channel: string, args: unknown[]) => {+ const invoke = vi.fn(async (_device: string, _channel: string, args: unknown[]): Promise<InvokeResultPayload> => {try {return { ok: true as const, result: await invokePatchMeta(args[0] as string, args[1] as Record<string, unknown>) };} catch (error) {diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.tsindex 2702b23331..24ed552444 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/sessionStatusRemote.test.ts@@ -1,6 +1,7 @@import { describe, expect, it, vi } from 'vitest';import { DeviceLinkError, type InvokeResultPayload } from '@cindy/device-link';import { createRemoteSessionsStatusSetter } from '../sessionStatusRemote.js';+import { createDeviceUnresponsiveError } from '../../device-link/responsivenessTracker.js';const request = { deviceId: 'studio', sessionIds: ['s1', 's2', 's3'], status: 'active' as const };const row = (id: string) => ({ ok: true as const, result: { id, status: 'active', title: 'remote title', workingDir: null } });@@ -28,7 +29,6 @@ describe('remote session archive status', () => {['CHANNEL_NOT_ALLOWED', '', 'REMOTE_UNSUPPORTED'],['VERSION_MISMATCH', '', 'REMOTE_UNSUPPORTED'],['NOT_CONNECTED', '', 'REMOTE_UNAVAILABLE'],- ['DEVICE_UNRESPONSIVE', '', 'REMOTE_UNAVAILABLE'],['BACKPRESSURE', 'db worker RPC queue overloaded', 'REMOTE_RESULT_UNKNOWN'],['IPC_ERROR', '[BACKPRESSURE] db worker RPC queue overloaded', 'REMOTE_RESULT_UNKNOWN'],['IPC_ERROR', '[DEVICE_LINK_CONTROL_DISABLED] off', 'REMOTE_DISABLED'],@@ -45,6 +45,15 @@ describe('remote session archive status', () => {expect(s.invoke).toHaveBeenCalledOnce();});+ it('classifies the local responsiveness breaker rejection without sending another item', async () => {+ const s = setup(createDeviceUnresponsiveError('studio'));+ expect(await s.setStatus(request)).toMatchObject({+ ok: false, errorCode: 'REMOTE_UNAVAILABLE', changed: [],+ failedSessionId: 's1', remainingSessionIds: ['s2', 's3'],+ });+ expect(s.invoke).toHaveBeenCalledOnce();+ });+it.each([false, true])('distinguishes local backpressure with inFlight=%s', async (inFlight) => {const s = setup(Object.assign(new DeviceLinkError('BACKPRESSURE', 'queue full'), { inFlight }));expect(await s.setStatus(request)).toMatchObject({