@tuturuuu/ui 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (584) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/biome.json +1 -1
  3. package/package.json +76 -118
  4. package/src/components/ui/calendar-app/calendar-client-page.tsx +12 -3
  5. package/src/components/ui/calendar-app/calendar-page-shell.tsx +38 -28
  6. package/src/components/ui/custom/notification-popover-client.tsx +3 -3
  7. package/src/components/ui/tasks/progress/activity-heatmap.tsx +256 -0
  8. package/src/components/ui/tasks/progress/breakdown-bars.tsx +79 -0
  9. package/src/components/ui/tasks/progress/cumulative-progress-chart.tsx +185 -0
  10. package/src/components/ui/tasks/progress/daily-bar-chart.tsx +97 -0
  11. package/src/components/ui/tasks/progress/habit-gauge.tsx +92 -0
  12. package/src/components/ui/tasks/progress/mini-sparkline.tsx +56 -0
  13. package/src/components/ui/tasks/progress/weekday-distribution-chart.tsx +72 -0
  14. package/src/components/ui/text-editor/editor.tsx +7 -1
  15. package/src/components/ui/text-editor/extensions.ts +4 -1
  16. package/src/components/ui/text-editor/mention-extension.tsx +33 -121
  17. package/src/lib/workspace-actions.ts +15 -4
  18. package/src/components/ui/calendar-app/components/actions-dropdown.tsx +0 -269
  19. package/src/components/ui/calendar-app/components/auto-schedule-comprehensive-dialog.tsx +0 -220
  20. package/src/components/ui/calendar-app/components/calendar-header-actions.tsx +0 -67
  21. package/src/components/ui/calendar-app/components/experimental-feature-dialog.tsx +0 -56
  22. package/src/components/ui/calendar-app/components/habits-panel.tsx +0 -335
  23. package/src/components/ui/calendar-app/components/load-smart-scheduling-tasks.tsx +0 -143
  24. package/src/components/ui/calendar-app/components/priority-dropdown.tsx +0 -113
  25. package/src/components/ui/calendar-app/components/priority-view.tsx +0 -954
  26. package/src/components/ui/calendar-app/components/quick-task-dialog.tsx +0 -335
  27. package/src/components/ui/calendar-app/components/quick-task-timer.tsx +0 -112
  28. package/src/components/ui/calendar-app/components/scheduling-dialog.tsx +0 -664
  29. package/src/components/ui/calendar-app/components/sidebar/calendar-sidebar.tsx +0 -128
  30. package/src/components/ui/calendar-app/components/sidebar/index.tsx +0 -1
  31. package/src/components/ui/calendar-app/components/smart-schedule-button.tsx +0 -117
  32. package/src/components/ui/calendar-app/components/smart-schedule-preview-dialog.tsx +0 -845
  33. package/src/components/ui/calendar-app/components/smart-schedule-preview-panel.tsx +0 -941
  34. package/src/components/ui/calendar-app/components/task-fetcher.ts +0 -51
  35. package/src/components/ui/calendar-app/components/task-form.tsx +0 -132
  36. package/src/components/ui/calendar-app/components/task-list-form.tsx +0 -84
  37. package/src/components/ui/calendar-app/components/task-scheduler-panel.tsx +0 -494
  38. package/src/components/ui/calendar-app/components/tasks-sidebar-content.tsx +0 -232
  39. package/src/components/ui/calendar-app/components/tasks-sidebar.tsx +0 -31
  40. package/src/components/ui/calendar-app/components/time-tracker/components/active-session-card.tsx +0 -113
  41. package/src/components/ui/calendar-app/components/time-tracker/components/index.ts +0 -3
  42. package/src/components/ui/calendar-app/components/time-tracker/components/session-card.tsx +0 -153
  43. package/src/components/ui/calendar-app/components/time-tracker/components/stats-cards.tsx +0 -58
  44. package/src/components/ui/calendar-app/components/time-tracker/dialogs/create-task-dialog.tsx +0 -190
  45. package/src/components/ui/calendar-app/components/time-tracker/dialogs/delete-session-dialog.tsx +0 -52
  46. package/src/components/ui/calendar-app/components/time-tracker/dialogs/edit-session-dialog.tsx +0 -173
  47. package/src/components/ui/calendar-app/components/time-tracker/dialogs/index.ts +0 -3
  48. package/src/components/ui/calendar-app/components/time-tracker/hooks/index.ts +0 -2
  49. package/src/components/ui/calendar-app/components/time-tracker/hooks/use-sessions.ts +0 -191
  50. package/src/components/ui/calendar-app/components/time-tracker/hooks/use-time-tracker.ts +0 -408
  51. package/src/components/ui/calendar-app/components/time-tracker/index.tsx +0 -907
  52. package/src/components/ui/calendar-app/components/time-tracker/tabs/history-tab.tsx +0 -28
  53. package/src/components/ui/calendar-app/components/time-tracker/tabs/index.ts +0 -2
  54. package/src/components/ui/calendar-app/components/time-tracker/tabs/recent-sessions-tab.tsx +0 -173
  55. package/src/components/ui/calendar-app/components/time-tracker/time-tracker-trigger.tsx +0 -50
  56. package/src/components/ui/calendar-app/components/time-tracker/utils/category-colors.ts +0 -38
  57. package/src/components/ui/calendar-app/components/time-tracker/utils/format-time.ts +0 -26
  58. package/src/components/ui/calendar-app/components/time-tracker/utils/index.ts +0 -2
  59. package/src/components/ui/calendar-app/components/time-tracker.tsx +0 -2040
  60. package/src/components/ui/custom/settings/task-settings.tsx +0 -543
  61. package/src/components/ui/custom/settings/task-sound-settings.test.tsx +0 -146
  62. package/src/components/ui/text-editor/__tests__/task-mention-chip.test.tsx +0 -476
  63. package/src/components/ui/text-editor/task-mention-chip.tsx +0 -1397
  64. package/src/components/ui/text-editor/task-mention-resolution.ts +0 -235
  65. package/src/components/ui/text-editor/task-summary-popover.tsx +0 -360
  66. package/src/components/ui/tu-do/boards/__tests__/board-share-dialog.test.tsx +0 -286
  67. package/src/components/ui/tu-do/boards/__tests__/quick-create-board-dialog.test.tsx +0 -52
  68. package/src/components/ui/tu-do/boards/__tests__/task-board-form.test.tsx +0 -142
  69. package/src/components/ui/tu-do/boards/__tests__/workspace-projects-client-page.test.tsx +0 -169
  70. package/src/components/ui/tu-do/boards/analytics/GanttChart.tsx +0 -419
  71. package/src/components/ui/tu-do/boards/analytics/GanttControls.tsx +0 -123
  72. package/src/components/ui/tu-do/boards/analytics/GanttHeader.tsx +0 -48
  73. package/src/components/ui/tu-do/boards/analytics/GanttTimeline.tsx +0 -355
  74. package/src/components/ui/tu-do/boards/analytics/StatusDistribution.tsx +0 -130
  75. package/src/components/ui/tu-do/boards/analytics/TaskCreationAnalytics.tsx +0 -285
  76. package/src/components/ui/tu-do/boards/analytics/TaskDetailCard.tsx +0 -270
  77. package/src/components/ui/tu-do/boards/analytics/TaskGroup.tsx +0 -282
  78. package/src/components/ui/tu-do/boards/analytics/TaskWorkflowAnalytics.tsx +0 -280
  79. package/src/components/ui/tu-do/boards/board-public-link-section.tsx +0 -231
  80. package/src/components/ui/tu-do/boards/board-selector.tsx +0 -301
  81. package/src/components/ui/tu-do/boards/board-share-dialog.tsx +0 -69
  82. package/src/components/ui/tu-do/boards/board-share-settings-panel.tsx +0 -351
  83. package/src/components/ui/tu-do/boards/boardId/__tests__/list-actions.test.tsx +0 -199
  84. package/src/components/ui/tu-do/boards/boardId/board-column-external-retry.test.tsx +0 -185
  85. package/src/components/ui/tu-do/boards/boardId/board-column-initial-load.test.ts +0 -38
  86. package/src/components/ui/tu-do/boards/boardId/board-column.tsx +0 -922
  87. package/src/components/ui/tu-do/boards/boardId/board-text-utils.test.ts +0 -24
  88. package/src/components/ui/tu-do/boards/boardId/board-text-utils.ts +0 -11
  89. package/src/components/ui/tu-do/boards/boardId/enhanced-task-list.tsx +0 -543
  90. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/__tests__/bulk-mutations-external-workspaces.test.tsx +0 -392
  91. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/__tests__/bulk-mutations-move.test.tsx +0 -252
  92. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-actions-island.test.tsx +0 -57
  93. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-actions-island.tsx +0 -106
  94. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-actions-menu.tsx +0 -689
  95. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-custom-date-dialog.tsx +0 -82
  96. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-delete-dialog.tsx +0 -58
  97. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-clear-delete.ts +0 -418
  98. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-move.ts +0 -662
  99. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-relations-assignees.ts +0 -375
  100. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-relations-labels.ts +0 -278
  101. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-relations-projects.ts +0 -297
  102. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-relations.ts +0 -12
  103. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-updates.ts +0 -462
  104. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-operation-i18n.ts +0 -524
  105. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-operation-types.ts +0 -34
  106. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-operation-utils.ts +0 -377
  107. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-operations.ts +0 -348
  108. package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-personal-external-move.ts +0 -132
  109. package/src/components/ui/tu-do/boards/boardId/kanban/data/kanban-deadline-query.ts +0 -90
  110. package/src/components/ui/tu-do/boards/boardId/kanban/data/use-applied-sets.ts +0 -79
  111. package/src/components/ui/tu-do/boards/boardId/kanban/data/use-bulk-resources.ts +0 -112
  112. package/src/components/ui/tu-do/boards/boardId/kanban/data/use-filtered-resources.ts +0 -54
  113. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/__tests__/column-reorder.test.ts +0 -80
  114. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/auto-scroll.test.ts +0 -118
  115. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/auto-scroll.ts +0 -160
  116. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/column-reorder.ts +0 -65
  117. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/drag-preview.tsx +0 -117
  118. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/kanban-sort-helpers.ts +0 -76
  119. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-cache.ts +0 -367
  120. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-geometry.test.ts +0 -67
  121. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-geometry.ts +0 -94
  122. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-order.ts +0 -150
  123. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-pending.test.ts +0 -37
  124. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-pending.ts +0 -42
  125. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-preview.test.ts +0 -318
  126. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-preview.ts +0 -260
  127. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-types.ts +0 -39
  128. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-sort-key.ts +0 -47
  129. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.test.ts +0 -859
  130. package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.ts +0 -1659
  131. package/src/components/ui/tu-do/boards/boardId/kanban/kanban-column-collapse.ts +0 -16
  132. package/src/components/ui/tu-do/boards/boardId/kanban/kanban-constants.ts +0 -43
  133. package/src/components/ui/tu-do/boards/boardId/kanban/planner/__tests__/kanban-planner-island.test.tsx +0 -380
  134. package/src/components/ui/tu-do/boards/boardId/kanban/planner/kanban-planner-dialog.tsx +0 -204
  135. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-digest-panel.tsx +0 -61
  136. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-item-strip.tsx +0 -54
  137. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-plan-toolbar.tsx +0 -251
  138. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-scope-badge.tsx +0 -27
  139. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-section.tsx +0 -58
  140. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-share-dialog.tsx +0 -238
  141. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-target-controls.tsx +0 -143
  142. package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-utils.ts +0 -65
  143. package/src/components/ui/tu-do/boards/boardId/kanban/planner/use-kanban-planner-state.ts +0 -234
  144. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-column-width.ts +0 -30
  145. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.test.tsx +0 -1077
  146. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.tsx +0 -447
  147. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-panels.tsx +0 -703
  148. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-tasks.test.ts +0 -267
  149. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-tasks.ts +0 -112
  150. package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-skeleton.tsx +0 -113
  151. package/src/components/ui/tu-do/boards/boardId/kanban/selection/use-keyboard-shortcuts.ts +0 -137
  152. package/src/components/ui/tu-do/boards/boardId/kanban/selection/use-multi-select.ts +0 -119
  153. package/src/components/ui/tu-do/boards/boardId/kanban.tsx +0 -631
  154. package/src/components/ui/tu-do/boards/boardId/list-actions.tsx +0 -522
  155. package/src/components/ui/tu-do/boards/boardId/menus/__tests__/task-estimation-menu.test.tsx +0 -261
  156. package/src/components/ui/tu-do/boards/boardId/menus/__tests__/task-menus.test.tsx +0 -708
  157. package/src/components/ui/tu-do/boards/boardId/menus/index.ts +0 -12
  158. package/src/components/ui/tu-do/boards/boardId/menus/task-assignees-menu.tsx +0 -176
  159. package/src/components/ui/tu-do/boards/boardId/menus/task-blocking-menu.tsx +0 -304
  160. package/src/components/ui/tu-do/boards/boardId/menus/task-due-date-menu.tsx +0 -201
  161. package/src/components/ui/tu-do/boards/boardId/menus/task-estimation-menu.tsx +0 -103
  162. package/src/components/ui/tu-do/boards/boardId/menus/task-labels-menu.tsx +0 -134
  163. package/src/components/ui/tu-do/boards/boardId/menus/task-move-menu.tsx +0 -66
  164. package/src/components/ui/tu-do/boards/boardId/menus/task-parent-menu.tsx +0 -228
  165. package/src/components/ui/tu-do/boards/boardId/menus/task-picker-popover.tsx +0 -300
  166. package/src/components/ui/tu-do/boards/boardId/menus/task-priority-menu.tsx +0 -178
  167. package/src/components/ui/tu-do/boards/boardId/menus/task-projects-menu.tsx +0 -143
  168. package/src/components/ui/tu-do/boards/boardId/menus/task-related-menu.tsx +0 -242
  169. package/src/components/ui/tu-do/boards/boardId/menus/task-scheduling-menu.tsx +0 -465
  170. package/src/components/ui/tu-do/boards/boardId/menus/task-scheduling-utils.ts +0 -109
  171. package/src/components/ui/tu-do/boards/boardId/status-grouped-board.tsx +0 -533
  172. package/src/components/ui/tu-do/boards/boardId/status-section.tsx +0 -274
  173. package/src/components/ui/tu-do/boards/boardId/task-actions.tsx +0 -675
  174. package/src/components/ui/tu-do/boards/boardId/task-board-server-page.test.tsx +0 -209
  175. package/src/components/ui/tu-do/boards/boardId/task-board-server-page.tsx +0 -109
  176. package/src/components/ui/tu-do/boards/boardId/task-card/TaskCardCheckbox.tsx +0 -50
  177. package/src/components/ui/tu-do/boards/boardId/task-card/TaskCardDates.tsx +0 -123
  178. package/src/components/ui/tu-do/boards/boardId/task-card/TaskCardHeader.tsx +0 -97
  179. package/src/components/ui/tu-do/boards/boardId/task-card/TaskCardMetadata.tsx +0 -152
  180. package/src/components/ui/tu-do/boards/boardId/task-card/measured-task-card.tsx +0 -118
  181. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-archive-visibility.test.ts +0 -44
  182. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-archive-visibility.ts +0 -17
  183. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-checkbox-style.ts +0 -39
  184. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-comparator.test.ts +0 -104
  185. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-comparator.ts +0 -123
  186. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-completion-checkbox-visibility.test.ts +0 -31
  187. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-completion-checkbox-visibility.ts +0 -9
  188. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-identifier-row.test.tsx +0 -124
  189. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-identifier-row.tsx +0 -88
  190. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-label-options.ts +0 -24
  191. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-open-options.test.ts +0 -166
  192. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-open-options.ts +0 -148
  193. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-resource-context.test.ts +0 -113
  194. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-resource-context.ts +0 -50
  195. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-visibility.test.ts +0 -41
  196. package/src/components/ui/tu-do/boards/boardId/task-card/task-card-visibility.ts +0 -14
  197. package/src/components/ui/tu-do/boards/boardId/task-card/task-card.tsx +0 -2889
  198. package/src/components/ui/tu-do/boards/boardId/task-card/task-scheduling-badge.tsx +0 -174
  199. package/src/components/ui/tu-do/boards/boardId/task-dialogs/BoardEstimationConfigDialog.tsx +0 -499
  200. package/src/components/ui/tu-do/boards/boardId/task-dialogs/TaskCustomDateDialog.tsx +0 -109
  201. package/src/components/ui/tu-do/boards/boardId/task-dialogs/TaskDeleteDialog.tsx +0 -96
  202. package/src/components/ui/tu-do/boards/boardId/task-dialogs/TaskNewLabelDialog.tsx +0 -178
  203. package/src/components/ui/tu-do/boards/boardId/task-dialogs/TaskNewProjectDialog.tsx +0 -127
  204. package/src/components/ui/tu-do/boards/boardId/task-filter.test.tsx +0 -152
  205. package/src/components/ui/tu-do/boards/boardId/task-filter.tsx +0 -996
  206. package/src/components/ui/tu-do/boards/boardId/task-form.tsx +0 -498
  207. package/src/components/ui/tu-do/boards/boardId/task-list-drag-preview.test.ts +0 -101
  208. package/src/components/ui/tu-do/boards/boardId/task-list-form.tsx +0 -91
  209. package/src/components/ui/tu-do/boards/boardId/task-list.tsx +0 -535
  210. package/src/components/ui/tu-do/boards/boardId/task-parent-badge-state.test.ts +0 -64
  211. package/src/components/ui/tu-do/boards/boardId/task-parent-badge-state.ts +0 -31
  212. package/src/components/ui/tu-do/boards/boardId/task.tsx +0 -2
  213. package/src/components/ui/tu-do/boards/boardId/timeline/task-edit-dialog.tsx +0 -109
  214. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-display.ts +0 -103
  215. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-grid.tsx +0 -381
  216. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-task-row.tsx +0 -339
  217. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-toolbar.tsx +0 -356
  218. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-utils.test.ts +0 -169
  219. package/src/components/ui/tu-do/boards/boardId/timeline/timeline-utils.ts +0 -517
  220. package/src/components/ui/tu-do/boards/boardId/timeline-board-open-task.test.tsx +0 -164
  221. package/src/components/ui/tu-do/boards/boardId/timeline-board.test.tsx +0 -217
  222. package/src/components/ui/tu-do/boards/boardId/timeline-board.tsx +0 -834
  223. package/src/components/ui/tu-do/boards/boards-list-skeleton.tsx +0 -62
  224. package/src/components/ui/tu-do/boards/columns.tsx +0 -159
  225. package/src/components/ui/tu-do/boards/copy-board-dialog.tsx +0 -156
  226. package/src/components/ui/tu-do/boards/enhanced-boards-view.tsx +0 -347
  227. package/src/components/ui/tu-do/boards/form.tsx +0 -264
  228. package/src/components/ui/tu-do/boards/quick-create-board-dialog.tsx +0 -75
  229. package/src/components/ui/tu-do/boards/row-actions.tsx +0 -397
  230. package/src/components/ui/tu-do/boards/share-section.tsx +0 -100
  231. package/src/components/ui/tu-do/boards/workspace-projects-client-page.tsx +0 -192
  232. package/src/components/ui/tu-do/boards/workspace-projects-page.tsx +0 -155
  233. package/src/components/ui/tu-do/cycles/task-cycles-client.tsx +0 -753
  234. package/src/components/ui/tu-do/cycles/task-cycles-page.tsx +0 -103
  235. package/src/components/ui/tu-do/drafts/draft-card.tsx +0 -204
  236. package/src/components/ui/tu-do/drafts/draft-convert-dialog.tsx +0 -195
  237. package/src/components/ui/tu-do/drafts/drafts-page.tsx +0 -122
  238. package/src/components/ui/tu-do/drafts/task-drafts-page.tsx +0 -90
  239. package/src/components/ui/tu-do/estimates/client.tsx +0 -292
  240. package/src/components/ui/tu-do/estimates/edit-estimation-dialog.tsx +0 -374
  241. package/src/components/ui/tu-do/estimates/task-estimates-page.tsx +0 -57
  242. package/src/components/ui/tu-do/estimates/use-task-estimates.ts +0 -324
  243. package/src/components/ui/tu-do/habits/client.tsx +0 -263
  244. package/src/components/ui/tu-do/habits/habit-card.tsx +0 -183
  245. package/src/components/ui/tu-do/habits/habit-form-dialog.tsx +0 -701
  246. package/src/components/ui/tu-do/habits/habits-page.tsx +0 -27
  247. package/src/components/ui/tu-do/hooks/__tests__/useDraftPersistence.test.ts +0 -494
  248. package/src/components/ui/tu-do/hooks/__tests__/useTaskDialog.test.tsx +0 -127
  249. package/src/components/ui/tu-do/hooks/__tests__/useTaskDialogState.test.ts +0 -217
  250. package/src/components/ui/tu-do/hooks/__tests__/useTaskLabelManagement.test.tsx +0 -572
  251. package/src/components/ui/tu-do/hooks/__tests__/useTaskProjectManagement.test.tsx +0 -144
  252. package/src/components/ui/tu-do/hooks/useDraftPersistence.ts +0 -199
  253. package/src/components/ui/tu-do/hooks/useTaskCardRelationships.ts +0 -340
  254. package/src/components/ui/tu-do/hooks/useTaskDialog.ts +0 -122
  255. package/src/components/ui/tu-do/hooks/useTaskDialogState.ts +0 -145
  256. package/src/components/ui/tu-do/hooks/useTaskFormState.ts +0 -206
  257. package/src/components/ui/tu-do/hooks/useTaskKeyboardShortcuts.ts +0 -58
  258. package/src/components/ui/tu-do/hooks/useTaskLabelManagement.ts +0 -425
  259. package/src/components/ui/tu-do/hooks/useTaskProjectManagement.ts +0 -454
  260. package/src/components/ui/tu-do/initiatives/task-initiatives-client.tsx +0 -889
  261. package/src/components/ui/tu-do/initiatives/task-initiatives-page.tsx +0 -116
  262. package/src/components/ui/tu-do/labels/client.tsx +0 -201
  263. package/src/components/ui/tu-do/labels/components/delete-label-dialog.tsx +0 -57
  264. package/src/components/ui/tu-do/labels/components/label-card.tsx +0 -86
  265. package/src/components/ui/tu-do/labels/components/label-dialog.tsx +0 -259
  266. package/src/components/ui/tu-do/labels/components/label-list.tsx +0 -83
  267. package/src/components/ui/tu-do/labels/hooks/use-task-labels.ts +0 -170
  268. package/src/components/ui/tu-do/labels/task-labels-page.tsx +0 -53
  269. package/src/components/ui/tu-do/labels/types.ts +0 -6
  270. package/src/components/ui/tu-do/logs/columns.tsx +0 -755
  271. package/src/components/ui/tu-do/logs/logs-client.tsx +0 -1006
  272. package/src/components/ui/tu-do/logs/logs-timeline.tsx +0 -2483
  273. package/src/components/ui/tu-do/logs/task-logs-page.tsx +0 -59
  274. package/src/components/ui/tu-do/my-tasks/__tests__/my-tasks-content.test.tsx +0 -408
  275. package/src/components/ui/tu-do/my-tasks/__tests__/use-my-tasks-query.test.ts +0 -469
  276. package/src/components/ui/tu-do/my-tasks/__tests__/use-my-tasks-state.test.ts +0 -1017
  277. package/src/components/ui/tu-do/my-tasks/__tests__/use-task-context-actions.test.ts +0 -584
  278. package/src/components/ui/tu-do/my-tasks/ai-credit-indicator.tsx +0 -143
  279. package/src/components/ui/tu-do/my-tasks/board-selector-dialog.tsx +0 -239
  280. package/src/components/ui/tu-do/my-tasks/command-bar.tsx +0 -1351
  281. package/src/components/ui/tu-do/my-tasks/label-project-filter.tsx +0 -194
  282. package/src/components/ui/tu-do/my-tasks/my-task-context-menu.tsx +0 -356
  283. package/src/components/ui/tu-do/my-tasks/my-tasks-content.tsx +0 -328
  284. package/src/components/ui/tu-do/my-tasks/my-tasks-data-loader.tsx +0 -17
  285. package/src/components/ui/tu-do/my-tasks/my-tasks-filters.tsx +0 -258
  286. package/src/components/ui/tu-do/my-tasks/my-tasks-header.tsx +0 -121
  287. package/src/components/ui/tu-do/my-tasks/my-tasks-page.tsx +0 -40
  288. package/src/components/ui/tu-do/my-tasks/personal-placement-dialog.tsx +0 -188
  289. package/src/components/ui/tu-do/my-tasks/task-filter.tsx +0 -235
  290. package/src/components/ui/tu-do/my-tasks/task-list-with-completion.tsx +0 -832
  291. package/src/components/ui/tu-do/my-tasks/task-list.tsx +0 -258
  292. package/src/components/ui/tu-do/my-tasks/task-preview-dialog.tsx +0 -1597
  293. package/src/components/ui/tu-do/my-tasks/task-section.tsx +0 -261
  294. package/src/components/ui/tu-do/my-tasks/use-my-tasks-query.ts +0 -149
  295. package/src/components/ui/tu-do/my-tasks/use-my-tasks-state.ts +0 -1037
  296. package/src/components/ui/tu-do/my-tasks/use-task-context-actions.ts +0 -474
  297. package/src/components/ui/tu-do/notes/note-edit-dialog.tsx +0 -118
  298. package/src/components/ui/tu-do/notes/note-list.tsx +0 -799
  299. package/src/components/ui/tu-do/notes/notes-content.tsx +0 -178
  300. package/src/components/ui/tu-do/notes/notes-page.tsx +0 -27
  301. package/src/components/ui/tu-do/progress/task-progress-import-panel.tsx +0 -60
  302. package/src/components/ui/tu-do/progress/task-progress-leaderboards-panel.tsx +0 -156
  303. package/src/components/ui/tu-do/progress/task-progress-page.tsx +0 -382
  304. package/src/components/ui/tu-do/progress/task-progress-panels.tsx +0 -303
  305. package/src/components/ui/tu-do/projects/components/index.ts +0 -11
  306. package/src/components/ui/tu-do/projects/components/project-actions-menu.tsx +0 -66
  307. package/src/components/ui/tu-do/projects/components/project-badges.tsx +0 -84
  308. package/src/components/ui/tu-do/projects/components/project-filter-menu.tsx +0 -170
  309. package/src/components/ui/tu-do/projects/components/project-grid-card.tsx +0 -198
  310. package/src/components/ui/tu-do/projects/components/project-list-item.tsx +0 -195
  311. package/src/components/ui/tu-do/projects/components/project-metrics.tsx +0 -87
  312. package/src/components/ui/tu-do/projects/components/project-progress-meter.tsx +0 -33
  313. package/src/components/ui/tu-do/projects/components/project-sort-menu.tsx +0 -71
  314. package/src/components/ui/tu-do/projects/components/projects-empty-state.tsx +0 -38
  315. package/src/components/ui/tu-do/projects/components/projects-loading-state.tsx +0 -26
  316. package/src/components/ui/tu-do/projects/components/projects-toolbar.tsx +0 -179
  317. package/src/components/ui/tu-do/projects/dialogs/create-project-dialog.tsx +0 -117
  318. package/src/components/ui/tu-do/projects/dialogs/edit-project-dialog.tsx +0 -125
  319. package/src/components/ui/tu-do/projects/dialogs/index.ts +0 -3
  320. package/src/components/ui/tu-do/projects/dialogs/manage-tasks-dialog.tsx +0 -205
  321. package/src/components/ui/tu-do/projects/hooks/index.ts +0 -2
  322. package/src/components/ui/tu-do/projects/hooks/use-project-filters.ts +0 -248
  323. package/src/components/ui/tu-do/projects/hooks/use-task-projects.ts +0 -238
  324. package/src/components/ui/tu-do/projects/projectId/components/__tests__/tasks-tab-layout.test.tsx +0 -169
  325. package/src/components/ui/tu-do/projects/projectId/components/documents-tab.tsx +0 -90
  326. package/src/components/ui/tu-do/projects/projectId/components/index.ts +0 -9
  327. package/src/components/ui/tu-do/projects/projectId/components/overview/description-card.tsx +0 -77
  328. package/src/components/ui/tu-do/projects/projectId/components/overview/linked-documents-card.tsx +0 -81
  329. package/src/components/ui/tu-do/projects/projectId/components/overview/linked-tasks-card.tsx +0 -85
  330. package/src/components/ui/tu-do/projects/projectId/components/overview/updates-card.tsx +0 -85
  331. package/src/components/ui/tu-do/projects/projectId/components/overview-tab.tsx +0 -35
  332. package/src/components/ui/tu-do/projects/projectId/components/project-configuration.tsx +0 -229
  333. package/src/components/ui/tu-do/projects/projectId/components/project-header.tsx +0 -115
  334. package/src/components/ui/tu-do/projects/projectId/components/project-lead-selector.tsx +0 -55
  335. package/src/components/ui/tu-do/projects/projectId/components/project-overview-context.tsx +0 -82
  336. package/src/components/ui/tu-do/projects/projectId/components/project-sidebar.tsx +0 -246
  337. package/src/components/ui/tu-do/projects/projectId/components/tasks-tab.tsx +0 -266
  338. package/src/components/ui/tu-do/projects/projectId/components/update-card.tsx +0 -162
  339. package/src/components/ui/tu-do/projects/projectId/components/updates-tab.tsx +0 -129
  340. package/src/components/ui/tu-do/projects/projectId/dialogs/index.ts +0 -1
  341. package/src/components/ui/tu-do/projects/projectId/dialogs/link-task-dialog.tsx +0 -114
  342. package/src/components/ui/tu-do/projects/projectId/hooks/index.ts +0 -4
  343. package/src/components/ui/tu-do/projects/projectId/hooks/use-animation-variants.ts +0 -68
  344. package/src/components/ui/tu-do/projects/projectId/hooks/use-project-form.ts +0 -214
  345. package/src/components/ui/tu-do/projects/projectId/hooks/use-project-updates.ts +0 -209
  346. package/src/components/ui/tu-do/projects/projectId/hooks/use-task-linking.ts +0 -101
  347. package/src/components/ui/tu-do/projects/projectId/task-project-detail-page-client.tsx +0 -93
  348. package/src/components/ui/tu-do/projects/projectId/task-project-detail-page.tsx +0 -78
  349. package/src/components/ui/tu-do/projects/projectId/task-project-detail.tsx +0 -367
  350. package/src/components/ui/tu-do/projects/projectId/types.ts +0 -51
  351. package/src/components/ui/tu-do/projects/task-projects-client.tsx +0 -270
  352. package/src/components/ui/tu-do/projects/task-projects-page.tsx +0 -97
  353. package/src/components/ui/tu-do/projects/types.ts +0 -62
  354. package/src/components/ui/tu-do/providers/__tests__/task-dialog-provider.test.tsx +0 -616
  355. package/src/components/ui/tu-do/providers/task-dialog-provider.tsx +0 -923
  356. package/src/components/ui/tu-do/providers/workspace-presence-provider.tsx +0 -88
  357. package/src/components/ui/tu-do/shared/AccessibleButton.tsx +0 -79
  358. package/src/components/ui/tu-do/shared/__tests__/assignee-select.test.tsx +0 -143
  359. package/src/components/ui/tu-do/shared/__tests__/board-client.test.tsx +0 -358
  360. package/src/components/ui/tu-do/shared/__tests__/board-header.test.tsx +0 -598
  361. package/src/components/ui/tu-do/shared/__tests__/board-query-cache.test.ts +0 -219
  362. package/src/components/ui/tu-do/shared/__tests__/board-switcher.test.tsx +0 -374
  363. package/src/components/ui/tu-do/shared/__tests__/board-views.test.tsx +0 -1288
  364. package/src/components/ui/tu-do/shared/__tests__/create-list-dialog.test.tsx +0 -118
  365. package/src/components/ui/tu-do/shared/__tests__/task-board-loading-state.test.tsx +0 -99
  366. package/src/components/ui/tu-do/shared/__tests__/task-cache-patches.test.ts +0 -147
  367. package/src/components/ui/tu-do/shared/__tests__/task-detail-page.test.tsx +0 -170
  368. package/src/components/ui/tu-do/shared/__tests__/task-dialog-manager.test.tsx +0 -945
  369. package/src/components/ui/tu-do/shared/__tests__/task-legacy-route-recovery.test.tsx +0 -101
  370. package/src/components/ui/tu-do/shared/__tests__/use-progressive-board-loader.test.tsx +0 -645
  371. package/src/components/ui/tu-do/shared/assignee-select.tsx +0 -592
  372. package/src/components/ui/tu-do/shared/board-broadcast-context.tsx +0 -45
  373. package/src/components/ui/tu-do/shared/board-client.tsx +0 -283
  374. package/src/components/ui/tu-do/shared/board-config-storage.ts +0 -94
  375. package/src/components/ui/tu-do/shared/board-header.tsx +0 -803
  376. package/src/components/ui/tu-do/shared/board-layout-settings.tsx +0 -1134
  377. package/src/components/ui/tu-do/shared/board-query-cache.ts +0 -157
  378. package/src/components/ui/tu-do/shared/board-switcher.tsx +0 -322
  379. package/src/components/ui/tu-do/shared/board-user-presence-avatars.tsx +0 -578
  380. package/src/components/ui/tu-do/shared/board-views.tsx +0 -1238
  381. package/src/components/ui/tu-do/shared/clear-menu-item.tsx +0 -34
  382. package/src/components/ui/tu-do/shared/create-list-dialog.tsx +0 -401
  383. package/src/components/ui/tu-do/shared/cursor-overlay-multi-wrapper.tsx +0 -245
  384. package/src/components/ui/tu-do/shared/cursor-overlay.tsx +0 -78
  385. package/src/components/ui/tu-do/shared/custom-date-picker/custom-date-picker-dialog.tsx +0 -157
  386. package/src/components/ui/tu-do/shared/description-overflow-warning-dialog.tsx +0 -68
  387. package/src/components/ui/tu-do/shared/edit-list-dialog.tsx +0 -383
  388. package/src/components/ui/tu-do/shared/empty-state-card.tsx +0 -46
  389. package/src/components/ui/tu-do/shared/estimation-mapping.test.ts +0 -32
  390. package/src/components/ui/tu-do/shared/estimation-mapping.ts +0 -74
  391. package/src/components/ui/tu-do/shared/estimation-utils.ts +0 -54
  392. package/src/components/ui/tu-do/shared/fade-setting-initializer.tsx +0 -61
  393. package/src/components/ui/tu-do/shared/label-chip.tsx +0 -46
  394. package/src/components/ui/tu-do/shared/list-view-context-menu.test.tsx +0 -203
  395. package/src/components/ui/tu-do/shared/list-view-sorting.test.ts +0 -50
  396. package/src/components/ui/tu-do/shared/list-view-sorting.ts +0 -108
  397. package/src/components/ui/tu-do/shared/list-view.tsx +0 -1248
  398. package/src/components/ui/tu-do/shared/mention-system/__tests__/mention-system.test.ts +0 -250
  399. package/src/components/ui/tu-do/shared/mention-system/mention-menu.tsx +0 -217
  400. package/src/components/ui/tu-do/shared/mention-system/types.ts +0 -141
  401. package/src/components/ui/tu-do/shared/mention-system/use-mention-suggestions.ts +0 -244
  402. package/src/components/ui/tu-do/shared/progressive-loader-context.tsx +0 -45
  403. package/src/components/ui/tu-do/shared/recent-sidebar-events.ts +0 -58
  404. package/src/components/ui/tu-do/shared/recycle-bin-panel.tsx +0 -651
  405. package/src/components/ui/tu-do/shared/relationship-task-identifier.ts +0 -14
  406. package/src/components/ui/tu-do/shared/slash-commands/__tests__/slash-commands.test.ts +0 -315
  407. package/src/components/ui/tu-do/shared/slash-commands/definitions.ts +0 -167
  408. package/src/components/ui/tu-do/shared/slash-commands/slash-command-menu.tsx +0 -114
  409. package/src/components/ui/tu-do/shared/special-task-list-pins.ts +0 -51
  410. package/src/components/ui/tu-do/shared/sync-warning-dialog.tsx +0 -133
  411. package/src/components/ui/tu-do/shared/task-board-errors.ts +0 -19
  412. package/src/components/ui/tu-do/shared/task-board-loading-state.tsx +0 -82
  413. package/src/components/ui/tu-do/shared/task-cache-patches.ts +0 -394
  414. package/src/components/ui/tu-do/shared/task-detail-page.tsx +0 -176
  415. package/src/components/ui/tu-do/shared/task-detail-server-page.tsx +0 -37
  416. package/src/components/ui/tu-do/shared/task-dialog-manager.tsx +0 -596
  417. package/src/components/ui/tu-do/shared/task-dialog-presentation.test.ts +0 -53
  418. package/src/components/ui/tu-do/shared/task-dialog-presentation.ts +0 -30
  419. package/src/components/ui/tu-do/shared/task-dialog-wrapper.tsx +0 -28
  420. package/src/components/ui/tu-do/shared/task-due-date-visibility.test.ts +0 -72
  421. package/src/components/ui/tu-do/shared/task-due-date-visibility.ts +0 -38
  422. package/src/components/ui/tu-do/shared/task-edit-dialog/components/compact-task-create-popover.test.tsx +0 -325
  423. package/src/components/ui/tu-do/shared/task-edit-dialog/components/compact-task-create-popover.tsx +0 -268
  424. package/src/components/ui/tu-do/shared/task-edit-dialog/components/mobile-floating-save-button.tsx +0 -46
  425. package/src/components/ui/tu-do/shared/task-edit-dialog/components/quick-settings-popover.tsx +0 -198
  426. package/src/components/ui/tu-do/shared/task-edit-dialog/components/smart-task-suggestions-panel.test.tsx +0 -129
  427. package/src/components/ui/tu-do/shared/task-edit-dialog/components/smart-task-suggestions-panel.tsx +0 -358
  428. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-description-editor.tsx +0 -496
  429. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-dialog-header.tsx +0 -545
  430. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-list-picker-panel.tsx +0 -220
  431. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-list-selector.tsx +0 -165
  432. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-list-trigger-styles.ts +0 -69
  433. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-name-input.test.tsx +0 -180
  434. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-name-input.tsx +0 -218
  435. package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-suggestion-menus.tsx +0 -148
  436. package/src/components/ui/tu-do/shared/task-edit-dialog/constants.ts +0 -18
  437. package/src/components/ui/tu-do/shared/task-edit-dialog/context-menu-guard.test.ts +0 -37
  438. package/src/components/ui/tu-do/shared/task-edit-dialog/description-diff-viewer.tsx +0 -1665
  439. package/src/components/ui/tu-do/shared/task-edit-dialog/description-versions.test.ts +0 -97
  440. package/src/components/ui/tu-do/shared/task-edit-dialog/description-versions.ts +0 -210
  441. package/src/components/ui/tu-do/shared/task-edit-dialog/field-diff-viewer.tsx +0 -716
  442. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-task-dialog-close.test.ts +0 -218
  443. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-task-dialog-keyboard-shortcuts.test.ts +0 -140
  444. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-task-mutations.test.tsx +0 -231
  445. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-task-overrides.test.ts +0 -412
  446. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-task-realtime-sync.test.tsx +0 -237
  447. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-task-yjs-sync.test.ts +0 -190
  448. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/__tests__/use-update-shared-task.test.ts +0 -107
  449. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/task-api.test.ts +0 -171
  450. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/task-api.ts +0 -296
  451. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-editor-commands.ts +0 -314
  452. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-suggestion-menus.ts +0 -503
  453. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-change-detection.ts +0 -175
  454. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-data.ts +0 -401
  455. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-dependencies.ts +0 -773
  456. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-dialog-close.ts +0 -193
  457. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-dialog-keyboard-shortcuts.ts +0 -365
  458. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-form-reset.ts +0 -231
  459. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-form-state.ts +0 -307
  460. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-mutations.ts +0 -609
  461. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-overrides.ts +0 -134
  462. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-realtime-sync.ts +0 -270
  463. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-relationships.test.tsx +0 -212
  464. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-relationships.ts +0 -554
  465. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-revert.ts +0 -140
  466. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-save.test.ts +0 -289
  467. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-save.ts +0 -1473
  468. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-snapshot.ts +0 -59
  469. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-yjs-sync.ts +0 -224
  470. package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-update-shared-task.ts +0 -60
  471. package/src/components/ui/tu-do/shared/task-edit-dialog/personal-overrides-section.tsx +0 -368
  472. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/components/clickable-task-item.tsx +0 -90
  473. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/components/index.ts +0 -4
  474. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/components/subtask-action-buttons.tsx +0 -140
  475. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/components/tab-button.tsx +0 -76
  476. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/components/task-relationship-action-buttons.tsx +0 -178
  477. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/dependencies-section.tsx +0 -140
  478. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/index.ts +0 -35
  479. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/parent-section.tsx +0 -70
  480. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/related-section.tsx +0 -81
  481. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/subtasks-section.tsx +0 -87
  482. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/task-search-popover.tsx +0 -229
  483. package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/types/task-relationships.types.ts +0 -194
  484. package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.test.tsx +0 -91
  485. package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.tsx +0 -365
  486. package/src/components/ui/tu-do/shared/task-edit-dialog/task-activity-section.tsx +0 -802
  487. package/src/components/ui/tu-do/shared/task-edit-dialog/task-delete-dialog.tsx +0 -104
  488. package/src/components/ui/tu-do/shared/task-edit-dialog/task-description-change-dialog.test.tsx +0 -63
  489. package/src/components/ui/tu-do/shared/task-edit-dialog/task-description-change-dialog.tsx +0 -218
  490. package/src/components/ui/tu-do/shared/task-edit-dialog/task-description-restore-banner.tsx +0 -83
  491. package/src/components/ui/tu-do/shared/task-edit-dialog/task-description-version-restore-dialog.test.tsx +0 -120
  492. package/src/components/ui/tu-do/shared/task-edit-dialog/task-description-version-restore-dialog.tsx +0 -180
  493. package/src/components/ui/tu-do/shared/task-edit-dialog/task-dialog-actions.test.tsx +0 -68
  494. package/src/components/ui/tu-do/shared/task-edit-dialog/task-dialog-actions.tsx +0 -239
  495. package/src/components/ui/tu-do/shared/task-edit-dialog/task-instances-section.tsx +0 -173
  496. package/src/components/ui/tu-do/shared/task-edit-dialog/task-properties-section.test.tsx +0 -303
  497. package/src/components/ui/tu-do/shared/task-edit-dialog/task-properties-section.tsx +0 -2213
  498. package/src/components/ui/tu-do/shared/task-edit-dialog/task-relationships-properties.tsx +0 -315
  499. package/src/components/ui/tu-do/shared/task-edit-dialog/task-snapshot-dialog.tsx +0 -167
  500. package/src/components/ui/tu-do/shared/task-edit-dialog/types/pending-relationship.test.ts +0 -52
  501. package/src/components/ui/tu-do/shared/task-edit-dialog/types/pending-relationship.ts +0 -134
  502. package/src/components/ui/tu-do/shared/task-edit-dialog/types.ts +0 -64
  503. package/src/components/ui/tu-do/shared/task-edit-dialog/user-display.test.ts +0 -58
  504. package/src/components/ui/tu-do/shared/task-edit-dialog/user-display.ts +0 -45
  505. package/src/components/ui/tu-do/shared/task-edit-dialog/utils/inline-task-target-list.test.ts +0 -98
  506. package/src/components/ui/tu-do/shared/task-edit-dialog/utils/inline-task-target-list.ts +0 -39
  507. package/src/components/ui/tu-do/shared/task-edit-dialog/utils.test.ts +0 -504
  508. package/src/components/ui/tu-do/shared/task-edit-dialog/utils.ts +0 -582
  509. package/src/components/ui/tu-do/shared/task-edit-dialog/yjs-prosemirror-compat.test.ts +0 -65
  510. package/src/components/ui/tu-do/shared/task-edit-dialog.tsx +0 -3196
  511. package/src/components/ui/tu-do/shared/task-estimation-display.tsx +0 -52
  512. package/src/components/ui/tu-do/shared/task-estimation-picker.tsx +0 -226
  513. package/src/components/ui/tu-do/shared/task-filter.types.ts +0 -65
  514. package/src/components/ui/tu-do/shared/task-label-selector.tsx +0 -217
  515. package/src/components/ui/tu-do/shared/task-labels-display.test.tsx +0 -51
  516. package/src/components/ui/tu-do/shared/task-labels-display.tsx +0 -119
  517. package/src/components/ui/tu-do/shared/task-legacy-route-recovery.tsx +0 -65
  518. package/src/components/ui/tu-do/shared/task-projects-display.tsx +0 -80
  519. package/src/components/ui/tu-do/shared/task-quick-create-target-list.ts +0 -20
  520. package/src/components/ui/tu-do/shared/task-resource-search-field.tsx +0 -49
  521. package/src/components/ui/tu-do/shared/task-resource-search-filters.ts +0 -27
  522. package/src/components/ui/tu-do/shared/task-row-actions-menu.test.tsx +0 -138
  523. package/src/components/ui/tu-do/shared/task-row-actions-menu.tsx +0 -402
  524. package/src/components/ui/tu-do/shared/task-share-dialog/components/share-link-settings.tsx +0 -86
  525. package/src/components/ui/tu-do/shared/task-share-dialog/components/shares-list.tsx +0 -85
  526. package/src/components/ui/tu-do/shared/task-share-dialog/hooks/use-task-sharing.ts +0 -296
  527. package/src/components/ui/tu-do/shared/task-share-dialog.tsx +0 -144
  528. package/src/components/ui/tu-do/shared/task-sound-effects.test.ts +0 -189
  529. package/src/components/ui/tu-do/shared/task-sound-effects.tsx +0 -468
  530. package/src/components/ui/tu-do/shared/task-url.ts +0 -56
  531. package/src/components/ui/tu-do/shared/text-diff-viewer.tsx +0 -55
  532. package/src/components/ui/tu-do/shared/types.ts +0 -14
  533. package/src/components/ui/tu-do/shared/unsaved-changes-warning-dialog.tsx +0 -71
  534. package/src/components/ui/tu-do/shared/use-progressive-board-loader.ts +0 -312
  535. package/src/components/ui/tu-do/shared/user-avatar.tsx +0 -46
  536. package/src/components/ui/tu-do/shared/user-presence-avatars.tsx +0 -415
  537. package/src/components/ui/tu-do/shared/utils/translate-task-list-display-name.ts +0 -28
  538. package/src/components/ui/tu-do/tasks-route-context.tsx +0 -50
  539. package/src/components/ui/tu-do/templates/client.tsx +0 -505
  540. package/src/components/ui/tu-do/templates/marketplace/client.tsx +0 -487
  541. package/src/components/ui/tu-do/templates/marketplace/task-marketplace-page.tsx +0 -169
  542. package/src/components/ui/tu-do/templates/save-as-template-dialog.tsx +0 -381
  543. package/src/components/ui/tu-do/templates/task-template-api.ts +0 -142
  544. package/src/components/ui/tu-do/templates/task-template-card.tsx +0 -118
  545. package/src/components/ui/tu-do/templates/task-template-client.test.tsx +0 -52
  546. package/src/components/ui/tu-do/templates/task-template-client.tsx +0 -258
  547. package/src/components/ui/tu-do/templates/task-template-dialogs.test.tsx +0 -167
  548. package/src/components/ui/tu-do/templates/task-template-dialogs.tsx +0 -376
  549. package/src/components/ui/tu-do/templates/task-templates-hub.test.tsx +0 -114
  550. package/src/components/ui/tu-do/templates/task-templates-hub.tsx +0 -53
  551. package/src/components/ui/tu-do/templates/task-templates-page.tsx +0 -157
  552. package/src/components/ui/tu-do/templates/templateId/client.tsx +0 -674
  553. package/src/components/ui/tu-do/templates/templateId/edit-template-dialog.tsx +0 -300
  554. package/src/components/ui/tu-do/templates/templateId/share-template-dialog.tsx +0 -261
  555. package/src/components/ui/tu-do/templates/templateId/task-template-detail-page-client.tsx +0 -127
  556. package/src/components/ui/tu-do/templates/templateId/task-template-detail-page.tsx +0 -89
  557. package/src/components/ui/tu-do/templates/templateId/use-template-dialog.tsx +0 -165
  558. package/src/components/ui/tu-do/templates/types.ts +0 -53
  559. package/src/components/ui/tu-do/utils/__tests__/label-colors.test.ts +0 -43
  560. package/src/components/ui/tu-do/utils/__tests__/taskColorUtils.test.ts +0 -267
  561. package/src/components/ui/tu-do/utils/__tests__/taskConstants.test.ts +0 -178
  562. package/src/components/ui/tu-do/utils/__tests__/taskDateUtils.test.ts +0 -226
  563. package/src/components/ui/tu-do/utils/__tests__/weekDateUtils.test.ts +0 -182
  564. package/src/components/ui/tu-do/utils/label-colors.test.ts +0 -15
  565. package/src/components/ui/tu-do/utils/label-colors.ts +0 -59
  566. package/src/components/ui/tu-do/utils/taskColorUtils.ts +0 -116
  567. package/src/components/ui/tu-do/utils/taskConstants.ts +0 -102
  568. package/src/components/ui/tu-do/utils/taskDateUtils.ts +0 -81
  569. package/src/components/ui/tu-do/utils/taskPriorityUtils.tsx +0 -80
  570. package/src/components/ui/tu-do/utils/weekDateUtils.ts +0 -64
  571. package/src/hooks/__tests__/use-task-actions.test.tsx +0 -2098
  572. package/src/hooks/__tests__/useBoardPresence.test.tsx +0 -191
  573. package/src/hooks/__tests__/useBoardRealtime.test.tsx +0 -1036
  574. package/src/hooks/__tests__/useCursorTracking.test.tsx +0 -212
  575. package/src/hooks/task-actions-personal-external.ts +0 -313
  576. package/src/hooks/use-task-actions.ts +0 -1910
  577. package/src/hooks/useBoardPresence.ts +0 -364
  578. package/src/hooks/useBoardRealtime.ts +0 -428
  579. package/src/hooks/useBoardRealtime.types.ts +0 -56
  580. package/src/hooks/useBoardRealtimeEventHandler.ts +0 -452
  581. package/src/hooks/useCursorTracking.ts +0 -402
  582. package/src/hooks/usePresence.ts +0 -272
  583. package/src/hooks/useTaskUserRealtime.ts +0 -340
  584. /package/src/{components/ui/tu-do/shared → lib}/task-open-events.ts +0 -0
@@ -1,3196 +0,0 @@
1
- 'use client';
2
-
3
- import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
4
- import type { Editor, JSONContent } from '@tiptap/react';
5
- import { Archive, CheckCircle2, Trash2 } from '@tuturuuu/icons';
6
- import {
7
- checkWorkspacePermission,
8
- createWorkspaceTask,
9
- createWorkspaceTaskSuggestions,
10
- updateWorkspaceCalendarEvent,
11
- uploadWorkspaceTaskFile,
12
- } from '@tuturuuu/internal-api';
13
- import type { WorkspaceTaskSuggestionTask } from '@tuturuuu/internal-api/tasks';
14
- import { getWorkspaceTaskHistory } from '@tuturuuu/internal-api/tasks';
15
- import type { Task } from '@tuturuuu/types/primitives/Task';
16
- import type { TaskList } from '@tuturuuu/types/primitives/TaskList';
17
- import { Button } from '@tuturuuu/ui/button';
18
- import { Dialog, DialogContent, DialogTitle } from '@tuturuuu/ui/dialog';
19
- import { SUPABASE_PROVIDER_SYNC_ORIGIN } from '@tuturuuu/ui/hooks/supabase-provider';
20
- import { useYjsCollaboration } from '@tuturuuu/ui/hooks/use-yjs-collaboration';
21
- import { toast } from '@tuturuuu/ui/sonner';
22
- import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
23
- import { MAX_TASK_DESCRIPTION_LENGTH } from '@tuturuuu/utils/constants';
24
- import { convertListItemToTask } from '@tuturuuu/utils/editor';
25
- import {
26
- getTicketIdentifier,
27
- invalidateTaskCaches,
28
- } from '@tuturuuu/utils/task-helper';
29
- import {
30
- convertJsonContentToYjsState,
31
- convertYjsStateToJsonContent,
32
- } from '@tuturuuu/utils/yjs-helper';
33
- import dayjs from 'dayjs';
34
- import { usePathname } from 'next/navigation';
35
- import { useLocale, useTranslations } from 'next-intl';
36
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
37
- import * as Y from 'yjs';
38
- import { getTaskApiUrl } from '../../../../lib/tasks-app-url';
39
- import { BoardEstimationConfigDialog } from '../boards/boardId/task-dialogs/BoardEstimationConfigDialog';
40
- import { TaskNewLabelDialog } from '../boards/boardId/task-dialogs/TaskNewLabelDialog';
41
- import { TaskNewProjectDialog } from '../boards/boardId/task-dialogs/TaskNewProjectDialog';
42
- import { useTaskDialogContext } from '../providers/task-dialog-provider';
43
- import { useOptionalWorkspacePresenceContext } from '../providers/workspace-presence-provider';
44
- import { getRandomNewLabelColor } from '../utils/taskConstants';
45
- import {
46
- type BoardBroadcastFn,
47
- getActiveBroadcast,
48
- } from './board-broadcast-context';
49
- import { DescriptionOverflowWarningDialog } from './description-overflow-warning-dialog';
50
- import { createInitialSuggestionState } from './mention-system/types';
51
- import { SyncWarningDialog } from './sync-warning-dialog';
52
- import {
53
- normalizeTaskDialogPresentation,
54
- resolveTaskDialogOpeningPresentation,
55
- type TaskDialogPresentation,
56
- } from './task-dialog-presentation';
57
- import { CompactTaskDialogPanel } from './task-edit-dialog/components/compact-task-create-popover';
58
- import { MobileFloatingSaveButton } from './task-edit-dialog/components/mobile-floating-save-button';
59
- import {
60
- SmartTaskSuggestionsButton,
61
- SmartTaskSuggestionsPanel,
62
- } from './task-edit-dialog/components/smart-task-suggestions-panel';
63
- import { TaskDescriptionEditor } from './task-edit-dialog/components/task-description-editor';
64
- import {
65
- getTaskDialogHeaderInfo,
66
- TaskDialogHeader,
67
- } from './task-edit-dialog/components/task-dialog-header';
68
- import { TaskNameInput } from './task-edit-dialog/components/task-name-input';
69
- import { TaskSuggestionMenus } from './task-edit-dialog/components/task-suggestion-menus';
70
- import { NAME_UPDATE_DEBOUNCE_MS } from './task-edit-dialog/constants';
71
- import {
72
- buildRecoverableTaskDescriptionVersions,
73
- type RecoverableTaskDescriptionVersion,
74
- } from './task-edit-dialog/description-versions';
75
- import {
76
- fetchWorkspaceTaskDescription,
77
- updateWorkspaceTaskDescription,
78
- } from './task-edit-dialog/hooks/task-api';
79
- import { useEditorCommands } from './task-edit-dialog/hooks/use-editor-commands';
80
- import { useSuggestionMenus } from './task-edit-dialog/hooks/use-suggestion-menus';
81
- import { useTaskChangeDetection } from './task-edit-dialog/hooks/use-task-change-detection';
82
- import {
83
- type SharedTaskContext,
84
- useTaskData,
85
- } from './task-edit-dialog/hooks/use-task-data';
86
- import { useTaskDependencies } from './task-edit-dialog/hooks/use-task-dependencies';
87
- import { useTaskDialogClose } from './task-edit-dialog/hooks/use-task-dialog-close';
88
- import { useTaskDialogKeyboardShortcuts } from './task-edit-dialog/hooks/use-task-dialog-keyboard-shortcuts';
89
- import { useTaskFormReset } from './task-edit-dialog/hooks/use-task-form-reset';
90
- import { useTaskFormState } from './task-edit-dialog/hooks/use-task-form-state';
91
- import { useTaskMutations } from './task-edit-dialog/hooks/use-task-mutations';
92
- import { useTaskRealtimeSync } from './task-edit-dialog/hooks/use-task-realtime-sync';
93
- import { useTaskRelationships } from './task-edit-dialog/hooks/use-task-relationships';
94
- import { useTaskSave } from './task-edit-dialog/hooks/use-task-save';
95
- import { useTaskYjsSync } from './task-edit-dialog/hooks/use-task-yjs-sync';
96
- import { PersonalOverridesSection } from './task-edit-dialog/personal-overrides-section';
97
- import { TaskActivitySection } from './task-edit-dialog/task-activity-section';
98
- import { TaskDeleteDialog } from './task-edit-dialog/task-delete-dialog';
99
- import { TaskDescriptionRestoreBanner } from './task-edit-dialog/task-description-restore-banner';
100
- import { TaskDescriptionVersionRestoreDialog } from './task-edit-dialog/task-description-version-restore-dialog';
101
- import { TaskInstancesSection } from './task-edit-dialog/task-instances-section';
102
- import { TaskPropertiesSection } from './task-edit-dialog/task-properties-section';
103
- import { TaskRelationshipsProperties } from './task-edit-dialog/task-relationships-properties';
104
- import type { WorkspaceTaskLabel } from './task-edit-dialog/types';
105
- // Re-export relationship types
106
- import type {
107
- PendingRelationship,
108
- PendingRelationshipType,
109
- PendingTaskRelationships,
110
- } from './task-edit-dialog/types/pending-relationship';
111
- import { getSeededPendingTaskRelationships } from './task-edit-dialog/types/pending-relationship';
112
- import {
113
- getTaskDialogUserDisplayName,
114
- normalizeTaskDialogCurrentUser,
115
- type TaskDialogCurrentUser,
116
- type TaskDialogUserIdentity,
117
- } from './task-edit-dialog/user-display';
118
- import {
119
- broadcastTaskDescriptionUpsert,
120
- canPersistTaskDescriptionSnapshot,
121
- clearDraft,
122
- createTaskDescriptionPersistenceGuardState,
123
- getDescriptionContent,
124
- getDraftStorageKey,
125
- getTaskDescriptionPercentLeft,
126
- getTaskDescriptionPreviewText,
127
- getTaskDescriptionStorageLength,
128
- normalizeTaskDescriptionSnapshot,
129
- recordTaskDescriptionEditorSnapshot,
130
- saveAndVerifyYjsDescriptionToDatabase,
131
- saveYjsDescriptionToDatabase,
132
- serializeTaskDescriptionPersistenceSnapshot,
133
- shouldPreserveNativeContextMenu,
134
- type TaskDescriptionPersistenceGuardState,
135
- updateTaskDescriptionCaches,
136
- } from './task-edit-dialog/utils';
137
- import {
138
- resolveInlineTaskTargetList,
139
- resolveInlineTaskTargetWorkspaceId,
140
- } from './task-edit-dialog/utils/inline-task-target-list';
141
- import { TaskShareDialog } from './task-share-dialog';
142
- import type { TaskFilters } from './types';
143
- import { UnsavedChangesWarningDialog } from './unsaved-changes-warning-dialog';
144
-
145
- type AssigneeMemberSource = 'workspace' | 'board' | 'workspace-and-board';
146
-
147
- const EMPTY_TASK_DESCRIPTION_DOC: JSONContent = {
148
- type: 'doc',
149
- content: [{ type: 'paragraph' }],
150
- };
151
-
152
- export {
153
- type DialogHeaderInfo,
154
- getTaskDialogHeaderInfo,
155
- } from './task-edit-dialog/components/task-dialog-header';
156
- export type { PendingRelationship, PendingRelationshipType, SharedTaskContext };
157
-
158
- export interface TaskEditDialogProps {
159
- wsId: string;
160
- taskWsId?: string;
161
- task?: Task;
162
- boardId: string;
163
- visibleBoardId?: string;
164
- visibleTaskSnapshot?: Partial<Task>;
165
- isOpen: boolean;
166
- /** Present when opened via /shared/task/[shareCode] */
167
- shareCode?: string;
168
- /** Permission returned from shared-task API */
169
- sharedPermission?: 'view' | 'edit';
170
- availableLists?: TaskList[];
171
- filters?: TaskFilters;
172
- mode?: 'edit' | 'create';
173
- collaborationMode?: boolean;
174
- /** Whether realtime features (Yjs sync, presence avatars) are enabled - true for all tiers */
175
- realtimeEnabled?: boolean;
176
- isHydratingTask?: boolean;
177
- taskLoadError?: boolean;
178
- taskHydrationVersion?: number;
179
- isPersonalWorkspace?: boolean;
180
- canUseBoardAssignees?: boolean;
181
- assigneeMemberSource?: AssigneeMemberSource;
182
- parentTaskId?: string;
183
- parentTaskName?: string;
184
- pendingRelationship?: PendingRelationship;
185
- currentUser?: TaskDialogCurrentUser;
186
- /** Pre-loaded data for shared task context - bypasses internal fetches when provided */
187
- sharedContext?: SharedTaskContext;
188
- /** Whether draft mode is enabled from user settings */
189
- draftModeEnabled?: boolean;
190
- /** Preferred opening presentation for normal task dialogs */
191
- defaultPresentation?: TaskDialogPresentation;
192
- /** When editing an existing draft, this is the draft ID */
193
- draftId?: string;
194
- onClose: () => void;
195
- onUpdate: () => void;
196
- onNavigateToTask?: (taskId: string) => Promise<void>;
197
- onAddSubtask?: () => void;
198
- onAddParentTask?: () => void;
199
- onAddBlockingTask?: () => void;
200
- onAddBlockedByTask?: () => void;
201
- onAddRelatedTask?: () => void;
202
- onRetryTaskLoad?: () => void;
203
- }
204
-
205
- export function TaskEditDialog({
206
- wsId,
207
- taskWsId,
208
- task,
209
- boardId,
210
- visibleBoardId,
211
- visibleTaskSnapshot,
212
- isOpen,
213
- shareCode,
214
- sharedPermission,
215
- availableLists: propAvailableLists,
216
- filters,
217
- mode = 'edit',
218
- collaborationMode = false,
219
- realtimeEnabled = false,
220
- isHydratingTask = false,
221
- taskLoadError = false,
222
- taskHydrationVersion = 0,
223
- isPersonalWorkspace = false,
224
- canUseBoardAssignees,
225
- assigneeMemberSource,
226
- parentTaskId,
227
- parentTaskName,
228
- pendingRelationship,
229
- currentUser: propsCurrentUser,
230
- sharedContext,
231
- draftModeEnabled = false,
232
- defaultPresentation = 'compact',
233
- draftId,
234
- onClose,
235
- onUpdate,
236
- onNavigateToTask,
237
- onAddSubtask,
238
- onAddParentTask,
239
- onAddBlockingTask,
240
- onAddBlockedByTask,
241
- onAddRelatedTask,
242
- onRetryTaskLoad,
243
- }: TaskEditDialogProps) {
244
- const isCreateMode = mode === 'create';
245
- const effectiveTaskWsId = !isCreateMode ? (taskWsId ?? wsId) : wsId;
246
- const pathname = usePathname();
247
- const locale = useLocale();
248
- const queryClient = useQueryClient();
249
- const t = useTranslations('common');
250
- const rootT = useTranslations();
251
- const dialogT = useTranslations('ws-task-boards.dialog');
252
- const historyT = useTranslations('tasks.history');
253
- const { registerCloseRequestHandler } = useTaskDialogContext();
254
-
255
- // Access workspace tier for tier-aware collaboration settings (null outside the provider)
256
- const presenceCtx = useOptionalWorkspacePresenceContext();
257
- const workspaceTier = presenceCtx?.tier ?? null;
258
-
259
- // Disable editing if we are viewing via a shared link
260
- // User requested: always disable editing for shared tasks, regardless of permission
261
- const disabled = !!shareCode;
262
- const taskControlsDisabled = disabled || isHydratingTask || taskLoadError;
263
- const taskTitleDisabled = disabled || taskLoadError;
264
- const effectiveRealtimeEnabled =
265
- realtimeEnabled && !isHydratingTask && !taskLoadError;
266
- const effectiveCollaborationMode =
267
- collaborationMode && !isHydratingTask && !taskLoadError;
268
-
269
- // Defer task media permission checks until an upload is requested. The dialog
270
- // is often opened from satellite app sessions that can edit task fields but
271
- // should not make a drive permission request unless the user uploads media.
272
- const { data: canManageTaskMedia, isPending: isCheckingTaskMediaPermission } =
273
- useQuery({
274
- queryKey: [
275
- 'workspace-permission',
276
- effectiveTaskWsId,
277
- 'manage_drive_tasks_directory',
278
- ],
279
- queryFn: async () => {
280
- const result = await checkWorkspacePermission(
281
- effectiveTaskWsId,
282
- 'manage_drive_tasks_directory'
283
- );
284
- return result.hasPermission;
285
- },
286
- enabled: false,
287
- staleTime: 5 * 60 * 1000,
288
- });
289
-
290
- // Core loading state
291
- const [isLoading, setIsLoading] = useState(false);
292
- const [isSaving, setIsSaving] = useState(false);
293
-
294
- // Form state
295
- const formState = useTaskFormState({
296
- task,
297
- boardId,
298
- isOpen,
299
- isCreateMode,
300
- isSaving,
301
- });
302
-
303
- // Refs
304
- const titleInputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null);
305
- const editorRef = useRef<HTMLDivElement>(null);
306
- const richTextEditorRef = useRef<HTMLDivElement>(null);
307
- const lastCursorPositionRef = useRef<number | null>(null);
308
- const targetEditorCursorRef = useRef<number | null>(null);
309
- const flushEditorPendingRef = useRef<(() => JSONContent | null) | undefined>(
310
- undefined
311
- );
312
- const nameUpdateTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
313
- const pendingNameRef = useRef<string | null>(null);
314
- const nameEditedDuringHydrationRef = useRef(false);
315
- const quickDueRef = useRef<(days: number | null) => void>(() => {});
316
- const updateEstimationRef = useRef<(points: number | null) => void>(() => {});
317
- const handleConvertToTaskRef = useRef<(() => Promise<void>) | null>(null);
318
- const descriptionRef = useRef<JSONContent | null>(formState.description);
319
- const persistedDescriptionRef = useRef<string | null>(null);
320
- const descriptionPersistenceGuardRef =
321
- useRef<TaskDescriptionPersistenceGuardState>(
322
- createTaskDescriptionPersistenceGuardState({
323
- persistedDescription: null,
324
- })
325
- );
326
- const taskRealtimeBroadcastRef = useRef<BoardBroadcastFn | null>(null);
327
- const [hasHydratedYjsState, setHasHydratedYjsState] = useState(false);
328
- const [showDescriptionVersionsDialog, setShowDescriptionVersionsDialog] =
329
- useState(false);
330
- const [restoringDescriptionVersionId, setRestoringDescriptionVersionId] =
331
- useState<string | null>(null);
332
-
333
- useEffect(() => {
334
- descriptionRef.current = formState.description;
335
- }, [formState.description]);
336
-
337
- const setTaskName = useCallback(
338
- (value: string) => {
339
- if (isHydratingTask) {
340
- nameEditedDuringHydrationRef.current = true;
341
- }
342
-
343
- formState.setName(value);
344
- },
345
- [formState.setName, isHydratingTask]
346
- );
347
-
348
- // User state
349
- const [user, setUser] = useState<TaskDialogUserIdentity | null>(
350
- propsCurrentUser ? normalizeTaskDialogCurrentUser(propsCurrentUser) : null
351
- );
352
-
353
- const userColor = useMemo(() => {
354
- const hashCode = (str: string) => {
355
- let hash = 0;
356
- for (let i = 0; i < str.length; i++) {
357
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
358
- }
359
- return hash;
360
- };
361
- const colors = [
362
- '#3b82f6',
363
- '#8b5cf6',
364
- '#ec4899',
365
- '#f97316',
366
- '#10b981',
367
- '#06b6d4',
368
- '#f59e0b',
369
- '#6366f1',
370
- ];
371
- const userId = user?.id || 'unknown';
372
- return colors[Math.abs(hashCode(userId)) % colors.length] || colors[0];
373
- }, [user?.id]);
374
-
375
- // Memoize the user object for Yjs collaboration to prevent unstable references
376
- // from causing the SupabaseProvider to be destroyed and recreated every render
377
- const userId = user?.id;
378
- const userDisplayName = getTaskDialogUserDisplayName(user);
379
-
380
- const yjsUser = useMemo(
381
- () =>
382
- userId
383
- ? {
384
- id: userId || '',
385
- name: userDisplayName,
386
- color: userColor || '',
387
- }
388
- : null,
389
- [userId, userDisplayName, userColor]
390
- );
391
-
392
- // User task settings
393
- const { data: userTaskSettings } = useQuery({
394
- queryKey: ['user-task-settings'],
395
- queryFn: async () => {
396
- const res = await fetch(getTaskApiUrl('/api/v1/users/task-settings'), {
397
- cache: 'no-store',
398
- credentials: 'include',
399
- });
400
- if (!res.ok) return { task_auto_assign_to_self: false };
401
- return res.json() as Promise<{ task_auto_assign_to_self: boolean }>;
402
- },
403
- enabled: isCreateMode && !!user?.id,
404
- staleTime: 5 * 60 * 1000,
405
- refetchOnWindowFocus: false,
406
- refetchOnReconnect: false,
407
- });
408
-
409
- const persistedTaskDescriptionSnapshot = useMemo(
410
- () =>
411
- serializeTaskDescriptionPersistenceSnapshot(
412
- getDescriptionContent(task?.description)
413
- ) ?? null,
414
- [task?.description]
415
- );
416
-
417
- useEffect(() => {
418
- if (!isOpen || isCreateMode) {
419
- persistedDescriptionRef.current = null;
420
- descriptionPersistenceGuardRef.current =
421
- createTaskDescriptionPersistenceGuardState({
422
- persistedDescription: null,
423
- });
424
- return;
425
- }
426
-
427
- persistedDescriptionRef.current = persistedTaskDescriptionSnapshot;
428
- descriptionPersistenceGuardRef.current =
429
- createTaskDescriptionPersistenceGuardState({
430
- persistedDescription: persistedTaskDescriptionSnapshot,
431
- trustPersistedDescription: !effectiveRealtimeEnabled,
432
- });
433
- }, [
434
- effectiveRealtimeEnabled,
435
- isOpen,
436
- isCreateMode,
437
- persistedTaskDescriptionSnapshot,
438
- ]);
439
-
440
- const canConfirmEmptyDescriptionSnapshot =
441
- !effectiveRealtimeEnabled || hasHydratedYjsState;
442
-
443
- const recordDescriptionSnapshot = useCallback(
444
- (nextDescription: JSONContent | null) => {
445
- descriptionPersistenceGuardRef.current =
446
- recordTaskDescriptionEditorSnapshot(
447
- descriptionPersistenceGuardRef.current,
448
- nextDescription,
449
- {
450
- canConfirmEmptySnapshot: canConfirmEmptyDescriptionSnapshot,
451
- }
452
- );
453
- },
454
- [canConfirmEmptyDescriptionSnapshot]
455
- );
456
-
457
- const loadTaskDescriptionState = useCallback(async () => {
458
- if (!task?.id) return null;
459
- const response = await fetchWorkspaceTaskDescription(
460
- effectiveTaskWsId,
461
- task.id
462
- );
463
- return response.description_yjs_state ?? null;
464
- }, [effectiveTaskWsId, task?.id]);
465
-
466
- const saveTaskDescriptionState = useCallback(
467
- async (yjsState: number[]) => {
468
- if (!task?.id) return false;
469
-
470
- let content: JSONContent | null;
471
- try {
472
- content = convertYjsStateToJsonContent(Uint8Array.from(yjsState));
473
- } catch (error) {
474
- console.error('Failed to decode task description Yjs state:', {
475
- taskId: task.id,
476
- ...(error instanceof Error
477
- ? { message: error.message, name: error.name }
478
- : { error }),
479
- });
480
- return false;
481
- }
482
-
483
- content = normalizeTaskDescriptionSnapshot(content);
484
- const serializedDescription =
485
- serializeTaskDescriptionPersistenceSnapshot(content);
486
-
487
- if (
488
- serializedDescription &&
489
- serializedDescription.length > MAX_TASK_DESCRIPTION_LENGTH
490
- ) {
491
- return false;
492
- }
493
-
494
- if (
495
- !canPersistTaskDescriptionSnapshot({
496
- currentSerializedDescription: serializedDescription,
497
- guardState: descriptionPersistenceGuardRef.current,
498
- })
499
- ) {
500
- return false;
501
- }
502
-
503
- const didPersist = await saveYjsDescriptionToDatabase({
504
- wsId: effectiveTaskWsId,
505
- taskId: task.id,
506
- getContent: () => content,
507
- getYjsState: () => yjsState,
508
- boardId,
509
- queryClient,
510
- context: 'realtime-persist',
511
- });
512
-
513
- if (!didPersist) return false;
514
-
515
- persistedDescriptionRef.current = serializedDescription;
516
- descriptionPersistenceGuardRef.current =
517
- createTaskDescriptionPersistenceGuardState({
518
- persistedDescription: serializedDescription,
519
- trustPersistedDescription: true,
520
- });
521
-
522
- const broadcast =
523
- getActiveBroadcast() ?? taskRealtimeBroadcastRef.current;
524
- broadcastTaskDescriptionUpsert({
525
- taskId: task.id,
526
- descriptionString: serializedDescription,
527
- broadcast: broadcast ?? undefined,
528
- });
529
-
530
- return true;
531
- },
532
- [boardId, effectiveTaskWsId, queryClient, task?.id]
533
- );
534
-
535
- // Yjs collaboration — paid tiers get immediate broadcasts; free tier coalesces rapid edits
536
- // Note: realtimeEnabled controls Yjs sync (all tiers), collaborationMode controls cursors (paid tiers)
537
- const { doc, provider, synced, connected } = useYjsCollaboration({
538
- channel: `task-editor-${task?.id || 'new'}`,
539
- tableName: 'tasks',
540
- columnName: 'description_yjs_state',
541
- id: task?.id || '',
542
- user: yjsUser,
543
- enabled: isOpen && !isCreateMode && effectiveRealtimeEnabled && !!task?.id,
544
- broadcastDebounceMs: workspaceTier && workspaceTier !== 'FREE' ? 0 : 200,
545
- saveDebounceMs: 5000,
546
- loadDocumentState: loadTaskDescriptionState,
547
- saveDocumentState: saveTaskDescriptionState,
548
- });
549
-
550
- useEffect(() => {
551
- if (!isOpen || isCreateMode || !effectiveRealtimeEnabled || !task?.id) {
552
- setHasHydratedYjsState(false);
553
- return;
554
- }
555
-
556
- if (synced) {
557
- setHasHydratedYjsState(true);
558
- }
559
- }, [isOpen, isCreateMode, effectiveRealtimeEnabled, task?.id, synced]);
560
-
561
- const isYjsSyncing = useMemo(() => {
562
- return (
563
- isOpen &&
564
- !isCreateMode &&
565
- effectiveRealtimeEnabled &&
566
- !!task?.id &&
567
- !hasHydratedYjsState &&
568
- !synced
569
- );
570
- }, [
571
- hasHydratedYjsState,
572
- isOpen,
573
- isCreateMode,
574
- effectiveRealtimeEnabled,
575
- task?.id,
576
- synced,
577
- ]);
578
-
579
- const { data: descriptionHistoryData } = useQuery({
580
- queryKey: ['task-history', effectiveTaskWsId, task?.id, 'description'],
581
- queryFn: async () => {
582
- if (!task?.id) return null;
583
-
584
- return getWorkspaceTaskHistory(effectiveTaskWsId, task.id, {
585
- limit: 100,
586
- changeType: 'field_updated',
587
- fieldName: 'description',
588
- });
589
- },
590
- enabled:
591
- isOpen &&
592
- !isCreateMode &&
593
- !taskControlsDisabled &&
594
- Boolean(effectiveTaskWsId) &&
595
- Boolean(task?.id),
596
- staleTime: 30 * 1000,
597
- });
598
-
599
- const recoverableDescriptionVersions = useMemo(
600
- () =>
601
- buildRecoverableTaskDescriptionVersions(
602
- descriptionHistoryData?.history ?? []
603
- ),
604
- [descriptionHistoryData?.history]
605
- );
606
-
607
- const currentSerializedDescription = useMemo(
608
- () =>
609
- serializeTaskDescriptionPersistenceSnapshot(formState.description) ??
610
- null,
611
- [formState.description]
612
- );
613
-
614
- const latestRestorableDescriptionVersion = useMemo(() => {
615
- const latestVersion = recoverableDescriptionVersions[0] ?? null;
616
- if (!latestVersion) return null;
617
- return latestVersion.description === currentSerializedDescription
618
- ? null
619
- : latestVersion;
620
- }, [currentSerializedDescription, recoverableDescriptionVersions]);
621
-
622
- // Update user when props change
623
- useEffect(() => {
624
- if (propsCurrentUser) {
625
- setUser(normalizeTaskDialogCurrentUser(propsCurrentUser));
626
- }
627
- }, [propsCurrentUser]);
628
-
629
- // Data fetching
630
- const [taskSearchQuery, setTaskSearchQuery] = useState<string>('');
631
- const taskSearchDebounceRef = useRef<NodeJS.Timeout | null>(null);
632
-
633
- const {
634
- boardConfig,
635
- availableLists,
636
- workspaceLabels,
637
- workspaceMembers,
638
- taskProjects,
639
- workspaceTasks,
640
- workspaceTasksLoading,
641
- } = useTaskData({
642
- wsId: effectiveTaskWsId,
643
- boardId,
644
- isOpen,
645
- propAvailableLists,
646
- taskSearchQuery,
647
- canUseBoardAssignees: canUseBoardAssignees ?? !isPersonalWorkspace,
648
- assigneeMemberSource,
649
- sharedContext,
650
- });
651
- const currentList = availableLists?.find(
652
- (list) => list.id === formState.selectedListId
653
- );
654
- const normalizedDefaultPresentation = useMemo(
655
- () => normalizeTaskDialogPresentation(defaultPresentation),
656
- [defaultPresentation]
657
- );
658
- const openingPresentation = useMemo(
659
- () =>
660
- resolveTaskDialogOpeningPresentation({
661
- defaultPresentation: normalizedDefaultPresentation,
662
- draftId,
663
- mode,
664
- selectedListStatus: currentList?.status,
665
- }),
666
- [currentList?.status, draftId, mode, normalizedDefaultPresentation]
667
- );
668
-
669
- // Update browser tab title
670
- useEffect(() => {
671
- if (!isOpen || isCreateMode || !task) return;
672
- const originalTitle = document.title;
673
- document.title = `${getTicketIdentifier(boardConfig?.ticket_prefix, task.display_number)} - ${task.name}`;
674
- return () => {
675
- document.title = originalTitle;
676
- };
677
- }, [isOpen, isCreateMode, task, boardConfig?.ticket_prefix]);
678
-
679
- // Labels state
680
- const [availableLabels, setAvailableLabels] = useState<WorkspaceTaskLabel[]>(
681
- []
682
- );
683
- const [newLabelName, setNewLabelName] = useState('');
684
- const [newLabelColor, setNewLabelColor] = useState(() =>
685
- getRandomNewLabelColor()
686
- );
687
- const previousWorkspaceLabelsRef = useRef<string>('');
688
-
689
- useEffect(() => {
690
- const currentLabelsKey = JSON.stringify(
691
- workspaceLabels.map((l) => l.id).sort()
692
- );
693
- if (previousWorkspaceLabelsRef.current !== currentLabelsKey) {
694
- previousWorkspaceLabelsRef.current = currentLabelsKey;
695
- setAvailableLabels(workspaceLabels);
696
- }
697
- }, [workspaceLabels]);
698
-
699
- // Projects state
700
- const [newProjectName, setNewProjectName] = useState('');
701
-
702
- // Editor state
703
- const [editorInstance, setEditorInstance] = useState<Editor | null>(null);
704
- const [showAdvancedOptions, setShowAdvancedOptions] = useState(true);
705
- const [descriptionStorageLength, setDescriptionStorageLength] = useState(() =>
706
- getTaskDescriptionStorageLength(formState.description)
707
- );
708
- const descriptionPayloadTooLargeNotifiedRef = useRef(false);
709
- const closeBlockedByOverflowRef = useRef(false);
710
-
711
- // Dialog states
712
- const [showNewLabelDialog, setShowNewLabelDialog] = useState(false);
713
- const [showNewProjectDialog, setShowNewProjectDialog] = useState(false);
714
- const [showEstimationConfigDialog, setShowEstimationConfigDialog] =
715
- useState(false);
716
- const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
717
- const [createMultiple, setCreateMultiple] = useState(false);
718
- const [showSyncWarning, setShowSyncWarning] = useState(false);
719
- const [showUnsavedWarning, setShowUnsavedWarning] = useState(false);
720
- const [showDescriptionOverflowWarning, setShowDescriptionOverflowWarning] =
721
- useState(false);
722
- const [showDescriptionCloseWarning, setShowDescriptionCloseWarning] =
723
- useState(false);
724
- const [showShareDialog, setShowShareDialog] = useState(false);
725
- const [saveAsDraft, setSaveAsDraft] = useState(draftModeEnabled);
726
- const [presentation, setPresentation] =
727
- useState<TaskDialogPresentation>(openingPresentation);
728
- const [smartSuggestions, setSmartSuggestions] = useState<
729
- WorkspaceTaskSuggestionTask[]
730
- >([]);
731
- const [selectedSmartSuggestionIds, setSelectedSmartSuggestionIds] = useState<
732
- string[]
733
- >([]);
734
- const [smartSuggestionError, setSmartSuggestionError] = useState<
735
- string | null
736
- >(null);
737
- const [smartCreateErrors, setSmartCreateErrors] = useState<
738
- Record<string, string>
739
- >({});
740
- const [creatingSmartSuggestionIds, setCreatingSmartSuggestionIds] = useState<
741
- string[]
742
- >([]);
743
- const [isCreatingSmartSuggestions, setIsCreatingSmartSuggestions] =
744
- useState(false);
745
- const previousOpenRef = useRef(false);
746
- const [isTitleVisible, setIsTitleVisible] = useState(true);
747
- const [scrollContainer, setScrollContainer] = useState<HTMLDivElement | null>(
748
- null
749
- );
750
-
751
- // Calendar events state
752
- const [localCalendarEvents, setLocalCalendarEvents] = useState<
753
- Task['calendar_events'] | undefined
754
- >(task?.calendar_events);
755
-
756
- const [lockingEventId, setLockingEventId] = useState<string | null>(null);
757
-
758
- const handleLockToggle = useCallback(
759
- async (eventId: string, currentLocked: boolean) => {
760
- setLockingEventId(eventId);
761
- try {
762
- await updateWorkspaceCalendarEvent(effectiveTaskWsId, eventId, {
763
- locked: !currentLocked,
764
- });
765
-
766
- // Update local state
767
- setLocalCalendarEvents((prev) =>
768
- prev?.map((e) =>
769
- e.id === eventId ? { ...e, locked: !currentLocked } : e
770
- )
771
- );
772
-
773
- toast(!currentLocked ? 'Event locked' : 'Event unlocked', {
774
- description: !currentLocked
775
- ? 'The auto-scheduler will no longer move this instance.'
776
- : 'The auto-scheduler can now move this instance.',
777
- });
778
- } catch (error) {
779
- console.error('Failed to update lock status for calendar event', error);
780
- toast.error('Error', {
781
- description: 'Failed to update lock status',
782
- });
783
- } finally {
784
- setLockingEventId(null);
785
- }
786
- },
787
- [effectiveTaskWsId]
788
- );
789
-
790
- useEffect(() => {
791
- setLocalCalendarEvents(task?.calendar_events);
792
- }, [task?.calendar_events]);
793
-
794
- const { data: personalScheduleData } = useQuery({
795
- queryKey: ['task-personal-schedule', task?.id, isOpen],
796
- enabled: !!isOpen && !isCreateMode && !!task?.id,
797
- queryFn: async () => {
798
- const response = await fetch(
799
- getTaskApiUrl(`/api/v1/users/me/tasks/${task!.id}/schedule`),
800
- { cache: 'no-store' }
801
- );
802
- if (!response.ok) return null;
803
- return (await response.json()) as null | {
804
- task: {
805
- total_duration: number | null;
806
- is_splittable: boolean | null;
807
- min_split_duration_minutes: number | null;
808
- max_split_duration_minutes: number | null;
809
- calendar_hours: any;
810
- auto_schedule: boolean | null;
811
- };
812
- events: Array<{
813
- id: string;
814
- title: string;
815
- start_at: string;
816
- end_at: string;
817
- scheduled_minutes: number;
818
- completed: boolean;
819
- }>;
820
- };
821
- },
822
- staleTime: 15_000,
823
- });
824
-
825
- // Sync scheduled events into local state for rendering
826
- useEffect(() => {
827
- if (!personalScheduleData?.events) return;
828
- setLocalCalendarEvents(
829
- personalScheduleData.events.map((e) => ({
830
- id: e.id,
831
- title: e.title,
832
- start_at: e.start_at,
833
- end_at: e.end_at,
834
- scheduled_minutes: e.scheduled_minutes,
835
- completed: e.completed,
836
- }))
837
- );
838
- }, [personalScheduleData?.events]);
839
-
840
- // Sync "my scheduling settings" into the form state when opening the dialog
841
- const {
842
- setTotalDuration,
843
- setIsSplittable,
844
- setMinSplitDurationMinutes,
845
- setMaxSplitDurationMinutes,
846
- setCalendarHours,
847
- setAutoSchedule,
848
- setEndDate,
849
- } = formState;
850
- useEffect(() => {
851
- if (!personalScheduleData?.task || !isOpen || isCreateMode) return;
852
- setTotalDuration(personalScheduleData.task.total_duration ?? null);
853
- setIsSplittable(!!personalScheduleData.task.is_splittable);
854
- setMinSplitDurationMinutes(
855
- personalScheduleData.task.min_split_duration_minutes ?? null
856
- );
857
- setMaxSplitDurationMinutes(
858
- personalScheduleData.task.max_split_duration_minutes ?? null
859
- );
860
- setCalendarHours(personalScheduleData.task.calendar_hours ?? null);
861
- setAutoSchedule(!!personalScheduleData.task.auto_schedule);
862
- }, [
863
- personalScheduleData?.task,
864
- isOpen,
865
- isCreateMode,
866
- setTotalDuration,
867
- setIsSplittable,
868
- setMinSplitDurationMinutes,
869
- setMaxSplitDurationMinutes,
870
- setCalendarHours,
871
- setAutoSchedule,
872
- ]);
873
-
874
- const hasUnsavedSchedulingChanges = useMemo(() => {
875
- if (isCreateMode) return false;
876
-
877
- const saved = personalScheduleData?.task;
878
- if (!saved) {
879
- return (
880
- formState.totalDuration !== null ||
881
- formState.isSplittable ||
882
- formState.minSplitDurationMinutes !== null ||
883
- formState.maxSplitDurationMinutes !== null ||
884
- formState.calendarHours !== null ||
885
- formState.autoSchedule
886
- );
887
- }
888
-
889
- return (
890
- formState.totalDuration !== (saved.total_duration ?? null) ||
891
- formState.isSplittable !== !!saved.is_splittable ||
892
- formState.minSplitDurationMinutes !==
893
- (saved.min_split_duration_minutes ?? null) ||
894
- formState.maxSplitDurationMinutes !==
895
- (saved.max_split_duration_minutes ?? null) ||
896
- formState.calendarHours !== (saved.calendar_hours ?? null) ||
897
- formState.autoSchedule !== !!saved.auto_schedule
898
- );
899
- }, [
900
- isCreateMode,
901
- personalScheduleData?.task,
902
- formState.totalDuration,
903
- formState.isSplittable,
904
- formState.minSplitDurationMinutes,
905
- formState.maxSplitDurationMinutes,
906
- formState.calendarHours,
907
- formState.autoSchedule,
908
- ]);
909
-
910
- const draftStorageKey = getDraftStorageKey(boardId);
911
-
912
- // Suggestion menus
913
- const suggestionMenus = useSuggestionMenus({
914
- editorInstance,
915
- isOpen,
916
- workspaceMembers,
917
- boardConfig,
918
- taskProjects,
919
- workspaceTasks,
920
- workspaceTasksLoading,
921
- wsId: effectiveTaskWsId,
922
- currentTaskId: task?.id,
923
- isPersonalWorkspace,
924
- endDate: formState.endDate,
925
- priority: formState.priority,
926
- showAdvancedOptions,
927
- setShowAdvancedOptions,
928
- });
929
-
930
- // Change detection
931
- const { hasUnsavedChanges, canSave } = useTaskChangeDetection({
932
- task,
933
- name: formState.name,
934
- description: formState.description,
935
- priority: formState.priority,
936
- startDate: formState.startDate,
937
- endDate: formState.endDate,
938
- selectedListId: formState.selectedListId,
939
- estimationPoints: formState.estimationPoints,
940
- selectedLabels: formState.selectedLabels,
941
- selectedAssignees: formState.selectedAssignees,
942
- isCreateMode,
943
- isLoading: isLoading || taskControlsDisabled,
944
- collaborationMode: effectiveCollaborationMode,
945
- draftId,
946
- });
947
-
948
- useEffect(() => {
949
- if (!isOpen || isCreateMode) return;
950
- if (effectiveRealtimeEnabled && !hasHydratedYjsState) return;
951
- if (
952
- serializeTaskDescriptionPersistenceSnapshot(formState.description) ===
953
- null
954
- ) {
955
- return;
956
- }
957
-
958
- descriptionPersistenceGuardRef.current =
959
- recordTaskDescriptionEditorSnapshot(
960
- descriptionPersistenceGuardRef.current,
961
- formState.description
962
- );
963
- }, [
964
- effectiveRealtimeEnabled,
965
- formState.description,
966
- hasHydratedYjsState,
967
- isOpen,
968
- isCreateMode,
969
- ]);
970
-
971
- // Realtime sync for task fields and relations. Description sync remains Yjs-only.
972
- const { broadcast: taskRealtimeBroadcast } = useTaskRealtimeSync({
973
- wsId: effectiveTaskWsId,
974
- taskWorkspaceId: taskWsId,
975
- taskId: task?.id,
976
- boardId,
977
- isCreateMode,
978
- isOpen,
979
- realtimeEnabled: effectiveRealtimeEnabled,
980
- isPersonalWorkspace,
981
- name: formState.name,
982
- priority: formState.priority,
983
- startDate: formState.startDate,
984
- endDate: formState.endDate,
985
- estimationPoints: formState.estimationPoints,
986
- selectedListId: formState.selectedListId,
987
- pendingNameRef,
988
- setName: formState.setName,
989
- setPriority: formState.setPriority,
990
- setStartDate: formState.setStartDate,
991
- setEndDate: formState.setEndDate,
992
- setEstimationPoints: formState.setEstimationPoints,
993
- setSelectedListId: formState.setSelectedListId,
994
- setSelectedLabels: formState.setSelectedLabels,
995
- setSelectedAssignees: formState.setSelectedAssignees,
996
- setSelectedProjects: formState.setSelectedProjects,
997
- disabled,
998
- });
999
- taskRealtimeBroadcastRef.current = taskRealtimeBroadcast;
1000
-
1001
- // Task mutations
1002
- const {
1003
- updateEstimation,
1004
- updatePriority,
1005
- updateStartDate,
1006
- updateEndDate,
1007
- updateList,
1008
- saveNameToDatabase,
1009
- saveSchedulingSettings,
1010
- schedulingSaving,
1011
- } = useTaskMutations({
1012
- wsId: effectiveTaskWsId,
1013
- taskId: task?.id,
1014
- isCreateMode,
1015
- boardId,
1016
- visibleBoardId,
1017
- visibleTaskSnapshot,
1018
- estimationPoints: formState.estimationPoints ?? null,
1019
- priority: formState.priority,
1020
- selectedListId: formState.selectedListId,
1021
- taskName: task?.name,
1022
- setEstimationPoints: formState.setEstimationPoints,
1023
- setPriority: formState.setPriority,
1024
- setStartDate: formState.setStartDate,
1025
- setEndDate: formState.setEndDate,
1026
- setSelectedListId: formState.setSelectedListId,
1027
- fallbackBroadcast: taskRealtimeBroadcast,
1028
- onUpdate,
1029
- });
1030
-
1031
- const doneList = availableLists?.find(
1032
- (list) => list.status === 'done' && !list.deleted
1033
- );
1034
- const closedList = availableLists?.find(
1035
- (list) => list.status === 'closed' && !list.deleted
1036
- );
1037
- const isDeletedTask = Boolean(
1038
- task?.deleted_at ||
1039
- (task as (Task & { deleted?: boolean }) | undefined)?.deleted
1040
- );
1041
- const canShowCompactEditActions =
1042
- !isCreateMode &&
1043
- !!task?.id &&
1044
- task.id !== 'new' &&
1045
- !isDeletedTask &&
1046
- !disabled &&
1047
- !taskLoadError;
1048
- const compactEditActionsDisabled = isLoading || isHydratingTask;
1049
- const isDocumentTask = currentList?.status === 'documents';
1050
- const canShowCompactStatusActions =
1051
- canShowCompactEditActions && !isDocumentTask;
1052
- const canShowArchiveAction =
1053
- canShowCompactEditActions &&
1054
- !!closedList &&
1055
- closedList.id !== formState.selectedListId &&
1056
- currentList?.status !== 'closed';
1057
- const showCompactDoneAction =
1058
- canShowCompactStatusActions &&
1059
- !!doneList &&
1060
- doneList.id !== formState.selectedListId &&
1061
- currentList?.status !== 'done';
1062
- const showCompactClosedAction =
1063
- canShowCompactStatusActions &&
1064
- !!closedList &&
1065
- closedList.id !== formState.selectedListId &&
1066
- closedList.id !== doneList?.id &&
1067
- currentList?.status !== 'closed';
1068
- const showDocumentArchiveAction = canShowArchiveAction && isDocumentTask;
1069
-
1070
- // Task relationships
1071
- const {
1072
- toggleLabel,
1073
- toggleAssignee,
1074
- toggleProject,
1075
- handleCreateLabel,
1076
- handleCreateProject,
1077
- creatingLabel,
1078
- creatingProject,
1079
- } = useTaskRelationships({
1080
- wsId: effectiveTaskWsId,
1081
- labelCacheWorkspaceId: boardConfig?.ws_id || effectiveTaskWsId,
1082
- taskId: task?.id,
1083
- isCreateMode,
1084
- boardId,
1085
- selectedLabels: formState.selectedLabels,
1086
- selectedAssignees: formState.selectedAssignees,
1087
- selectedProjects: formState.selectedProjects,
1088
- newLabelName,
1089
- newLabelColor,
1090
- newProjectName,
1091
- setSelectedLabels: formState.setSelectedLabels,
1092
- setSelectedAssignees: formState.setSelectedAssignees,
1093
- setSelectedProjects: formState.setSelectedProjects,
1094
- setAvailableLabels,
1095
- setNewLabelName,
1096
- setNewLabelColor,
1097
- setNewProjectName,
1098
- setShowNewLabelDialog,
1099
- setShowNewProjectDialog,
1100
- fallbackBroadcast: taskRealtimeBroadcast,
1101
- onUpdate,
1102
- });
1103
-
1104
- const seededPendingRelationships = useMemo<PendingTaskRelationships>(
1105
- () =>
1106
- getSeededPendingTaskRelationships({
1107
- parentTaskId,
1108
- parentTaskName,
1109
- pendingRelationship,
1110
- }),
1111
- [parentTaskId, parentTaskName, pendingRelationship]
1112
- );
1113
-
1114
- // Task dependencies
1115
- const {
1116
- isLoading: dependenciesLoading,
1117
- parentTask,
1118
- setParentTask,
1119
- childTasks,
1120
- addChildTask,
1121
- blocking: blockingTasks,
1122
- addBlockingTask,
1123
- removeBlockingTask,
1124
- blockedBy: blockedByTasks,
1125
- addBlockedByTask,
1126
- removeBlockedByTask,
1127
- relatedTasks,
1128
- addRelatedTask,
1129
- removeRelatedTask,
1130
- savingRelationship,
1131
- pendingRelationships,
1132
- } = useTaskDependencies({
1133
- taskId: task?.id,
1134
- boardId,
1135
- wsId: effectiveTaskWsId,
1136
- listId: task?.list_id,
1137
- isCreateMode,
1138
- initialPendingRelationships: seededPendingRelationships,
1139
- onUpdate,
1140
- });
1141
-
1142
- // Form reset
1143
- useTaskFormReset({
1144
- isOpen,
1145
- isCreateMode,
1146
- task,
1147
- filters,
1148
- taskHydrationVersion,
1149
- preserveNameOnHydration: nameEditedDuringHydrationRef.current,
1150
- setName: formState.setName,
1151
- setDescription: formState.setDescription,
1152
- setPriority: formState.setPriority,
1153
- setStartDate: formState.setStartDate,
1154
- setEndDate: formState.setEndDate,
1155
- setSelectedListId: formState.setSelectedListId,
1156
- setEstimationPoints: formState.setEstimationPoints,
1157
- setSelectedLabels: formState.setSelectedLabels,
1158
- setSelectedAssignees: formState.setSelectedAssignees,
1159
- setSelectedProjects: formState.setSelectedProjects,
1160
- });
1161
-
1162
- useEffect(() => {
1163
- if (!isHydratingTask) {
1164
- nameEditedDuringHydrationRef.current = false;
1165
- }
1166
- }, [isHydratingTask]);
1167
-
1168
- // Yjs sync
1169
- useTaskYjsSync({
1170
- taskId: task?.id,
1171
- wsId: effectiveTaskWsId,
1172
- boardId,
1173
- isOpen,
1174
- isCreateMode,
1175
- realtimeEnabled: effectiveRealtimeEnabled,
1176
- editorInstance,
1177
- doc,
1178
- yjsProvider: provider,
1179
- queryClient,
1180
- flushEditorPendingRef,
1181
- });
1182
-
1183
- useEffect(() => {
1184
- setDescriptionStorageLength(
1185
- getTaskDescriptionStorageLength(formState.description)
1186
- );
1187
- }, [formState.description]);
1188
-
1189
- const handleDescriptionStorageLengthChange = useCallback((length: number) => {
1190
- setDescriptionStorageLength((currentLength) =>
1191
- currentLength === length ? currentLength : length
1192
- );
1193
- }, []);
1194
-
1195
- const applyRestoredDescriptionToOpenEditor = useCallback(
1196
- ({
1197
- content,
1198
- yjsState,
1199
- }: {
1200
- content: JSONContent | null;
1201
- yjsState: number[] | null;
1202
- }) => {
1203
- const nextContent = content ?? EMPTY_TASK_DESCRIPTION_DOC;
1204
-
1205
- const nextYjsState =
1206
- yjsState && yjsState.length > 0
1207
- ? Uint8Array.from(yjsState)
1208
- : doc && editorInstance?.schema
1209
- ? convertJsonContentToYjsState(nextContent, editorInstance.schema)
1210
- : null;
1211
-
1212
- if (doc && nextYjsState) {
1213
- const syncOrigin = provider ?? SUPABASE_PROVIDER_SYNC_ORIGIN;
1214
- doc.transact(() => {
1215
- const fragment = doc.getXmlFragment('prosemirror');
1216
- if (fragment.length > 0) {
1217
- fragment.delete(0, fragment.length);
1218
- }
1219
- }, syncOrigin);
1220
- Y.applyUpdate(doc, nextYjsState, syncOrigin);
1221
- return;
1222
- }
1223
-
1224
- editorInstance?.commands.setContent(nextContent, {
1225
- emitUpdate: false,
1226
- });
1227
- },
1228
- [doc, editorInstance, provider]
1229
- );
1230
-
1231
- const handleRestoreDescriptionVersion = useCallback(
1232
- async (version: RecoverableTaskDescriptionVersion) => {
1233
- if (!task?.id) return;
1234
-
1235
- setRestoringDescriptionVersionId(version.id);
1236
-
1237
- try {
1238
- const response = await updateWorkspaceTaskDescription(
1239
- effectiveTaskWsId,
1240
- task.id,
1241
- { description: version.description }
1242
- );
1243
- const restoredDescription = response.description ?? version.description;
1244
- const restoredContent = normalizeTaskDescriptionSnapshot(
1245
- getDescriptionContent(restoredDescription)
1246
- );
1247
- const serializedRestoredDescription =
1248
- serializeTaskDescriptionPersistenceSnapshot(restoredContent) ?? null;
1249
-
1250
- applyRestoredDescriptionToOpenEditor({
1251
- content: restoredContent,
1252
- yjsState: response.description_yjs_state,
1253
- });
1254
- formState.setDescription(restoredContent);
1255
- setDescriptionStorageLength(
1256
- getTaskDescriptionStorageLength(restoredContent)
1257
- );
1258
- persistedDescriptionRef.current = serializedRestoredDescription;
1259
- descriptionPersistenceGuardRef.current =
1260
- createTaskDescriptionPersistenceGuardState({
1261
- persistedDescription: serializedRestoredDescription,
1262
- trustPersistedDescription: true,
1263
- });
1264
- setHasHydratedYjsState(true);
1265
-
1266
- updateTaskDescriptionCaches({
1267
- taskId: task.id,
1268
- descriptionString: serializedRestoredDescription,
1269
- boardId,
1270
- queryClient,
1271
- });
1272
-
1273
- await Promise.all([
1274
- queryClient.invalidateQueries({
1275
- queryKey: ['task-history', effectiveTaskWsId, task.id],
1276
- }),
1277
- queryClient.invalidateQueries({
1278
- queryKey: ['task', task.id],
1279
- }),
1280
- queryClient.invalidateQueries({
1281
- queryKey: ['task-snapshot', effectiveTaskWsId, task.id],
1282
- }),
1283
- ]);
1284
-
1285
- const broadcast =
1286
- getActiveBroadcast() ?? taskRealtimeBroadcastRef.current;
1287
- broadcastTaskDescriptionUpsert({
1288
- taskId: task.id,
1289
- descriptionString: serializedRestoredDescription,
1290
- broadcast: broadcast ?? undefined,
1291
- });
1292
-
1293
- onUpdate();
1294
- setShowDescriptionVersionsDialog(false);
1295
- toast.success(
1296
- historyT('description_restore_success', {
1297
- defaultValue: 'Description restored',
1298
- })
1299
- );
1300
- } catch (error) {
1301
- toast.error(
1302
- error instanceof Error
1303
- ? error.message
1304
- : historyT('description_restore_failed', {
1305
- defaultValue: 'Failed to restore description',
1306
- })
1307
- );
1308
- } finally {
1309
- setRestoringDescriptionVersionId(null);
1310
- }
1311
- },
1312
- [
1313
- applyRestoredDescriptionToOpenEditor,
1314
- boardId,
1315
- effectiveTaskWsId,
1316
- formState.setDescription,
1317
- historyT,
1318
- onUpdate,
1319
- queryClient,
1320
- task?.id,
1321
- ]
1322
- );
1323
-
1324
- const isDescriptionOverLimit =
1325
- descriptionStorageLength > MAX_TASK_DESCRIPTION_LENGTH;
1326
- const descriptionPercentLeft = getTaskDescriptionPercentLeft(
1327
- descriptionStorageLength,
1328
- MAX_TASK_DESCRIPTION_LENGTH
1329
- );
1330
-
1331
- const showDescriptionPayloadTooLargeToast = useCallback(() => {
1332
- const title = dialogT.has('description_payload_too_large_title')
1333
- ? dialogT('description_payload_too_large_title')
1334
- : 'Description payload is too large';
1335
- const description = dialogT.has('description_payload_too_large_description')
1336
- ? dialogT('description_payload_too_large_description')
1337
- : 'This description is too large to sync. Please shorten it or split it into smaller documents.';
1338
-
1339
- toast.error(title, { description });
1340
- }, [dialogT]);
1341
-
1342
- useEffect(() => {
1343
- if (!isOpen) {
1344
- descriptionPayloadTooLargeNotifiedRef.current = false;
1345
- return;
1346
- }
1347
-
1348
- if (!isDescriptionOverLimit) {
1349
- descriptionPayloadTooLargeNotifiedRef.current = false;
1350
- return;
1351
- }
1352
-
1353
- if (descriptionPayloadTooLargeNotifiedRef.current) return;
1354
-
1355
- descriptionPayloadTooLargeNotifiedRef.current = true;
1356
- showDescriptionPayloadTooLargeToast();
1357
- }, [isDescriptionOverLimit, isOpen, showDescriptionPayloadTooLargeToast]);
1358
-
1359
- // Quick due date handler
1360
- const handleQuickDueDate = useCallback(
1361
- (days: number | null) => {
1362
- const newDate =
1363
- days !== null
1364
- ? dayjs().add(days, 'day').endOf('day').toDate()
1365
- : undefined;
1366
- setEndDate(newDate);
1367
- if (!isCreateMode) updateEndDate(newDate);
1368
- },
1369
- [isCreateMode, setEndDate, updateEndDate]
1370
- );
1371
-
1372
- // Name update handlers
1373
- const updateName = useCallback(
1374
- (newName: string) => {
1375
- if (nameUpdateTimerRef.current) clearTimeout(nameUpdateTimerRef.current);
1376
- pendingNameRef.current = newName;
1377
- nameUpdateTimerRef.current = setTimeout(() => {
1378
- saveNameToDatabase(newName);
1379
- pendingNameRef.current = null;
1380
- nameUpdateTimerRef.current = null;
1381
- }, NAME_UPDATE_DEBOUNCE_MS);
1382
- },
1383
- [saveNameToDatabase]
1384
- );
1385
-
1386
- const flushNameUpdate = useCallback(async () => {
1387
- if (nameUpdateTimerRef.current) {
1388
- clearTimeout(nameUpdateTimerRef.current);
1389
- nameUpdateTimerRef.current = null;
1390
- }
1391
- if (pendingNameRef.current) {
1392
- await saveNameToDatabase(pendingNameRef.current);
1393
- pendingNameRef.current = null;
1394
- }
1395
- }, [saveNameToDatabase]);
1396
-
1397
- // Image upload handler
1398
- const handleImageUpload = useCallback(
1399
- async (file: File): Promise<string> => {
1400
- if (!effectiveTaskWsId) {
1401
- throw new Error(t('error'));
1402
- }
1403
-
1404
- if (disabled) {
1405
- throw Object.assign(new Error(t('insufficient_permissions')), {
1406
- code: 'INSUFFICIENT_PERMISSIONS',
1407
- });
1408
- }
1409
-
1410
- let hasPermission = canManageTaskMedia;
1411
- if (hasPermission === undefined || isCheckingTaskMediaPermission) {
1412
- try {
1413
- hasPermission = await queryClient.fetchQuery({
1414
- queryKey: [
1415
- 'workspace-permission',
1416
- effectiveTaskWsId,
1417
- 'manage_drive_tasks_directory',
1418
- ],
1419
- queryFn: async () => {
1420
- const result = await checkWorkspacePermission(
1421
- effectiveTaskWsId,
1422
- 'manage_drive_tasks_directory'
1423
- );
1424
- return result.hasPermission;
1425
- },
1426
- staleTime: 5 * 60 * 1000,
1427
- });
1428
- } catch {
1429
- throw Object.assign(new Error(t('insufficient_permissions')), {
1430
- code: 'INSUFFICIENT_PERMISSIONS',
1431
- });
1432
- }
1433
- }
1434
-
1435
- if (!hasPermission) {
1436
- throw Object.assign(new Error(t('insufficient_permissions')), {
1437
- code: 'INSUFFICIENT_PERMISSIONS',
1438
- });
1439
- }
1440
-
1441
- const uploadResult = await uploadWorkspaceTaskFile(
1442
- effectiveTaskWsId,
1443
- file,
1444
- { taskId: task?.id }
1445
- );
1446
-
1447
- const query = new URLSearchParams({ path: uploadResult.path });
1448
- if (task?.id) {
1449
- query.set('taskId', task.id);
1450
- }
1451
-
1452
- return `/api/v1/workspaces/${encodeURIComponent(effectiveTaskWsId)}/storage/share?${query.toString()}`;
1453
- },
1454
- [
1455
- canManageTaskMedia,
1456
- disabled,
1457
- effectiveTaskWsId,
1458
- isCheckingTaskMediaPermission,
1459
- queryClient,
1460
- task?.id,
1461
- t,
1462
- ]
1463
- );
1464
-
1465
- const imageUploadHandler =
1466
- !effectiveTaskWsId || disabled || canManageTaskMedia === false
1467
- ? undefined
1468
- : handleImageUpload;
1469
-
1470
- const handleEstimationConfigSuccess = useCallback(async () => {
1471
- await queryClient.invalidateQueries({
1472
- queryKey: ['board-config', boardId],
1473
- });
1474
- await invalidateTaskCaches(queryClient, boardId);
1475
- onUpdate();
1476
- }, [queryClient, boardId, onUpdate]);
1477
-
1478
- // Editor commands
1479
- const { executeSlashCommand, insertMentionOption, handleCustomDateSelect } =
1480
- useEditorCommands({
1481
- editorInstance,
1482
- slashState: suggestionMenus.slashState,
1483
- mentionState: suggestionMenus.mentionState,
1484
- includeTime: suggestionMenus.includeTime,
1485
- selectedHour: suggestionMenus.selectedHour,
1486
- selectedMinute: suggestionMenus.selectedMinute,
1487
- selectedPeriod: suggestionMenus.selectedPeriod,
1488
- handleQuickDueDate,
1489
- setPriority: formState.setPriority,
1490
- setShowAdvancedOptions,
1491
- setShowCustomDatePicker: suggestionMenus.setShowCustomDatePicker,
1492
- setCustomDate: suggestionMenus.setCustomDate,
1493
- setIncludeTime: suggestionMenus.setIncludeTime,
1494
- setSelectedHour: suggestionMenus.setSelectedHour,
1495
- setSelectedMinute: suggestionMenus.setSelectedMinute,
1496
- setSelectedPeriod: suggestionMenus.setSelectedPeriod,
1497
- closeSlashMenu: suggestionMenus.closeSlashMenu,
1498
- closeMentionMenu: suggestionMenus.closeMentionMenu,
1499
- handleConvertToTaskRef,
1500
- mentionWorkspaceId: boardConfig?.ws_id ?? effectiveTaskWsId,
1501
- });
1502
-
1503
- // Convert to task handler
1504
- const handleConvertToTask = useCallback(async () => {
1505
- if (!editorInstance || !boardId) return;
1506
-
1507
- const targetList = resolveInlineTaskTargetList({
1508
- availableLists,
1509
- preferredListId: formState.selectedListId || task?.list_id,
1510
- });
1511
-
1512
- if (!targetList) {
1513
- toast.error('No lists available', {
1514
- description: 'Create a list first before converting items to tasks',
1515
- });
1516
- return;
1517
- }
1518
-
1519
- const inlineTaskWorkspaceId = resolveInlineTaskTargetWorkspaceId({
1520
- boardWorkspaceId: boardConfig?.ws_id,
1521
- fallbackWorkspaceId: effectiveTaskWsId,
1522
- });
1523
-
1524
- // Store the created task to add to cache later
1525
- let createdTask: Task | null = null;
1526
-
1527
- const result = await convertListItemToTask({
1528
- editor: editorInstance,
1529
- listId: targetList.id,
1530
- listName: targetList.name,
1531
- wrapInParagraph: false,
1532
- createTask: async ({
1533
- name,
1534
- listId,
1535
- }: {
1536
- name: string;
1537
- listId: string;
1538
- }) => {
1539
- const response = await createWorkspaceTask(inlineTaskWorkspaceId, {
1540
- name,
1541
- listId,
1542
- });
1543
- const newTask = response.task;
1544
- if (!newTask) {
1545
- throw new Error('Failed to create task');
1546
- }
1547
-
1548
- // Store full task for cache update
1549
- createdTask = {
1550
- ...newTask,
1551
- assignees: [],
1552
- labels: [],
1553
- projects: [],
1554
- } as Task;
1555
-
1556
- return {
1557
- id: newTask.id,
1558
- name: newTask.name,
1559
- display_number: newTask.display_number ?? undefined,
1560
- priority: newTask.priority || undefined,
1561
- listColor: targetList.color || undefined,
1562
- workspaceId: inlineTaskWorkspaceId,
1563
- };
1564
- },
1565
- });
1566
- if (!result.success) {
1567
- toast.error(result.error!.message, {
1568
- description: result.error!.description,
1569
- });
1570
- return;
1571
- }
1572
-
1573
- // CRITICAL: Flush the debounced editor change immediately after inserting the mention.
1574
- // Without this, the editor's onChange is debounced (500ms delay), and any re-render
1575
- // during that window causes the editor to sync back to stale content, erasing the mention.
1576
- // This ensures the React state (description) is updated BEFORE any cache invalidations.
1577
- if (flushEditorPendingRef.current) {
1578
- flushEditorPendingRef.current();
1579
- }
1580
-
1581
- // Add the new task to the cache directly instead of relying on realtime
1582
- // This ensures the task appears immediately in personal workspaces (no realtime)
1583
- // and avoids full-board refetch flickering
1584
- if (createdTask) {
1585
- queryClient.setQueryData(
1586
- ['tasks', boardId],
1587
- (old: Task[] | undefined) => {
1588
- if (!old) return [createdTask];
1589
- // Check if task already exists (from realtime), if so don't duplicate
1590
- if (old.some((t) => t.id === createdTask!.id)) return old;
1591
- return [...old, createdTask];
1592
- }
1593
- );
1594
- }
1595
-
1596
- // Only invalidate time tracking data since task availability affects it
1597
- await queryClient.invalidateQueries({
1598
- queryKey: ['time-tracking-data'],
1599
- });
1600
-
1601
- toast('Task created', {
1602
- description: `Created task "${result.taskName}" and added mention`,
1603
- });
1604
- }, [
1605
- editorInstance,
1606
- boardId,
1607
- availableLists,
1608
- formState.selectedListId,
1609
- task?.list_id,
1610
- queryClient,
1611
- effectiveTaskWsId,
1612
- boardConfig?.ws_id,
1613
- ]);
1614
-
1615
- // Save handler
1616
- // Transform user for save hook (ensure id is string if present)
1617
- const userForSave = useMemo(() => {
1618
- if (!user?.id) return null;
1619
- return {
1620
- id: user.id,
1621
- display_name: user.display_name,
1622
- avatar_url: user.avatar_url,
1623
- };
1624
- }, [user?.id, user?.display_name, user?.avatar_url]);
1625
-
1626
- const { handleSave, handleSaveRef } = useTaskSave({
1627
- wsId: effectiveTaskWsId,
1628
- boardId,
1629
- taskId: task?.id,
1630
- saveAsDraft: isCreateMode && (!!draftId || saveAsDraft),
1631
- draftId,
1632
- isCreateMode,
1633
- collaborationMode: effectiveCollaborationMode,
1634
- isPersonalWorkspace,
1635
- shareCode,
1636
- sharedPermission,
1637
- parentTaskId,
1638
- pendingRelationship,
1639
- pendingTaskRelationships: pendingRelationships,
1640
- draftStorageKey,
1641
- name: formState.name,
1642
- description: formState.description,
1643
- editorInstance,
1644
- priority: formState.priority,
1645
- startDate: formState.startDate,
1646
- endDate: formState.endDate,
1647
- selectedListId: formState.selectedListId,
1648
- estimationPoints: formState.estimationPoints,
1649
- selectedLabels: formState.selectedLabels,
1650
- selectedAssignees: formState.selectedAssignees,
1651
- selectedProjects: formState.selectedProjects,
1652
- totalDuration: formState.totalDuration,
1653
- isSplittable: formState.isSplittable,
1654
- minSplitDurationMinutes: formState.minSplitDurationMinutes,
1655
- maxSplitDurationMinutes: formState.maxSplitDurationMinutes,
1656
- calendarHours: formState.calendarHours,
1657
- autoSchedule: formState.autoSchedule,
1658
- saveSchedulingSettings,
1659
- hasUnsavedSchedulingChanges,
1660
- user: userForSave,
1661
- userTaskSettings,
1662
- createMultiple,
1663
- nameUpdateTimerRef,
1664
- pendingNameRef,
1665
- flushEditorPendingRef,
1666
- queryClient,
1667
- onUpdate,
1668
- onClose,
1669
- setIsSaving,
1670
- setIsLoading,
1671
- setName: formState.setName,
1672
- setDescription: formState.setDescription,
1673
- setPriority: formState.setPriority,
1674
- setStartDate: formState.setStartDate,
1675
- setEndDate: formState.setEndDate,
1676
- setEstimationPoints: formState.setEstimationPoints,
1677
- setSelectedLabels: formState.setSelectedLabels,
1678
- setSelectedAssignees: formState.setSelectedAssignees,
1679
- setSelectedProjects: formState.setSelectedProjects,
1680
- });
1681
-
1682
- const smartSuggestionsMutation = useMutation({
1683
- mutationFn: async () => {
1684
- const prompt = formState.name.trim();
1685
- if (!prompt) {
1686
- throw new Error(dialogT('smart_prompt_required'));
1687
- }
1688
-
1689
- const currentDescription =
1690
- flushEditorPendingRef.current?.() ?? formState.description;
1691
-
1692
- return createWorkspaceTaskSuggestions(effectiveTaskWsId, {
1693
- boardId,
1694
- prompt,
1695
- description:
1696
- serializeTaskDescriptionPersistenceSnapshot(currentDescription),
1697
- currentListId: formState.selectedListId || undefined,
1698
- clientTimezone:
1699
- Intl.DateTimeFormat().resolvedOptions().timeZone || undefined,
1700
- clientTimestamp: new Date().toISOString(),
1701
- });
1702
- },
1703
- onMutate: () => {
1704
- setSmartSuggestionError(null);
1705
- setSmartCreateErrors({});
1706
- },
1707
- onSuccess: (response) => {
1708
- const suggestions = response.tasks ?? [];
1709
- setSmartSuggestions(suggestions);
1710
- setSelectedSmartSuggestionIds(
1711
- suggestions.map((suggestion) => suggestion.id)
1712
- );
1713
- if (!suggestions.length) {
1714
- setSmartSuggestionError(dialogT('smart_no_suggestions'));
1715
- }
1716
- },
1717
- onError: (error) => {
1718
- setSmartSuggestionError(
1719
- error instanceof Error
1720
- ? error.message
1721
- : dialogT('smart_suggestions_failed_description')
1722
- );
1723
- },
1724
- });
1725
-
1726
- const canUseSmartSuggestions =
1727
- isCreateMode && !draftId && !disabled && Boolean(boardId);
1728
-
1729
- const handleGenerateSmartSuggestions = useCallback(() => {
1730
- if (!canUseSmartSuggestions) return;
1731
-
1732
- if (!formState.name.trim()) {
1733
- toast.error(dialogT('smart_prompt_required'));
1734
- return;
1735
- }
1736
-
1737
- smartSuggestionsMutation.mutate();
1738
- }, [
1739
- canUseSmartSuggestions,
1740
- dialogT,
1741
- formState.name,
1742
- smartSuggestionsMutation,
1743
- ]);
1744
-
1745
- const applySmartSuggestion = useCallback(
1746
- (suggestion: WorkspaceTaskSuggestionTask) => {
1747
- formState.setName(suggestion.title);
1748
- formState.setDescription(getDescriptionContent(suggestion.description));
1749
- formState.setPriority(suggestion.priority);
1750
- formState.setEndDate(
1751
- suggestion.endDate ? new Date(suggestion.endDate) : undefined
1752
- );
1753
- formState.setSelectedListId(suggestion.listId);
1754
- formState.setEstimationPoints(suggestion.estimationPoints);
1755
- formState.setSelectedLabels(
1756
- suggestion.labels.map((label) => ({
1757
- id: label.id,
1758
- name: label.name,
1759
- color: label.color ?? '',
1760
- created_at: label.created_at ?? '',
1761
- }))
1762
- );
1763
- formState.setSelectedProjects(
1764
- suggestion.projects.map((project) => ({
1765
- id: project.id,
1766
- name: project.name,
1767
- status: project.status ?? 'active',
1768
- }))
1769
- );
1770
- formState.setTotalDuration(
1771
- suggestion.durationMinutes ? suggestion.durationMinutes / 60 : null
1772
- );
1773
- formState.setIsSplittable(suggestion.isSplittable);
1774
- formState.setMinSplitDurationMinutes(suggestion.minSplitDurationMinutes);
1775
- formState.setMaxSplitDurationMinutes(suggestion.maxSplitDurationMinutes);
1776
- formState.setCalendarHours(suggestion.calendarHours ?? null);
1777
- formState.setAutoSchedule(suggestion.autoSchedule);
1778
- toast.success(dialogT('smart_suggestion_applied'));
1779
- },
1780
- [
1781
- dialogT,
1782
- formState.setAutoSchedule,
1783
- formState.setCalendarHours,
1784
- formState.setDescription,
1785
- formState.setEndDate,
1786
- formState.setEstimationPoints,
1787
- formState.setIsSplittable,
1788
- formState.setMaxSplitDurationMinutes,
1789
- formState.setMinSplitDurationMinutes,
1790
- formState.setName,
1791
- formState.setPriority,
1792
- formState.setSelectedLabels,
1793
- formState.setSelectedListId,
1794
- formState.setSelectedProjects,
1795
- formState.setTotalDuration,
1796
- ]
1797
- );
1798
-
1799
- const handleToggleSmartSuggestion = useCallback((suggestionId: string) => {
1800
- setSelectedSmartSuggestionIds((current) =>
1801
- current.includes(suggestionId)
1802
- ? current.filter((id) => id !== suggestionId)
1803
- : [...current, suggestionId]
1804
- );
1805
- }, []);
1806
-
1807
- const handleCreateSelectedSmartSuggestions = useCallback(async () => {
1808
- if (!selectedSmartSuggestionIds.length) return;
1809
-
1810
- const selectedSuggestions = smartSuggestions.filter((suggestion) =>
1811
- selectedSmartSuggestionIds.includes(suggestion.id)
1812
- );
1813
- if (!selectedSuggestions.length) return;
1814
-
1815
- setIsCreatingSmartSuggestions(true);
1816
- setSmartCreateErrors({});
1817
- setCreatingSmartSuggestionIds(selectedSuggestions.map((s) => s.id));
1818
-
1819
- let resolvedUserId = user?.id;
1820
- if (!resolvedUserId && isPersonalWorkspace) {
1821
- resolvedUserId = userForSave?.id;
1822
- }
1823
-
1824
- const currentAssigneeIds = formState.selectedAssignees
1825
- .map((assignee) => assignee.user_id || assignee.id)
1826
- .filter((assigneeId): assigneeId is string => !!assigneeId);
1827
- const desiredAssigneeIds =
1828
- currentAssigneeIds.length > 0
1829
- ? currentAssigneeIds
1830
- : userTaskSettings?.task_auto_assign_to_self &&
1831
- resolvedUserId &&
1832
- !isPersonalWorkspace
1833
- ? [resolvedUserId]
1834
- : [];
1835
- const nextErrors: Record<string, string> = {};
1836
- const broadcast = getActiveBroadcast() ?? taskRealtimeBroadcastRef.current;
1837
-
1838
- for (const suggestion of selectedSuggestions) {
1839
- setCreatingSmartSuggestionIds((current) =>
1840
- current.includes(suggestion.id) ? current : [...current, suggestion.id]
1841
- );
1842
-
1843
- try {
1844
- const response = await createWorkspaceTask(effectiveTaskWsId, {
1845
- name: suggestion.title,
1846
- description: suggestion.description,
1847
- listId: suggestion.listId,
1848
- priority: suggestion.priority,
1849
- end_date: suggestion.endDate,
1850
- estimation_points: suggestion.estimationPoints,
1851
- label_ids: suggestion.labelIds,
1852
- project_ids: suggestion.projectIds,
1853
- assignee_ids: desiredAssigneeIds,
1854
- total_duration: suggestion.durationMinutes
1855
- ? suggestion.durationMinutes / 60
1856
- : null,
1857
- is_splittable: suggestion.isSplittable,
1858
- min_split_duration_minutes: suggestion.minSplitDurationMinutes,
1859
- max_split_duration_minutes: suggestion.maxSplitDurationMinutes,
1860
- calendar_hours: suggestion.calendarHours,
1861
- auto_schedule: suggestion.autoSchedule,
1862
- });
1863
-
1864
- const createdTask: Task = {
1865
- ...(response.task as Task),
1866
- labels: suggestion.labels.map((label) => ({
1867
- id: label.id,
1868
- name: label.name,
1869
- color: label.color ?? '',
1870
- created_at: label.created_at ?? '',
1871
- })),
1872
- assignees: desiredAssigneeIds.map((assigneeId) => ({
1873
- id: assigneeId,
1874
- })),
1875
- projects: suggestion.projects.map((project) => ({
1876
- id: project.id,
1877
- name: project.name,
1878
- status: project.status ?? 'active',
1879
- })),
1880
- };
1881
-
1882
- queryClient.setQueryData(
1883
- ['tasks', boardId],
1884
- (old: Task[] | undefined) => {
1885
- if (!old) return [createdTask];
1886
- if (old.some((task) => task.id === createdTask.id)) return old;
1887
- return [...old, createdTask];
1888
- }
1889
- );
1890
- broadcast?.('task:upsert', { task: createdTask });
1891
- if (
1892
- suggestion.labelIds.length ||
1893
- suggestion.projectIds.length ||
1894
- desiredAssigneeIds.length
1895
- ) {
1896
- broadcast?.('task:relations-changed', { taskId: createdTask.id });
1897
- }
1898
- } catch (error) {
1899
- nextErrors[suggestion.id] =
1900
- error instanceof Error
1901
- ? error.message
1902
- : dialogT('smart_create_failed');
1903
- } finally {
1904
- setCreatingSmartSuggestionIds((current) =>
1905
- current.filter((id) => id !== suggestion.id)
1906
- );
1907
- }
1908
- }
1909
-
1910
- await invalidateTaskCaches(queryClient, boardId);
1911
- onUpdate();
1912
-
1913
- setSmartCreateErrors(nextErrors);
1914
- const failedIds = Object.keys(nextErrors);
1915
- setSelectedSmartSuggestionIds(failedIds);
1916
-
1917
- if (failedIds.length) {
1918
- toast.error(dialogT('smart_create_partial_failed'));
1919
- } else {
1920
- toast.success(
1921
- dialogT('smart_create_selected_success', {
1922
- count: selectedSuggestions.length,
1923
- })
1924
- );
1925
- setSmartSuggestions([]);
1926
- setSelectedSmartSuggestionIds([]);
1927
- onClose();
1928
- }
1929
-
1930
- setIsCreatingSmartSuggestions(false);
1931
- setCreatingSmartSuggestionIds([]);
1932
- }, [
1933
- boardId,
1934
- dialogT,
1935
- effectiveTaskWsId,
1936
- formState.selectedAssignees,
1937
- isPersonalWorkspace,
1938
- onClose,
1939
- onUpdate,
1940
- queryClient,
1941
- selectedSmartSuggestionIds,
1942
- smartSuggestions,
1943
- user?.id,
1944
- userForSave?.id,
1945
- userTaskSettings?.task_auto_assign_to_self,
1946
- ]);
1947
-
1948
- const smartSuggestionsPanel =
1949
- canUseSmartSuggestions &&
1950
- (smartSuggestionsMutation.isPending ||
1951
- smartSuggestionError ||
1952
- smartSuggestions.length > 0) ? (
1953
- <SmartTaskSuggestionsPanel
1954
- suggestions={smartSuggestions}
1955
- selectedSuggestionIds={selectedSmartSuggestionIds}
1956
- createErrors={smartCreateErrors}
1957
- creatingSuggestionIds={creatingSmartSuggestionIds}
1958
- errorMessage={smartSuggestionError}
1959
- isCreatingSelected={isCreatingSmartSuggestions}
1960
- isLoading={smartSuggestionsMutation.isPending}
1961
- onApplyFirst={() => {
1962
- const firstSuggestion = smartSuggestions[0];
1963
- if (firstSuggestion) applySmartSuggestion(firstSuggestion);
1964
- }}
1965
- onApplySuggestion={applySmartSuggestion}
1966
- onClose={() => {
1967
- setSmartSuggestions([]);
1968
- setSelectedSmartSuggestionIds([]);
1969
- setSmartSuggestionError(null);
1970
- setSmartCreateErrors({});
1971
- }}
1972
- onCreateSelected={handleCreateSelectedSmartSuggestions}
1973
- onRetry={handleGenerateSmartSuggestions}
1974
- onToggleSuggestion={handleToggleSmartSuggestion}
1975
- />
1976
- ) : null;
1977
-
1978
- const smartSuggestionsButton = canUseSmartSuggestions ? (
1979
- <SmartTaskSuggestionsButton
1980
- disabled={smartSuggestionsMutation.isPending || isLoading}
1981
- isLoading={smartSuggestionsMutation.isPending}
1982
- onClick={handleGenerateSmartSuggestions}
1983
- />
1984
- ) : null;
1985
-
1986
- const persistTaskDescriptionOnClose = useCallback(async () => {
1987
- if (isCreateMode || !task?.id || !flushEditorPendingRef.current) {
1988
- return true;
1989
- }
1990
-
1991
- closeBlockedByOverflowRef.current = false;
1992
-
1993
- const currentContent = normalizeTaskDescriptionSnapshot(
1994
- flushEditorPendingRef.current()
1995
- );
1996
- const currentSerializedDescription =
1997
- serializeTaskDescriptionPersistenceSnapshot(currentContent) ?? null;
1998
-
1999
- if (
2000
- currentSerializedDescription &&
2001
- currentSerializedDescription.length > MAX_TASK_DESCRIPTION_LENGTH
2002
- ) {
2003
- closeBlockedByOverflowRef.current = true;
2004
- setShowDescriptionOverflowWarning(true);
2005
- return false;
2006
- }
2007
-
2008
- const initialSerializedDescription = persistedDescriptionRef.current;
2009
-
2010
- if (currentSerializedDescription === initialSerializedDescription) {
2011
- return true;
2012
- }
2013
-
2014
- if (
2015
- !canPersistTaskDescriptionSnapshot({
2016
- currentSerializedDescription,
2017
- guardState: descriptionPersistenceGuardRef.current,
2018
- })
2019
- ) {
2020
- return false;
2021
- }
2022
-
2023
- const yjsState =
2024
- currentContent && editorInstance?.schema
2025
- ? Array.from(
2026
- convertJsonContentToYjsState(currentContent, editorInstance.schema)
2027
- )
2028
- : null;
2029
-
2030
- const didPersist = await saveAndVerifyYjsDescriptionToDatabase({
2031
- wsId: effectiveTaskWsId,
2032
- taskId: task.id,
2033
- getContent: () => currentContent,
2034
- getYjsState: () => yjsState,
2035
- boardId,
2036
- queryClient,
2037
- context: 'close',
2038
- });
2039
-
2040
- if (didPersist) {
2041
- persistedDescriptionRef.current = currentSerializedDescription;
2042
- descriptionPersistenceGuardRef.current =
2043
- createTaskDescriptionPersistenceGuardState({
2044
- persistedDescription: currentSerializedDescription,
2045
- trustPersistedDescription: true,
2046
- });
2047
- }
2048
-
2049
- return didPersist;
2050
- }, [
2051
- isCreateMode,
2052
- task?.id,
2053
- effectiveTaskWsId,
2054
- editorInstance,
2055
- boardId,
2056
- queryClient,
2057
- ]);
2058
-
2059
- const hasPendingRealtimeDescriptionChanges = useCallback(() => {
2060
- if (isCreateMode || !task?.id || !flushEditorPendingRef.current) {
2061
- return false;
2062
- }
2063
-
2064
- const currentContent = normalizeTaskDescriptionSnapshot(
2065
- flushEditorPendingRef.current()
2066
- );
2067
- const currentSerializedDescription =
2068
- serializeTaskDescriptionPersistenceSnapshot(currentContent) ?? null;
2069
-
2070
- if (
2071
- currentSerializedDescription &&
2072
- currentSerializedDescription.length > MAX_TASK_DESCRIPTION_LENGTH
2073
- ) {
2074
- return false;
2075
- }
2076
-
2077
- const initialSerializedDescription = persistedDescriptionRef.current;
2078
-
2079
- return currentSerializedDescription !== initialSerializedDescription;
2080
- }, [isCreateMode, task?.id]);
2081
-
2082
- // Close handlers
2083
- const { handleClose, handleForceClose, handleNavigateBack, handleCloseRef } =
2084
- useTaskDialogClose({
2085
- taskId: task?.id,
2086
- isCreateMode,
2087
- collaborationMode: effectiveCollaborationMode,
2088
- synced,
2089
- connected,
2090
- draftStorageKey,
2091
- parentTaskId,
2092
- pendingRelationship,
2093
- onClose,
2094
- onNavigateToTask,
2095
- flushNameUpdate,
2096
- persistTaskDescription: persistTaskDescriptionOnClose,
2097
- hasPendingRealtimeDescriptionChanges,
2098
- onCloseBlocked: () => {
2099
- if (closeBlockedByOverflowRef.current) {
2100
- return;
2101
- }
2102
-
2103
- setShowDescriptionCloseWarning(true);
2104
- },
2105
- setShowSyncWarning,
2106
- });
2107
-
2108
- // Attempt close — intercepts in create mode with unsaved changes
2109
- const handleAttemptClose = useCallback(async () => {
2110
- if (isCreateMode && hasUnsavedChanges && formState.name.trim()) {
2111
- setShowUnsavedWarning(true);
2112
- return false;
2113
- }
2114
- return handleClose();
2115
- }, [isCreateMode, hasUnsavedChanges, formState.name, handleClose]);
2116
-
2117
- const handleConfirmCloseWithOverflow = useCallback(async () => {
2118
- closeBlockedByOverflowRef.current = false;
2119
- setShowDescriptionOverflowWarning(false);
2120
-
2121
- await flushNameUpdate();
2122
-
2123
- if (!isCreateMode) {
2124
- clearDraft(draftStorageKey);
2125
- }
2126
-
2127
- onClose();
2128
- }, [flushNameUpdate, isCreateMode, draftStorageKey, onClose]);
2129
-
2130
- const handleConfirmCloseWithUnconfirmedDescription = useCallback(async () => {
2131
- setShowDescriptionCloseWarning(false);
2132
- await handleForceClose();
2133
- }, [handleForceClose]);
2134
-
2135
- // Dialog open change - prevents close when menus are open
2136
- const handleDialogOpenChange = useCallback(
2137
- (open: boolean) => {
2138
- if (
2139
- !open &&
2140
- !suggestionMenus.showCustomDatePicker &&
2141
- !suggestionMenus.slashState.open &&
2142
- !suggestionMenus.mentionState.open
2143
- ) {
2144
- void handleAttemptClose();
2145
- }
2146
- },
2147
- [
2148
- suggestionMenus.showCustomDatePicker,
2149
- suggestionMenus.slashState.open,
2150
- suggestionMenus.mentionState.open,
2151
- handleAttemptClose,
2152
- ]
2153
- );
2154
-
2155
- useEffect(() => {
2156
- if (!isOpen) {
2157
- registerCloseRequestHandler(null);
2158
- return;
2159
- }
2160
-
2161
- registerCloseRequestHandler(() => {
2162
- return handleAttemptClose();
2163
- });
2164
-
2165
- return () => {
2166
- registerCloseRequestHandler(null);
2167
- };
2168
- }, [handleAttemptClose, isOpen, registerCloseRequestHandler]);
2169
-
2170
- // Unsaved changes warning handlers
2171
- const handleWarningDiscard = useCallback(() => {
2172
- setShowUnsavedWarning(false);
2173
- handleClose();
2174
- }, [handleClose]);
2175
-
2176
- const handleWarningSaveAsDraft = useCallback(() => {
2177
- setShowUnsavedWarning(false);
2178
- setSaveAsDraft(true);
2179
- // Wait for React to re-render with updated saveAsDraft before triggering save
2180
- setTimeout(() => handleSaveRef.current(), 0);
2181
- }, [handleSaveRef]);
2182
-
2183
- const handleWarningCreateTask = useCallback(() => {
2184
- setShowUnsavedWarning(false);
2185
- setSaveAsDraft(false);
2186
- // Wait for React to re-render with updated saveAsDraft before triggering save
2187
- setTimeout(() => handleSaveRef.current(), 0);
2188
- }, [handleSaveRef]);
2189
-
2190
- const handleEditorReady = useCallback((editor: Editor) => {
2191
- setEditorInstance(editor);
2192
- }, []);
2193
-
2194
- // Navigate to a collaborator's cursor position in the editor.
2195
- // The CollaborationCaret extension renders `<span class="collaboration-carets__label">`
2196
- // with the user's display name. We match by name and scroll it into view.
2197
- const scrollToUserCursor = useCallback(
2198
- (_userId: string, displayName: string) => {
2199
- if (!editorInstance) return;
2200
-
2201
- // Search inside the ProseMirror editor DOM for caret labels
2202
- const labels = editorInstance.view.dom.querySelectorAll(
2203
- '.collaboration-carets__label'
2204
- );
2205
- for (const label of labels) {
2206
- if (label.textContent?.trim() === displayName) {
2207
- // Scroll the parent caret element into view (the label is positioned absolute)
2208
- const caret = label.closest('.collaboration-carets__caret');
2209
- (caret ?? label).scrollIntoView({
2210
- behavior: 'smooth',
2211
- block: 'center',
2212
- });
2213
- // Briefly flash the label so the user spots it
2214
- const el = label as HTMLElement;
2215
- el.style.opacity = '1';
2216
- el.style.animation = 'none';
2217
- setTimeout(() => {
2218
- el.style.animation = '';
2219
- }, 2000);
2220
- return;
2221
- }
2222
- }
2223
- },
2224
- [editorInstance]
2225
- );
2226
-
2227
- // Keyboard shortcuts
2228
- const hasUnsavedChangesRef = useRef<boolean>(false);
2229
- hasUnsavedChangesRef.current = hasUnsavedChanges;
2230
-
2231
- useTaskDialogKeyboardShortcuts({
2232
- isOpen,
2233
- canSave,
2234
- isCreateMode,
2235
- collaborationMode: effectiveCollaborationMode,
2236
- disabled: taskControlsDisabled,
2237
- editorInstance,
2238
- boardConfig,
2239
- slashState: suggestionMenus.slashState,
2240
- filteredSlashCommands: suggestionMenus.filteredSlashCommands,
2241
- slashHighlightIndex: suggestionMenus.slashHighlightIndex,
2242
- setSlashHighlightIndex: suggestionMenus.setSlashHighlightIndex,
2243
- mentionState: suggestionMenus.mentionState,
2244
- filteredMentionOptions: suggestionMenus.filteredMentionOptions,
2245
- mentionHighlightIndex: suggestionMenus.mentionHighlightIndex,
2246
- setMentionHighlightIndex: suggestionMenus.setMentionHighlightIndex,
2247
- showCustomDatePicker: suggestionMenus.showCustomDatePicker,
2248
- setShowCustomDatePicker: suggestionMenus.setShowCustomDatePicker,
2249
- setCustomDate: suggestionMenus.setCustomDate,
2250
- handleSaveRef,
2251
- handleCloseRef,
2252
- hasUnsavedChangesRef,
2253
- quickDueRef,
2254
- updateEstimationRef,
2255
- setPriority: formState.setPriority,
2256
- setShowAdvancedOptions,
2257
- executeSlashCommand,
2258
- insertMentionOption,
2259
- closeSlashMenu: suggestionMenus.closeSlashMenu,
2260
- closeMentionMenu: suggestionMenus.closeMentionMenu,
2261
- });
2262
-
2263
- // Auto-close sync warning
2264
- useEffect(() => {
2265
- if (showSyncWarning && synced && connected) {
2266
- const timer = setTimeout(async () => {
2267
- setShowSyncWarning(false);
2268
- await handleClose();
2269
- }, 500);
2270
- return () => clearTimeout(timer);
2271
- }
2272
- }, [showSyncWarning, synced, connected, handleClose]);
2273
-
2274
- // Sync saveAsDraft with user setting when dialog opens (always on when editing a draft)
2275
- useEffect(() => {
2276
- if (isOpen) {
2277
- setSaveAsDraft(!!draftId || draftModeEnabled);
2278
- }
2279
- }, [isOpen, draftModeEnabled, draftId]);
2280
-
2281
- useEffect(() => {
2282
- const justOpened = isOpen && !previousOpenRef.current;
2283
- previousOpenRef.current = isOpen;
2284
-
2285
- if (!isOpen) {
2286
- setPresentation(openingPresentation);
2287
- setSmartSuggestions([]);
2288
- setSelectedSmartSuggestionIds([]);
2289
- setSmartSuggestionError(null);
2290
- setSmartCreateErrors({});
2291
- setCreatingSmartSuggestionIds([]);
2292
- setIsCreatingSmartSuggestions(false);
2293
- return;
2294
- }
2295
-
2296
- if (justOpened) {
2297
- setPresentation(openingPresentation);
2298
- return;
2299
- }
2300
-
2301
- if (!isCreateMode && currentList?.status === 'documents') {
2302
- setPresentation('fullscreen');
2303
- }
2304
- }, [currentList?.status, isCreateMode, isOpen, openingPresentation]);
2305
-
2306
- // Track whether the title input is scrolled out of view
2307
- useEffect(() => {
2308
- const el = titleInputRef.current;
2309
- if (!el || !scrollContainer || !isOpen) {
2310
- setIsTitleVisible(true);
2311
- return;
2312
- }
2313
- const observer = new IntersectionObserver(
2314
- ([entry]) => setIsTitleVisible(!!entry?.isIntersecting),
2315
- { root: scrollContainer, threshold: 0 }
2316
- );
2317
- observer.observe(el);
2318
- return () => observer.disconnect();
2319
- }, [isOpen, scrollContainer]);
2320
-
2321
- // Reset state when dialog closes
2322
- useEffect(() => {
2323
- if (!isOpen) {
2324
- if (nameUpdateTimerRef.current) {
2325
- clearTimeout(nameUpdateTimerRef.current);
2326
- nameUpdateTimerRef.current = null;
2327
- pendingNameRef.current = null;
2328
- }
2329
- suggestionMenus.setSlashState(createInitialSuggestionState());
2330
- suggestionMenus.setMentionState(createInitialSuggestionState());
2331
- setEditorInstance(null);
2332
- suggestionMenus.setSlashHighlightIndex(0);
2333
- suggestionMenus.setMentionHighlightIndex(0);
2334
- suggestionMenus.setShowCustomDatePicker(false);
2335
- suggestionMenus.setCustomDate(undefined);
2336
- suggestionMenus.setIncludeTime(false);
2337
- suggestionMenus.setSelectedHour('11');
2338
- suggestionMenus.setSelectedMinute('59');
2339
- suggestionMenus.setSelectedPeriod('PM');
2340
- }
2341
- }, [isOpen, suggestionMenus]);
2342
-
2343
- // Task search debouncing
2344
- useEffect(() => {
2345
- if (!isOpen || !effectiveTaskWsId || !suggestionMenus.mentionState.open) {
2346
- if (taskSearchQuery) setTaskSearchQuery('');
2347
- return;
2348
- }
2349
- const query = suggestionMenus.mentionState.query.trim();
2350
- if (taskSearchDebounceRef.current)
2351
- clearTimeout(taskSearchDebounceRef.current);
2352
- taskSearchDebounceRef.current = setTimeout(() => {
2353
- if (query !== taskSearchQuery) setTaskSearchQuery(query);
2354
- }, 300);
2355
- return () => {
2356
- if (taskSearchDebounceRef.current)
2357
- clearTimeout(taskSearchDebounceRef.current);
2358
- };
2359
- }, [
2360
- isOpen,
2361
- effectiveTaskWsId,
2362
- suggestionMenus.mentionState.open,
2363
- suggestionMenus.mentionState.query,
2364
- taskSearchQuery,
2365
- ]);
2366
-
2367
- const showCompactDialog = presentation === 'compact' && !draftId;
2368
- const compactDescriptionPreview = useMemo(() => {
2369
- if (isCreateMode) return null;
2370
-
2371
- const previewText = getTaskDescriptionPreviewText(
2372
- formState.description
2373
- ).trim();
2374
-
2375
- return previewText || null;
2376
- }, [formState.description, isCreateMode]);
2377
- const taskHydrationNotice = taskLoadError ? (
2378
- <div
2379
- className="mx-4 mb-2 flex items-center justify-between gap-3 rounded-md border border-dynamic-red/30 bg-dynamic-red/10 px-3 py-2 text-dynamic-red text-sm md:mx-8"
2380
- role="alert"
2381
- >
2382
- <span>{t('please_try_again_later')}</span>
2383
- {onRetryTaskLoad && (
2384
- <Button
2385
- type="button"
2386
- variant="secondary"
2387
- size="xs"
2388
- onClick={onRetryTaskLoad}
2389
- >
2390
- {t('retry')}
2391
- </Button>
2392
- )}
2393
- </div>
2394
- ) : null;
2395
- const compactHeaderInfo = useMemo(
2396
- () =>
2397
- getTaskDialogHeaderInfo(
2398
- {
2399
- isCreateMode,
2400
- parentTaskId,
2401
- parentTaskName,
2402
- pendingRelationship,
2403
- draftId,
2404
- },
2405
- rootT
2406
- ),
2407
- [
2408
- isCreateMode,
2409
- parentTaskId,
2410
- parentTaskName,
2411
- pendingRelationship,
2412
- draftId,
2413
- rootT,
2414
- ]
2415
- );
2416
- const compactEditActions = canShowCompactEditActions ? (
2417
- <>
2418
- {showCompactDoneAction && doneList && (
2419
- <Tooltip>
2420
- <TooltipTrigger asChild>
2421
- <Button
2422
- type="button"
2423
- variant="ghost"
2424
- size="icon"
2425
- aria-label={t('mark_as_done')}
2426
- disabled={compactEditActionsDisabled}
2427
- className="h-8 w-8 text-muted-foreground hover:text-foreground"
2428
- onClick={() => void updateList(doneList.id)}
2429
- >
2430
- <CheckCircle2 className="h-4 w-4" />
2431
- </Button>
2432
- </TooltipTrigger>
2433
- <TooltipContent side="top">{t('mark_as_done')}</TooltipContent>
2434
- </Tooltip>
2435
- )}
2436
- {(showCompactClosedAction || showDocumentArchiveAction) && closedList && (
2437
- <Tooltip>
2438
- <TooltipTrigger asChild>
2439
- <Button
2440
- type="button"
2441
- variant="ghost"
2442
- size="icon"
2443
- aria-label={t('archive')}
2444
- disabled={compactEditActionsDisabled}
2445
- className="h-8 w-8 text-muted-foreground hover:text-foreground"
2446
- onClick={() => void updateList(closedList.id)}
2447
- >
2448
- <Archive className="h-4 w-4" />
2449
- </Button>
2450
- </TooltipTrigger>
2451
- <TooltipContent side="top">{t('archive')}</TooltipContent>
2452
- </Tooltip>
2453
- )}
2454
- <Tooltip>
2455
- <TooltipTrigger asChild>
2456
- <Button
2457
- type="button"
2458
- variant="ghost"
2459
- size="icon"
2460
- aria-label={t('delete_task')}
2461
- disabled={compactEditActionsDisabled}
2462
- className="h-8 w-8 text-muted-foreground hover:text-foreground"
2463
- onClick={() => setShowDeleteConfirm(true)}
2464
- >
2465
- <Trash2 className="h-4 w-4" />
2466
- </Button>
2467
- </TooltipTrigger>
2468
- <TooltipContent side="top">{t('delete_task')}</TooltipContent>
2469
- </Tooltip>
2470
- </>
2471
- ) : undefined;
2472
-
2473
- // Update refs
2474
- quickDueRef.current = handleQuickDueDate;
2475
- updateEstimationRef.current = updateEstimation;
2476
- handleConvertToTaskRef.current = handleConvertToTask;
2477
-
2478
- const renderTaskPropertiesSection = (
2479
- variant: 'default' | 'compact' = 'default'
2480
- ) => (
2481
- <TaskPropertiesSection
2482
- wsId={effectiveTaskWsId}
2483
- boardId={boardId}
2484
- taskId={task?.id}
2485
- priority={formState.priority}
2486
- startDate={formState.startDate}
2487
- endDate={formState.endDate}
2488
- estimationPoints={formState.estimationPoints}
2489
- selectedLabels={formState.selectedLabels}
2490
- selectedProjects={formState.selectedProjects}
2491
- selectedListId={formState.selectedListId}
2492
- selectedAssignees={formState.selectedAssignees}
2493
- isLoading={isLoading}
2494
- isPersonalWorkspace={isPersonalWorkspace}
2495
- canUseBoardAssignees={canUseBoardAssignees ?? !isPersonalWorkspace}
2496
- totalDuration={formState.totalDuration}
2497
- isSplittable={formState.isSplittable}
2498
- minSplitDurationMinutes={formState.minSplitDurationMinutes}
2499
- maxSplitDurationMinutes={formState.maxSplitDurationMinutes}
2500
- calendarHours={formState.calendarHours}
2501
- autoSchedule={formState.autoSchedule}
2502
- availableLists={availableLists}
2503
- availableLabels={availableLabels}
2504
- taskProjects={taskProjects}
2505
- workspaceMembers={workspaceMembers}
2506
- boardConfig={boardConfig}
2507
- onPriorityChange={updatePriority}
2508
- onStartDateChange={updateStartDate}
2509
- onEndDateChange={updateEndDate}
2510
- onEstimationChange={updateEstimation}
2511
- onLabelToggle={toggleLabel}
2512
- onProjectToggle={toggleProject}
2513
- onListChange={updateList}
2514
- onAssigneeToggle={toggleAssignee}
2515
- onQuickDueDate={handleQuickDueDate}
2516
- onShowNewLabelDialog={() => {
2517
- setNewLabelColor((previousColor) =>
2518
- getRandomNewLabelColor(previousColor)
2519
- );
2520
- setShowNewLabelDialog(true);
2521
- }}
2522
- onShowNewProjectDialog={() => setShowNewProjectDialog(true)}
2523
- onShowEstimationConfigDialog={() => setShowEstimationConfigDialog(true)}
2524
- onTotalDurationChange={formState.setTotalDuration}
2525
- onIsSplittableChange={formState.setIsSplittable}
2526
- onMinSplitDurationChange={formState.setMinSplitDurationMinutes}
2527
- onMaxSplitDurationChange={formState.setMaxSplitDurationMinutes}
2528
- onCalendarHoursChange={formState.setCalendarHours}
2529
- onAutoScheduleChange={formState.setAutoSchedule}
2530
- isCreateMode={isCreateMode}
2531
- savedSchedulingSettings={
2532
- personalScheduleData?.task
2533
- ? {
2534
- totalDuration: personalScheduleData.task.total_duration ?? null,
2535
- isSplittable: !!personalScheduleData.task.is_splittable,
2536
- minSplitDurationMinutes:
2537
- personalScheduleData.task.min_split_duration_minutes ?? null,
2538
- maxSplitDurationMinutes:
2539
- personalScheduleData.task.max_split_duration_minutes ?? null,
2540
- calendarHours: personalScheduleData.task.calendar_hours ?? null,
2541
- autoSchedule: !!personalScheduleData.task.auto_schedule,
2542
- }
2543
- : undefined
2544
- }
2545
- onSaveSchedulingSettings={saveSchedulingSettings}
2546
- schedulingSaving={schedulingSaving}
2547
- scheduledEvents={localCalendarEvents}
2548
- disabled={taskControlsDisabled}
2549
- isDraftMode={!!draftId || (isCreateMode && saveAsDraft)}
2550
- variant={variant}
2551
- />
2552
- );
2553
-
2554
- return (
2555
- <>
2556
- <TaskSuggestionMenus
2557
- slashState={suggestionMenus.slashState}
2558
- filteredSlashCommands={suggestionMenus.filteredSlashCommands}
2559
- slashHighlightIndex={suggestionMenus.slashHighlightIndex}
2560
- setSlashHighlightIndex={suggestionMenus.setSlashHighlightIndex}
2561
- slashListRef={suggestionMenus.slashListRef}
2562
- mentionState={suggestionMenus.mentionState}
2563
- filteredMentionOptions={suggestionMenus.filteredMentionOptions}
2564
- mentionHighlightIndex={suggestionMenus.mentionHighlightIndex}
2565
- setMentionHighlightIndex={suggestionMenus.setMentionHighlightIndex}
2566
- mentionListRef={suggestionMenus.mentionListRef}
2567
- workspaceTasksLoading={workspaceTasksLoading}
2568
- showCustomDatePicker={suggestionMenus.showCustomDatePicker}
2569
- setShowCustomDatePicker={suggestionMenus.setShowCustomDatePicker}
2570
- customDate={suggestionMenus.customDate}
2571
- setCustomDate={suggestionMenus.setCustomDate}
2572
- includeTime={suggestionMenus.includeTime}
2573
- setIncludeTime={suggestionMenus.setIncludeTime}
2574
- selectedHour={suggestionMenus.selectedHour}
2575
- setSelectedHour={suggestionMenus.setSelectedHour}
2576
- selectedMinute={suggestionMenus.selectedMinute}
2577
- setSelectedMinute={suggestionMenus.setSelectedMinute}
2578
- selectedPeriod={suggestionMenus.selectedPeriod}
2579
- setSelectedPeriod={suggestionMenus.setSelectedPeriod}
2580
- executeSlashCommand={executeSlashCommand}
2581
- insertMentionOption={insertMentionOption}
2582
- handleCustomDateSelect={handleCustomDateSelect}
2583
- />
2584
-
2585
- <Dialog open={isOpen} onOpenChange={handleDialogOpenChange} modal={true}>
2586
- <DialogContent
2587
- showCloseButton={false}
2588
- presentation={showCompactDialog ? 'default' : 'fullscreen'}
2589
- className={
2590
- showCompactDialog
2591
- ? 'w-[min(calc(100vw-2rem),30rem)] max-w-[30rem] gap-0 overflow-visible rounded-lg border p-0 shadow-xl'
2592
- : undefined
2593
- }
2594
- onContextMenu={(e) => {
2595
- if (shouldPreserveNativeContextMenu(e.target)) {
2596
- return;
2597
- }
2598
-
2599
- e.preventDefault();
2600
- e.stopPropagation();
2601
- }}
2602
- onPointerDownOutside={(e) => {
2603
- if (
2604
- suggestionMenus.showCustomDatePicker ||
2605
- suggestionMenus.slashState.open ||
2606
- suggestionMenus.mentionState.open
2607
- )
2608
- e.preventDefault();
2609
- }}
2610
- onInteractOutside={(e) => {
2611
- if (
2612
- suggestionMenus.showCustomDatePicker ||
2613
- suggestionMenus.slashState.open ||
2614
- suggestionMenus.mentionState.open
2615
- )
2616
- e.preventDefault();
2617
- }}
2618
- >
2619
- {showCompactDialog ? (
2620
- <CompactTaskDialogPanel
2621
- title={compactHeaderInfo.title}
2622
- description={compactHeaderInfo.description}
2623
- icon={compactHeaderInfo.icon}
2624
- iconBgClass={compactHeaderInfo.iconBgClass}
2625
- iconRingClass={compactHeaderInfo.iconRingClass}
2626
- showHeaderTitle={isCreateMode}
2627
- descriptionPreview={compactDescriptionPreview}
2628
- descriptionPreviewLabel={dialogT('open_fullscreen')}
2629
- titleInput={
2630
- <TaskNameInput
2631
- name={formState.name}
2632
- isCreateMode={isCreateMode}
2633
- titleInputRef={titleInputRef}
2634
- editorRef={editorRef}
2635
- lastCursorPositionRef={lastCursorPositionRef}
2636
- targetEditorCursorRef={targetEditorCursorRef}
2637
- setName={setTaskName}
2638
- updateName={updateName}
2639
- flushNameUpdate={flushNameUpdate}
2640
- disabled={taskTitleDisabled}
2641
- variant="compact"
2642
- onSubmit={
2643
- isCreateMode && !taskControlsDisabled
2644
- ? handleSave
2645
- : undefined
2646
- }
2647
- />
2648
- }
2649
- propertyControls={renderTaskPropertiesSection('compact')}
2650
- taskStatus={taskHydrationNotice}
2651
- smartAction={smartSuggestionsButton}
2652
- smartPanel={smartSuggestionsPanel}
2653
- saveAsDraft={isCreateMode ? saveAsDraft : undefined}
2654
- createMultiple={isCreateMode ? createMultiple : undefined}
2655
- canSave={
2656
- isCreateMode
2657
- ? canSave && !isDescriptionOverLimit && !taskControlsDisabled
2658
- : undefined
2659
- }
2660
- isLoading={isLoading}
2661
- isPersonalWorkspace={isPersonalWorkspace}
2662
- editActions={compactEditActions}
2663
- onSaveAsDraftChange={isCreateMode ? setSaveAsDraft : undefined}
2664
- onCreateMultipleChange={
2665
- isCreateMode ? setCreateMultiple : undefined
2666
- }
2667
- onClose={handleAttemptClose}
2668
- onFullscreen={() => setPresentation('fullscreen')}
2669
- onDescriptionPreviewClick={() => setPresentation('fullscreen')}
2670
- onSave={
2671
- isCreateMode && !taskControlsDisabled ? handleSave : undefined
2672
- }
2673
- />
2674
- ) : (
2675
- <>
2676
- <div className="flex min-w-0 flex-1 flex-col bg-background transition-all duration-300">
2677
- {disabled && (
2678
- <DialogTitle className="sr-only">Task Details</DialogTitle>
2679
- )}
2680
- {!disabled && (
2681
- <TaskDialogHeader
2682
- isCreateMode={isCreateMode}
2683
- collaborationMode={effectiveCollaborationMode}
2684
- realtimeEnabled={effectiveRealtimeEnabled}
2685
- isOpen={isOpen}
2686
- synced={synced}
2687
- connected={connected}
2688
- taskId={task?.id}
2689
- parentTaskId={parentTaskId}
2690
- parentTaskName={parentTaskName}
2691
- pendingRelationship={pendingRelationship}
2692
- saveAsDraft={saveAsDraft}
2693
- setSaveAsDraft={setSaveAsDraft}
2694
- draftId={draftId}
2695
- isTitleVisible={isTitleVisible}
2696
- taskName={formState.name}
2697
- ticketPrefix={boardConfig?.ticket_prefix}
2698
- displayNumber={task?.display_number}
2699
- user={
2700
- user
2701
- ? {
2702
- id: user.id || '',
2703
- display_name: user.display_name ?? null,
2704
- avatar_url: user.avatar_url ?? null,
2705
- email: user.email ?? null,
2706
- }
2707
- : null
2708
- }
2709
- createMultiple={createMultiple}
2710
- hasDraft={formState.hasDraft}
2711
- wsId={effectiveTaskWsId}
2712
- boardId={boardId}
2713
- pathname={pathname}
2714
- canSave={
2715
- canSave &&
2716
- !isDescriptionOverLimit &&
2717
- !taskControlsDisabled
2718
- }
2719
- isLoading={isLoading}
2720
- setCreateMultiple={setCreateMultiple}
2721
- handleClose={handleAttemptClose}
2722
- setShowDeleteConfirm={setShowDeleteConfirm}
2723
- clearDraftState={formState.clearDraftState}
2724
- handleSave={handleSave}
2725
- onNavigateBack={
2726
- isCreateMode && (pendingRelationship || parentTaskId)
2727
- ? handleNavigateBack
2728
- : undefined
2729
- }
2730
- isPersonalWorkspace={isPersonalWorkspace}
2731
- onOpenShareDialog={
2732
- !isCreateMode && task?.id
2733
- ? () => setShowShareDialog(true)
2734
- : undefined
2735
- }
2736
- onArchiveTask={
2737
- showDocumentArchiveAction && closedList
2738
- ? () => void updateList(closedList.id)
2739
- : undefined
2740
- }
2741
- archiveTaskDisabled={compactEditActionsDisabled}
2742
- disabled={disabled}
2743
- controlsDisabled={taskControlsDisabled}
2744
- onScrollToUserCursor={
2745
- effectiveCollaborationMode
2746
- ? scrollToUserCursor
2747
- : undefined
2748
- }
2749
- />
2750
- )}
2751
-
2752
- <div
2753
- ref={setScrollContainer}
2754
- className="relative flex min-h-0 flex-1 flex-col overflow-y-auto"
2755
- >
2756
- <div className="flex flex-col">
2757
- <TaskNameInput
2758
- name={formState.name}
2759
- isCreateMode={isCreateMode}
2760
- titleInputRef={titleInputRef}
2761
- editorRef={editorRef}
2762
- lastCursorPositionRef={lastCursorPositionRef}
2763
- targetEditorCursorRef={targetEditorCursorRef}
2764
- setName={setTaskName}
2765
- updateName={updateName}
2766
- flushNameUpdate={flushNameUpdate}
2767
- disabled={taskTitleDisabled}
2768
- />
2769
-
2770
- {smartSuggestionsButton && (
2771
- <div className="flex justify-end px-4 pb-2 md:px-8">
2772
- {smartSuggestionsButton}
2773
- </div>
2774
- )}
2775
-
2776
- {!disabled && renderTaskPropertiesSection()}
2777
-
2778
- {taskHydrationNotice}
2779
-
2780
- {smartSuggestionsPanel && (
2781
- <div className="px-4 pb-3 md:px-8">
2782
- {smartSuggestionsPanel}
2783
- </div>
2784
- )}
2785
-
2786
- {!taskControlsDisabled && !isCreateMode && (
2787
- <PersonalOverridesSection
2788
- taskId={task?.id}
2789
- isCreateMode={isCreateMode}
2790
- boardConfig={boardConfig}
2791
- onUpdate={onUpdate}
2792
- />
2793
- )}
2794
-
2795
- {!taskControlsDisabled &&
2796
- !draftId &&
2797
- !(isCreateMode && saveAsDraft) && (
2798
- <TaskRelationshipsProperties
2799
- wsId={effectiveTaskWsId}
2800
- taskId={task?.id}
2801
- boardId={boardId}
2802
- listId={task?.list_id}
2803
- isCreateMode={isCreateMode}
2804
- initialActiveTab={
2805
- seededPendingRelationships.initialActiveTab
2806
- }
2807
- initialDependencySubTab={
2808
- seededPendingRelationships.initialDependencySubTab
2809
- }
2810
- parentTask={parentTask}
2811
- childTasks={childTasks}
2812
- blockingTasks={blockingTasks}
2813
- blockedByTasks={blockedByTasks}
2814
- relatedTasks={relatedTasks}
2815
- isLoading={dependenciesLoading}
2816
- onSetParent={setParentTask}
2817
- onRemoveParent={() => setParentTask(null)}
2818
- onAddBlockingTask={addBlockingTask}
2819
- onRemoveBlockingTask={removeBlockingTask}
2820
- onAddBlockedByTask={addBlockedByTask}
2821
- onRemoveBlockedByTask={removeBlockedByTask}
2822
- onAddRelatedTask={addRelatedTask}
2823
- onRemoveRelatedTask={removeRelatedTask}
2824
- onNavigateToTask={async (taskId) => {
2825
- if (onNavigateToTask)
2826
- await onNavigateToTask(taskId);
2827
- }}
2828
- onAddSubtask={isCreateMode ? undefined : onAddSubtask}
2829
- onAddParentTask={
2830
- isCreateMode ? undefined : onAddParentTask
2831
- }
2832
- onAddBlockingTaskDialog={
2833
- isCreateMode ? undefined : onAddBlockingTask
2834
- }
2835
- onAddBlockedByTaskDialog={
2836
- isCreateMode ? undefined : onAddBlockedByTask
2837
- }
2838
- onAddRelatedTaskDialog={
2839
- isCreateMode ? undefined : onAddRelatedTask
2840
- }
2841
- onAddExistingAsSubtask={addChildTask}
2842
- isSaving={!!savingRelationship}
2843
- savingTaskId={savingRelationship}
2844
- disabled={taskControlsDisabled}
2845
- />
2846
- )}
2847
-
2848
- {!taskControlsDisabled && !isCreateMode && (
2849
- <TaskDescriptionRestoreBanner
2850
- isRestoring={Boolean(restoringDescriptionVersionId)}
2851
- latestVersion={latestRestorableDescriptionVersion}
2852
- onRestoreLatest={() => {
2853
- if (latestRestorableDescriptionVersion) {
2854
- void handleRestoreDescriptionVersion(
2855
- latestRestorableDescriptionVersion
2856
- );
2857
- }
2858
- }}
2859
- onViewVersions={() =>
2860
- setShowDescriptionVersionsDialog(true)
2861
- }
2862
- t={
2863
- historyT as (
2864
- key: string,
2865
- options?: { count?: number; defaultValue?: string }
2866
- ) => string
2867
- }
2868
- versionCount={recoverableDescriptionVersions.length}
2869
- />
2870
- )}
2871
-
2872
- <TaskDescriptionEditor
2873
- description={formState.description}
2874
- setDescription={formState.setDescription}
2875
- isOpen={isOpen}
2876
- isCreateMode={isCreateMode}
2877
- collaborationMode={effectiveCollaborationMode}
2878
- realtimeEnabled={effectiveRealtimeEnabled}
2879
- isYjsSyncing={isYjsSyncing}
2880
- wsId={effectiveTaskWsId}
2881
- boardId={boardId}
2882
- taskId={task?.id}
2883
- availableLists={availableLists}
2884
- queryClient={queryClient}
2885
- editorRef={editorRef}
2886
- richTextEditorRef={richTextEditorRef}
2887
- titleInputRef={titleInputRef}
2888
- lastCursorPositionRef={lastCursorPositionRef}
2889
- targetEditorCursorRef={targetEditorCursorRef}
2890
- flushEditorPendingRef={flushEditorPendingRef}
2891
- yjsDoc={doc}
2892
- yjsProvider={provider ?? undefined}
2893
- collaborationUser={
2894
- user
2895
- ? {
2896
- id: user.id || '',
2897
- name: userDisplayName,
2898
- color: userColor || '',
2899
- }
2900
- : null
2901
- }
2902
- onImageUpload={imageUploadHandler}
2903
- onEditorReady={handleEditorReady}
2904
- onConvertToTask={handleConvertToTask}
2905
- onDescriptionSnapshotChange={recordDescriptionSnapshot}
2906
- onDescriptionStorageLengthChange={
2907
- handleDescriptionStorageLengthChange
2908
- }
2909
- descriptionStorageLength={descriptionStorageLength}
2910
- descriptionPercentLeft={descriptionPercentLeft}
2911
- descriptionLimit={MAX_TASK_DESCRIPTION_LENGTH}
2912
- isDescriptionOverLimit={isDescriptionOverLimit}
2913
- disabled={taskControlsDisabled}
2914
- mentionTranslations={{
2915
- delete_task: t('delete_task'),
2916
- delete_task_confirmation: (name: string) =>
2917
- t('delete_task_confirmation', { name }),
2918
- cancel: t('cancel'),
2919
- deleting: t('deleting'),
2920
- set_custom_due_date: t('set_custom_due_date'),
2921
- custom_due_date_description: t(
2922
- 'custom_due_date_description'
2923
- ),
2924
- remove_due_date: t('remove_due_date'),
2925
- create_new_label: t('create_new_label'),
2926
- create_new_label_description: t(
2927
- 'create_new_label_description'
2928
- ),
2929
- label_name: t('label_name'),
2930
- color: t('color'),
2931
- preview: t('preview'),
2932
- creating: t('creating'),
2933
- create_label: t('create_label'),
2934
- create_new_project: t('create_new_project'),
2935
- create_new_project_description: t(
2936
- 'create_new_project_description'
2937
- ),
2938
- project_name: t('project_name'),
2939
- create_project: t('create_project'),
2940
- }}
2941
- />
2942
-
2943
- {!isCreateMode && localCalendarEvents && (
2944
- <TaskInstancesSection
2945
- wsId={effectiveTaskWsId}
2946
- taskId={task?.id}
2947
- scheduledEvents={localCalendarEvents}
2948
- onLockToggle={handleLockToggle}
2949
- isLocking={lockingEventId}
2950
- />
2951
- )}
2952
-
2953
- {!disabled && !isCreateMode && task && (
2954
- <TaskActivitySection
2955
- wsId={effectiveTaskWsId}
2956
- taskId={task.id}
2957
- boardId={boardId}
2958
- currentTask={{
2959
- id: task.id,
2960
- name: formState.name || task.name || '',
2961
- description: formState.description,
2962
- priority: formState.priority,
2963
- start_date:
2964
- formState.startDate?.toISOString() || null,
2965
- end_date: formState.endDate?.toISOString() || null,
2966
- estimation_points: formState.estimationPoints ?? null,
2967
- list_id:
2968
- formState.selectedListId || task.list_id || '',
2969
- list_name:
2970
- availableLists?.find(
2971
- (l) => l.id === formState.selectedListId
2972
- )?.name || null,
2973
- completed: !!task.completed_at,
2974
- assignees: formState.selectedAssignees.map((a) => ({
2975
- id: a.id,
2976
- user_id: a.id,
2977
- })),
2978
- labels: formState.selectedLabels.map((l) => ({
2979
- id: l.id,
2980
- })),
2981
- projects: formState.selectedProjects.map((p) => ({
2982
- id: p.id,
2983
- })),
2984
- }}
2985
- onRestoreDescriptionVersion={
2986
- handleRestoreDescriptionVersion
2987
- }
2988
- revertDisabled={true}
2989
- restoringDescriptionVersionId={
2990
- restoringDescriptionVersionId
2991
- }
2992
- />
2993
- )}
2994
- </div>
2995
- </div>
2996
- </div>
2997
-
2998
- <MobileFloatingSaveButton
2999
- isCreateMode={isCreateMode}
3000
- collaborationMode={effectiveCollaborationMode}
3001
- isLoading={isLoading}
3002
- canSave={
3003
- canSave && !isDescriptionOverLimit && !taskControlsDisabled
3004
- }
3005
- handleSave={handleSave}
3006
- disabled={taskControlsDisabled}
3007
- />
3008
- </>
3009
- )}
3010
- </DialogContent>
3011
- </Dialog>
3012
-
3013
- <TaskDescriptionVersionRestoreDialog
3014
- currentDescription={currentSerializedDescription}
3015
- isOpen={showDescriptionVersionsDialog}
3016
- locale={locale}
3017
- onClose={() => setShowDescriptionVersionsDialog(false)}
3018
- onRestoreVersion={handleRestoreDescriptionVersion}
3019
- restoringVersionId={restoringDescriptionVersionId}
3020
- t={
3021
- historyT as (
3022
- key: string,
3023
- options?: { count?: number; defaultValue?: string }
3024
- ) => string
3025
- }
3026
- versions={recoverableDescriptionVersions}
3027
- />
3028
-
3029
- <TaskDeleteDialog
3030
- open={showDeleteConfirm}
3031
- onOpenChange={setShowDeleteConfirm}
3032
- taskId={task?.id}
3033
- workspaceId={taskWsId ?? wsId}
3034
- isLoading={isLoading}
3035
- onSuccess={onUpdate}
3036
- onClose={onClose}
3037
- />
3038
-
3039
- {isCreateMode && (
3040
- <UnsavedChangesWarningDialog
3041
- open={showUnsavedWarning}
3042
- onOpenChange={setShowUnsavedWarning}
3043
- onDiscard={handleWarningDiscard}
3044
- onSaveAsDraft={handleWarningSaveAsDraft}
3045
- onCreateTask={handleWarningCreateTask}
3046
- canSave={canSave}
3047
- />
3048
- )}
3049
-
3050
- <SyncWarningDialog
3051
- open={showSyncWarning}
3052
- onOpenChange={setShowSyncWarning}
3053
- synced={synced}
3054
- connected={connected}
3055
- onForceClose={handleForceClose}
3056
- />
3057
-
3058
- <DescriptionOverflowWarningDialog
3059
- open={showDescriptionCloseWarning}
3060
- onOpenChange={setShowDescriptionCloseWarning}
3061
- onConfirmClose={handleConfirmCloseWithUnconfirmedDescription}
3062
- title={
3063
- dialogT.has('description_close_failed_title')
3064
- ? dialogT('description_close_failed_title')
3065
- : 'Task description is still syncing'
3066
- }
3067
- description={
3068
- dialogT.has('description_close_failed_description')
3069
- ? dialogT('description_close_failed_description')
3070
- : 'The latest description changes have not been confirmed on the server yet. You can wait and try closing again, or close now without saving those description changes.'
3071
- }
3072
- cancelLabel={
3073
- dialogT.has('description_overflow_close_warning_cancel')
3074
- ? dialogT('description_overflow_close_warning_cancel')
3075
- : 'Go back and edit'
3076
- }
3077
- confirmLabel={
3078
- dialogT.has('description_overflow_close_warning_confirm')
3079
- ? dialogT('description_overflow_close_warning_confirm')
3080
- : 'Close without saving description'
3081
- }
3082
- warningMessage={
3083
- dialogT.has('description_close_failed_warning')
3084
- ? dialogT('description_close_failed_warning')
3085
- : 'Unconfirmed description changes may be lost if you close now.'
3086
- }
3087
- />
3088
-
3089
- <DescriptionOverflowWarningDialog
3090
- open={showDescriptionOverflowWarning}
3091
- onOpenChange={setShowDescriptionOverflowWarning}
3092
- onConfirmClose={handleConfirmCloseWithOverflow}
3093
- title={
3094
- dialogT.has('description_overflow_close_warning_title')
3095
- ? dialogT('description_overflow_close_warning_title')
3096
- : 'Description is too large to save'
3097
- }
3098
- description={
3099
- dialogT.has('description_overflow_close_warning_description')
3100
- ? dialogT('description_overflow_close_warning_description')
3101
- : 'This description is too large to sync right now. You can go back and shorten or split it, or close now and discard the unsaved description changes.'
3102
- }
3103
- cancelLabel={
3104
- dialogT.has('description_overflow_close_warning_cancel')
3105
- ? dialogT('description_overflow_close_warning_cancel')
3106
- : 'Go back and edit'
3107
- }
3108
- confirmLabel={
3109
- dialogT.has('description_overflow_close_warning_confirm')
3110
- ? dialogT('description_overflow_close_warning_confirm')
3111
- : 'Close without saving description'
3112
- }
3113
- warningMessage={
3114
- dialogT.has('description_overflow_close_warning_warning')
3115
- ? dialogT('description_overflow_close_warning_warning')
3116
- : 'Oversized content will be discarded if you close now.'
3117
- }
3118
- />
3119
-
3120
- <TaskNewLabelDialog
3121
- open={showNewLabelDialog}
3122
- newLabelName={newLabelName}
3123
- newLabelColor={newLabelColor}
3124
- creatingLabel={creatingLabel}
3125
- onOpenChange={(open) => {
3126
- if (open) {
3127
- setNewLabelColor((previousColor) =>
3128
- getRandomNewLabelColor(previousColor)
3129
- );
3130
- }
3131
- setShowNewLabelDialog(open);
3132
- }}
3133
- onNameChange={setNewLabelName}
3134
- onColorChange={setNewLabelColor}
3135
- onConfirm={handleCreateLabel}
3136
- translations={{
3137
- create_new_label: t('create_new_label'),
3138
- create_new_label_description: t('create_new_label_description'),
3139
- label_name: t('label_name'),
3140
- color: t('color'),
3141
- preview: t('preview'),
3142
- cancel: t('cancel'),
3143
- creating: t('creating'),
3144
- create_label: t('create_label'),
3145
- randomize_color: t('randomize_color'),
3146
- }}
3147
- />
3148
-
3149
- <TaskNewProjectDialog
3150
- open={showNewProjectDialog}
3151
- newProjectName={newProjectName}
3152
- creatingProject={creatingProject}
3153
- onOpenChange={setShowNewProjectDialog}
3154
- onNameChange={setNewProjectName}
3155
- onConfirm={handleCreateProject}
3156
- translations={{
3157
- create_new_project: t('create_new_project'),
3158
- create_new_project_description: t('create_new_project_description'),
3159
- project_name: t('project_name'),
3160
- cancel: t('cancel'),
3161
- creating: t('creating'),
3162
- create_project: t('create_project'),
3163
- }}
3164
- />
3165
-
3166
- {boardConfig && effectiveTaskWsId && (
3167
- <BoardEstimationConfigDialog
3168
- open={showEstimationConfigDialog}
3169
- wsId={effectiveTaskWsId}
3170
- boardId={boardId}
3171
- boardName={(boardConfig as { name?: string }).name || 'Board'}
3172
- currentEstimationType={boardConfig.estimation_type || null}
3173
- currentExtendedEstimation={boardConfig.extended_estimation || false}
3174
- currentAllowZeroEstimates={boardConfig.allow_zero_estimates ?? true}
3175
- currentCountUnestimatedIssues={
3176
- (boardConfig as { count_unestimated_issues?: boolean })
3177
- .count_unestimated_issues || false
3178
- }
3179
- onOpenChange={setShowEstimationConfigDialog}
3180
- onSuccess={handleEstimationConfigSuccess}
3181
- />
3182
- )}
3183
-
3184
- {/* Task Share Dialog */}
3185
- {!isCreateMode && task?.id && (
3186
- <TaskShareDialog
3187
- open={showShareDialog}
3188
- onOpenChange={setShowShareDialog}
3189
- taskId={task.id}
3190
- taskName={formState.name}
3191
- wsId={effectiveTaskWsId}
3192
- />
3193
- )}
3194
- </>
3195
- );
3196
- }