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): discard Todo action after stale link setup

zqchrisd47c22c33a59
diff --git a/apps/mobile/src/__tests__/CompanionTodos.test.tsx b/apps/mobile/src/__tests__/CompanionTodos.test.tsx
index 5a6a7d7483..16122826a5 100644
--- a/apps/mobile/src/__tests__/CompanionTodos.test.tsx
+++ b/apps/mobile/src/__tests__/CompanionTodos.test.tsx
@@ -196,3 +196,17 @@ it('routes Open from completed directly to open, and labels the hidden-list acti
await flush();
expect(JSON.parse(h.get.mock.calls.at(-1)![5]).view).toBe('open');
});
+
+it('does not send a stale operation whose link opens only after disconnect', async () => {
+ let finishLink!: () => void;
+ await render();
+ h.openLink.mockImplementationOnce(() => new Promise<void>(resolve => { finishLink = resolve; }));
+ await act(async () => row().click());
+ expect(h.sheet.preventDismiss).toBe(true);
+ await render(false);
+ await act(async () => finishLink());
+ expect(h.action).not.toHaveBeenCalled();
+ expect(h.sheet.preventDismiss).toBe(false);
+ await render(true);
+ expect(row().disabled).toBe(false);
+});
diff --git a/apps/mobile/src/session/CompanionTodos.tsx b/apps/mobile/src/session/CompanionTodos.tsx
index 0791444402..62dbb947a5 100644
--- a/apps/mobile/src/session/CompanionTodos.tsx
+++ b/apps/mobile/src/session/CompanionTodos.tsx
@@ -199,6 +199,7 @@ function CompanionTodosContent({ visible, onClose, deviceId, deviceName, botId,
mounted.current && scope === binding.current && operation === operationEpoch.current;
try {
await openLink(deviceId);
+ if (!current()) return;
await invokeRemoteResourceAction(
invoke,
{ deviceId, deviceName },