@taskforcehq/taskforce 0.3.303 → 0.3.305

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 (237) hide show
  1. package/README.md +140 -247
  2. package/dist/Taskforce.module.css +102 -5
  3. package/dist/TaskforceCore.js +635 -238
  4. package/dist/TaskforceCore.test.js +2243 -495
  5. package/dist/annotatedAttachments/service.d.ts +1 -1
  6. package/dist/annotatedAttachments/types.d.ts +1 -1
  7. package/dist/compat/workspaceSyncCompat.js +6 -0
  8. package/dist/components/features/AgentsModule.js +1 -1
  9. package/dist/components/features/AgentsModule.test.js +1 -1
  10. package/dist/components/features/DocumentIndex.d.ts +1 -1
  11. package/dist/components/features/DocumentIndex.js +1 -1
  12. package/dist/components/features/DocumentViewer.d.ts +1 -1
  13. package/dist/components/features/DocumentViewer.js +32 -9
  14. package/dist/components/features/DocumentWorkspace.d.ts +5 -22
  15. package/dist/components/features/DocumentWorkspace.js +12 -155
  16. package/dist/components/features/DocumentWorkspace.test.js +193 -6
  17. package/dist/components/features/TaskSettings.js +87 -41
  18. package/dist/components/features/TaskSettings.test.js +180 -40
  19. package/dist/components/features/documentWorkspaceModel.d.ts +24 -0
  20. package/dist/components/features/documentWorkspaceModel.js +57 -0
  21. package/dist/components/features/useDocumentWorkspaceController.d.ts +34 -0
  22. package/dist/components/features/useDocumentWorkspaceController.js +113 -0
  23. package/dist/components/task/TaskActionHeader.d.ts +2 -1
  24. package/dist/components/task/TaskActionHeader.js +3 -3
  25. package/dist/components/task/TaskActionHeader.test.js +8 -0
  26. package/dist/components/task/TaskCard.js +16 -1
  27. package/dist/components/task/TaskCard.test.js +31 -0
  28. package/dist/components/task/TaskForm.d.ts +9 -8
  29. package/dist/components/task/TaskForm.js +374 -219
  30. package/dist/components/task/TaskForm.test.js +482 -361
  31. package/dist/components/task/TaskKanban.d.ts +1 -1
  32. package/dist/components/task/TaskKanban.js +33 -161
  33. package/dist/components/task/TaskStatusActions.d.ts +6 -1
  34. package/dist/components/task/TaskStatusActions.js +8 -3
  35. package/dist/components/task/TaskStatusActions.test.js +9 -0
  36. package/dist/components/task/taskKanbanDropRules.d.ts +58 -0
  37. package/dist/components/task/taskKanbanDropRules.js +187 -0
  38. package/dist/components/task/taskKanbanDropRules.test.d.ts +1 -0
  39. package/dist/components/task/taskKanbanDropRules.test.js +114 -0
  40. package/dist/components/ui/Modal.d.ts +1 -1
  41. package/dist/components/ui/Modal.js +1 -0
  42. package/dist/components/views/AppShellHeader.js +5 -1
  43. package/dist/components/views/AppShellHeader.test.js +4 -0
  44. package/dist/components/views/PlanComparisonPage.d.ts +3 -2
  45. package/dist/components/views/PlanComparisonPage.js +9 -10
  46. package/dist/components/views/PlanComparisonPage.test.js +55 -41
  47. package/dist/components/views/PlansPage.d.ts +5 -1
  48. package/dist/components/views/PlansPage.js +150 -81
  49. package/dist/components/views/PlansPage.test.js +367 -41
  50. package/dist/components/views/StandaloneLayout.js +135 -54
  51. package/dist/components/views/WidgetView.js +11 -2
  52. package/dist/components/views/panels/FilterToolbar.test.js +6 -4
  53. package/dist/components/views/standalone/modals/AccountHubModal.d.ts +2 -14
  54. package/dist/components/views/standalone/modals/AccountHubModal.js +12 -14
  55. package/dist/components/views/standalone/modals/AccountHubModal.test.js +24 -1
  56. package/dist/components/views/standalone/modals/SyncStatusModal.js +1 -1
  57. package/dist/config/envSchema.js +1 -1
  58. package/dist/core/AiProfileService.d.ts +6 -1
  59. package/dist/core/AiProfileService.js +161 -16
  60. package/dist/core/AiProfileService.test.js +3 -1
  61. package/dist/core/AiProfiles.test.js +200 -0
  62. package/dist/core/AuthTokenService.test.d.ts +1 -0
  63. package/dist/core/AuthTokenService.test.js +78 -0
  64. package/dist/core/DeletedTaskLifecycleService.d.ts +2 -1
  65. package/dist/core/EntitlementsPolicy.test.js +75 -13
  66. package/dist/core/PlanEntitlementService.d.ts +9 -1
  67. package/dist/core/PlanEntitlementService.js +144 -19
  68. package/dist/core/PlanVersionPolicy.test.js +19 -26
  69. package/dist/core/SignupMonetizationSettings.test.js +75 -15
  70. package/dist/core/SystemAdmin.test.js +212 -56
  71. package/dist/core/TaskActivityService.d.ts +4 -1
  72. package/dist/core/TaskActivityService.js +45 -0
  73. package/dist/core/TaskAuditTimeline.test.js +52 -1
  74. package/dist/core/TaskTaxonomyValidation.test.js +53 -0
  75. package/dist/core/Taskforce.d.ts +18 -11
  76. package/dist/core/Taskforce.js +93 -12
  77. package/dist/core/WorkspacePlanMode.test.js +73 -8
  78. package/dist/core/shared.d.ts +2 -0
  79. package/dist/core/shared.js +11 -0
  80. package/dist/documentReviews/service.d.ts +1 -1
  81. package/dist/documentReviews/types.d.ts +1 -1
  82. package/dist/hooks/auth/useTaskforceAuthBootstrap.d.ts +48 -0
  83. package/dist/hooks/auth/useTaskforceAuthBootstrap.js +219 -0
  84. package/dist/hooks/sync/auth.d.ts +37 -0
  85. package/dist/hooks/sync/auth.js +63 -0
  86. package/dist/hooks/sync/bootstrap.d.ts +34 -0
  87. package/dist/hooks/sync/bootstrap.js +52 -0
  88. package/dist/hooks/sync/orchestratorShared.d.ts +36 -0
  89. package/dist/hooks/sync/orchestratorShared.js +209 -0
  90. package/dist/hooks/sync/orchestratorShared.test.d.ts +1 -0
  91. package/dist/hooks/sync/orchestratorShared.test.js +49 -0
  92. package/dist/hooks/sync/realtime.d.ts +25 -0
  93. package/dist/hooks/sync/realtime.js +60 -0
  94. package/dist/hooks/sync/recovery.d.ts +69 -0
  95. package/dist/hooks/sync/recovery.js +118 -0
  96. package/dist/hooks/sync/transfers.d.ts +123 -0
  97. package/dist/hooks/sync/transfers.js +435 -0
  98. package/dist/hooks/sync/useDataVersionRefresh.d.ts +16 -0
  99. package/dist/hooks/sync/useDataVersionRefresh.js +73 -0
  100. package/dist/hooks/ui/useResourceExport.d.ts +3 -1
  101. package/dist/hooks/ui/useResourceExport.js +5 -2
  102. package/dist/hooks/ui/useWorkflowTemplates.js +11 -6
  103. package/dist/hooks/useRealtimeSync.js +2 -1
  104. package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +8 -0
  105. package/dist/hooks/useSyncOrchestrator.context-assets.test.d.ts +1 -0
  106. package/dist/hooks/useSyncOrchestrator.context-assets.test.js +228 -0
  107. package/dist/hooks/useSyncOrchestrator.d.ts +12 -8
  108. package/dist/hooks/useSyncOrchestrator.js +388 -879
  109. package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +641 -6
  110. package/dist/hooks/useTaskMutations.d.ts +2 -1
  111. package/dist/hooks/useTaskMutations.js +57 -7
  112. package/dist/hooks/useTaskMutations.test.js +176 -0
  113. package/dist/hooks/useTaskforce.d.ts +13 -4
  114. package/dist/hooks/useTaskforce.js +302 -817
  115. package/dist/hooks/useTaskforce.sync-behavior.test.js +78 -0
  116. package/dist/hooks/useWorkspaceSyncController.d.ts +4 -1
  117. package/dist/hooks/useWorkspaceSyncController.js +33 -11
  118. package/dist/hooks/useWorkspaceSyncController.test.js +1 -0
  119. package/dist/hooks/workspace/useTaskforceApiRouting.test.js +17 -0
  120. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.d.ts +166 -0
  121. package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +434 -0
  122. package/dist/hooks/workspace/workspaceLocalState.d.ts +19 -0
  123. package/dist/hooks/workspace/workspaceLocalState.js +100 -0
  124. package/dist/hooks/workspace/workspaceLocalState.test.d.ts +1 -0
  125. package/dist/hooks/workspace/workspaceLocalState.test.js +59 -0
  126. package/dist/localization/locales/en-US.js +2 -2
  127. package/dist/mcp/adminWorkspaceRegistrar.d.ts +2 -0
  128. package/dist/mcp/adminWorkspaceRegistrar.js +154 -0
  129. package/dist/mcp/canonicalAssetHelpers.d.ts +70 -0
  130. package/dist/mcp/canonicalAssetHelpers.js +259 -0
  131. package/dist/mcp/clientIntegrations.d.ts +12 -1
  132. package/dist/mcp/clientIntegrations.js +161 -6
  133. package/dist/mcp/clientIntegrations.test.js +76 -4
  134. package/dist/mcp/collaborationRegistrar.d.ts +2 -0
  135. package/dist/mcp/collaborationRegistrar.js +71 -0
  136. package/dist/mcp/documentAssetRegistrar.d.ts +2 -0
  137. package/dist/mcp/documentAssetRegistrar.js +346 -0
  138. package/dist/mcp/documentHelpers.d.ts +100 -0
  139. package/dist/mcp/documentHelpers.js +161 -0
  140. package/dist/mcp/runtime.js +2455 -3925
  141. package/dist/mcp/runtime.test.js +240 -8
  142. package/dist/mcp/taskAttachmentHelpers.d.ts +41 -0
  143. package/dist/mcp/taskAttachmentHelpers.js +60 -0
  144. package/dist/mcp/taskAttachmentTypes.d.ts +37 -0
  145. package/dist/mcp/taskAttachmentTypes.js +1 -0
  146. package/dist/mcp/taskPlanningRegistrar.d.ts +2 -0
  147. package/dist/mcp/taskPlanningRegistrar.js +418 -0
  148. package/dist/mcp/toolCatalog.d.ts +35 -0
  149. package/dist/mcp/toolCatalog.js +3 -0
  150. package/dist/plugins/vite.js +1 -1
  151. package/dist/runtime/appGateDefinitions.d.ts +1 -1
  152. package/dist/runtime/appGateDefinitions.js +1 -1
  153. package/dist/server/index.d.ts +1 -0
  154. package/dist/server/index.js +46 -3
  155. package/dist/server/index.test.js +12 -1
  156. package/dist/server/routes/admin.d.ts +1 -5
  157. package/dist/server/routes/admin.js +151 -80
  158. package/dist/server/routes/annotatedAttachments.d.ts +1 -1
  159. package/dist/server/routes/annotatedAttachments.js +1 -1
  160. package/dist/server/routes/auth.d.ts +1 -4
  161. package/dist/server/routes/auth.js +59 -64
  162. package/dist/server/routes/authSupport.d.ts +30 -0
  163. package/dist/server/routes/authSupport.js +81 -0
  164. package/dist/server/routes/billing.d.ts +1 -1
  165. package/dist/server/routes/billing.js +122 -255
  166. package/dist/server/routes/billing.test.js +257 -86
  167. package/dist/server/routes/documentReviews.d.ts +1 -1
  168. package/dist/server/routes/documentReviews.js +1 -1
  169. package/dist/server/routes/documents.d.ts +4 -2
  170. package/dist/server/routes/documents.js +73 -7
  171. package/dist/server/routes/primitives.d.ts +11 -0
  172. package/dist/server/routes/primitives.js +73 -0
  173. package/dist/server/routes/resources.d.ts +1 -1
  174. package/dist/server/routes/resources.js +1 -1
  175. package/dist/server/routes/shared.d.ts +31 -1
  176. package/dist/server/routes/shared.js +26 -0
  177. package/dist/server/routes/sync.d.ts +1 -1
  178. package/dist/server/routes/sync.integration.test.js +20 -0
  179. package/dist/server/routes/sync.js +111 -238
  180. package/dist/server/routes/tasks.d.ts +1 -1
  181. package/dist/server/routes/tasks.js +50 -8
  182. package/dist/server/routes/workspaces.d.ts +1 -1
  183. package/dist/server/routes/workspaces.js +1 -1
  184. package/dist/server/routes.d.ts +2 -9
  185. package/dist/server/routes.js +84 -181
  186. package/dist/server/routes.test.js +912 -32
  187. package/dist/shared/taskActor.d.ts +10 -0
  188. package/dist/shared/taskActor.js +1 -0
  189. package/dist/sync/collaborationSyncPayload.js +4 -0
  190. package/dist/sync/collaborationSyncPayload.test.js +8 -0
  191. package/dist/sync/collaborationSyncState.d.ts +3 -1
  192. package/dist/sync/collaborationSyncState.js +19 -0
  193. package/dist/sync/contentSyncState.js +28 -17
  194. package/dist/sync/syncApplyHandlers.d.ts +87 -1
  195. package/dist/sync/syncApplyHandlers.js +370 -8
  196. package/dist/sync/syncApplyHandlers.test.d.ts +1 -0
  197. package/dist/sync/syncApplyHandlers.test.js +379 -0
  198. package/dist/sync/syncService.d.ts +9 -1
  199. package/dist/sync/syncService.js +44 -2
  200. package/dist/sync/syncService.test.js +62 -0
  201. package/dist/sync/workspacePullFeed.d.ts +1 -0
  202. package/dist/sync/workspacePullFeed.js +66 -59
  203. package/dist/sync/workspacePullFeed.test.js +72 -4
  204. package/dist/sync/workspaceSyncModel.d.ts +25 -1
  205. package/dist/sync/workspaceSyncModel.js +77 -3
  206. package/dist/sync/workspaceSyncModel.test.js +153 -0
  207. package/dist/sync/workspaceSyncState.d.ts +2 -0
  208. package/dist/sync/workspaceSyncState.js +1 -0
  209. package/dist/types.d.ts +2 -10
  210. package/dist/ui/assets/AgentsModule-N2MnQBZk.js +1 -0
  211. package/dist/ui/assets/{AnnotatedAttachmentWorkspace-C_TmXZwA.js → AnnotatedAttachmentWorkspace-BG6P_GVW.js} +1 -1
  212. package/dist/ui/assets/DocumentWorkspace-B3nV_Gc5.css +1 -0
  213. package/dist/ui/assets/DocumentWorkspace-DRbDMwh8.js +252 -0
  214. package/dist/ui/assets/{InitiativesModule-4-Rh2K2n.js → InitiativesModule-Dhm7M8e7.js} +1 -1
  215. package/dist/ui/assets/{PlansPage-BlVC_lRq.css → PlansPage-C2dd2n1X.css} +1 -1
  216. package/dist/ui/assets/PlansPage-Cq0zXj3I.js +1 -0
  217. package/dist/ui/assets/TaskSettings-ln0aF7xc.js +9 -0
  218. package/dist/ui/assets/{WorkflowsModule-CGk9s3NJ.js → WorkflowsModule-BcS4afRn.js} +1 -1
  219. package/dist/ui/assets/index-C2-OXZV7.css +1 -0
  220. package/dist/ui/assets/index-DcSI5F86.js +6 -0
  221. package/dist/ui/assets/{vendor-icons-pWocEipT.js → vendor-icons-BSUaRwF8.js} +1 -1
  222. package/dist/ui/index.html +4 -4
  223. package/dist/utils/commercialLifecyclePresentation.d.ts +19 -0
  224. package/dist/utils/commercialLifecyclePresentation.js +196 -0
  225. package/dist/utils/taskActivity.js +4 -0
  226. package/dist/utils/taskActivity.test.js +25 -1
  227. package/package.json +10 -1
  228. package/scripts/check-cloud-mcp.mjs +83 -0
  229. package/scripts/playwright-auth.sh +9 -1
  230. package/scripts/run-billing-performance-smoke.sh +24 -0
  231. package/dist/ui/assets/AgentsModule-CpsTmrIW.js +0 -1
  232. package/dist/ui/assets/DocumentWorkspace-C3GyzrWm.js +0 -250
  233. package/dist/ui/assets/DocumentWorkspace-C_8T8oz-.css +0 -1
  234. package/dist/ui/assets/PlansPage-BP7AYOqr.js +0 -1
  235. package/dist/ui/assets/TaskSettings-BOC5F6Ag.js +0 -8
  236. package/dist/ui/assets/index-CLIMgR6g.js +0 -6
  237. package/dist/ui/assets/index-DneETxcu.css +0 -1
@@ -0,0 +1,228 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { act, renderHook, waitFor } from '@testing-library/react';
3
+ import { useSyncOrchestrator } from './useSyncOrchestrator';
4
+ const { ensureCloudWorkspaceReadyForSyncServiceMock, runWorkspacePullSyncServiceMock, runWorkspacePushSyncServiceMock, syncUserGlobalSettingsServiceMock } = vi.hoisted(() => ({
5
+ ensureCloudWorkspaceReadyForSyncServiceMock: vi.fn(),
6
+ runWorkspacePullSyncServiceMock: vi.fn(),
7
+ runWorkspacePushSyncServiceMock: vi.fn(),
8
+ syncUserGlobalSettingsServiceMock: vi.fn()
9
+ }));
10
+ vi.mock('../sync/syncService', async () => {
11
+ const actual = await vi.importActual('../sync/syncService');
12
+ return {
13
+ ...actual,
14
+ calculateWorkspaceRetryDelayMs: vi.fn(() => 100),
15
+ ensureCloudWorkspaceReadyForSyncService: ensureCloudWorkspaceReadyForSyncServiceMock,
16
+ runWorkspacePullSyncService: runWorkspacePullSyncServiceMock,
17
+ runWorkspacePushSyncService: runWorkspacePushSyncServiceMock,
18
+ syncUserGlobalSettingsService: syncUserGlobalSettingsServiceMock
19
+ };
20
+ });
21
+ function buildInput(overrides) {
22
+ return {
23
+ currentWorkspaceId: 'workspace-local-active',
24
+ cloudAuthConfigured: true,
25
+ runtimeMode: 'local',
26
+ authSessionResolved: true,
27
+ isAuthenticated: true,
28
+ authUserId: 'user-1',
29
+ projectName: 'Test Project',
30
+ resolveCloudAuthUrl: (path) => `https://cloud.example.com${path}`,
31
+ resolveWebSocketUrl: (path) => `wss://api.example.com${path}`,
32
+ realtimeSyncEnabled: false,
33
+ tasks: [],
34
+ archivedTasks: [],
35
+ initiatives: [],
36
+ workstreams: [],
37
+ taxonomies: [],
38
+ setupState: null,
39
+ globalTheme: 'dark',
40
+ locale: 'en-US',
41
+ globalWeekStartsOn: 'monday',
42
+ themeUseGlobalDefault: true,
43
+ setTasks: vi.fn(),
44
+ setArchivedTasks: vi.fn(),
45
+ setAuthBlocked: vi.fn(),
46
+ setIsAuthenticated: vi.fn(),
47
+ checkAuthSession: vi.fn(async () => true),
48
+ setGlobalTheme: vi.fn(),
49
+ setCurrentTheme: vi.fn(),
50
+ setSetupState: vi.fn(),
51
+ setLocale: vi.fn(),
52
+ setGlobalWeekStartsOn: vi.fn(),
53
+ fetchPlanningEntities: vi.fn(async () => { }),
54
+ ...overrides
55
+ };
56
+ }
57
+ describe('useSyncOrchestrator context asset refreshes', () => {
58
+ beforeEach(() => {
59
+ ensureCloudWorkspaceReadyForSyncServiceMock.mockReset();
60
+ runWorkspacePullSyncServiceMock.mockReset();
61
+ runWorkspacePushSyncServiceMock.mockReset();
62
+ syncUserGlobalSettingsServiceMock.mockReset();
63
+ ensureCloudWorkspaceReadyForSyncServiceMock.mockResolvedValue({ success: true });
64
+ runWorkspacePullSyncServiceMock.mockResolvedValue({
65
+ success: true,
66
+ syncedAt: '2026-03-15T18:00:00.000Z',
67
+ cursor: null,
68
+ pages: 0,
69
+ appliedChanges: 0,
70
+ pullRequestMs: 1,
71
+ applyMs: 0,
72
+ pulledDeleteTaskIds: new Set(),
73
+ pulledActiveUpserts: false,
74
+ pulledArchivedUpserts: false,
75
+ documentDecryptFailures: []
76
+ });
77
+ runWorkspacePushSyncServiceMock.mockResolvedValue({
78
+ success: true,
79
+ syncedAt: '2026-03-15T18:00:00.000Z',
80
+ requestMs: 1,
81
+ changeCount: 0,
82
+ deleteCount: 0,
83
+ currentTaskIds: new Set(),
84
+ currentInitiativeIds: new Set(),
85
+ currentInitiativeWatermarks: new Map(),
86
+ currentWorkstreamIds: new Set(),
87
+ currentWorkstreamWatermarks: new Map(),
88
+ currentAiProfileIds: new Set(),
89
+ currentAiProfileWatermarks: new Map(),
90
+ currentDocumentPaths: new Set(),
91
+ currentDocumentWatermarks: new Map(),
92
+ currentAssetPaths: new Set(),
93
+ currentAssetWatermarks: new Map(),
94
+ currentDocumentReviewSessionIds: new Set(),
95
+ currentDocumentReviewSessionWatermarks: new Map(),
96
+ currentDocumentReviewCommentIds: new Set(),
97
+ currentDocumentReviewCommentWatermarks: new Map(),
98
+ currentAnnotatedAttachmentSessionIds: new Set(),
99
+ currentAnnotatedAttachmentSessionWatermarks: new Map(),
100
+ currentTaskEventWatermarks: new Map(),
101
+ deleteTaskIds: new Set(),
102
+ pushedWatermarks: new Map(),
103
+ emittedEventIds: []
104
+ });
105
+ syncUserGlobalSettingsServiceMock.mockResolvedValue({
106
+ success: true,
107
+ mode: 'pulled',
108
+ updatedAt: new Date().toISOString()
109
+ });
110
+ });
111
+ afterEach(() => {
112
+ vi.unstubAllGlobals();
113
+ vi.clearAllMocks();
114
+ });
115
+ it('refreshes only document and asset snapshots when task attachments change', async () => {
116
+ const fetchCounts = {
117
+ documents: 0,
118
+ assets: 0,
119
+ aiProfiles: 0,
120
+ documentReviews: 0,
121
+ annotatedAttachments: 0
122
+ };
123
+ vi.stubGlobal('fetch', vi.fn((url, init) => {
124
+ if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
125
+ return Promise.resolve({
126
+ ok: true,
127
+ json: () => Promise.resolve({
128
+ success: true,
129
+ state: {
130
+ version: 2,
131
+ enabled: true,
132
+ phase: 'active',
133
+ pullCursor: null,
134
+ lastPullAt: null,
135
+ lastPushAt: null,
136
+ lastSyncedAt: null
137
+ }
138
+ })
139
+ });
140
+ }
141
+ if (url.includes('/api/taskforce/ui-state') && String(init?.method || '').toUpperCase() === 'POST') {
142
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ success: true }) });
143
+ }
144
+ if (url.includes('/api/taskforce/sync/workspace/documents')) {
145
+ fetchCounts.documents += 1;
146
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ documents: [] }) });
147
+ }
148
+ if (url.includes('/api/taskforce/sync/workspace/assets')) {
149
+ fetchCounts.assets += 1;
150
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ assets: [] }) });
151
+ }
152
+ if (url.includes('/api/taskforce/sync/workspace/ai-profiles')) {
153
+ fetchCounts.aiProfiles += 1;
154
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ aiProfiles: [] }) });
155
+ }
156
+ if (url.includes('/api/taskforce/sync/workspace/document-reviews')) {
157
+ fetchCounts.documentReviews += 1;
158
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ sessions: [], comments: [] }) });
159
+ }
160
+ if (url.includes('/api/taskforce/sync/workspace/annotated-attachments')) {
161
+ fetchCounts.annotatedAttachments += 1;
162
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ sessions: [] }) });
163
+ }
164
+ if (url.includes('/api/taskforce/sync/events')) {
165
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ success: true }) });
166
+ }
167
+ if (url.includes('/api/taskforce/tasks')) {
168
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ tasks: [] }) });
169
+ }
170
+ if (url.includes('/api/taskforce/archive')) {
171
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ archived: [] }) });
172
+ }
173
+ return Promise.resolve({ ok: true, json: () => Promise.resolve({ success: true }) });
174
+ }));
175
+ const baseTask = {
176
+ id: 'task-with-attachments',
177
+ title: 'Task with attachment refreshes',
178
+ description: '',
179
+ category: 'general',
180
+ type: 'task',
181
+ priority: 2,
182
+ complexity: 3,
183
+ status: 'task',
184
+ createdAt: '2026-03-15T12:00:00.000Z',
185
+ updatedAt: '2026-03-15T12:00:00.000Z',
186
+ attachments: [],
187
+ taskEvents: []
188
+ };
189
+ const initialInput = buildInput({
190
+ tasks: [baseTask]
191
+ });
192
+ const { result, rerender, unmount } = renderHook((props) => useSyncOrchestrator(props), {
193
+ initialProps: initialInput
194
+ });
195
+ act(() => {
196
+ result.current.applyWorkspaceSyncStateSnapshot({
197
+ enabled: true,
198
+ phase: 'active',
199
+ pullCursor: null
200
+ });
201
+ });
202
+ await waitFor(() => {
203
+ expect(fetchCounts.documents).toBeGreaterThan(0);
204
+ expect(fetchCounts.assets).toBeGreaterThan(0);
205
+ expect(fetchCounts.aiProfiles).toBeGreaterThan(0);
206
+ expect(fetchCounts.documentReviews).toBeGreaterThan(0);
207
+ });
208
+ const baselineCounts = { ...fetchCounts };
209
+ rerender({
210
+ ...initialInput,
211
+ tasks: [{
212
+ ...baseTask,
213
+ attachments: [{
214
+ id: 'asset-1',
215
+ path: 'workspaces/workspace-local-active/assets/file.txt'
216
+ }]
217
+ }]
218
+ });
219
+ await waitFor(() => {
220
+ expect(fetchCounts.documents).toBeGreaterThan(baselineCounts.documents);
221
+ expect(fetchCounts.assets).toBeGreaterThan(baselineCounts.assets);
222
+ });
223
+ expect(fetchCounts.aiProfiles).toBe(baselineCounts.aiProfiles);
224
+ expect(fetchCounts.documentReviews).toBe(baselineCounts.documentReviews);
225
+ expect(fetchCounts.annotatedAttachments).toBe(baselineCounts.annotatedAttachments);
226
+ unmount();
227
+ });
228
+ });
@@ -1,9 +1,8 @@
1
- import type { InitiativeItem, TaskItem, TaskforceTheme, WorkstreamItem } from '../types';
2
- import { type WorkspaceSyncPhase } from '../sync/workspaceSyncState';
3
- import { type WorkspaceSyncAiProfileSnapshot } from '../sync/workspaceSyncModel';
1
+ import type { DeletedTaskRecord, InitiativeItem, TaskItem, TaskforceTheme, WorkstreamItem } from '../types';
2
+ import { type WorkspaceSyncPhase, type WorkspaceSyncSetupIntent } from '../sync/workspaceSyncState';
4
3
  import type { WorkspaceTaxonomyState } from '../shared/taxonomyState.js';
5
4
  import type { SupportedLocale } from '../localization';
6
- export declare function normalizeWorkspaceSyncAiProfileSnapshotEntry(entry: any): WorkspaceSyncAiProfileSnapshot;
5
+ import { normalizeWorkspaceSyncAiProfileSnapshotEntry } from './sync/orchestratorShared';
7
6
  export interface UseSyncOrchestratorInput {
8
7
  currentWorkspaceId: string;
9
8
  cloudAuthConfigured: boolean;
@@ -17,6 +16,7 @@ export interface UseSyncOrchestratorInput {
17
16
  realtimeSyncEnabled: boolean;
18
17
  tasks: TaskItem[];
19
18
  archivedTasks: TaskItem[];
19
+ deletedTasks?: DeletedTaskRecord[];
20
20
  initiatives: InitiativeItem[];
21
21
  workstreams: WorkstreamItem[];
22
22
  taxonomies: unknown[];
@@ -41,9 +41,10 @@ export interface UseSyncOrchestratorInput {
41
41
  fetchPlanningEntities: () => Promise<void>;
42
42
  }
43
43
  export type WorkspaceSyncStatus = 'off' | 'syncing' | 'attention' | 'healthy';
44
+ export { normalizeWorkspaceSyncAiProfileSnapshotEntry };
44
45
  export declare function useSyncOrchestrator(input: UseSyncOrchestratorInput): {
45
- userGlobalSyncStatus: "error" | "idle" | "syncing" | "disconnected";
46
- setUserGlobalSyncStatus: import("react").Dispatch<import("react").SetStateAction<"error" | "idle" | "syncing" | "disconnected">>;
46
+ userGlobalSyncStatus: "error" | "idle" | "disconnected" | "syncing";
47
+ setUserGlobalSyncStatus: import("react").Dispatch<import("react").SetStateAction<"error" | "idle" | "disconnected" | "syncing">>;
47
48
  userGlobalSyncError: string | null;
48
49
  setUserGlobalSyncError: import("react").Dispatch<import("react").SetStateAction<string | null>>;
49
50
  workspaceLastPullAt: string | null;
@@ -53,6 +54,7 @@ export declare function useSyncOrchestrator(input: UseSyncOrchestratorInput): {
53
54
  workspaceLastSuccessfulSyncAt: string | null;
54
55
  workspaceCloudSyncEnabled: boolean;
55
56
  workspaceSyncPhase: WorkspaceSyncPhase;
57
+ workspaceSyncSetupIntent: WorkspaceSyncSetupIntent;
56
58
  workspaceSyncStatus: WorkspaceSyncStatus;
57
59
  workspaceSyncSummary: string;
58
60
  workspaceSyncRecommendedAction: string;
@@ -67,14 +69,15 @@ export declare function useSyncOrchestrator(input: UseSyncOrchestratorInput): {
67
69
  workspacePendingSignatureRef: import("react").RefObject<string>;
68
70
  workspaceLastPushedTaskIdsRef: import("react").RefObject<Set<string>>;
69
71
  workspaceDeletedTaskIdsRef: import("react").RefObject<Set<string>>;
72
+ workspaceDeletedTaskWatermarksRef: import("react").RefObject<Map<string, string>>;
70
73
  workspacePullCursorRef: import("react").RefObject<string | null>;
71
74
  clearWorkspaceRetry: () => void;
72
75
  persistWorkspaceSyncPatch: (patch: Partial<import("../sync/workspaceSyncState").WorkspaceSyncStateV2>) => Promise<import("../sync/workspaceSyncState").WorkspaceSyncStateV2>;
73
76
  loadWorkspaceSyncState: () => Promise<void>;
74
- applyWorkspaceSyncStateSnapshot: (nextState: Partial<import("../sync/workspaceSyncState").WorkspaceSyncStateV2> & {
77
+ applyWorkspaceSyncStateSnapshot: (nextState: Parameters<(nextState: Partial<import("../sync/workspaceSyncState").WorkspaceSyncStateV2> & {
75
78
  enabled: boolean;
76
79
  phase?: WorkspaceSyncPhase | null;
77
- }) => void;
80
+ }) => void>[0]) => void;
78
81
  syncUserGlobalSettings: (options?: {
79
82
  preferCloudOnFirstSync?: boolean;
80
83
  }) => Promise<void>;
@@ -85,6 +88,7 @@ export declare function useSyncOrchestrator(input: UseSyncOrchestratorInput): {
85
88
  }) => Promise<boolean>;
86
89
  pullWorkspaceChangesFromCloud: (options?: {
87
90
  repairMode?: boolean;
91
+ forceCursorNull?: boolean;
88
92
  }) => Promise<boolean>;
89
93
  saveWorkspaceCloudSyncSettings: (settings: {
90
94
  enabled: boolean;