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(mobile): 按结构化错误码兼容旧 Host 索引

Dash611a0c6c1717
diff --git a/apps/mobile/src/__tests__/scheduleIndex.test.ts b/apps/mobile/src/__tests__/scheduleIndex.test.ts
index 58b3fed62e..eb41f360a8 100644
--- a/apps/mobile/src/__tests__/scheduleIndex.test.ts
+++ b/apps/mobile/src/__tests__/scheduleIndex.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from 'vitest';
+import { DeviceLinkError } from '@cindy/device-link';
import type { MobileMakerTransport } from '@/device-link/mobileMakerTransport';
import { unresponsiveDevicesStore } from '@/device-link/unresponsiveDevicesStore';
import {
@@ -107,7 +108,7 @@ describe('scheduleIndex', () => {
vi.useRealTimers();
}
});
- it.each([false, true])('shares complete schedule metadata and historical failures with legacy fallback=%s', async (legacy) => {
+ it.each([false, true, 'structured', 'capability'])('shares complete schedule metadata and historical failures with legacy fallback=%s', async (legacy) => {
resetScheduleIndexThrottleForTesting();
const list = vi.fn(async () => [
{ id: 'sched-1', name: 'run', status: 'active', targetSessionId: 'current' },
@@ -116,6 +117,8 @@ describe('scheduleIndex', () => {
const run = { runId: 'old-failure', scheduleId: 'sched-1', scheduleName: 'run', scheduleStatus: 'active',
sessionId: 'current', status: 'failed', firedAt: 1, readAt: 2 };
const listSidebarIndexRuns = vi.fn(async () => {
+ if (legacy === 'structured') throw new DeviceLinkError('CHANNEL_NOT_ALLOWED', "channel 'maker:schedule:list-sidebar-index-runs' not allowed remotely");
+ if (legacy === 'capability') throw Object.assign(new Error('Unsupported endpoint'), { code: 'UNSUPPORTED_CAPABILITY' });
if (legacy) throw new Error('[CHANNEL_NOT_ALLOWED] unsupported');
return { runs: [run, { ...run, runId: 'old-binding', sessionId: 'previous' }] };
});
@@ -135,6 +138,18 @@ describe('scheduleIndex', () => {
resetScheduleIndexThrottleForTesting();
});
+ it.each(['ACCESS_REVOKED', 'INVOKE_TIMEOUT'])('does not turn %s into a legacy scan', async (code) => {
+ const error = Object.assign(new Error('Request failed'), { code });
+ const listRuns = vi.fn();
+ const maker = { schedule: {
+ list: async () => [{ id: 'schedule', name: 'run', status: 'active' }],
+ listSidebarIndexRuns: async () => { throw error; },
+ listRuns,
+ } } as unknown as Pick<MobileMakerTransport, 'schedule'>;
+ await expect(loadSessionScheduleIndex(maker)).rejects.toBe(error);
+ expect(listRuns).not.toHaveBeenCalled();
+ });
+
it('stops retries after blur without negative-caching cancellation for the next screen', async () => {
vi.useFakeTimers();
resetScheduleIndexThrottleForTesting();
diff --git a/apps/mobile/src/session/scheduleIndex.ts b/apps/mobile/src/session/scheduleIndex.ts
index 46ab709096..f9057cb5f5 100644
--- a/apps/mobile/src/session/scheduleIndex.ts
+++ b/apps/mobile/src/session/scheduleIndex.ts
@@ -28,7 +28,9 @@ export async function loadSessionScheduleIndex(
try {
return buildLightweightSessionScheduleIndex(await maker.schedule.listSidebarIndexRuns(), schedules);
} catch (error) {
- if (!isHistoryViewUnavailable(error)) throw error;
+ if (!hasRemoteErrorMarker(error, 'CHANNEL_NOT_ALLOWED')
+ && !hasRemoteErrorMarker(error, 'UNSUPPORTED_CAPABILITY')
+ && !isHistoryViewUnavailable(error)) throw error;
}
}
// listRuns 逐个串行而非 Promise.all 全并发:device-link 是无优先级的单 WS 管道,