Skip to content

Commit 3533c44

Browse files
committed
Fixed: Update Linear assignee
1 parent aac9e42 commit 3533c44

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

.changeset/blue-toys-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/tool-linear": patch
3+
---
4+
5+
Fixed: Update Linear assignee

tools/linear/src/linear.ts

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export class Linear extends Tool<Linear> implements ProjectTool {
451451
},
452452
notes,
453453
preview: hasDescription ? description : null,
454-
unread: !initialSync, // false for initial sync, true for incremental updates
454+
...(initialSync ? { unread: false } : {}), // false for initial sync, omit for incremental updates
455455
...(initialSync ? { archived: false } : {}), // unarchive on initial sync only
456456
};
457457

@@ -483,8 +483,50 @@ export class Linear extends Tool<Linear> implements ProjectTool {
483483
updateFields.title = activity.title;
484484
}
485485

486-
// Handle assignee
487-
updateFields.assigneeId = activity.assignee?.id || null;
486+
// Handle assignee - map Plot actor to Linear user via email lookup
487+
const currentAssigneeActorId = activity.assignee?.id || null;
488+
489+
if (!currentAssigneeActorId) {
490+
updateFields.assigneeId = null;
491+
} else {
492+
const actors = await this.tools.plot.getActors([
493+
currentAssigneeActorId,
494+
]);
495+
const actor = actors[0];
496+
const email = actor?.email;
497+
498+
if (email) {
499+
// Check cache first
500+
let linearUserId = await this.get<string>(
501+
`linear_user:${email}`
502+
);
503+
504+
if (!linearUserId) {
505+
// Query Linear for user by email
506+
const users = await client.users({
507+
filter: { email: { eq: email } },
508+
});
509+
const linearUser = users.nodes[0];
510+
511+
if (linearUser) {
512+
linearUserId = linearUser.id;
513+
await this.set(`linear_user:${email}`, linearUserId);
514+
}
515+
}
516+
517+
if (linearUserId) {
518+
updateFields.assigneeId = linearUserId;
519+
} else {
520+
console.warn(
521+
`No Linear user found for email ${email}, skipping assignee update`
522+
);
523+
}
524+
} else {
525+
console.warn(
526+
`No email found for actor ${currentAssigneeActorId}, skipping assignee update`
527+
);
528+
}
529+
}
488530

489531
// Handle state based on start + done combination
490532
const team = await issue.team;

0 commit comments

Comments
 (0)