Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(contacts): propagate newest conflict stamp
Chrise78a47bf304c
diff --git a/packages/maker-core/src/contacts/__tests__/contactsSync.test.ts b/packages/maker-core/src/contacts/__tests__/contactsSync.test.tsindex 9fae1b1a2c..9938855ea8 100644--- a/packages/maker-core/src/contacts/__tests__/contactsSync.test.ts+++ b/packages/maker-core/src/contacts/__tests__/contactsSync.test.ts@@ -281,6 +281,40 @@ describe("contacts device sync", () => {expect(b.stats().pending).toBe(1);});+ it("用户确认后出现更新的同身份冲突时,所有关联联系人重新变成待确认", () => {+ const a = createStore();+ const b = createStore();+ a.activateDeviceSync();+ b.activateDeviceSync();+ const aContact = a.createContact({+ kind: "person",+ displayName: "甲",+ identities: [{ platform: "email", value: "[email protected]" }],+ });+ a.updateContact(aContact.id, { status: "pending" });+ stateOf(a);+ a.updateContact(aContact.id, { status: "confirmed" });+ stateOf(a);++ // 让离线设备 B 的后续身份写入晚于 A 的确认裁决。+ for (const displayName of ["垫高时钟一", "垫高时钟二", "垫高时钟三"]) {+ b.createContact({ kind: "person", displayName });+ stateOf(b);+ }+ const bContact = b.createContact({+ kind: "person",+ displayName: "乙",+ identities: [{ platform: "email", value: "[email protected]" }],+ });++ exchange(a, b);+ exchange(b, a);+ expect(a.getContact(aContact.id).status).toBe("pending");+ expect(a.getContact(bContact.id).status).toBe("pending");+ expect(b.getContact(aContact.id).status).toBe("pending");+ expect(b.getContact(bContact.id).status).toBe("pending");+ });+it("FTS 重建失败后重复接收相同状态仍会重试", () => {const a = createStore();const b = createStore();diff --git a/packages/maker-core/src/contacts/sync/materialize.ts b/packages/maker-core/src/contacts/sync/materialize.tsindex 4fe3d6fae9..108c05c910 100644--- a/packages/maker-core/src/contacts/sync/materialize.ts+++ b/packages/maker-core/src/contacts/sync/materialize.ts@@ -125,15 +125,25 @@ export function materializeContactsSyncState(const conflictedContactIds = new Set<string>();for (const [key, owners] of identityOwners.entries()) {if (owners.size <= 1) continue;+ let latestConflictStamp: ContactsSyncStamp | undefined;for (const record of identityRecordsByKey.get(key) ?? []) {const value = record.value.value;conflictedContactIds.add(value.contactId);- const previous = latestConflictStampByContact.get(value.contactId);+ if (+ !latestConflictStamp ||+ compareContactsSyncStamp(latestConflictStamp, record.value.stamp) < 0+ ) {+ latestConflictStamp = record.value.stamp;+ }+ }+ if (!latestConflictStamp) continue;+ for (const contactId of owners) {+ const previous = latestConflictStampByContact.get(contactId);if (!previous ||- compareContactsSyncStamp(previous, record.value.stamp) < 0+ compareContactsSyncStamp(previous, latestConflictStamp) < 0) {- latestConflictStampByContact.set(value.contactId, record.value.stamp);+ latestConflictStampByContact.set(contactId, latestConflictStamp);}}}