@@ -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