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(archive): 远程投影透传持续会话标记,手机批量归档等提醒查完再允许确认

Dash99674d2d576f
diff --git a/apps/desktop/src/main/device-link/__tests__/providerListProjection.test.ts b/apps/desktop/src/main/device-link/__tests__/providerListProjection.test.ts
index c9af0a9923..7416a4b885 100644
--- a/apps/desktop/src/main/device-link/__tests__/providerListProjection.test.ts
+++ b/apps/desktop/src/main/device-link/__tests__/providerListProjection.test.ts
@@ -58,13 +58,20 @@ describe('schedule binding list projection', () => {
const full = [
{ ...fields, prompt: 'x'.repeat(5 * 1024 * 1024), script: { code: 'private' } },
{ ...fields, id: 'second', recurring: false },
+ { ...fields, id: 'persistent', persistentSession: true },
+ { ...fields, id: 'explicit-off', persistentSession: false },
{ ...fields, id: 'expired', status: 'expired' },
{ ...fields, id: 'unbound', targetSessionId: undefined },
];
const projected = __testing.projectInvokeResultForTunnel(
'maker:schedule:list', full, false, [null, { sessionBindings: true }],
);
- expect(projected).toEqual([fields, { ...fields, id: 'second', recurring: false }]);
+ expect(projected).toEqual([
+ fields,
+ { ...fields, id: 'second', recurring: false },
+ { ...fields, id: 'persistent', persistentSession: true },
+ { ...fields, id: 'explicit-off' },
+ ]);
expect(Buffer.byteLength(JSON.stringify(full))).toBeGreaterThan(4 * 1024 * 1024);
expect(Buffer.byteLength(JSON.stringify(projected))).toBeLessThan(1024);
});
diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.ts
index 21de9804af..751ee2c79d 100644
--- a/apps/desktop/src/main/device-link/dispatch.ts
+++ b/apps/desktop/src/main/device-link/dispatch.ts
@@ -794,6 +794,8 @@ function projectInvokeResultForTunnel(
manual: row.manual,
recurring: row.recurring,
intervalMs: row.intervalMs,
+ // 归档确认据此区分持续会话(归档后换绑新任务继续跑,不会暂停);旧控制端忽略该字段。
+ ...(row.persistentSession === true ? { persistentSession: true } : {}),
}));
}
if (channel !== 'maker:provider:list') return result;
diff --git a/apps/desktop/src/renderer/__tests__/remoteScheduleBindings.test.tsx b/apps/desktop/src/renderer/__tests__/remoteScheduleBindings.test.tsx
index f7ade462dd..3ae4857b52 100644
--- a/apps/desktop/src/renderer/__tests__/remoteScheduleBindings.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/remoteScheduleBindings.test.tsx
@@ -199,6 +199,13 @@ describe('remote schedule binding badges', () => {
expect(() => parseScheduleBindings([{ ...binding(), recurring: 'false' }])).toThrow();
});
+ it('keeps the persistent-session flag only when true, so archive confirmation can skip it', () => {
+ expect(parseScheduleBindings([{ ...binding(), persistentSession: true }])).toEqual([
+ { ...binding(), persistentSession: true },
+ ]);
+ expect(parseScheduleBindings([{ ...binding(), persistentSession: false }])).toEqual([binding()]);
+ });
+
it.each([
[{ intervalMs: 600_000 }, 'Every 10 minutes'],
[{ intervalMs: 1_680_000 }, 'Every 28 minutes'],
diff --git a/apps/mobile/app/devices/[deviceId].tsx b/apps/mobile/app/devices/[deviceId].tsx
index d37e95b38f..186fb6ebac 100644
--- a/apps/mobile/app/devices/[deviceId].tsx
+++ b/apps/mobile/app/devices/[deviceId].tsx
@@ -278,6 +278,8 @@ function DeviceDetailScreenContent() {
const [bulkConfirmAction, setBulkConfirmAction] = useState<MobileSessionBulkAction | null>(null);
// 批量归档确认里「绑定了自动化的任务数」;按请求序号丢弃过期结果。
const [bulkScheduleCount, setBulkScheduleCount] = useState(0);
+ // 查询返回(成功或失败)前不允许确认归档,否则提醒还没出现任务就已归档。
+ const [bulkScheduleLoading, setBulkScheduleLoading] = useState(false);
const bulkScheduleRequestRef = useRef(0);
const [bulkNotice, setBulkNotice] = useState<string | null>(null);
const [scheduleIndex, setScheduleIndex] = useState<Map<string, RemoteSessionScheduleInfo>>(
@@ -668,10 +670,13 @@ function DeviceDetailScreenContent() {
}
const scheduleRequest = ++bulkScheduleRequestRef.current;
setBulkScheduleCount(0);
+ setBulkScheduleLoading(action === 'archive');
if (action === 'archive') {
void countSessionsWithActiveBoundSchedules(maker, summary.candidates.map((session) => session.id))
.then((count) => {
- if (bulkScheduleRequestRef.current === scheduleRequest) setBulkScheduleCount(count);
+ if (bulkScheduleRequestRef.current !== scheduleRequest) return;
+ setBulkScheduleCount(count);
+ setBulkScheduleLoading(false);
});
}
setBulkConfirmAction(action);
@@ -1185,7 +1190,8 @@ function DeviceDetailScreenContent() {
primaryActions={[
{
accessibilityLabel: bulkActionAccessibilityLabel(bulkConfirmSummary.action, t),
- disabled: bulkActionPending !== null || bulkConfirmSummary.candidates.length === 0,
+ disabled: bulkActionPending !== null || bulkConfirmSummary.candidates.length === 0
+ || (bulkConfirmSummary.action === 'archive' && bulkScheduleLoading),
label: bulkActionPending === bulkConfirmSummary.action
? bulkActionPendingLabel(bulkConfirmSummary.action, t)
: bulkConfirmSummary.confirmText,