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(cindy-make): preserve unknown ordinary share records

MagicLizi673f4be5a03f
diff --git a/apps/desktop/src/main/device-link/__tests__/sharedTaskHost.test.ts b/apps/desktop/src/main/device-link/__tests__/sharedTaskHost.test.ts
index 6d920587bc..6a99135cd6 100644
--- a/apps/desktop/src/main/device-link/__tests__/sharedTaskHost.test.ts
+++ b/apps/desktop/src/main/device-link/__tests__/sharedTaskHost.test.ts
@@ -114,6 +114,16 @@ describe('task host sharedTask lifecycle', () => {
expect(canRead()).toBe(false);
});
+ it('does not close a cold ordinary share offline when local metadata is still absent', async () => {
+ records.set('sharedTask', { sharedTaskId: 'sharedTask', sessionId: 'session', terminal: false, snapshot: parseSharedTaskSnapshot(detail()) });
+ options.readSession = vi.fn(async () => null);
+ await host.restore(false);
+ expect(records.get('sharedTask')?.terminal).toBe(false);
+ expect(api.close).not.toHaveBeenCalled();
+ expect(api.list).not.toHaveBeenCalled();
+ expect(options.revoke).not.toHaveBeenCalled();
+ });
+
it('consumes another instance closure offline and invalidates captured access without touching another share', async () => {
await host.open('session');
const old = host.capturePeer(sharedTaskGuestPeer('sharedTask', 'member-a', 'phone-a'))!;
diff --git a/apps/desktop/src/main/device-link/sharedTaskHost.ts b/apps/desktop/src/main/device-link/sharedTaskHost.ts
index 6a9be098c0..32ddd9d7d3 100644
--- a/apps/desktop/src/main/device-link/sharedTaskHost.ts
+++ b/apps/desktop/src/main/device-link/sharedTaskHost.ts
@@ -219,16 +219,17 @@ export class SharedTaskHost {
// Close access objects as well as the index so existing captures also expire.
for (const item of journal) if (item.terminal) this.revokeLocally(item.sharedTaskId);
const sessions = new Set([...this.entries.values()].map((entry) => entry.identity.sessionId));
+ for (const identity of this.created.values()) sessions.add(identity.sessionId);
+ for (const sessionId of this.creating.values()) sessions.add(sessionId);
+ const runtimeSessions = new Set(sessions);
for (const item of journal) if (!item.terminal && item.snapshot
&& item.snapshot.ownerAccountId === this.options.ownerAccountId
&& item.snapshot.hostDeviceId === this.options.hostDeviceId) sessions.add(item.sessionId);
- for (const identity of this.created.values()) sessions.add(identity.sessionId);
- for (const sessionId of this.creating.values()) sessions.add(sessionId);
for (const sessionId of sessions) {
const session = await this.options.readSession(sessionId);
this.assertCurrent();
- if ((!session || session.status !== 'active'
- || !CINDY_MAKE_ENABLED && isCindyMakeSource(session.source)) && !this.closedSessions.has(sessionId)) {
+ if ((runtimeSessions.has(sessionId) && (!session || session.status !== 'active')
+ || !CINDY_MAKE_ENABLED && isCindyMakeSource(session?.source)) && !this.closedSessions.has(sessionId)) {
await this.closeLocallyForBoundary(sessionId);
this.assertCurrent();
}