5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading
, '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
5 changes: 5 additions & 0 deletions .changeset/emoji-reactions.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Added: `Reaction`, `Reactions`, `NewReactions` types and a `reactions` field on `ThreadCommon` (covering both `Thread` and `Note`), along with optional `reactions?: NewReactions` on `NewThread`, `NewNote`, `ThreadUpdate`, `NoteUpdate`. Also adds `Connector.reactionCapabilities` (open-unicode / unicode-subset / fixed) so the Plot picker and outbound dispatch can filter reactions to what the source platform supports. Foundation for higher-fidelity emoji reaction sync across Slack, Microsoft Teams, Google Chat, LinkedIn Messaging, and Plot-native threads.
5 changes: 5 additions & 0 deletions .changeset/retire-count-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@plotday/twister": minor
---

Removed: count-tag entries (`Tag.Yes` through `Tag.Dismayed`, IDs 1000–1027) from the `Tag` enum. The full Unicode emoji `Reaction` type (added in the previous changeset) replaces them; connectors that previously wrote `note.tags[Tag.Yes]` now write `note.reactions['👍']`. Compute (Todo, Done) and toggle tags (Pinned, Urgent, …, Idea) are unchanged.
7 changes: 7 additions & 0 deletions .changeset/retire-toggle-tags.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
---
"@plotday/twister": minor
---

Removed: 10 toggle-tag entries (`Tag.Pinned`, `Tag.Urgent`, `Tag.Goal`, `Tag.Decision`, `Tag.Waiting`, `Tag.Blocked`, `Tag.Warning`, `Tag.Question`, `Tag.Star`, `Tag.Idea`) and the `tag?: Tag` field on `LinkTypeConfig.statuses[]`. The status-tag propagation mechanism is retired — connectors signal completion via the `done: true` boolean and messaging-active state via `active: true`, which is what was driving behaviour anyway. Reactions on threads/notes flow exclusively through the open Unicode emoji `Reaction` type.

Changed: `Tag.Twist` moves from `109` (toggle range) to `12` (compute range). It's still the system marker for "a twist is processing this note"; the runtime keeps writing/clearing it, and twists may still toggle it via `note.twistTags`. Code referencing `Tag.Twist` recompiles transparently against the new id.
2 changes: 1 addition & 1 deletion connectors/AGENTS.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,7 +393,7 @@ Opt a link type in by marking one status with `createDefault: true`:
statuses: [
{ status: "backlog", label: "Backlog" },
{ status: "unstarted", label: "To Do", todo: true, createDefault: true },
{ status: "completed", label: "Done", tag: Tag.Done, done: true },
{ status: "completed", label: "Done", done: true },
]
```

Expand Down
4 changes: 1 addition & 3 deletions connectors/airtable/src/airtable.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -118,7 +117,6 @@ export class Airtable extends Connector<Airtable> {
{
status: STATUS_DONE,
label: "Done",
tag: Tag.Done,
done: true as const,
},
],
Expand DownExpand Up@@ -225,7 +223,7 @@ export class Airtable extends Connector<Airtable> {
const pushStatus = (status: string, label: string) => {
const isDone = DONE_OPTION_MATCHERS.test(status);
if (isDone) {
statuses.push({ status, label, done: true, tag: Tag.Done });
statuses.push({ status, label, done: true });
} else if (!createDefaultAssigned) {
statuses.push({ status, label, task: true, createDefault: true });
createDefaultAssigned = true;
Expand Down
3 changes: 1 addition & 2 deletions connectors/asana/src/asana.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import {
type NewLinkWithNotes,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -60,7 +59,7 @@ export class Asana extends Connector<Asana> {
logoMono: "https://api.iconify.design/simple-icons/asana.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 1 addition & 5 deletions connectors/attio/src/attio.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type Thread,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Connector } from "@plotday/twister/connector";
import type { ToolBuilder } from "@plotday/twister/tool";
import {
Expand DownExpand Up@@ -121,7 +120,6 @@ export class Attio extends Connector<Attio> {
let dealStatuses: Array<{
status: string;
label: string;
tag?: Tag;
done?: true;
todo?: true;
}> = [];
Expand All@@ -138,9 +136,7 @@ export class Attio extends Connector<Attio> {
status: stage.title,
label: stage.title,
...(i === firstActiveIndex ? { task: true as const } : {}),
...(isWonStage(stage.title)
? { tag: Tag.Done, done: true as const }
: {}),
...(isWonStage(stage.title) ? { done: true as const } : {}),
...(isLostStage(stage.title) ? { done: true as const } : {}),
}));
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions connectors/github/src/github.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { NewContact } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import { Options } from "@plotday/twister/options";
import {
AuthProvider,
Expand DownExpand Up@@ -129,8 +128,8 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "merged", label: "Merged", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
{ status: "merged", label: "Merged", done: true },
],
supportsAssignee: true,
},
Expand All@@ -143,7 +142,7 @@ export class GitHub extends Connector<GitHub> {
logoMono: "https://api.iconify.design/simple-icons/github.svg",
statuses: [
{ status: "open", label: "Open", task: true },
{ status: "closed", label: "Closed", tag: Tag.Done, done: true },
{ status: "closed", label: "Closed", done: true },
],
supportsAssignee: true,
},
Expand Down
6 changes: 3 additions & 3 deletions connectors/gmail/src/gmail.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -117,14 +117,14 @@ export class Gmail extends Connector<Gmail> {
readonly linkTypes = [
{
type: "email",
label: "Email",
label: "Thread",
noteLabel: "Reply",
logo: "https://api.iconify.design/logos/google-gmail.svg",
logoMono: "https://api.iconify.design/simple-icons/gmail.svg",
statuses: [
{ status: "inbox", label: "Inbox" },
{ status: "starred", label: "Starred", tag: Tag.Star, active: true },
{ status: "archived", label: "Archived", tag: Tag.Done, done: true },
{ status: "starred", label: "Starred", active: true },
{ status: "archived", label: "Archived", done: true },
],
contactRoles: [
{ id: "to", label: "To", default: true },
Expand Down
76 changes: 21 additions & 55 deletions connectors/google-chat/src/google-chat-api.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,9 +2,8 @@ import type {
NewLinkWithNotes,
NewActor,
NewContact,
NewTags,
NewReactions,
} from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";

// ---- Google Chat API types ----

Expand DownExpand Up@@ -539,101 +538,68 @@ export function groupMessagesByThread(
return groups;
}

/**
* Maps common Unicode emoji to Plot Count Tags.
*/
export const EMOJI_TO_TAG: Record<string, Tag> = {
"👍": Tag.Yes,
"👎": Tag.No,
"🎉": Tag.Tada,
"🔥": Tag.Fire,
"❤️": Tag.Love,
"❤": Tag.Love,
"🚀": Tag.Rocket,
"✨": Tag.Sparkles,
"🙏": Tag.Thanks,
"😊": Tag.Smile,
"👋": Tag.Wave,
"👏": Tag.Applause,
"😎": Tag.Cool,
"😢": Tag.Sad,
"👀": Tag.Looking,
"💯": Tag.Totally,
};

/**
* Reverse mapping: Plot Count Tag → Unicode emoji.
* Derived from EMOJI_TO_TAG, preferring the first match for duplicates.
*/
export const TAG_TO_EMOJI: Partial<Record<Tag, string>> = {};
for (const [emoji, tag] of Object.entries(EMOJI_TO_TAG)) {
if (!TAG_TO_EMOJI[tag as Tag]) TAG_TO_EMOJI[tag as Tag] = emoji;
}

// Note: mentions on notes are for twist/connector dispatch routing only.
// Person contacts should NOT be in mentions — use thread-level accessContacts
// for visibility. The thread already has accessContacts set to space members.

/**
* Builds note-level tags for a single message from its reactions.
* Builds note-level reactions for a single message from Google Chat's
* reaction data. Unicode emoji pass through directly; custom workspace
* emojis are skipped for now (cached image_url support is a follow-up).
*
* When per-user reaction data is available (from listReactions API),
* uses that for accurate actor attribution. Otherwise falls back to
* each reactor is attributed individually. Otherwise falls back to
* emojiReactionSummaries and attributes to the message sender as a proxy.
*/
function extractMessageReactionTags(
export function extractMessageReactions(
msg: Message,
reactions?: EmojiReaction[],
memberInfo?: Map<string, MemberInfo>,
): NewTags | undefined {
const tagActors = new Map<Tag, NewActor[]>();
): NewReactions | undefined {
const byEmoji = new Map<string, NewActor[]>();

if (reactions && reactions.length > 0) {
// Per-user reaction data available — filter to this message
const msgId = msg.name;
for (const reaction of reactions) {
// Reaction name: spaces/{spaceId}/messages/{messageId}/reactions/{reactionId}
// Check if this reaction belongs to this message
if (reaction.name && !reaction.name.startsWith(msgId + "/")) continue;

const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
if (!unicode) continue; // skip custom emojis until image caching lands

const actor = reactionUserToNewActor(reaction.user, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
} else if (msg.emojiReactionSummaries) {
// Fall back to summary data — attribute to message sender as a proxy
for (const summary of msg.emojiReactionSummaries) {
const unicode = summary.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;

const actor = senderToNewActor(msg.sender, memberInfo);
const existing = tagActors.get(tag) ?? [];
const existing = byEmoji.get(unicode) ?? [];
existing.push(actor);
tagActors.set(tag, existing);
byEmoji.set(unicode, existing);
}
}

if (tagActors.size === 0) return undefined;
if (byEmoji.size === 0) return undefined;

const tags: NewTags = {};
for (const [tag, actors] of tagActors) {
const out: NewReactions = {};
for (const [emoji, actors] of byEmoji) {
// Deduplicate actors by source accountId
const seen = new Set<string>();
tags[tag] = actors.filter((a) => {
out[emoji] = actors.filter((a) => {
const key = "source" in a && a.source ? a.source.accountId : "name" in a ? a.name : "";
if (!key || seen.has(key)) return false;
seen.add(key);
return true;
});
}
return tags;
return out;
}

/**
Expand DownExpand Up@@ -711,15 +677,15 @@ export function transformChatThread(
const content = baseContent && attachmentMarkdown
? baseContent + attachmentMarkdown
: baseContent;
const reactionTags = extractMessageReactionTags(msg, reactions, memberInfo);
const messageReactions = extractMessageReactions(msg, reactions, memberInfo);

return {
key: `message-${extractMessageId(msg.name)}`,
content,
contentType: msg.formattedText ? ("html" as const) : ("text" as const),
created: new Date(msg.createTime),
author: senderToNewActor(msg.sender, memberInfo),
...(reactionTags ? { tags: reactionTags } : {}),
...(messageReactions ? { reactions: messageReactions } : {}),
checkForTasks: true,
};
}),
Expand Down
47 changes: 25 additions & 22 deletions connectors/google-chat/src/google-chat.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import {
type ToolBuilder,
} from "@plotday/twister";
import type { Actor, ContentType, NewActor, NewContact, NewLinkWithNotes, Note, Thread } from "@plotday/twister/plot";
import { Tag } from "@plotday/twister/tag";
import {
AuthProvider,
type AuthToken,
Expand All@@ -19,8 +18,6 @@ import { Network, type WebhookRequest } from "@plotday/twister/tools/network";

import {
GoogleChatApi,
EMOJI_TO_TAG,
TAG_TO_EMOJI,
type EmojiReaction,
type Message,
type MemberInfo,
Expand DownExpand Up@@ -95,6 +92,13 @@ export class GoogleChat extends Connector<GoogleChat> {
GoogleChat.SCOPES,
GoogleContacts.SCOPES
);
readonly reactionCapabilities = {
mode: "open-unicode" as const,
// Custom workspace emojis are skipped on sync-in and not yet pushed
// on write-back; flip to "workspace" once the custom_emoji image
// cache lands.
customEmoji: "none" as const,
};
readonly linkTypes = [
{
type: "message",
Expand DownExpand Up@@ -1227,32 +1231,31 @@ export class GoogleChat extends Connector<GoogleChat> {
return writeBack; // Message may not exist anymore
}

// Build set of Plot tags that have emoji mappings (any actor)
const plotTags = new Set<Tag>();
for (const [tagIdStr, actorIds] of Object.entries(note.tags)) {
const tagId = parseInt(tagIdStr) as Tag;
if (!TAG_TO_EMOJI[tagId]) continue;
if (actorIds && actorIds.length > 0) {
plotTags.add(tagId);
}
// Plot-side: any emoji with at least one reactor is "present in Plot".
// Pre-existing behavior is to write back as the authenticated user
// regardless of which actor reacted in Plot; per-actor write-back
// via actAs() can be a follow-up.
const plotEmojis = new Set<string>();
for (const [emoji, actorIds] of Object.entries(note.reactions)) {
// Only Unicode emoji round-trip today (custom emoji are skipped
// on sync-in and have no createReaction path here yet).
if (emoji.includes(":")) continue;
if (actorIds && actorIds.length > 0) plotEmojis.add(emoji);
}

// Build set of the authenticated user's current reactions in Google Chat
const chatTags = new Map<Tag, string>(); // Tag → reaction resource name
// Google Chat side: the authenticated user's existing reactions on
// this message, keyed by unicode → reaction resource name.
const chatEmojis = new Map<string, string>();
for (const reaction of currentReactions) {
if (reaction.user.name !== authUser.googleUserId) continue;
const unicode = reaction.emoji.unicode;
if (!unicode) continue;
const tag = EMOJI_TO_TAG[unicode];
if (!tag) continue;
chatTags.set(tag, reaction.name);
chatEmojis.set(unicode, reaction.name);
}

// Add reactions present in Plot but not in Google Chat
for (const tag of plotTags) {
if (chatTags.has(tag)) continue;
const emoji = TAG_TO_EMOJI[tag];
if (!emoji) continue;
for (const emoji of plotEmojis) {
if (chatEmojis.has(emoji)) continue;
try {
await api.createReaction(messageName, emoji);
} catch (error) {
Expand All@@ -1261,8 +1264,8 @@ export class GoogleChat extends Connector<GoogleChat> {
}

// Remove reactions present in Google Chat but not in Plot
for (const [tag, reactionName] of chatTags) {
if (plotTags.has(tag)) continue;
for (const [emoji, reactionName] of chatEmojis) {
if (plotEmojis.has(emoji)) continue;
try {
await api.deleteReaction(reactionName);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/google-tasks/src/google-tasks.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ export class GoogleTasks extends Connector<GoogleTasks> {
logoMono: "https://api.iconify.design/simple-icons/googletasks.svg",
statuses: [
{ status: "open", label: "Open", task: true, createDefault: true },
{ status: "done", label: "Done", tag: Tag.Done, done: true },
{ status: "done", label: "Done", done: true },
],
supportsAssignee: false,
},
Expand Down
Loading
Loading