Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Commit 44db2b0

Browse files
KrisBraunclaude
andcommitted
Qualify connector source strings for cross-user dedup
The Plot runtime now dedupes threads across users on (twist_id, key), so two connector instances emitting the same `source` for the same external item converge on one shared thread. `source` must therefore be globally unique for the logical item, not merely unique within one user's account. Fix connectors whose external ids are workspace-, tenant-, mailbox-, or project-scoped: - attio: `attio:<workspaceId>:<type>:<recordId>` (workspace_id comes directly off every AttioRecord/Task/Note id; also cached from getWorkspace for completeness). - posthog: `posthog:<projectId>:person:<distinctId>` — distinct_id is project-scoped and often just a bare email. - outlook-calendar: `outlook-calendar:<calendarId>:<eventId>` — Graph event ids are mailbox-local. - fellow: `fellow:<subdomain>:note:<id>` — Fellow ids are tenant-scoped. - google-calendar: switch to `google-calendar:<iCalUID>` so the same meeting converges across attendees' calendars. Occurrences share the master's iCalUID, so instance/exception paths land on the same thread. RSVP write-back now reads the per-calendar event id from `meta.id` (previously parsed out of `source`), since source is no longer the per-calendar id. Backfill is intentionally out of scope — existing threads with old source strings will get new threads on next sync. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be1cd2f commit 44db2b0

8 files changed

Lines changed: 63 additions & 25 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/twister": patch
3+
---
4+
5+
Fixed: qualify `source` strings in workspace/tenant/mailbox-scoped connectors so they stay globally unique under cross-user thread dedup. attio now uses `attio:<workspaceId>:<type>:<recordId>`; posthog uses `posthog:<projectId>:person:<distinctId>`; outlook-calendar uses `outlook-calendar:<calendarId>:<eventId>`; fellow uses `fellow:<subdomain>:note:<id>`. google-calendar now uses the event's `iCalUID` (shared across attendees' copies) in place of the per-calendar event id, so the same meeting converges into one thread across users.

‎connectors/attio/src/attio-api.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,15 @@ export class AttioAPI {
239239
}
240240

241241
/** Get the current workspace info via /v2/self. */
242-
asyncgetWorkspace(): Promise<{name: string;slug: string}>{
242+
asyncgetWorkspace(): Promise<{id: string;name: string;slug: string}>{
243243
constself=awaitthis.request<{
244244
workspace_id: string;
245245
workspace_name: string;
246246
workspace_slug: string;
247247
}>("GET","/self");
248248

249249
return{
250+
id: self.workspace_id,
250251
name: self.workspace_name||self.workspace_id,
251252
slug: self.workspace_slug,
252253
};

‎connectors/attio/src/attio.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Attio extends Connector<Attio> {
9999
constapi=this.getAPI();
100100
constworkspace=awaitapi.getWorkspace();
101101
awaitthis.set("workspace_slug",workspace.slug);
102+
awaitthis.set("workspace_id",workspace.id);
102103
returnworkspace.name;
103104
}
104105

@@ -358,6 +359,7 @@ export class Attio extends Connector<Attio> {
358359
constworkspace=awaitapi.getWorkspace();
359360
slug=workspace.slug;
360361
if(slug)awaitthis.set("workspace_slug",slug);
362+
if(workspace.id)awaitthis.set("workspace_id",workspace.id);
361363
}catch{
362364
// Fall through — return null
363365
}
@@ -392,8 +394,10 @@ export class Attio extends Connector<Attio> {
392394
? `${value.currency}${value.amount.toLocaleString()}`
393395
: null;
394396

397+
constworkspaceId=record.id.workspace_id;
398+
395399
return{
396-
source: `attio:deal:${recordId}`,
400+
source: `attio:${workspaceId}:deal:${recordId}`,
397401
type: "deal",
398402
title: name,
399403
created: newDate(record.created_at),
@@ -429,8 +433,10 @@ export class Attio extends Connector<Attio> {
429433
? { name }
430434
: undefined;
431435

436+
constworkspaceId=record.id.workspace_id;
437+
432438
return{
433-
source: `attio:person:${recordId}`,
439+
source: `attio:${workspaceId}:person:${recordId}`,
434440
type: "person",
435441
title: name||email||"Unknown Person",
436442
created: newDate(record.created_at),
@@ -458,9 +464,10 @@ export class Attio extends Connector<Attio> {
458464
constname=extractName(v)||"Untitled Company";
459465
constdomain=extractDomain(v);
460466
constrecordId=record.id.record_id;
467+
constworkspaceId=record.id.workspace_id;
461468

462469
return{
463-
source: `attio:company:${recordId}`,
470+
source: `attio:${workspaceId}:company:${recordId}`,
464471
type: "company",
465472
title: name,
466473
created: newDate(record.created_at),
@@ -491,12 +498,14 @@ export class Attio extends Connector<Attio> {
491498
constcontent=
492499
(task.content_plaintext||"Untitled Task")+statusSuffix;
493500

501+
constworkspaceId=task.id.workspace_id;
502+
494503
for(constlinkedoftask.linked_records){
495504
constlinkType=OBJECT_TO_LINK_TYPE[linked.target_object];
496505
if(!linkType)continue;
497506

498507
awaitthis.tools.integrations.saveLink({
499-
source: `attio:${linkType}:${linked.target_record_id}`,
508+
source: `attio:${workspaceId}:${linkType}:${linked.target_record_id}`,
500509
type: linkType,
501510
channelId: "attio",
502511
meta: {
@@ -527,8 +536,10 @@ export class Attio extends Connector<Attio> {
527536
constcontent=note.content_plaintext||note.title||"";
528537
if(!content)return;
529538

539+
constworkspaceId=note.id.workspace_id;
540+
530541
awaitthis.tools.integrations.saveLink({
531-
source: `attio:${linkType}:${note.parent_record_id}`,
542+
source: `attio:${workspaceId}:${linkType}:${note.parent_record_id}`,
532543
type: linkType,
533544
channelId: "attio",
534545
meta: {

‎connectors/fellow/src/fellow.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ export class Fellow extends Connector<Fellow> {
276276
constsubdomain=this.tools.options.subdomainasstring;
277277

278278
return{
279-
source: `fellow:note:${note.id}`,
279+
// Fellow note ids are tenant-scoped, so qualify with the workspace
280+
// subdomain to keep source globally unique across users.
281+
source: `fellow:${subdomain}:note:${note.id}`,
280282
// Cross-connector thread bundling: join existing calendar thread
281283
...(note.event_guid
282284
? {relatedSource: `google-calendar:${note.event_guid}`}

‎connectors/google-calendar/src/google-api.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export type TransformedEvent = {
1616

1717
exporttypeGoogleEvent={
1818
id: string;
19+
/**
20+
* RFC5545 event identifier. Globally unique across calendars — all
21+
* attendees' copies of the same event share this value, as do all
22+
* occurrences of a recurring event. Prefer this over `id` (which is
23+
* per-calendar) when building a cross-user-stable `source`.
24+
*/
25+
iCalUID?: string;
1926
recurringEventId?: string;
2027
originalStartTime?: {
2128
dateTime?: string;

‎connectors/google-calendar/src/google-calendar.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
716716
if(initialSync){
717717
continue;
718718
}
719-
// Canonical source for this event (required for upsert)
720-
constcanonicalUrl=`google-calendar:${event.id}`;
719+
// Canonical source for this event (required for upsert).
720+
// iCalUID is shared across all attendees' copies of a meeting,
721+
// so using it converges cross-user threads for the same event.
722+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
721723

722724
// Create cancellation note
723725
constcancelledBy=
@@ -845,8 +847,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
845847
continue;
846848
}
847849

848-
// Canonical source for this event (required for upsert)
849-
constcanonicalUrl=`google-calendar:${event.id}`;
850+
// Canonical source for this event (required for upsert).
851+
// iCalUID is shared across all attendees' copies of a meeting,
852+
// so using it converges cross-user threads for the same event.
853+
constcanonicalUrl=`google-calendar:${event.iCalUID??event.id}`;
850854

851855
// Build description note if available
852856
constdescriptionNote=hasDescription
@@ -909,8 +913,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
909913
syncableId: calendarId,
910914
};
911915

912-
// Merge any buffered occurrences that arrived before this master event
913-
constpendingKey=`pending_occ:google-calendar:${event.id}`;
916+
// Merge any buffered occurrences that arrived before this master event.
917+
// Key matches the form used when instances buffer themselves (see
918+
// processEventInstance → `pending_occ:${masterCanonicalUrl}`).
919+
constpendingKey=`pending_occ:${canonicalUrl}`;
914920
constpendingOccurrences=awaitthis.get<PendingOccurrence[]>(
915921
pendingKey
916922
);
@@ -954,8 +960,10 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
954960
return;
955961
}
956962

957-
// Canonical URL for the master recurring event
958-
constmasterCanonicalUrl=`google-calendar:${event.recurringEventId}`;
963+
// Canonical URL for the master recurring event. All occurrences share
964+
// the master's iCalUID, so this produces the same source the master
965+
// event path uses (and converges cross-user threads for shared meetings).
966+
constmasterCanonicalUrl=`google-calendar:${event.iCalUID??event.recurringEventId}`;
959967

960968
// Transform the instance data
961969
constinstanceData=transformGoogleEvent(event,calendarId);
@@ -1231,14 +1239,13 @@ export class GoogleCalendar extends Connector<GoogleCalendar> {
12311239
actor: Actor
12321240
): Promise<void>{
12331241
constmeta=thread.metaasRecord<string,unknown>|null;
1234-
constlinkSource=meta?.linkSourceasstring|null;
12351242
constcalendarId=meta?.syncableIdasstring|null;
1243+
// Per-calendar Google event id is stored in meta.id by transformGoogleEvent.
1244+
// We can't derive it from `source` anymore, because source uses iCalUID
1245+
// (shared across calendars) for cross-user dedup.
1246+
consteventId=meta?.idasstring|null;
12361247

1237-
if(!linkSource||!calendarId)return;
1238-
1239-
// Extract event ID from source format "google-calendar:<eventId>"
1240-
consteventId=linkSource.replace(/^google-calendar:/,"");
1241-
if(!eventId||eventId===linkSource)return;
1248+
if(!eventId||!calendarId)return;
12421249

12431250
// Map Plot status to Google Calendar status
12441251
constgoogleStatus=

‎connectors/outlook-calendar/src/outlook-calendar.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,9 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
423423
if(initialSync){
424424
continue;
425425
}
426-
// Build source URL using event ID
427-
constsource=`outlook-calendar:${outlookEvent.id}`;
426+
// Graph event ids are mailbox-local, so qualify with calendarId
427+
// to keep source globally unique across users.
428+
constsource=`outlook-calendar:${calendarId}:${outlookEvent.id}`;
428429

429430
// Create cancellation note
430431
constcancelNote={
@@ -578,7 +579,7 @@ export class OutlookCalendar extends Connector<OutlookCalendar> {
578579

579580
// Build NewLinkWithNotes from the transformed thread data
580581
constlinkWithNotes: NewLinkWithNotes={
581-
source: `outlook-calendar:${outlookEvent.id}`,
582+
source: `outlook-calendar:${calendarId}:${outlookEvent.id}`,
582583
type: "event",
583584
title: threadData.title||"",
584585
access: "private",

‎connectors/posthog/src/posthog.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ export class PostHog extends Connector<PostHog> {
177177
};
178178
});
179179

180+
constprojectId=this.tools.options.projectIdasstring;
181+
180182
constlink: NewLinkWithNotes={
181-
source: `posthog:person:${distinctId}`,
183+
// PostHog distinct_id is project-scoped (often just an email), so we
184+
// qualify with projectId to keep source globally unique across users.
185+
source: `posthog:${projectId}:person:${distinctId}`,
182186
title: personName,
183187
type: "person",
184188
channelId: eventName,

0 commit comments

Comments
 (0)