@@ -391,6 +391,102 @@ module.exports = {
391391
392392 return userModel . updateLastProjectVisit ( projectId ) ;
393393 } ,
394+
395+ /**
396+ * Disconnect Task Manager integration from project
397+ *
398+ * @param {ResolverObj } _obj
399+ * @param {string } projectId - project ID to disconnect Task Manager from
400+ * @param {UserInContext } user - current authorized user {@see ../index.js}
401+ * @param {ContextFactories } factories - factories for working with models
402+ *
403+ * @returns {Project }
404+ */
405+ async disconnectTaskManager ( _obj , { projectId } , { user, factories } ) {
406+ const project = await factories . projectsFactory . findById ( projectId ) ;
407+
408+ if ( ! project ) {
409+ throw new ApolloError ( 'There is no project with that id' ) ;
410+ }
411+
412+ if ( project . workspaceId . toString ( ) === '6213b6a01e6281087467cc7a' ) {
413+ throw new ApolloError ( 'Unable to update demo project' ) ;
414+ }
415+
416+ try {
417+ /**
418+ * Remove taskManager field from project
419+ * Set updatedAt to current date
420+ */
421+ return await project . updateProject ( {
422+ taskManager : null ,
423+ } ) ;
424+ } catch ( err ) {
425+ throw new ApolloError ( 'Failed to disconnect Task Manager' , { originalError : err } ) ;
426+ }
427+ } ,
428+
429+ /**
430+ * Update Task Manager settings for project
431+ *
432+ * @param {ResolverObj } _obj
433+ * @param {Object } input - Task Manager settings input
434+ * @param {string } input.projectId - project ID to update
435+ * @param {boolean } input.autoTaskEnabled - enable automatic task creation
436+ * @param {number } input.taskThresholdTotalCount - threshold for auto task creation
437+ * @param {boolean } input.assignAgent - assign agent (e.g. Copilot) to tasks
438+ * @param {UserInContext } user - current authorized user {@see ../index.js}
439+ * @param {ContextFactories } factories - factories for working with models
440+ *
441+ * @returns {Project }
442+ */
443+ async updateTaskManagerSettings ( _obj , { input } , { user, factories } ) {
444+ const { projectId, autoTaskEnabled, taskThresholdTotalCount, assignAgent } = input ;
445+
446+ const project = await factories . projectsFactory . findById ( projectId ) ;
447+
448+ if ( ! project ) {
449+ throw new ApolloError ( 'There is no project with that id' ) ;
450+ }
451+
452+ if ( project . workspaceId . toString ( ) === '6213b6a01e6281087467cc7a' ) {
453+ throw new ApolloError ( 'Unable to update demo project' ) ;
454+ }
455+
456+ /**
457+ * Check if taskManager is configured
458+ */
459+ if ( ! project . taskManager ) {
460+ throw new UserInputError ( 'Task Manager is not configured for this project' ) ;
461+ }
462+
463+ /**
464+ * Validate taskThresholdTotalCount
465+ */
466+ if ( typeof taskThresholdTotalCount !== 'number' || taskThresholdTotalCount <= 0 ) {
467+ throw new UserInputError ( 'taskThresholdTotalCount must be a positive integer greater than 0' ) ;
468+ }
469+
470+ try {
471+ /**
472+ * Update taskManager settings
473+ * Keep existing config and usage, update only settings
474+ */
475+ const updatedTaskManager = {
476+ ...project . taskManager ,
477+ autoTaskEnabled,
478+ taskThresholdTotalCount,
479+ assignAgent,
480+ updatedAt : new Date ( ) ,
481+ } ;
482+
483+ return await project . updateProject ( {
484+ taskManager : updatedTaskManager ,
485+ } ) ;
486+ } catch ( err ) {
487+ throw new ApolloError ( 'Failed to update Task Manager settings' , { originalError : err } ) ;
488+ }
489+ } ,
394490 } ,
395491 Project : {
396492 /**
0 commit comments