{"results":{"result":{"added-files":{"code-health":9.737858031828644,"old-code-health":0.0,"files":[{"file":"src/modules/services/components/FilePicker/FilePickerBody.jsx","loc":122,"code-health":9.608927141875917},{"file":"src/modules/services/components/FilePicker/FilePickerBodyItem.jsx","loc":112,"code-health":9.636288422716657},{"file":"src/modules/services/components/FilePicker/FilePickerBreadcrumb.jsx","loc":51,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/FilePickerFooter.jsx","loc":109,"code-health":9.6882083290695},{"file":"src/modules/services/components/FilePicker/FilePickerHeader.jsx","loc":74,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/config.js","loc":26,"code-health":9.6882083290695},{"file":"src/modules/services/components/FilePicker/config.spec.js","loc":72,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/constraints.js","loc":50,"code-health":9.240656298427343},{"file":"src/modules/services/components/FilePicker/constraints.spec.jsx","loc":123,"code-health":9.387218218812514},{"file":"src/modules/services/components/FilePicker/helpers.js","loc":40,"code-health":9.6882083290695},{"file":"src/modules/services/components/FilePicker/helpers.spec.js","loc":95,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/index.jsx","loc":113,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/index.spec.jsx","loc":144,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/payload.js","loc":13,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/payload.spec.js","loc":60,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/queries.js","loc":34,"code-health":10.0},{"file":"src/modules/services/components/FilePicker/sharing.js","loc":71,"code-health":10.0},{"file":"src/modules/services/components/Picker.jsx","loc":56,"code-health":10.0},{"file":"src/modules/services/components/Picker.spec.jsx","loc":280,"code-health":9.387218218812514},{"file":"src/modules/navigation/components/FilePickerButton.jsx","loc":170,"code-health":10.0},{"file":"e2e/pages/FilePickerPage.ts","loc":101,"code-health":10.0},{"file":"e2e/tests/file-picker.spec.ts","loc":212,"code-health":9.387218218812514}]},"external-review-url":"https://github.com/linagora/twake-drive/pull/4006","old-code-health":9.88470959144663,"modified-files":{"code-health":9.88433534788062,"old-code-health":9.88470959144663,"files":[{"file":"src/modules/services/components/IntentHandler.jsx","loc":47,"old-loc":47,"code-health":10.0,"old-code-health":10.0},{"file":"src/lib/flags.js","loc":34,"old-loc":33,"code-health":10.0,"old-code-health":10.0},{"file":"src/modules/layout/Layout.jsx","loc":161,"old-loc":159,"code-health":9.6882083290695,"old-code-health":9.6882083290695},{"file":"e2e/setup/global-setup.ts","loc":192,"old-loc":191,"code-health":10.0,"old-code-health":10.0}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"4006","analysis-time":"2026-07-03T14:31:02Z","negative-impact-count":11,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":1,"commits":["4fbea2e4951e4259f5183497e9d99e82e1c67385","8cfe70812fec7b8041586a1f02aaa427ff66f4fa","5fa9b439d1954139a1ff3db56a112ba182f5f9a9","0c0496b669d2e56356cd678f2ab1469958a8cee6","7f322586e0c5a9ffd962749ae65172122e4e1391","ee1722d8abd1390f0f286ac84d7bda3d03d481b2","f4afe54c19ee8662752ca4f8e39c5ddb2308d98e","b0923e96c777c0279b015693e761be3bb8efcc0d","f03d4b87e7e582d000c23b29a10bacb3a4ff572a","a080f0955221a190cb9c47a1df5451d6ee28aa59","a60f69922b8b4b7b21e3ebfad3480718cef0c76b","a6d4cd227f4c6f3a3a8398c8008846cf8c9b8d30"],"is-negative-review":true,"negative-findings":{"number-of-types":5,"number-of-files-touched":9,"findings":[{"method":"FilePickerBody","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the React language is a cyclomatic complexity lower than 10.","name":"Complex Method","file":"src/modules/services/components/FilePicker/FilePickerBody.jsx","refactoring-examples":[{"architectural-component-id":null,"author-name":"doubleface","training-data":{"loc-added":"1","loc-deleted":"3","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"mr.thiriot@gmail.com","commit-full-message":"","commit-date":"2026-06-11T12:08:23Z","current-rev":"4e5b7c962","filename":"twake-drive/src/modules/public/PublicToolbarByLink.jsx","previous-rev":"9196b60a4","commit-title":"feat: Move Download button in public page more menu","language":"React","id":"b79cb4c3e03e7bb9f11c52da99e6e5fc031d91b2","model-score":0.96,"author-id":null,"project-id":76928,"delta-file-score":0.31179166,"diff":"diff --git a/src/modules/public/PublicToolbarByLink.jsx b/src/modules/public/PublicToolbarByLink.jsx\nindex c6ef9e097..1d7f1ff02 100644\n--- a/src/modules/public/PublicToolbarByLink.jsx\n+++ b/src/modules/public/PublicToolbarByLink.jsx\n@@ -16,3 +16,2 @@ import AddButton from '@/modules/drive/Toolbar/components/AddButton'\n import ViewSwitcher from '@/modules/drive/Toolbar/components/ViewSwitcher'\n-import { DownloadFilesButton } from '@/modules/public/DownloadFilesButton'\n import PublicToolbarMoreMenu from '@/modules/public/PublicToolbarMoreMenu'\n@@ -39,3 +38,3 @@ const PublicToolbarByLink = ({\n     [\n-      isMobile && download,\n+      download,\n       files.length > 1 && select,\n@@ -80,3 +79,2 @@ const PublicToolbarByLink = ({\n             )}\n-            {files.length > 0 && <DownloadFilesButton files={files} />}\n             <ViewSwitcher className=\"u-ml-half\" />\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"doubleface","training-data":{"loc-added":"8","loc-deleted":"3","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"christophe@cozycloud.cc","commit-full-message":"Use a ref to track nextCursor inside fetchMore so it does not need to\nbe listed as a dependency, preventing fetchMore from being recreated\non every page load.","commit-date":"2026-04-07T14:05:15Z","current-rev":"fe37361e4","filename":"twake-drive/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx","previous-rev":"6ac8736f7","commit-title":"refactor: Stabilize fetchMore reference using a cursor ref","language":"React","id":"0725fbf036466b669c341d7308e240454398396e","model-score":0.92,"author-id":null,"project-id":76928,"delta-file-score":0.61278176,"diff":"diff --git a/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx b/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx\nindex df10a751e..d403e119b 100644\n--- a/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx\n+++ b/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx\n@@ -38,2 +38,3 @@ const useSharedDriveFolder = ({\n   const [nextCursor, setNextCursor] = useState<string | null>(null)\n+  const nextCursorRef = useRef<string | null>(null)\n   const isFetchingMore = useRef(false)\n@@ -61,2 +62,3 @@ const useSharedDriveFolder = ({\n       setSharedDriveResult({ data: undefined, included: undefined })\n+      nextCursorRef.current = null\n       setNextCursor(null)\n@@ -70,2 +72,3 @@ const useSharedDriveFolder = ({\n           setSharedDriveResult({ included })\n+          nextCursorRef.current = cursor\n           setNextCursor(cursor)\n@@ -76,2 +79,3 @@ const useSharedDriveFolder = ({\n           setSharedDriveResult({ data: undefined, included: undefined })\n+          nextCursorRef.current = null\n           setNextCursor(null)\n@@ -106,3 +110,3 @@ const useSharedDriveFolder = ({\n   const fetchMore = useCallback(async (): Promise<void> => {\n-    if (isFetchingMore.current || !nextCursor || !client) return\n+    if (isFetchingMore.current || !nextCursorRef.current || !client) return\n \n@@ -115,3 +119,3 @@ const useSharedDriveFolder = ({\n         folderId,\n-        nextCursor\n+        nextCursorRef.current\n       )\n@@ -125,2 +129,3 @@ const useSharedDriveFolder = ({\n       }))\n+      nextCursorRef.current = cursor\n       setNextCursor(cursor)\n@@ -131,3 +136,3 @@ const useSharedDriveFolder = ({\n     }\n-  }, [nextCursor, client, folderId, statById])\n+  }, [client, folderId, statById])\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Khaled FERJANI","training-data":{"loc-added":"2","loc-deleted":"9","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.536386775820924"},"author-email":"kferjani@linagora.com","commit-full-message":"Folder uploads used to recurse inside processNextFile via uploadDirectory,\nscattering 409 conflict handling across three places. The shape produced\nthe long-standing \"no internet connection\" symptom on folder re-drops:\nan inner-file 409 escaped the recursion and ended up in the file-overwrite\npath, which Chrome surfaced as \"Failed to fetch\".\n\nFolder uploads are now flattened at enqueue time. flattenEntries walks\nthe dropped tree once, creates intermediate folders server-side via\ncreateFolderOrGetExisting (handles 409 reuse), and turns each file into\nits own queue item with a relative path and target folder id.\nprocessNextFile only ever handles single files. Conflict handling\ncollapses into two parallel helpers: uploadOrOverwriteFile (file 409\n-> overwrite) and createFolderOrGetExisting (folder 409 -> reuse).\nError classification is one function (classifyUploadError); the\nprep-time alert routes through one handler (reportPrepError).\n\nTo keep folder drops responsive on deep trees, a placeholder row per\ntop-level folder is dispatched immediately so the upload tray reflects\nthe drop. flattenEntries runs in the background and a\nRESOLVE_FOLDER_ITEMS action swaps placeholders for the real per-file\nrows when it finishes.\n\nThe drive.enable-encryption flag was never enabled in production, so\nthe entire encryption code path - both write and read sides - is\nremoved in the same pass. Beyond cleanup, the encrypted upload\nbranch in uploadFile had a synchronous fr.readAsArrayBuffer that\nreturned undefined immediately, breaking conflict detection on\nencrypted uploads.\n\nWhat goes:\n\n- The flag itself.\n- The encryption write path: encryptAndUploadNewFile, createEncryptedDir,\n  AddEncryptedFolderItem, the related JSX gates in AddMenuContent, and\n  vaultClient threading through Dropzone, DropzoneDnD, UploadButton,\n  UploadItem, AddFolder, FolderPickerAddFolderItem, plus the createFolder\n  and uploadFiles actions.\n- The encryption read path: getEncryptionKeyFromDirId, decryptFile,\n  getDecryptedFileURL, downloadEncryptedFile, and the encryption branches\n  in downloadFiles, viewer/helpers downloadFile, FilesViewer, and\n  download.jsx.\n- src/lib/encryption.js entirely.\n- FolderUnlocker (the vault-unlock prompt) plus the wrappers in\n  FolderViewBody, FolderViewBodyContent and the four FolderPicker\n  Content* files.\n- The isEncrypted prop chain (getMimeTypeIcon, EncryptedFolderIcon,\n  FileIcon, FileThumbnail, AddFolderCard, AddFolderRow, SuggestionItem,\n  FolderPickerHeaderIllustration, useSearch).\n- The dead 'encrypted' branch in EmptyCanvas.\n- Stale translation keys (menu_new_encrypted_folder,\n  download.error.encryption_many) across 11 locales.\n\nFollow-up work folded into the same commit:\n\n- The file-limit guard moves into addToUploadQueue itself: the\n  navigation thunk no longer runs exceedsFileLimit ahead of the\n  queue, so a folder drop that trips the limit shows up in the\n  tray as a failed row before the modal appears, and prep-time\n  errors classify through the same RECEIVE_UPLOAD_ERROR path file\n  uploads already use.\n- The single-file download in actions/utils.js is now awaited\n  inside the try/catch so 404 and offline rejections reach the\n  catch arm again - collapsing the try block during the encrypted\n  cleanup had silently dropped the await and suppressed the\n  'This file is missing' / 'You should be connected' alerts.\n- A per-drop nonce scopes both folder-placeholder ids and flattened\n  file ids, so a folder dropped twice (or two files with the same\n  relative path) can't share a queue identity. The reducer's\n  by-fileId update would otherwise flip both rows on a single\n  dispatch.\n- The reducer no-ops same-reference returns when an UPLOAD_*\n  action's fileId matches nothing in state, and ignores\n  RESOLVE_FOLDER_ITEMS if the queue was purged while flatten was\n  in flight - so cancelled drops can't quietly re-fill the tray.\n- The flow inside addToUploadQueue runs the limit check before\n  kicking processing, so loose files don't begin uploading behind\n  the limit-exceeded modal. failPlaceholders -> failDrop now\n  applies to every row in the drop, including loose files.\n- overwriteFile passes the upload options at the top level of\n  updateFile's params (the rest of params is what cozy-stack-client\n  treats as upload options), so onUploadProgress reaches XHR on\n  conflict-overwrite paths and folder-uploaded files emit progress\n  events.\n- The runThunk test helper now drains promises returned by nested\n  thunks so any action dispatched after an inner thunk's first\n  await is captured before assertions run.\n\nSpecs cover the new placeholder-id shape, the no-op reducer, and\nthe overwrite onUploadProgress propagation.","commit-date":"2026-04-28T08:03:46Z","current-rev":"823594568","filename":"twake-drive/src/modules/filelist/icons/FileIconMime.jsx","previous-rev":"98d25068f","commit-title":"refactor: rework upload pipeline and drop the encrypted-folder feature","language":"React","id":"2f0d5d48e15bf735709e8ae170f9c59e90cb7f94","model-score":0.68,"author-id":null,"project-id":76928,"delta-file-score":0.29573047,"diff":"diff --git a/src/modules/filelist/icons/FileIconMime.jsx b/src/modules/filelist/icons/FileIconMime.jsx\nindex 27ce354bf..81537f5e0 100644\n--- a/src/modules/filelist/icons/FileIconMime.jsx\n+++ b/src/modules/filelist/icons/FileIconMime.jsx\n@@ -7,3 +7,2 @@ import Icon from 'cozy-ui/transpiled/react/Icon'\n \n-import { isEncryptedFolder } from '@/lib/encryption'\n import getMimeTypeIcon from '@/lib/getMimeTypeIcon'\n@@ -11,5 +10,4 @@ import { CustomizedIcon } from '@/modules/views/Folder/CustomizedIcon'\n \n-const FileIconMime = ({ file, size = 32, isEncrypted = false }) => {\n+const FileIconMime = ({ file, size = 32 }) => {\n   const isDir = isDirectory(file)\n-  const isDirEncrypted = isEncrypted || (isDirectory && isEncryptedFolder(file)) // use file.ref + file.type\n \n@@ -30,8 +28,3 @@ const FileIconMime = ({ file, size = 32, isEncrypted = false }) => {\n     return (\n-      <Icon\n-        icon={getMimeTypeIcon(isDir, file.name, file.mime, {\n-          isEncrypted: isDirEncrypted\n-        })}\n-        size={size}\n-      />\n+      <Icon icon={getMimeTypeIcon(isDir, file.name, file.mime)} size={size} />\n     )\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"1","loc-deleted":"13","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"On touch screens the editor opened in edit mode, which hid the Drive\ntoolbar (file name and back button) and left the read-only fab as the\nonly way out. The fab toggle was also immediately reverted to edit mode\nby the provider, so it could never restore the toolbar.\n\nAlways render the editor toolbar so the back-to-Drive control stays\navailable, and drop the now-redundant read-only fab.","commit-date":"2026-06-20T15:59:56Z","current-rev":"970343948","filename":"twake-drive/src/modules/views/OnlyOffice/View.jsx","previous-rev":"4d8bbda80","commit-title":"fix(onlyoffice): always show editor toolbar and remove read-only fab","language":"React","id":"f8b8eedcce05fbf1172dc1ab8f26d27ab859bbe7","model-score":0.59,"author-id":null,"project-id":76928,"delta-file-score":0.31179166,"diff":"diff --git a/src/modules/views/OnlyOffice/View.jsx b/src/modules/views/OnlyOffice/View.jsx\nindex 23308ec9f..957a3f95e 100644\n--- a/src/modules/views/OnlyOffice/View.jsx\n+++ b/src/modules/views/OnlyOffice/View.jsx\n@@ -4,3 +4,2 @@ import React, { useEffect, useCallback, useState } from 'react'\n import Spinner from 'cozy-ui/transpiled/react/Spinner'\n-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'\n \n@@ -9,5 +8,3 @@ import OnlyOfficeAIAssistantPanel from '@/modules/views/OnlyOffice/OnlyOfficeAIA\n import { useOnlyOfficeContext } from '@/modules/views/OnlyOffice/OnlyOfficeProvider'\n-import ReadOnlyFab from '@/modules/views/OnlyOffice/ReadOnlyFab'\n import { FRAME_EDITOR_NAME } from '@/modules/views/OnlyOffice/config'\n-import { isOfficeEditingEnabled } from '@/modules/views/OnlyOffice/helpers'\n \n@@ -21,4 +18,3 @@ const View = ({ id, apiUrl, docEditorConfig }) => {\n \n-  const { isEditorReady, isReadOnly, isTrashed } = useOnlyOfficeContext()\n-  const { isMobile, isDesktop } = useBreakpoints()\n+  const { isEditorReady } = useOnlyOfficeContext()\n \n@@ -55,9 +51,2 @@ const View = ({ id, apiUrl, docEditorConfig }) => {\n \n-  const showReadOnlyFab =\n-    isMobile &&\n-    isEditorReady &&\n-    !isReadOnly &&\n-    !isTrashed &&\n-    isOfficeEditingEnabled(isDesktop)\n-\n   if (isError) return <Error />\n@@ -75,3 +64,2 @@ const View = ({ id, apiUrl, docEditorConfig }) => {\n       </div>\n-      {showReadOnlyFab && <ReadOnlyFab />}\n     </>\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"doubleface","training-data":{"loc-added":"40","loc-deleted":"18","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.17","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"mr.thiriot@gmail.com","commit-full-message":"","commit-date":"2026-05-05T07:05:41Z","current-rev":"13bdeb6c8","filename":"twake-drive/src/components/Migration/MigrationProgressBanner.jsx","previous-rev":"1fbf1cbcc","commit-title":"refactor: extract banner logic into reusable hooks","language":"React","id":"e77f1c49afe95818963c3b68c706fa4977a1c78e","model-score":0.54,"author-id":null,"project-id":76928,"delta-file-score":0.36371157,"diff":"diff --git a/src/components/Migration/MigrationProgressBanner.jsx b/src/components/Migration/MigrationProgressBanner.jsx\nindex 88fb011c8..63a158f29 100644\n--- a/src/components/Migration/MigrationProgressBanner.jsx\n+++ b/src/components/Migration/MigrationProgressBanner.jsx\n@@ -17,10 +17,25 @@ const SNACKBAR_AUTO_HIDE_MS = 6000\n \n-const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n-  const { t } = useI18n()\n-  const client = useClient()\n-  const { showAlert } = useAlert()\n+const computeMigrationPercent = progress => {\n+  if (!progress?.bytes_total) return 0\n \n-  const migrationId = migrationDoc?._id\n+  return Math.round((progress.bytes_imported / progress.bytes_total) * 100)\n+}\n \n-  const [isCanceling, setIsCanceling] = useState(false)\n+const showCompletedMigrationAlert = ({ doc, showAlert, t }) => {\n+  if (doc.status !== 'completed') return\n+\n+  showAlert({\n+    title: t('MigrationProgressBanner.done.title'),\n+    message: t('MigrationProgressBanner.done.body', {\n+      count: doc.progress?.files_total ?? 0\n+    }),\n+    severity: 'success',\n+    duration: SNACKBAR_AUTO_HIDE_MS\n+  })\n+}\n+\n+const useMigrationCompletionAlert = ({ migrationId }) => {\n+  const client = useClient()\n+  const { showAlert } = useAlert()\n+  const { t } = useI18n()\n \n@@ -29,13 +44,4 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n \n-    const handleUpdate = doc => {\n-      if (doc.status === 'completed') {\n-        showAlert({\n-          title: t('MigrationProgressBanner.done.title'),\n-          message: t('MigrationProgressBanner.done.body', {\n-            count: doc.progress?.files_total ?? 0\n-          }),\n-          severity: 'success',\n-          duration: SNACKBAR_AUTO_HIDE_MS\n-        })\n-      }\n+    const handleMigrationUpdate = doc => {\n+      showCompletedMigrationAlert({ doc, showAlert, t })\n     }\n@@ -46,4 +52,5 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n       migrationId,\n-      handleUpdate\n+      handleMigrationUpdate\n     )\n+\n     return () => {\n@@ -53,3 +60,3 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n         migrationId,\n-        handleUpdate\n+        handleMigrationUpdate\n       )\n@@ -57,2 +64,7 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n   }, [client, migrationId, showAlert, t])\n+}\n+\n+const useMigrationCancel = ({ migrationId }) => {\n+  const client = useClient()\n+  const [isCanceling, setIsCanceling] = useState(false)\n \n@@ -60,3 +72,5 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n     if (!migrationId || isCanceling) return\n+\n     setIsCanceling(true)\n+\n     try {\n@@ -70,9 +84,19 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n     }\n-  }, [client, migrationId, isCanceling])\n+  }, [client, isCanceling, migrationId])\n+\n+  return { isCanceling, handleCancel }\n+}\n+\n+const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n+  const { t } = useI18n()\n \n+  const migrationId = migrationDoc?._id\n   const progress = migrationDoc?.progress\n-  const percent =\n-    progress?.bytes_total > 0\n-      ? Math.round((progress.bytes_imported / progress.bytes_total) * 100)\n-      : 0\n+  const percent = computeMigrationPercent(progress)\n+\n+  useMigrationCompletionAlert({ migrationId })\n+\n+  const { isCanceling, handleCancel } = useMigrationCancel({\n+    migrationId\n+  })\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Théo Poizat","training-data":{"loc-added":"7","loc-deleted":"26","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"hello@zatteo.com","commit-full-message":"New in stack for shared folder recipient:\n- download folder\n- download multiple files\n\nCan not download multiple share folders at same time.\n\nIt is not necessary to pass a driveId to downloadFiles because it can\nbe infered from the files passed to downloadFiles.","commit-date":"2026-03-23T10:09:41Z","current-rev":"2598dcf1f","filename":"twake-drive/src/modules/actions/download.jsx","previous-rev":"245b5989a","commit-title":"feat: Enable archive download for shared folder recipient","language":"React","id":"7f66850d1d867acfffa848c8cfc4700a95638f73","model-score":0.49,"author-id":null,"project-id":76928,"delta-file-score":0.44755203,"diff":"diff --git a/src/modules/actions/download.jsx b/src/modules/actions/download.jsx\nindex d6d54bdf2..715a44f89 100644\n--- a/src/modules/actions/download.jsx\n+++ b/src/modules/actions/download.jsx\n@@ -2,3 +2,2 @@ import React, { forwardRef } from 'react'\n \n-import { isDirectory } from 'cozy-client/dist/models/file'\n import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'\n@@ -35,3 +34,3 @@ export const download = ({\n   showAlert,\n-  driveId,\n+  shouldHideIfSharedDriveRecipient,\n   isSelectAll,\n@@ -48,8 +47,8 @@ export const download = ({\n     displayCondition: files => {\n-      // # We cannot download folders or multiple files in shared drives\n-\n-      // ## For sharing tab\n+      // ## For sharing tab where we can see multiple shared folders as recipient,\n+      // we disable it because we can not download different shared folders at same time\n       if (\n-        driveId &&\n-        (files.length > 1 || (files.length === 1 && isDirectory(files[0])))\n+        shouldHideIfSharedDriveRecipient &&\n+        files.length > 1 &&\n+        files.some(file => isFromSharedDriveRecipient(file))\n       ) {\n@@ -58,15 +57,2 @@ export const download = ({\n \n-      // ## For shared drive view\n-      const isSingleSharedDriveFolder =\n-        files.length === 1 &&\n-        isFromSharedDriveRecipient(files[0]) &&\n-        isDirectory(files[0])\n-\n-      const hasMultipleFilesIncludeShareDriveFiles =\n-        files.length > 1 && files.some(file => isFromSharedDriveRecipient(file))\n-\n-      if (isSingleSharedDriveFolder || hasMultipleFilesIncludeShareDriveFiles) {\n-        return false\n-      }\n-\n       // We cannot generate archive for encrypted files, for now.\n@@ -85,8 +71,3 @@ export const download = ({\n       }\n-      return downloadFiles(\n-        client,\n-        selectedFiles,\n-        { vaultClient, showAlert, t },\n-        driveId\n-      )\n+      return downloadFiles(client, selectedFiles, { vaultClient, showAlert, t })\n     },\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"9","loc-deleted":"58","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the title bar, its leading cluster, the shared helpers and the\nloading spinner into a common editor module reused by the pdf and\nexcalidraw editors, and lower the cyclomatic complexity flagged by code\nhealth. Also fixes the root parent path (\"/\" instead of \"//\"), hides the\nopen/close entries in the editor document menu, and disables rsbuild\nlazy compilation in dev.","commit-date":"2026-06-11T08:39:11Z","current-rev":"423a2150c","filename":"twake-drive/src/modules/views/Pdf/Title.jsx","previous-rev":"d81edfeaf","commit-title":"refactor(editor): share the editor chrome across pdf and excalidraw","language":"React","id":"81e1696fc9145dbe29ee067384d0efa43b84426a","model-score":0.43,"author-id":null,"project-id":76928,"delta-file-score":0.31179166,"diff":"diff --git a/src/modules/views/Pdf/Title.jsx b/src/modules/views/Pdf/Title.jsx\nindex 89b30cab3..b4a26a497 100644\n--- a/src/modules/views/Pdf/Title.jsx\n+++ b/src/modules/views/Pdf/Title.jsx\n@@ -4,27 +4,6 @@ import React, { useCallback } from 'react'\n import Button from 'cozy-ui/transpiled/react/Buttons'\n-import { DialogTitle } from 'cozy-ui/transpiled/react/Dialog'\n-import Divider from 'cozy-ui/transpiled/react/Divider'\n-import Icon from 'cozy-ui/transpiled/react/Icon'\n import PdfIcon from 'cozy-ui/transpiled/react/Icons/FileTypePdf'\n-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'\n-import { makeStyles } from 'cozy-ui/transpiled/react/styles'\n import { useI18n } from 'twake-i18n'\n \n-import BackButton from '@/components/EditorToolbar/BackButton'\n-import FileName from '@/components/EditorToolbar/FileName'\n-import HomeIcon from '@/components/EditorToolbar/HomeIcon'\n-import HomeLinker from '@/components/EditorToolbar/HomeLinker'\n-import Separator from '@/components/EditorToolbar/Separator'\n-import Sharing from '@/components/EditorToolbar/Sharing'\n-import { useRedirectLink } from '@/hooks/useRedirectLink'\n-\n-// Match the OnlyOffice and Excalidraw editors: keep the title bar a fixed 3rem\n-// tall on its paper background.\n-const useStyles = makeStyles(theme => ({\n-  root: {\n-    width: '100%',\n-    height: '3rem',\n-    backgroundColor: theme.palette.background.paper\n-  }\n-}))\n+import EditorTitle from '@/modules/views/editor/EditorTitle'\n \n@@ -32,11 +11,2 @@ const Title = ({ file, flushRef, isPublic = false, isReadOnly = false }) => {\n   const { t } = useI18n()\n-  const { isMobile } = useBreakpoints()\n-  const { redirectBack, canRedirect } = useRedirectLink({ isPublic })\n-  const styles = useStyles()\n-\n-  // Force a save of any pending change before leaving the editor.\n-  const handleBack = useCallback(async () => {\n-    await flushRef?.current?.()\n-    redirectBack()\n-  }, [flushRef, redirectBack])\n \n@@ -47,38 +17,19 @@ const Title = ({ file, flushRef, isPublic = false, isReadOnly = false }) => {\n   return (\n-    <div style={{ zIndex: 'var(--zIndex-nav)' }}>\n-      <DialogTitle\n-        data-testid=\"pdf-title\"\n-        disableTypography\n-        className=\"u-ellipsis u-flex u-flex-items-center u-p-0 u-pr-1\"\n-        classes={styles}\n-      >\n-        <div className=\"u-flex u-flex-items-center u-flex-grow-1 u-ellipsis\">\n-          {!isMobile && (\n-            <>\n-              {isPublic ? (\n-                <HomeIcon />\n-              ) : (\n-                <HomeLinker>\n-                  <HomeIcon />\n-                </HomeLinker>\n-              )}\n-              <Separator />\n-            </>\n-          )}\n-          {canRedirect && <BackButton onClick={handleBack} />}\n-          {!isMobile && <Icon className=\"u-ml-half\" icon={PdfIcon} size={32} />}\n-          <FileName file={file} isPublic={isPublic} isReadOnly={isReadOnly} />\n-        </div>\n-        {!isReadOnly && (\n-          <Button\n-            variant=\"secondary\"\n-            label={t('Pdf.save')}\n-            onClick={handleSave}\n-            className=\"u-mr-half\"\n-          />\n-        )}\n-        {!isPublic && <Sharing file={file} />}\n-      </DialogTitle>\n-      <Divider />\n-    </div>\n+    <EditorTitle\n+      file={file}\n+      flushRef={flushRef}\n+      icon={PdfIcon}\n+      dataTestId=\"pdf-title\"\n+      isPublic={isPublic}\n+      isReadOnly={isReadOnly}\n+    >\n+      {!isReadOnly && (\n+        <Button\n+          variant=\"secondary\"\n+          label={t('Pdf.save')}\n+          onClick={handleSave}\n+          className=\"u-mr-half\"\n+        />\n+      )}\n+    </EditorTitle>\n   )\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"4","loc-deleted":"40","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.35","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Group the note/docs/excalidraw/office create entries into a\nCreateDocumentItems component so AddMenuContent drops back below the\ncyclomatic-complexity threshold; table-drive the related menu tests.","commit-date":"2026-06-05T11:22:14Z","current-rev":"b75038ace","filename":"twake-drive/src/modules/drive/AddMenu/AddMenuContent.jsx","previous-rev":"95179a95f","commit-title":"refactor(drive): extract document-create items from the add menu","language":"React","id":"f4b7070c3b0645e60dc8ab10791a11f0a9bf48a2","model-score":0.42,"author-id":null,"project-id":76928,"delta-file-score":0.41834745,"diff":"diff --git a/src/modules/drive/AddMenu/AddMenuContent.jsx b/src/modules/drive/AddMenu/AddMenuContent.jsx\nindex 7e8f9eca7..54388580c 100644\n--- a/src/modules/drive/AddMenu/AddMenuContent.jsx\n+++ b/src/modules/drive/AddMenu/AddMenuContent.jsx\n@@ -2,3 +2,2 @@ import React, { forwardRef } from 'react'\n \n-import flag from 'cozy-flags'\n import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader'\n@@ -7,3 +6,2 @@ import ListItemText from 'cozy-ui/transpiled/react/ListItemText'\n import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'\n-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'\n import { useI18n } from 'twake-i18n'\n@@ -11,6 +9,3 @@ import { useI18n } from 'twake-i18n'\n import AddFolderItem from '@/modules/drive/Toolbar/components/AddFolderItem'\n-import CreateDocsItem from '@/modules/drive/Toolbar/components/CreateDocsItem'\n-import CreateExcalidrawItem from '@/modules/drive/Toolbar/components/CreateExcalidrawItem'\n-import CreateNoteItem from '@/modules/drive/Toolbar/components/CreateNoteItem'\n-import CreateOnlyOfficeItem from '@/modules/drive/Toolbar/components/CreateOnlyOfficeItem'\n+import CreateDocumentItems from '@/modules/drive/Toolbar/components/CreateDocumentItems'\n import CreateShortcut from '@/modules/drive/Toolbar/components/CreateShortcut'\n@@ -21,3 +16,2 @@ import { isFromSharedDriveRecipient } from '@/modules/shareddrives/helpers'\n import { NewItemHighlightProvider } from '@/modules/upload/NewItemHighlightProvider'\n-import { isOfficeEditingEnabled } from '@/modules/views/OnlyOffice/helpers'\n \n@@ -38,3 +32,2 @@ const AddMenuContent = forwardRef(\n     const { t } = useI18n()\n-    const { isDesktop } = useBreakpoints()\n     const { hasScanner } = useScannerContext()\n@@ -69,38 +62,9 @@ const AddMenuContent = forwardRef(\n         )}\n-        {!isPublic && (\n-          <CreateNoteItem\n-            displayedFolder={displayedFolder}\n-            isReadOnly={isReadOnly}\n-            onClick={onClick}\n-          />\n-        )}\n-        {!isPublic && flag('drive.lasuitedocs.enabled') && (\n-          <CreateDocsItem\n-            displayedFolder={displayedFolder}\n-            isReadOnly={isReadOnly}\n-            onClick={onClick}\n-          />\n-        )}\n-        {flag('drive.excalidraw.enabled') && (!isPublic || canUpload) && (\n-          <CreateExcalidrawItem isReadOnly={isReadOnly} onClick={onClick} />\n-        )}\n-        {canUpload && isOfficeEditingEnabled(isDesktop) && (\n-          <>\n-            <CreateOnlyOfficeItem\n-              fileClass=\"text\"\n-              isReadOnly={isReadOnly}\n-              onClick={onClick}\n-            />\n-            <CreateOnlyOfficeItem\n-              fileClass=\"spreadsheet\"\n-              isReadOnly={isReadOnly}\n-              onClick={onClick}\n-            />\n-            <CreateOnlyOfficeItem\n-              fileClass=\"slide\"\n-              isReadOnly={isReadOnly}\n-              onClick={onClick}\n-            />\n-          </>\n-        )}\n+        <CreateDocumentItems\n+          isPublic={isPublic}\n+          canUpload={canUpload}\n+          displayedFolder={displayedFolder}\n+          isReadOnly={isReadOnly}\n+          onClick={onClick}\n+        />\n         {!isFromSharedDriveRecipient(displayedFolder) && (\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Khaled FERJANI","training-data":{"loc-added":"8","loc-deleted":"39","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"kferjani@linagora.com","commit-full-message":"The shared-drives-dir folder is hidden from the normal file list but was\nmanually injected at the root of the move/copy destination picker, so it\nshowed up as a target there. Drop the injection and rely on the existing\nbuildMoveOrImportQuery filter.","commit-date":"2026-06-10T12:55:30Z","current-rev":"11d2caf7f","filename":"twake-drive/src/components/FolderPicker/FolderPickerContentCozy.tsx","previous-rev":"f29ad889e","commit-title":"fix(folderpicker): hide Drives folder in move/copy picker","language":"React","id":"89c8e1e6969d0abaec7456a2a8b02421558c2314","model-score":0.33,"author-id":null,"project-id":76928,"delta-file-score":0.59155285,"diff":"diff --git a/src/components/FolderPicker/FolderPickerContentCozy.tsx b/src/components/FolderPicker/FolderPickerContentCozy.tsx\nindex 72286fe40..80f23e413 100644\n--- a/src/components/FolderPicker/FolderPickerContentCozy.tsx\n+++ b/src/components/FolderPicker/FolderPickerContentCozy.tsx\n@@ -1,2 +1,2 @@\n-import React, { useMemo } from 'react'\n+import React from 'react'\n \n@@ -15,4 +15,3 @@ import { computeNextcloudRootFolder } from '@/components/FolderPicker/helpers'\n import type { File, FolderPickerEntry } from '@/components/FolderPicker/types'\n-import { ROOT_DIR_ID } from '@/constants/config'\n-import { buildMoveOrImportQuery, buildMagicFolderQuery } from '@/queries'\n+import { buildMoveOrImportQuery } from '@/queries'\n \n@@ -33,5 +32,3 @@ const FolderPickerContentCozy: React.FC<FolderPickerContentCozyProps> = ({\n   entries,\n-  navigateTo,\n-  showNextcloudFolder,\n-  showSharedDriveFolder\n+  navigateTo\n }) => {\n@@ -50,35 +47,7 @@ const FolderPickerContentCozy: React.FC<FolderPickerContentCozyProps> = ({\n \n-  const sharedFolderQuery = buildMagicFolderQuery({\n-    id: 'io.cozy.files.shared-drives-dir',\n-    enabled: folder._id === ROOT_DIR_ID\n-  })\n-  const sharedFolderResult = useQuery(\n-    sharedFolderQuery.definition,\n-    sharedFolderQuery.options\n-  ) as unknown as {\n-    fetchStatus: string\n-    data?: IOCozyFile[]\n-  }\n-\n-  const files: IOCozyFile[] = useMemo(() => {\n-    if (\n-      folder._id === ROOT_DIR_ID &&\n-      (showNextcloudFolder || showSharedDriveFolder)\n-    ) {\n-      return [\n-        ...(sharedFolderResult.fetchStatus === 'loaded'\n-          ? (sharedFolderResult.data ?? [])\n-          : []),\n-        ...(filesData ?? [])\n-      ]\n-    }\n-    return [...(filesData ?? [])]\n-  }, [\n-    folder._id,\n-    showNextcloudFolder,\n-    showSharedDriveFolder,\n-    filesData,\n-    sharedFolderResult.fetchStatus,\n-    sharedFolderResult.data\n-  ])\n+  // The \"Drives\" folder (shared-drives-dir) is hidden from the normal file\n+  // list, so it must not appear as a destination in the move/copy picker.\n+  // buildMoveOrImportQuery already excludes it via partialIndex, so the list\n+  // is used as-is with no manual injection.\n+  const files: IOCozyFile[] = filesData ?? []\n \n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":18,"what-changed":"FilePickerBody has a cyclomatic complexity of 14, threshold = 10","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"FilePickerBodyItem","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the React language is a cyclomatic complexity lower than 10.","name":"Complex Method","file":"src/modules/services/components/FilePicker/FilePickerBodyItem.jsx","refactoring-examples":[{"architectural-component-id":null,"author-name":"doubleface","training-data":{"loc-added":"1","loc-deleted":"3","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"mr.thiriot@gmail.com","commit-full-message":"","commit-date":"2026-06-11T12:08:23Z","current-rev":"4e5b7c962","filename":"twake-drive/src/modules/public/PublicToolbarByLink.jsx","previous-rev":"9196b60a4","commit-title":"feat: Move Download button in public page more menu","language":"React","id":"b79cb4c3e03e7bb9f11c52da99e6e5fc031d91b2","model-score":0.96,"author-id":null,"project-id":76928,"delta-file-score":0.31179166,"diff":"diff --git a/src/modules/public/PublicToolbarByLink.jsx b/src/modules/public/PublicToolbarByLink.jsx\nindex c6ef9e097..1d7f1ff02 100644\n--- a/src/modules/public/PublicToolbarByLink.jsx\n+++ b/src/modules/public/PublicToolbarByLink.jsx\n@@ -16,3 +16,2 @@ import AddButton from '@/modules/drive/Toolbar/components/AddButton'\n import ViewSwitcher from '@/modules/drive/Toolbar/components/ViewSwitcher'\n-import { DownloadFilesButton } from '@/modules/public/DownloadFilesButton'\n import PublicToolbarMoreMenu from '@/modules/public/PublicToolbarMoreMenu'\n@@ -39,3 +38,3 @@ const PublicToolbarByLink = ({\n     [\n-      isMobile && download,\n+      download,\n       files.length > 1 && select,\n@@ -80,3 +79,2 @@ const PublicToolbarByLink = ({\n             )}\n-            {files.length > 0 && <DownloadFilesButton files={files} />}\n             <ViewSwitcher className=\"u-ml-half\" />\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"doubleface","training-data":{"loc-added":"8","loc-deleted":"3","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"christophe@cozycloud.cc","commit-full-message":"Use a ref to track nextCursor inside fetchMore so it does not need to\nbe listed as a dependency, preventing fetchMore from being recreated\non every page load.","commit-date":"2026-04-07T14:05:15Z","current-rev":"fe37361e4","filename":"twake-drive/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx","previous-rev":"6ac8736f7","commit-title":"refactor: Stabilize fetchMore reference using a cursor ref","language":"React","id":"0725fbf036466b669c341d7308e240454398396e","model-score":0.92,"author-id":null,"project-id":76928,"delta-file-score":0.61278176,"diff":"diff --git a/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx b/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx\nindex df10a751e..d403e119b 100644\n--- a/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx\n+++ b/src/modules/shareddrives/hooks/useSharedDriveFolder.tsx\n@@ -38,2 +38,3 @@ const useSharedDriveFolder = ({\n   const [nextCursor, setNextCursor] = useState<string | null>(null)\n+  const nextCursorRef = useRef<string | null>(null)\n   const isFetchingMore = useRef(false)\n@@ -61,2 +62,3 @@ const useSharedDriveFolder = ({\n       setSharedDriveResult({ data: undefined, included: undefined })\n+      nextCursorRef.current = null\n       setNextCursor(null)\n@@ -70,2 +72,3 @@ const useSharedDriveFolder = ({\n           setSharedDriveResult({ included })\n+          nextCursorRef.current = cursor\n           setNextCursor(cursor)\n@@ -76,2 +79,3 @@ const useSharedDriveFolder = ({\n           setSharedDriveResult({ data: undefined, included: undefined })\n+          nextCursorRef.current = null\n           setNextCursor(null)\n@@ -106,3 +110,3 @@ const useSharedDriveFolder = ({\n   const fetchMore = useCallback(async (): Promise<void> => {\n-    if (isFetchingMore.current || !nextCursor || !client) return\n+    if (isFetchingMore.current || !nextCursorRef.current || !client) return\n \n@@ -115,3 +119,3 @@ const useSharedDriveFolder = ({\n         folderId,\n-        nextCursor\n+        nextCursorRef.current\n       )\n@@ -125,2 +129,3 @@ const useSharedDriveFolder = ({\n       }))\n+      nextCursorRef.current = cursor\n       setNextCursor(cursor)\n@@ -131,3 +136,3 @@ const useSharedDriveFolder = ({\n     }\n-  }, [nextCursor, client, folderId, statById])\n+  }, [client, folderId, statById])\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Khaled FERJANI","training-data":{"loc-added":"2","loc-deleted":"9","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.536386775820924"},"author-email":"kferjani@linagora.com","commit-full-message":"Folder uploads used to recurse inside processNextFile via uploadDirectory,\nscattering 409 conflict handling across three places. The shape produced\nthe long-standing \"no internet connection\" symptom on folder re-drops:\nan inner-file 409 escaped the recursion and ended up in the file-overwrite\npath, which Chrome surfaced as \"Failed to fetch\".\n\nFolder uploads are now flattened at enqueue time. flattenEntries walks\nthe dropped tree once, creates intermediate folders server-side via\ncreateFolderOrGetExisting (handles 409 reuse), and turns each file into\nits own queue item with a relative path and target folder id.\nprocessNextFile only ever handles single files. Conflict handling\ncollapses into two parallel helpers: uploadOrOverwriteFile (file 409\n-> overwrite) and createFolderOrGetExisting (folder 409 -> reuse).\nError classification is one function (classifyUploadError); the\nprep-time alert routes through one handler (reportPrepError).\n\nTo keep folder drops responsive on deep trees, a placeholder row per\ntop-level folder is dispatched immediately so the upload tray reflects\nthe drop. flattenEntries runs in the background and a\nRESOLVE_FOLDER_ITEMS action swaps placeholders for the real per-file\nrows when it finishes.\n\nThe drive.enable-encryption flag was never enabled in production, so\nthe entire encryption code path - both write and read sides - is\nremoved in the same pass. Beyond cleanup, the encrypted upload\nbranch in uploadFile had a synchronous fr.readAsArrayBuffer that\nreturned undefined immediately, breaking conflict detection on\nencrypted uploads.\n\nWhat goes:\n\n- The flag itself.\n- The encryption write path: encryptAndUploadNewFile, createEncryptedDir,\n  AddEncryptedFolderItem, the related JSX gates in AddMenuContent, and\n  vaultClient threading through Dropzone, DropzoneDnD, UploadButton,\n  UploadItem, AddFolder, FolderPickerAddFolderItem, plus the createFolder\n  and uploadFiles actions.\n- The encryption read path: getEncryptionKeyFromDirId, decryptFile,\n  getDecryptedFileURL, downloadEncryptedFile, and the encryption branches\n  in downloadFiles, viewer/helpers downloadFile, FilesViewer, and\n  download.jsx.\n- src/lib/encryption.js entirely.\n- FolderUnlocker (the vault-unlock prompt) plus the wrappers in\n  FolderViewBody, FolderViewBodyContent and the four FolderPicker\n  Content* files.\n- The isEncrypted prop chain (getMimeTypeIcon, EncryptedFolderIcon,\n  FileIcon, FileThumbnail, AddFolderCard, AddFolderRow, SuggestionItem,\n  FolderPickerHeaderIllustration, useSearch).\n- The dead 'encrypted' branch in EmptyCanvas.\n- Stale translation keys (menu_new_encrypted_folder,\n  download.error.encryption_many) across 11 locales.\n\nFollow-up work folded into the same commit:\n\n- The file-limit guard moves into addToUploadQueue itself: the\n  navigation thunk no longer runs exceedsFileLimit ahead of the\n  queue, so a folder drop that trips the limit shows up in the\n  tray as a failed row before the modal appears, and prep-time\n  errors classify through the same RECEIVE_UPLOAD_ERROR path file\n  uploads already use.\n- The single-file download in actions/utils.js is now awaited\n  inside the try/catch so 404 and offline rejections reach the\n  catch arm again - collapsing the try block during the encrypted\n  cleanup had silently dropped the await and suppressed the\n  'This file is missing' / 'You should be connected' alerts.\n- A per-drop nonce scopes both folder-placeholder ids and flattened\n  file ids, so a folder dropped twice (or two files with the same\n  relative path) can't share a queue identity. The reducer's\n  by-fileId update would otherwise flip both rows on a single\n  dispatch.\n- The reducer no-ops same-reference returns when an UPLOAD_*\n  action's fileId matches nothing in state, and ignores\n  RESOLVE_FOLDER_ITEMS if the queue was purged while flatten was\n  in flight - so cancelled drops can't quietly re-fill the tray.\n- The flow inside addToUploadQueue runs the limit check before\n  kicking processing, so loose files don't begin uploading behind\n  the limit-exceeded modal. failPlaceholders -> failDrop now\n  applies to every row in the drop, including loose files.\n- overwriteFile passes the upload options at the top level of\n  updateFile's params (the rest of params is what cozy-stack-client\n  treats as upload options), so onUploadProgress reaches XHR on\n  conflict-overwrite paths and folder-uploaded files emit progress\n  events.\n- The runThunk test helper now drains promises returned by nested\n  thunks so any action dispatched after an inner thunk's first\n  await is captured before assertions run.\n\nSpecs cover the new placeholder-id shape, the no-op reducer, and\nthe overwrite onUploadProgress propagation.","commit-date":"2026-04-28T08:03:46Z","current-rev":"823594568","filename":"twake-drive/src/modules/filelist/icons/FileIconMime.jsx","previous-rev":"98d25068f","commit-title":"refactor: rework upload pipeline and drop the encrypted-folder feature","language":"React","id":"2f0d5d48e15bf735709e8ae170f9c59e90cb7f94","model-score":0.68,"author-id":null,"project-id":76928,"delta-file-score":0.29573047,"diff":"diff --git a/src/modules/filelist/icons/FileIconMime.jsx b/src/modules/filelist/icons/FileIconMime.jsx\nindex 27ce354bf..81537f5e0 100644\n--- a/src/modules/filelist/icons/FileIconMime.jsx\n+++ b/src/modules/filelist/icons/FileIconMime.jsx\n@@ -7,3 +7,2 @@ import Icon from 'cozy-ui/transpiled/react/Icon'\n \n-import { isEncryptedFolder } from '@/lib/encryption'\n import getMimeTypeIcon from '@/lib/getMimeTypeIcon'\n@@ -11,5 +10,4 @@ import { CustomizedIcon } from '@/modules/views/Folder/CustomizedIcon'\n \n-const FileIconMime = ({ file, size = 32, isEncrypted = false }) => {\n+const FileIconMime = ({ file, size = 32 }) => {\n   const isDir = isDirectory(file)\n-  const isDirEncrypted = isEncrypted || (isDirectory && isEncryptedFolder(file)) // use file.ref + file.type\n \n@@ -30,8 +28,3 @@ const FileIconMime = ({ file, size = 32, isEncrypted = false }) => {\n     return (\n-      <Icon\n-        icon={getMimeTypeIcon(isDir, file.name, file.mime, {\n-          isEncrypted: isDirEncrypted\n-        })}\n-        size={size}\n-      />\n+      <Icon icon={getMimeTypeIcon(isDir, file.name, file.mime)} size={size} />\n     )\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"1","loc-deleted":"13","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"On touch screens the editor opened in edit mode, which hid the Drive\ntoolbar (file name and back button) and left the read-only fab as the\nonly way out. The fab toggle was also immediately reverted to edit mode\nby the provider, so it could never restore the toolbar.\n\nAlways render the editor toolbar so the back-to-Drive control stays\navailable, and drop the now-redundant read-only fab.","commit-date":"2026-06-20T15:59:56Z","current-rev":"970343948","filename":"twake-drive/src/modules/views/OnlyOffice/View.jsx","previous-rev":"4d8bbda80","commit-title":"fix(onlyoffice): always show editor toolbar and remove read-only fab","language":"React","id":"f8b8eedcce05fbf1172dc1ab8f26d27ab859bbe7","model-score":0.59,"author-id":null,"project-id":76928,"delta-file-score":0.31179166,"diff":"diff --git a/src/modules/views/OnlyOffice/View.jsx b/src/modules/views/OnlyOffice/View.jsx\nindex 23308ec9f..957a3f95e 100644\n--- a/src/modules/views/OnlyOffice/View.jsx\n+++ b/src/modules/views/OnlyOffice/View.jsx\n@@ -4,3 +4,2 @@ import React, { useEffect, useCallback, useState } from 'react'\n import Spinner from 'cozy-ui/transpiled/react/Spinner'\n-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'\n \n@@ -9,5 +8,3 @@ import OnlyOfficeAIAssistantPanel from '@/modules/views/OnlyOffice/OnlyOfficeAIA\n import { useOnlyOfficeContext } from '@/modules/views/OnlyOffice/OnlyOfficeProvider'\n-import ReadOnlyFab from '@/modules/views/OnlyOffice/ReadOnlyFab'\n import { FRAME_EDITOR_NAME } from '@/modules/views/OnlyOffice/config'\n-import { isOfficeEditingEnabled } from '@/modules/views/OnlyOffice/helpers'\n \n@@ -21,4 +18,3 @@ const View = ({ id, apiUrl, docEditorConfig }) => {\n \n-  const { isEditorReady, isReadOnly, isTrashed } = useOnlyOfficeContext()\n-  const { isMobile, isDesktop } = useBreakpoints()\n+  const { isEditorReady } = useOnlyOfficeContext()\n \n@@ -55,9 +51,2 @@ const View = ({ id, apiUrl, docEditorConfig }) => {\n \n-  const showReadOnlyFab =\n-    isMobile &&\n-    isEditorReady &&\n-    !isReadOnly &&\n-    !isTrashed &&\n-    isOfficeEditingEnabled(isDesktop)\n-\n   if (isError) return <Error />\n@@ -75,3 +64,2 @@ const View = ({ id, apiUrl, docEditorConfig }) => {\n       </div>\n-      {showReadOnlyFab && <ReadOnlyFab />}\n     </>\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"doubleface","training-data":{"loc-added":"40","loc-deleted":"18","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.17","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"mr.thiriot@gmail.com","commit-full-message":"","commit-date":"2026-05-05T07:05:41Z","current-rev":"13bdeb6c8","filename":"twake-drive/src/components/Migration/MigrationProgressBanner.jsx","previous-rev":"1fbf1cbcc","commit-title":"refactor: extract banner logic into reusable hooks","language":"React","id":"e77f1c49afe95818963c3b68c706fa4977a1c78e","model-score":0.54,"author-id":null,"project-id":76928,"delta-file-score":0.36371157,"diff":"diff --git a/src/components/Migration/MigrationProgressBanner.jsx b/src/components/Migration/MigrationProgressBanner.jsx\nindex 88fb011c8..63a158f29 100644\n--- a/src/components/Migration/MigrationProgressBanner.jsx\n+++ b/src/components/Migration/MigrationProgressBanner.jsx\n@@ -17,10 +17,25 @@ const SNACKBAR_AUTO_HIDE_MS = 6000\n \n-const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n-  const { t } = useI18n()\n-  const client = useClient()\n-  const { showAlert } = useAlert()\n+const computeMigrationPercent = progress => {\n+  if (!progress?.bytes_total) return 0\n \n-  const migrationId = migrationDoc?._id\n+  return Math.round((progress.bytes_imported / progress.bytes_total) * 100)\n+}\n \n-  const [isCanceling, setIsCanceling] = useState(false)\n+const showCompletedMigrationAlert = ({ doc, showAlert, t }) => {\n+  if (doc.status !== 'completed') return\n+\n+  showAlert({\n+    title: t('MigrationProgressBanner.done.title'),\n+    message: t('MigrationProgressBanner.done.body', {\n+      count: doc.progress?.files_total ?? 0\n+    }),\n+    severity: 'success',\n+    duration: SNACKBAR_AUTO_HIDE_MS\n+  })\n+}\n+\n+const useMigrationCompletionAlert = ({ migrationId }) => {\n+  const client = useClient()\n+  const { showAlert } = useAlert()\n+  const { t } = useI18n()\n \n@@ -29,13 +44,4 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n \n-    const handleUpdate = doc => {\n-      if (doc.status === 'completed') {\n-        showAlert({\n-          title: t('MigrationProgressBanner.done.title'),\n-          message: t('MigrationProgressBanner.done.body', {\n-            count: doc.progress?.files_total ?? 0\n-          }),\n-          severity: 'success',\n-          duration: SNACKBAR_AUTO_HIDE_MS\n-        })\n-      }\n+    const handleMigrationUpdate = doc => {\n+      showCompletedMigrationAlert({ doc, showAlert, t })\n     }\n@@ -46,4 +52,5 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n       migrationId,\n-      handleUpdate\n+      handleMigrationUpdate\n     )\n+\n     return () => {\n@@ -53,3 +60,3 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n         migrationId,\n-        handleUpdate\n+        handleMigrationUpdate\n       )\n@@ -57,2 +64,7 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n   }, [client, migrationId, showAlert, t])\n+}\n+\n+const useMigrationCancel = ({ migrationId }) => {\n+  const client = useClient()\n+  const [isCanceling, setIsCanceling] = useState(false)\n \n@@ -60,3 +72,5 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n     if (!migrationId || isCanceling) return\n+\n     setIsCanceling(true)\n+\n     try {\n@@ -70,9 +84,19 @@ const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n     }\n-  }, [client, migrationId, isCanceling])\n+  }, [client, isCanceling, migrationId])\n+\n+  return { isCanceling, handleCancel }\n+}\n+\n+const DumbMigrationProgressBanner = ({ migrationDoc }) => {\n+  const { t } = useI18n()\n \n+  const migrationId = migrationDoc?._id\n   const progress = migrationDoc?.progress\n-  const percent =\n-    progress?.bytes_total > 0\n-      ? Math.round((progress.bytes_imported / progress.bytes_total) * 100)\n-      : 0\n+  const percent = computeMigrationPercent(progress)\n+\n+  useMigrationCompletionAlert({ migrationId })\n+\n+  const { isCanceling, handleCancel } = useMigrationCancel({\n+    migrationId\n+  })\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Théo Poizat","training-data":{"loc-added":"7","loc-deleted":"26","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"hello@zatteo.com","commit-full-message":"New in stack for shared folder recipient:\n- download folder\n- download multiple files\n\nCan not download multiple share folders at same time.\n\nIt is not necessary to pass a driveId to downloadFiles because it can\nbe infered from the files passed to downloadFiles.","commit-date":"2026-03-23T10:09:41Z","current-rev":"2598dcf1f","filename":"twake-drive/src/modules/actions/download.jsx","previous-rev":"245b5989a","commit-title":"feat: Enable archive download for shared folder recipient","language":"React","id":"7f66850d1d867acfffa848c8cfc4700a95638f73","model-score":0.49,"author-id":null,"project-id":76928,"delta-file-score":0.44755203,"diff":"diff --git a/src/modules/actions/download.jsx b/src/modules/actions/download.jsx\nindex d6d54bdf2..715a44f89 100644\n--- a/src/modules/actions/download.jsx\n+++ b/src/modules/actions/download.jsx\n@@ -2,3 +2,2 @@ import React, { forwardRef } from 'react'\n \n-import { isDirectory } from 'cozy-client/dist/models/file'\n import ActionsMenuItem from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem'\n@@ -35,3 +34,3 @@ export const download = ({\n   showAlert,\n-  driveId,\n+  shouldHideIfSharedDriveRecipient,\n   isSelectAll,\n@@ -48,8 +47,8 @@ export const download = ({\n     displayCondition: files => {\n-      // # We cannot download folders or multiple files in shared drives\n-\n-      // ## For sharing tab\n+      // ## For sharing tab where we can see multiple shared folders as recipient,\n+      // we disable it because we can not download different shared folders at same time\n       if (\n-        driveId &&\n-        (files.length > 1 || (files.length === 1 && isDirectory(files[0])))\n+        shouldHideIfSharedDriveRecipient &&\n+        files.length > 1 &&\n+        files.some(file => isFromSharedDriveRecipient(file))\n       ) {\n@@ -58,15 +57,2 @@ export const download = ({\n \n-      // ## For shared drive view\n-      const isSingleSharedDriveFolder =\n-        files.length === 1 &&\n-        isFromSharedDriveRecipient(files[0]) &&\n-        isDirectory(files[0])\n-\n-      const hasMultipleFilesIncludeShareDriveFiles =\n-        files.length > 1 && files.some(file => isFromSharedDriveRecipient(file))\n-\n-      if (isSingleSharedDriveFolder || hasMultipleFilesIncludeShareDriveFiles) {\n-        return false\n-      }\n-\n       // We cannot generate archive for encrypted files, for now.\n@@ -85,8 +71,3 @@ export const download = ({\n       }\n-      return downloadFiles(\n-        client,\n-        selectedFiles,\n-        { vaultClient, showAlert, t },\n-        driveId\n-      )\n+      return downloadFiles(client, selectedFiles, { vaultClient, showAlert, t })\n     },\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"9","loc-deleted":"58","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the title bar, its leading cluster, the shared helpers and the\nloading spinner into a common editor module reused by the pdf and\nexcalidraw editors, and lower the cyclomatic complexity flagged by code\nhealth. Also fixes the root parent path (\"/\" instead of \"//\"), hides the\nopen/close entries in the editor document menu, and disables rsbuild\nlazy compilation in dev.","commit-date":"2026-06-11T08:39:11Z","current-rev":"423a2150c","filename":"twake-drive/src/modules/views/Pdf/Title.jsx","previous-rev":"d81edfeaf","commit-title":"refactor(editor): share the editor chrome across pdf and excalidraw","language":"React","id":"81e1696fc9145dbe29ee067384d0efa43b84426a","model-score":0.43,"author-id":null,"project-id":76928,"delta-file-score":0.31179166,"diff":"diff --git a/src/modules/views/Pdf/Title.jsx b/src/modules/views/Pdf/Title.jsx\nindex 89b30cab3..b4a26a497 100644\n--- a/src/modules/views/Pdf/Title.jsx\n+++ b/src/modules/views/Pdf/Title.jsx\n@@ -4,27 +4,6 @@ import React, { useCallback } from 'react'\n import Button from 'cozy-ui/transpiled/react/Buttons'\n-import { DialogTitle } from 'cozy-ui/transpiled/react/Dialog'\n-import Divider from 'cozy-ui/transpiled/react/Divider'\n-import Icon from 'cozy-ui/transpiled/react/Icon'\n import PdfIcon from 'cozy-ui/transpiled/react/Icons/FileTypePdf'\n-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'\n-import { makeStyles } from 'cozy-ui/transpiled/react/styles'\n import { useI18n } from 'twake-i18n'\n \n-import BackButton from '@/components/EditorToolbar/BackButton'\n-import FileName from '@/components/EditorToolbar/FileName'\n-import HomeIcon from '@/components/EditorToolbar/HomeIcon'\n-import HomeLinker from '@/components/EditorToolbar/HomeLinker'\n-import Separator from '@/components/EditorToolbar/Separator'\n-import Sharing from '@/components/EditorToolbar/Sharing'\n-import { useRedirectLink } from '@/hooks/useRedirectLink'\n-\n-// Match the OnlyOffice and Excalidraw editors: keep the title bar a fixed 3rem\n-// tall on its paper background.\n-const useStyles = makeStyles(theme => ({\n-  root: {\n-    width: '100%',\n-    height: '3rem',\n-    backgroundColor: theme.palette.background.paper\n-  }\n-}))\n+import EditorTitle from '@/modules/views/editor/EditorTitle'\n \n@@ -32,11 +11,2 @@ const Title = ({ file, flushRef, isPublic = false, isReadOnly = false }) => {\n   const { t } = useI18n()\n-  const { isMobile } = useBreakpoints()\n-  const { redirectBack, canRedirect } = useRedirectLink({ isPublic })\n-  const styles = useStyles()\n-\n-  // Force a save of any pending change before leaving the editor.\n-  const handleBack = useCallback(async () => {\n-    await flushRef?.current?.()\n-    redirectBack()\n-  }, [flushRef, redirectBack])\n \n@@ -47,38 +17,19 @@ const Title = ({ file, flushRef, isPublic = false, isReadOnly = false }) => {\n   return (\n-    <div style={{ zIndex: 'var(--zIndex-nav)' }}>\n-      <DialogTitle\n-        data-testid=\"pdf-title\"\n-        disableTypography\n-        className=\"u-ellipsis u-flex u-flex-items-center u-p-0 u-pr-1\"\n-        classes={styles}\n-      >\n-        <div className=\"u-flex u-flex-items-center u-flex-grow-1 u-ellipsis\">\n-          {!isMobile && (\n-            <>\n-              {isPublic ? (\n-                <HomeIcon />\n-              ) : (\n-                <HomeLinker>\n-                  <HomeIcon />\n-                </HomeLinker>\n-              )}\n-              <Separator />\n-            </>\n-          )}\n-          {canRedirect && <BackButton onClick={handleBack} />}\n-          {!isMobile && <Icon className=\"u-ml-half\" icon={PdfIcon} size={32} />}\n-          <FileName file={file} isPublic={isPublic} isReadOnly={isReadOnly} />\n-        </div>\n-        {!isReadOnly && (\n-          <Button\n-            variant=\"secondary\"\n-            label={t('Pdf.save')}\n-            onClick={handleSave}\n-            className=\"u-mr-half\"\n-          />\n-        )}\n-        {!isPublic && <Sharing file={file} />}\n-      </DialogTitle>\n-      <Divider />\n-    </div>\n+    <EditorTitle\n+      file={file}\n+      flushRef={flushRef}\n+      icon={PdfIcon}\n+      dataTestId=\"pdf-title\"\n+      isPublic={isPublic}\n+      isReadOnly={isReadOnly}\n+    >\n+      {!isReadOnly && (\n+        <Button\n+          variant=\"secondary\"\n+          label={t('Pdf.save')}\n+          onClick={handleSave}\n+          className=\"u-mr-half\"\n+        />\n+      )}\n+    </EditorTitle>\n   )\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"4","loc-deleted":"40","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.35","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Group the note/docs/excalidraw/office create entries into a\nCreateDocumentItems component so AddMenuContent drops back below the\ncyclomatic-complexity threshold; table-drive the related menu tests.","commit-date":"2026-06-05T11:22:14Z","current-rev":"b75038ace","filename":"twake-drive/src/modules/drive/AddMenu/AddMenuContent.jsx","previous-rev":"95179a95f","commit-title":"refactor(drive): extract document-create items from the add menu","language":"React","id":"f4b7070c3b0645e60dc8ab10791a11f0a9bf48a2","model-score":0.42,"author-id":null,"project-id":76928,"delta-file-score":0.41834745,"diff":"diff --git a/src/modules/drive/AddMenu/AddMenuContent.jsx b/src/modules/drive/AddMenu/AddMenuContent.jsx\nindex 7e8f9eca7..54388580c 100644\n--- a/src/modules/drive/AddMenu/AddMenuContent.jsx\n+++ b/src/modules/drive/AddMenu/AddMenuContent.jsx\n@@ -2,3 +2,2 @@ import React, { forwardRef } from 'react'\n \n-import flag from 'cozy-flags'\n import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader'\n@@ -7,3 +6,2 @@ import ListItemText from 'cozy-ui/transpiled/react/ListItemText'\n import { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'\n-import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'\n import { useI18n } from 'twake-i18n'\n@@ -11,6 +9,3 @@ import { useI18n } from 'twake-i18n'\n import AddFolderItem from '@/modules/drive/Toolbar/components/AddFolderItem'\n-import CreateDocsItem from '@/modules/drive/Toolbar/components/CreateDocsItem'\n-import CreateExcalidrawItem from '@/modules/drive/Toolbar/components/CreateExcalidrawItem'\n-import CreateNoteItem from '@/modules/drive/Toolbar/components/CreateNoteItem'\n-import CreateOnlyOfficeItem from '@/modules/drive/Toolbar/components/CreateOnlyOfficeItem'\n+import CreateDocumentItems from '@/modules/drive/Toolbar/components/CreateDocumentItems'\n import CreateShortcut from '@/modules/drive/Toolbar/components/CreateShortcut'\n@@ -21,3 +16,2 @@ import { isFromSharedDriveRecipient } from '@/modules/shareddrives/helpers'\n import { NewItemHighlightProvider } from '@/modules/upload/NewItemHighlightProvider'\n-import { isOfficeEditingEnabled } from '@/modules/views/OnlyOffice/helpers'\n \n@@ -38,3 +32,2 @@ const AddMenuContent = forwardRef(\n     const { t } = useI18n()\n-    const { isDesktop } = useBreakpoints()\n     const { hasScanner } = useScannerContext()\n@@ -69,38 +62,9 @@ const AddMenuContent = forwardRef(\n         )}\n-        {!isPublic && (\n-          <CreateNoteItem\n-            displayedFolder={displayedFolder}\n-            isReadOnly={isReadOnly}\n-            onClick={onClick}\n-          />\n-        )}\n-        {!isPublic && flag('drive.lasuitedocs.enabled') && (\n-          <CreateDocsItem\n-            displayedFolder={displayedFolder}\n-            isReadOnly={isReadOnly}\n-            onClick={onClick}\n-          />\n-        )}\n-        {flag('drive.excalidraw.enabled') && (!isPublic || canUpload) && (\n-          <CreateExcalidrawItem isReadOnly={isReadOnly} onClick={onClick} />\n-        )}\n-        {canUpload && isOfficeEditingEnabled(isDesktop) && (\n-          <>\n-            <CreateOnlyOfficeItem\n-              fileClass=\"text\"\n-              isReadOnly={isReadOnly}\n-              onClick={onClick}\n-            />\n-            <CreateOnlyOfficeItem\n-              fileClass=\"spreadsheet\"\n-              isReadOnly={isReadOnly}\n-              onClick={onClick}\n-            />\n-            <CreateOnlyOfficeItem\n-              fileClass=\"slide\"\n-              isReadOnly={isReadOnly}\n-              onClick={onClick}\n-            />\n-          </>\n-        )}\n+        <CreateDocumentItems\n+          isPublic={isPublic}\n+          canUpload={canUpload}\n+          displayedFolder={displayedFolder}\n+          isReadOnly={isReadOnly}\n+          onClick={onClick}\n+        />\n         {!isFromSharedDriveRecipient(displayedFolder) && (\n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Khaled FERJANI","training-data":{"loc-added":"8","loc-deleted":"39","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.0","delta-n-functions":"0","current-file-score":"9.6882083290695"},"author-email":"kferjani@linagora.com","commit-full-message":"The shared-drives-dir folder is hidden from the normal file list but was\nmanually injected at the root of the move/copy destination picker, so it\nshowed up as a target there. Drop the injection and rely on the existing\nbuildMoveOrImportQuery filter.","commit-date":"2026-06-10T12:55:30Z","current-rev":"11d2caf7f","filename":"twake-drive/src/components/FolderPicker/FolderPickerContentCozy.tsx","previous-rev":"f29ad889e","commit-title":"fix(folderpicker): hide Drives folder in move/copy picker","language":"React","id":"89c8e1e6969d0abaec7456a2a8b02421558c2314","model-score":0.33,"author-id":null,"project-id":76928,"delta-file-score":0.59155285,"diff":"diff --git a/src/components/FolderPicker/FolderPickerContentCozy.tsx b/src/components/FolderPicker/FolderPickerContentCozy.tsx\nindex 72286fe40..80f23e413 100644\n--- a/src/components/FolderPicker/FolderPickerContentCozy.tsx\n+++ b/src/components/FolderPicker/FolderPickerContentCozy.tsx\n@@ -1,2 +1,2 @@\n-import React, { useMemo } from 'react'\n+import React from 'react'\n \n@@ -15,4 +15,3 @@ import { computeNextcloudRootFolder } from '@/components/FolderPicker/helpers'\n import type { File, FolderPickerEntry } from '@/components/FolderPicker/types'\n-import { ROOT_DIR_ID } from '@/constants/config'\n-import { buildMoveOrImportQuery, buildMagicFolderQuery } from '@/queries'\n+import { buildMoveOrImportQuery } from '@/queries'\n \n@@ -33,5 +32,3 @@ const FolderPickerContentCozy: React.FC<FolderPickerContentCozyProps> = ({\n   entries,\n-  navigateTo,\n-  showNextcloudFolder,\n-  showSharedDriveFolder\n+  navigateTo\n }) => {\n@@ -50,35 +47,7 @@ const FolderPickerContentCozy: React.FC<FolderPickerContentCozyProps> = ({\n \n-  const sharedFolderQuery = buildMagicFolderQuery({\n-    id: 'io.cozy.files.shared-drives-dir',\n-    enabled: folder._id === ROOT_DIR_ID\n-  })\n-  const sharedFolderResult = useQuery(\n-    sharedFolderQuery.definition,\n-    sharedFolderQuery.options\n-  ) as unknown as {\n-    fetchStatus: string\n-    data?: IOCozyFile[]\n-  }\n-\n-  const files: IOCozyFile[] = useMemo(() => {\n-    if (\n-      folder._id === ROOT_DIR_ID &&\n-      (showNextcloudFolder || showSharedDriveFolder)\n-    ) {\n-      return [\n-        ...(sharedFolderResult.fetchStatus === 'loaded'\n-          ? (sharedFolderResult.data ?? [])\n-          : []),\n-        ...(filesData ?? [])\n-      ]\n-    }\n-    return [...(filesData ?? [])]\n-  }, [\n-    folder._id,\n-    showNextcloudFolder,\n-    showSharedDriveFolder,\n-    filesData,\n-    sharedFolderResult.fetchStatus,\n-    sharedFolderResult.data\n-  ])\n+  // The \"Drives\" folder (shared-drives-dir) is hidden from the normal file\n+  // list, so it must not appear as a destination in the move/copy picker.\n+  // buildMoveOrImportQuery already excludes it via partialIndex, so the list\n+  // is used as-is with no manual injection.\n+  const files: IOCozyFile[] = filesData ?? []\n \n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":25,"what-changed":"FilePickerBodyItem has a cyclomatic complexity of 13, threshold = 10","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"FilePickerFooter.renderAction","why-it-occurs":"Functions with many arguments indicate either a) low cohesion where the function has too many responsibilities, or b) a missing abstraction that encapsulates those arguments.\n\nThe threshold for the React language is 4 function arguments.","name":"Excess Number of Function Arguments","file":"src/modules/services/components/FilePicker/FilePickerFooter.jsx","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":36,"what-changed":"FilePickerFooter.renderAction has 6 arguments, max arguments = 4","how-to-fix":"Start by investigating the responsibilities of the function. Make sure it doesn't do too many things, in which case it should be split into smaller and more cohesive functions. Consider the refactoring [INTRODUCE PARAMETER OBJECT](https://refactoring.com/catalog/introduceParameterObject.html) to encapsulate arguments that refer to the same logical concept.","change-type":"introduced"},{"method":"getFilePickerConfig","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the JavaScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"src/modules/services/components/FilePicker/config.js","refactoring-examples":[{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"28","loc-deleted":"81","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.52","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the collab message sender, the incoming-message router and the\npresence heartbeat into focused hooks, and move scene-merge and peer-entry\nlogic into pure helpers. This brings useCollab, usePresence and useSceneRelay\nback under the CodeScene complexity and method-size thresholds without\nchanging behaviour.","commit-date":"2026-06-10T08:46:41Z","current-rev":"bce29c68f","filename":"twake-drive/src/modules/views/Excalidraw/useCollab.js","previous-rev":"dfa5943f1","commit-title":"refactor(excalidraw): split collab hooks to clear CodeScene complexity","language":"JavaScript","id":"985a3f643de6b5efd863a91c74263e40b63ec2df","model-score":0.47,"author-id":null,"project-id":76928,"delta-file-score":0.76515263,"diff":"diff --git a/src/modules/views/Excalidraw/useCollab.js b/src/modules/views/Excalidraw/useCollab.js\nindex 4bf269749..1ed5a5e53 100644\n--- a/src/modules/views/Excalidraw/useCollab.js\n+++ b/src/modules/views/Excalidraw/useCollab.js\n@@ -4,3 +4,2 @@ import { useClient } from 'cozy-client'\n \n-import logger from '@/lib/logger'\n import {\n@@ -8,6 +7,6 @@ import {\n   MESSAGE_TYPES,\n-  makeSessionId,\n-  shouldRespondToHello,\n-  unwrapMessage\n+  makeSessionId\n } from '@/modules/views/Excalidraw/collabProtocol'\n+import { useCollabRouter } from '@/modules/views/Excalidraw/useCollabRouter'\n+import { useCollabSender } from '@/modules/views/Excalidraw/useCollabSender'\n import { usePresence } from '@/modules/views/Excalidraw/usePresence'\n@@ -17,2 +16,7 @@ const REALTIME_EVENT = 'notified'\n \n+// Collaboration only goes live once the flag is on, the canvas API is mounted,\n+// we have a file to key the room on, and the realtime plugin exists.\n+const isCollabReady = (enabled, excalidrawAPI, fileId, realtime) =>\n+  Boolean(enabled && excalidrawAPI && fileId && realtime)\n+\n /**\n@@ -21,4 +25,5 @@ const REALTIME_EVENT = 'notified'\n  * sub-protocols Socket.IO gave Excalidraw for free: presence ({@link usePresence}),\n- * the new-arrival resync handshake, and auto-echo dedup. Element merging stays\n- * last-write-wins in {@link useSceneRelay}.\n+ * the new-arrival resync handshake ({@link useCollabRouter}), and auto-echo\n+ * dedup. Element merging stays last-write-wins in {@link useSceneRelay}, and\n+ * every broadcast goes through the gated {@link useCollabSender}.\n  *\n@@ -42,18 +47,13 @@ export const useCollab = ({\n   const realtime = client?.plugins?.realtime\n-  // A read-only viewer (read share, public link) subscribes to receive, but its\n-  // sharecode has no POST on the file, so it never broadcasts — that keeps the\n-  // realtime endpoint from 403-ing on every cursor move.\n-  const active = Boolean(enabled && excalidrawAPI && fileId && realtime)\n-  const canSend = active && !isReadOnly\n+  const active = isCollabReady(enabled, excalidrawAPI, fileId, realtime)\n \n   // Unique per tab: the client-side substitute for Socket.IO's socket.id, used\n-  // as the presence key and the auto-echo filter.\n+  // as the presence key and the auto-echo filter. Kept in a ref (read only from\n+  // deferred callbacks) so it survives re-renders without a new identity.\n   const sessionIdRef = useRef(null)\n   if (sessionIdRef.current === null) sessionIdRef.current = makeSessionId()\n-  const sessionId = sessionIdRef.current\n \n-  // Kept in refs so the latest value is read without re-subscribing the socket.\n+  // Kept in a ref so the latest name is read without re-subscribing the socket.\n   const apiRef = useRef(null)\n   const usernameRef = useRef('')\n-\n   useEffect(() => {\n@@ -65,24 +65,10 @@ export const useCollab = ({\n \n-  const sendMessage = useCallback(\n-    (type, payload, targetId) => {\n-      // Gate every send on `canSend`, so with collaboration off (no flag, API\n-      // not ready) or as a read-only viewer, editing never POSTs to /realtime.\n-      if (!canSend || !realtime || !fileId) return\n-      const message = {\n-        senderId: sessionId,\n-        username: usernameRef.current,\n-        type\n-      }\n-      if (payload !== undefined) message.payload = payload\n-      if (targetId !== undefined) message.targetId = targetId\n-      // RealtimePlugin.sendNotification returns undefined (not a promise), so\n-      // guard the call itself instead of chaining .catch on its result.\n-      try {\n-        realtime.sendNotification(COLLAB_DOCTYPE, fileId, message)\n-      } catch (error) {\n-        logger.warn(`Excalidraw collab send failed: ${error}`)\n-      }\n-    },\n-    [canSend, realtime, fileId, sessionId]\n-  )\n+  const sendMessage = useCollabSender({\n+    active,\n+    isReadOnly,\n+    realtime,\n+    fileId,\n+    sessionIdRef,\n+    usernameRef\n+  })\n \n@@ -104,51 +90,12 @@ export const useCollab = ({\n \n-  // Only the elected existing peer answers a newcomer, so a HELLO is resynced\n-  // once instead of once per peer.\n-  const respondToHello = useCallback(\n-    senderId => {\n-      if (shouldRespondToHello(sessionId, getPeerIds(), senderId)) {\n-        broadcastInitTo(senderId)\n-      }\n-    },\n-    [sessionId, getPeerIds, broadcastInitTo]\n-  )\n-\n-  const handleMessage = useCallback(\n-    doc => {\n-      const message = unwrapMessage(doc)\n-      if (!message || message.senderId === sessionId) return // drop auto-echo\n-      // A leaving peer should not be resurrected by its own goodbye.\n-      if (message.type !== MESSAGE_TYPES.PRESENCE_BYE) touchPeer(message)\n-\n-      switch (message.type) {\n-        case MESSAGE_TYPES.SCENE_UPDATE:\n-          applyRemoteScene(message.payload)\n-          break\n-        case MESSAGE_TYPES.SCENE_INIT:\n-          if (message.targetId === sessionId) applyRemoteScene(message.payload)\n-          break\n-        case MESSAGE_TYPES.MOUSE_LOCATION:\n-          updatePeerPointer(message)\n-          break\n-        case MESSAGE_TYPES.PRESENCE_HELLO:\n-          respondToHello(message.senderId)\n-          break\n-        case MESSAGE_TYPES.PRESENCE_BYE:\n-          removePeer(message.senderId)\n-          break\n-        default:\n-          break // PRESENCE_PING: touchPeer already refreshed last-seen\n-      }\n-      refresh()\n-    },\n-    [\n-      sessionId,\n-      touchPeer,\n-      removePeer,\n-      updatePeerPointer,\n-      applyRemoteScene,\n-      respondToHello,\n-      refresh\n-    ]\n-  )\n+  const handleMessage = useCollabRouter({\n+    sessionIdRef,\n+    touchPeer,\n+    removePeer,\n+    updatePeerPointer,\n+    getPeerIds,\n+    applyRemoteScene,\n+    broadcastInitTo,\n+    refresh\n+  })\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"17","loc-deleted":"42","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.53","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the collab message sender, the incoming-message router and the\npresence heartbeat into focused hooks, and move scene-merge and peer-entry\nlogic into pure helpers. This brings useCollab, usePresence and useSceneRelay\nback under the CodeScene complexity and method-size thresholds without\nchanging behaviour.","commit-date":"2026-06-10T08:46:41Z","current-rev":"bce29c68f","filename":"twake-drive/src/modules/views/Excalidraw/usePresence.js","previous-rev":"dfa5943f1","commit-title":"refactor(excalidraw): split collab hooks to clear CodeScene complexity","language":"JavaScript","id":"fc6e891fbc126b791062302b75c06297de1a3658","model-score":0.45,"author-id":null,"project-id":76928,"delta-file-score":0.47263768,"diff":"diff --git a/src/modules/views/Excalidraw/usePresence.js b/src/modules/views/Excalidraw/usePresence.js\nindex e95c92e82..1588e10cb 100644\n--- a/src/modules/views/Excalidraw/usePresence.js\n+++ b/src/modules/views/Excalidraw/usePresence.js\n@@ -1,3 +1,3 @@\n import { CaptureUpdateAction } from '@excalidraw/excalidraw'\n-import { useCallback, useEffect, useRef, useState } from 'react'\n+import { useCallback, useRef, useState } from 'react'\n \n@@ -6,9 +6,7 @@ import {\n   MESSAGE_TYPES,\n-  PEER_TTL_MS,\n-  PING_INTERVAL_MS,\n-  PRESENCE_SWEEP_MS,\n   collaboratorsFromPeers,\n-  colorFromSessionId,\n-  prunePeers\n+  makePeerEntry,\n+  readPointer\n } from '@/modules/views/Excalidraw/collabProtocol'\n+import { usePresenceHeartbeat } from '@/modules/views/Excalidraw/usePresenceHeartbeat'\n \n@@ -48,8 +46,6 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n     const existing = peersRef.current.get(message.senderId)\n-    peersRef.current.set(message.senderId, {\n-      ...existing,\n-      username: message.username || existing?.username || '',\n-      color: existing?.color || colorFromSessionId(message.senderId),\n-      lastSeen: Date.now()\n-    })\n+    peersRef.current.set(\n+      message.senderId,\n+      makePeerEntry(existing, message, Date.now())\n+    )\n   }, [])\n@@ -63,4 +59,3 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n     if (!peer) return\n-    peer.pointer = message.payload?.pointer\n-    peer.button = message.payload?.button\n+    Object.assign(peer, readPointer(message.payload))\n   }, [])\n@@ -77,6 +72,3 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n       lastPointerSentRef.current = now\n-      sendMessage(MESSAGE_TYPES.MOUSE_LOCATION, {\n-        pointer: payload?.pointer,\n-        button: payload?.button\n-      })\n+      sendMessage(MESSAGE_TYPES.MOUSE_LOCATION, readPointer(payload))\n     },\n@@ -85,26 +77,9 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n \n-  useEffect(() => {\n-    if (!active) return undefined\n-    const pingId = setInterval(\n-      () => sendMessage(MESSAGE_TYPES.PRESENCE_PING),\n-      PING_INTERVAL_MS\n-    )\n-    const sweepId = setInterval(() => {\n-      const { peers, changed } = prunePeers(\n-        peersRef.current,\n-        Date.now(),\n-        PEER_TTL_MS\n-      )\n-      if (changed) {\n-        peersRef.current = peers\n-        refresh()\n-      }\n-    }, PRESENCE_SWEEP_MS)\n-    return () => {\n-      clearInterval(pingId)\n-      clearInterval(sweepId)\n-      peersRef.current = new Map()\n-      setIsCollaborating(false)\n-    }\n-  }, [active, sendMessage, refresh])\n+  usePresenceHeartbeat({\n+    active,\n+    sendMessage,\n+    peersRef,\n+    refresh,\n+    setIsCollaborating\n+  })\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"55","loc-deleted":"40","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.53","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the collab message sender, the incoming-message router and the\npresence heartbeat into focused hooks, and move scene-merge and peer-entry\nlogic into pure helpers. This brings useCollab, usePresence and useSceneRelay\nback under the CodeScene complexity and method-size thresholds without\nchanging behaviour.","commit-date":"2026-06-10T08:46:41Z","current-rev":"bce29c68f","filename":"twake-drive/src/modules/views/Excalidraw/useSceneRelay.js","previous-rev":"dfa5943f1","commit-title":"refactor(excalidraw): split collab hooks to clear CodeScene complexity","language":"JavaScript","id":"598e0f6819cb9b63472ccc207ad2c1781dc95e33","model-score":0.28,"author-id":null,"project-id":76928,"delta-file-score":0.47263768,"diff":"diff --git a/src/modules/views/Excalidraw/useSceneRelay.js b/src/modules/views/Excalidraw/useSceneRelay.js\nindex 40a8c688c..fa5672a88 100644\n--- a/src/modules/views/Excalidraw/useSceneRelay.js\n+++ b/src/modules/views/Excalidraw/useSceneRelay.js\n@@ -10,2 +10,45 @@ import { MESSAGE_TYPES } from '@/modules/views/Excalidraw/collabProtocol'\n \n+// Merge a remote scene (live update or initial handshake) onto the canvas and\n+// return the version the canvas settled on, or null when there is nothing to\n+// apply. Kept out of the hook so its branching does not weigh on useSceneRelay.\n+const applyRemoteSceneToApi = (api, payload, knownFileIds) => {\n+  if (!api || !payload) return null\n+  const remote = restoreElements(payload.elements || [], null)\n+  const reconciled = reconcileElements(\n+    api.getSceneElements(),\n+    remote,\n+    api.getAppState()\n+  )\n+  const fileEntries = payload.files ? Object.entries(payload.files) : []\n+  if (fileEntries.length) {\n+    // Add the images first so the elements referencing them resolve, and mark\n+    // them known only once addFiles accepted them — otherwise a throw on\n+    // malformed data would suppress them forever.\n+    api.addFiles(fileEntries.map(([, fileData]) => fileData))\n+    fileEntries.forEach(([id]) => knownFileIds.add(id))\n+  }\n+  api.updateScene({\n+    elements: reconciled,\n+    captureUpdate: CaptureUpdateAction.NEVER\n+  })\n+  return getSceneVersion(api.getSceneElements())\n+}\n+\n+// Embedded images added since the last broadcast, so steady-state element\n+// updates stay light while new images still propagate as they appear.\n+const pickNewFiles = (api, knownFileIds) => {\n+  if (!api) return undefined\n+  const files = api.getFiles() || {}\n+  const added = {}\n+  let hasNew = false\n+  for (const [id, fileData] of Object.entries(files)) {\n+    if (!knownFileIds.has(id)) {\n+      knownFileIds.add(id)\n+      added[id] = fileData\n+      hasNew = true\n+    }\n+  }\n+  return hasNew ? added : undefined\n+}\n+\n /**\n@@ -34,28 +77,13 @@ export const useSceneRelay = ({\n \n-  // Merge a remote scene (live update or initial handshake) into the canvas.\n+  // Merge a remote scene (live update or initial handshake) into the canvas and\n+  // watermark from the version the canvas settled on, so the onChange this\n+  // triggers is recognised as remote and not echoed back.\n   const applyRemoteScene = useCallback(\n     payload => {\n-      const api = apiRef.current\n-      if (!api || !payload) return\n-      const remote = restoreElements(payload.elements || [], null)\n-      const reconciled = reconcileElements(\n-        api.getSceneElements(),\n-        remote,\n-        api.getAppState()\n+      const version = applyRemoteSceneToApi(\n+        apiRef.current,\n+        payload,\n+        knownFileIdsRef.current\n       )\n-      const fileEntries = payload.files ? Object.entries(payload.files) : []\n-      if (fileEntries.length) {\n-        // Add the images first so the elements referencing them resolve, and\n-        // mark them known only once addFiles accepted them — otherwise a throw\n-        // on malformed data would suppress them forever.\n-        api.addFiles(fileEntries.map(([, fileData]) => fileData))\n-        fileEntries.forEach(([id]) => knownFileIdsRef.current.add(id))\n-      }\n-      api.updateScene({\n-        elements: reconciled,\n-        captureUpdate: CaptureUpdateAction.NEVER\n-      })\n-      // Watermark from the version the canvas actually settled on, so the\n-      // onChange this triggers is recognised as remote and not echoed back.\n-      lastBroadcastVersionRef.current = getSceneVersion(api.getSceneElements())\n+      if (version !== null) lastBroadcastVersionRef.current = version\n     },\n@@ -64,19 +92,6 @@ export const useSceneRelay = ({\n \n-  // Embedded images added since the last broadcast, so steady-state element\n-  // updates stay light while new images still propagate as they appear.\n-  const collectNewFiles = useCallback(() => {\n-    const api = apiRef.current\n-    if (!api) return undefined\n-    const files = api.getFiles() || {}\n-    const added = {}\n-    let hasNew = false\n-    for (const [id, fileData] of Object.entries(files)) {\n-      if (!knownFileIdsRef.current.has(id)) {\n-        knownFileIdsRef.current.add(id)\n-        added[id] = fileData\n-        hasNew = true\n-      }\n-    }\n-    return hasNew ? added : undefined\n-  }, [apiRef])\n+  const collectNewFiles = useCallback(\n+    () => pickNewFiles(apiRef.current, knownFileIdsRef.current),\n+    [apiRef]\n+  )\n \n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":25,"what-changed":"getFilePickerConfig has a cyclomatic complexity of 10, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"getActionDisabledState","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the JavaScript language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"src/modules/services/components/FilePicker/constraints.js","refactoring-examples":[{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"28","loc-deleted":"81","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"2.52","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the collab message sender, the incoming-message router and the\npresence heartbeat into focused hooks, and move scene-merge and peer-entry\nlogic into pure helpers. This brings useCollab, usePresence and useSceneRelay\nback under the CodeScene complexity and method-size thresholds without\nchanging behaviour.","commit-date":"2026-06-10T08:46:41Z","current-rev":"bce29c68f","filename":"twake-drive/src/modules/views/Excalidraw/useCollab.js","previous-rev":"dfa5943f1","commit-title":"refactor(excalidraw): split collab hooks to clear CodeScene complexity","language":"JavaScript","id":"985a3f643de6b5efd863a91c74263e40b63ec2df","model-score":0.47,"author-id":null,"project-id":76928,"delta-file-score":0.76515263,"diff":"diff --git a/src/modules/views/Excalidraw/useCollab.js b/src/modules/views/Excalidraw/useCollab.js\nindex 4bf269749..1ed5a5e53 100644\n--- a/src/modules/views/Excalidraw/useCollab.js\n+++ b/src/modules/views/Excalidraw/useCollab.js\n@@ -4,3 +4,2 @@ import { useClient } from 'cozy-client'\n \n-import logger from '@/lib/logger'\n import {\n@@ -8,6 +7,6 @@ import {\n   MESSAGE_TYPES,\n-  makeSessionId,\n-  shouldRespondToHello,\n-  unwrapMessage\n+  makeSessionId\n } from '@/modules/views/Excalidraw/collabProtocol'\n+import { useCollabRouter } from '@/modules/views/Excalidraw/useCollabRouter'\n+import { useCollabSender } from '@/modules/views/Excalidraw/useCollabSender'\n import { usePresence } from '@/modules/views/Excalidraw/usePresence'\n@@ -17,2 +16,7 @@ const REALTIME_EVENT = 'notified'\n \n+// Collaboration only goes live once the flag is on, the canvas API is mounted,\n+// we have a file to key the room on, and the realtime plugin exists.\n+const isCollabReady = (enabled, excalidrawAPI, fileId, realtime) =>\n+  Boolean(enabled && excalidrawAPI && fileId && realtime)\n+\n /**\n@@ -21,4 +25,5 @@ const REALTIME_EVENT = 'notified'\n  * sub-protocols Socket.IO gave Excalidraw for free: presence ({@link usePresence}),\n- * the new-arrival resync handshake, and auto-echo dedup. Element merging stays\n- * last-write-wins in {@link useSceneRelay}.\n+ * the new-arrival resync handshake ({@link useCollabRouter}), and auto-echo\n+ * dedup. Element merging stays last-write-wins in {@link useSceneRelay}, and\n+ * every broadcast goes through the gated {@link useCollabSender}.\n  *\n@@ -42,18 +47,13 @@ export const useCollab = ({\n   const realtime = client?.plugins?.realtime\n-  // A read-only viewer (read share, public link) subscribes to receive, but its\n-  // sharecode has no POST on the file, so it never broadcasts — that keeps the\n-  // realtime endpoint from 403-ing on every cursor move.\n-  const active = Boolean(enabled && excalidrawAPI && fileId && realtime)\n-  const canSend = active && !isReadOnly\n+  const active = isCollabReady(enabled, excalidrawAPI, fileId, realtime)\n \n   // Unique per tab: the client-side substitute for Socket.IO's socket.id, used\n-  // as the presence key and the auto-echo filter.\n+  // as the presence key and the auto-echo filter. Kept in a ref (read only from\n+  // deferred callbacks) so it survives re-renders without a new identity.\n   const sessionIdRef = useRef(null)\n   if (sessionIdRef.current === null) sessionIdRef.current = makeSessionId()\n-  const sessionId = sessionIdRef.current\n \n-  // Kept in refs so the latest value is read without re-subscribing the socket.\n+  // Kept in a ref so the latest name is read without re-subscribing the socket.\n   const apiRef = useRef(null)\n   const usernameRef = useRef('')\n-\n   useEffect(() => {\n@@ -65,24 +65,10 @@ export const useCollab = ({\n \n-  const sendMessage = useCallback(\n-    (type, payload, targetId) => {\n-      // Gate every send on `canSend`, so with collaboration off (no flag, API\n-      // not ready) or as a read-only viewer, editing never POSTs to /realtime.\n-      if (!canSend || !realtime || !fileId) return\n-      const message = {\n-        senderId: sessionId,\n-        username: usernameRef.current,\n-        type\n-      }\n-      if (payload !== undefined) message.payload = payload\n-      if (targetId !== undefined) message.targetId = targetId\n-      // RealtimePlugin.sendNotification returns undefined (not a promise), so\n-      // guard the call itself instead of chaining .catch on its result.\n-      try {\n-        realtime.sendNotification(COLLAB_DOCTYPE, fileId, message)\n-      } catch (error) {\n-        logger.warn(`Excalidraw collab send failed: ${error}`)\n-      }\n-    },\n-    [canSend, realtime, fileId, sessionId]\n-  )\n+  const sendMessage = useCollabSender({\n+    active,\n+    isReadOnly,\n+    realtime,\n+    fileId,\n+    sessionIdRef,\n+    usernameRef\n+  })\n \n@@ -104,51 +90,12 @@ export const useCollab = ({\n \n-  // Only the elected existing peer answers a newcomer, so a HELLO is resynced\n-  // once instead of once per peer.\n-  const respondToHello = useCallback(\n-    senderId => {\n-      if (shouldRespondToHello(sessionId, getPeerIds(), senderId)) {\n-        broadcastInitTo(senderId)\n-      }\n-    },\n-    [sessionId, getPeerIds, broadcastInitTo]\n-  )\n-\n-  const handleMessage = useCallback(\n-    doc => {\n-      const message = unwrapMessage(doc)\n-      if (!message || message.senderId === sessionId) return // drop auto-echo\n-      // A leaving peer should not be resurrected by its own goodbye.\n-      if (message.type !== MESSAGE_TYPES.PRESENCE_BYE) touchPeer(message)\n-\n-      switch (message.type) {\n-        case MESSAGE_TYPES.SCENE_UPDATE:\n-          applyRemoteScene(message.payload)\n-          break\n-        case MESSAGE_TYPES.SCENE_INIT:\n-          if (message.targetId === sessionId) applyRemoteScene(message.payload)\n-          break\n-        case MESSAGE_TYPES.MOUSE_LOCATION:\n-          updatePeerPointer(message)\n-          break\n-        case MESSAGE_TYPES.PRESENCE_HELLO:\n-          respondToHello(message.senderId)\n-          break\n-        case MESSAGE_TYPES.PRESENCE_BYE:\n-          removePeer(message.senderId)\n-          break\n-        default:\n-          break // PRESENCE_PING: touchPeer already refreshed last-seen\n-      }\n-      refresh()\n-    },\n-    [\n-      sessionId,\n-      touchPeer,\n-      removePeer,\n-      updatePeerPointer,\n-      applyRemoteScene,\n-      respondToHello,\n-      refresh\n-    ]\n-  )\n+  const handleMessage = useCollabRouter({\n+    sessionIdRef,\n+    touchPeer,\n+    removePeer,\n+    updatePeerPointer,\n+    getPeerIds,\n+    applyRemoteScene,\n+    broadcastInitTo,\n+    refresh\n+  })\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"17","loc-deleted":"42","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.53","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the collab message sender, the incoming-message router and the\npresence heartbeat into focused hooks, and move scene-merge and peer-entry\nlogic into pure helpers. This brings useCollab, usePresence and useSceneRelay\nback under the CodeScene complexity and method-size thresholds without\nchanging behaviour.","commit-date":"2026-06-10T08:46:41Z","current-rev":"bce29c68f","filename":"twake-drive/src/modules/views/Excalidraw/usePresence.js","previous-rev":"dfa5943f1","commit-title":"refactor(excalidraw): split collab hooks to clear CodeScene complexity","language":"JavaScript","id":"fc6e891fbc126b791062302b75c06297de1a3658","model-score":0.45,"author-id":null,"project-id":76928,"delta-file-score":0.47263768,"diff":"diff --git a/src/modules/views/Excalidraw/usePresence.js b/src/modules/views/Excalidraw/usePresence.js\nindex e95c92e82..1588e10cb 100644\n--- a/src/modules/views/Excalidraw/usePresence.js\n+++ b/src/modules/views/Excalidraw/usePresence.js\n@@ -1,3 +1,3 @@\n import { CaptureUpdateAction } from '@excalidraw/excalidraw'\n-import { useCallback, useEffect, useRef, useState } from 'react'\n+import { useCallback, useRef, useState } from 'react'\n \n@@ -6,9 +6,7 @@ import {\n   MESSAGE_TYPES,\n-  PEER_TTL_MS,\n-  PING_INTERVAL_MS,\n-  PRESENCE_SWEEP_MS,\n   collaboratorsFromPeers,\n-  colorFromSessionId,\n-  prunePeers\n+  makePeerEntry,\n+  readPointer\n } from '@/modules/views/Excalidraw/collabProtocol'\n+import { usePresenceHeartbeat } from '@/modules/views/Excalidraw/usePresenceHeartbeat'\n \n@@ -48,8 +46,6 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n     const existing = peersRef.current.get(message.senderId)\n-    peersRef.current.set(message.senderId, {\n-      ...existing,\n-      username: message.username || existing?.username || '',\n-      color: existing?.color || colorFromSessionId(message.senderId),\n-      lastSeen: Date.now()\n-    })\n+    peersRef.current.set(\n+      message.senderId,\n+      makePeerEntry(existing, message, Date.now())\n+    )\n   }, [])\n@@ -63,4 +59,3 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n     if (!peer) return\n-    peer.pointer = message.payload?.pointer\n-    peer.button = message.payload?.button\n+    Object.assign(peer, readPointer(message.payload))\n   }, [])\n@@ -77,6 +72,3 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n       lastPointerSentRef.current = now\n-      sendMessage(MESSAGE_TYPES.MOUSE_LOCATION, {\n-        pointer: payload?.pointer,\n-        button: payload?.button\n-      })\n+      sendMessage(MESSAGE_TYPES.MOUSE_LOCATION, readPointer(payload))\n     },\n@@ -85,26 +77,9 @@ export const usePresence = ({ apiRef, active, sendMessage }) => {\n \n-  useEffect(() => {\n-    if (!active) return undefined\n-    const pingId = setInterval(\n-      () => sendMessage(MESSAGE_TYPES.PRESENCE_PING),\n-      PING_INTERVAL_MS\n-    )\n-    const sweepId = setInterval(() => {\n-      const { peers, changed } = prunePeers(\n-        peersRef.current,\n-        Date.now(),\n-        PEER_TTL_MS\n-      )\n-      if (changed) {\n-        peersRef.current = peers\n-        refresh()\n-      }\n-    }, PRESENCE_SWEEP_MS)\n-    return () => {\n-      clearInterval(pingId)\n-      clearInterval(sweepId)\n-      peersRef.current = new Map()\n-      setIsCollaborating(false)\n-    }\n-  }, [active, sendMessage, refresh])\n+  usePresenceHeartbeat({\n+    active,\n+    sendMessage,\n+    peersRef,\n+    refresh,\n+    setIsCollaborating\n+  })\n \n","improvement-type":"Complex Method"},{"architectural-component-id":null,"author-name":"Crash--","training-data":{"loc-added":"55","loc-deleted":"40","delta-cc-mean":"0.0","delta-cc-total":"0","delta-penalties":"1.53","delta-n-functions":"0","current-file-score":"10.0"},"author-email":"quentin.valmori@gmail.com","commit-full-message":"Extract the collab message sender, the incoming-message router and the\npresence heartbeat into focused hooks, and move scene-merge and peer-entry\nlogic into pure helpers. This brings useCollab, usePresence and useSceneRelay\nback under the CodeScene complexity and method-size thresholds without\nchanging behaviour.","commit-date":"2026-06-10T08:46:41Z","current-rev":"bce29c68f","filename":"twake-drive/src/modules/views/Excalidraw/useSceneRelay.js","previous-rev":"dfa5943f1","commit-title":"refactor(excalidraw): split collab hooks to clear CodeScene complexity","language":"JavaScript","id":"598e0f6819cb9b63472ccc207ad2c1781dc95e33","model-score":0.28,"author-id":null,"project-id":76928,"delta-file-score":0.47263768,"diff":"diff --git a/src/modules/views/Excalidraw/useSceneRelay.js b/src/modules/views/Excalidraw/useSceneRelay.js\nindex 40a8c688c..fa5672a88 100644\n--- a/src/modules/views/Excalidraw/useSceneRelay.js\n+++ b/src/modules/views/Excalidraw/useSceneRelay.js\n@@ -10,2 +10,45 @@ import { MESSAGE_TYPES } from '@/modules/views/Excalidraw/collabProtocol'\n \n+// Merge a remote scene (live update or initial handshake) onto the canvas and\n+// return the version the canvas settled on, or null when there is nothing to\n+// apply. Kept out of the hook so its branching does not weigh on useSceneRelay.\n+const applyRemoteSceneToApi = (api, payload, knownFileIds) => {\n+  if (!api || !payload) return null\n+  const remote = restoreElements(payload.elements || [], null)\n+  const reconciled = reconcileElements(\n+    api.getSceneElements(),\n+    remote,\n+    api.getAppState()\n+  )\n+  const fileEntries = payload.files ? Object.entries(payload.files) : []\n+  if (fileEntries.length) {\n+    // Add the images first so the elements referencing them resolve, and mark\n+    // them known only once addFiles accepted them — otherwise a throw on\n+    // malformed data would suppress them forever.\n+    api.addFiles(fileEntries.map(([, fileData]) => fileData))\n+    fileEntries.forEach(([id]) => knownFileIds.add(id))\n+  }\n+  api.updateScene({\n+    elements: reconciled,\n+    captureUpdate: CaptureUpdateAction.NEVER\n+  })\n+  return getSceneVersion(api.getSceneElements())\n+}\n+\n+// Embedded images added since the last broadcast, so steady-state element\n+// updates stay light while new images still propagate as they appear.\n+const pickNewFiles = (api, knownFileIds) => {\n+  if (!api) return undefined\n+  const files = api.getFiles() || {}\n+  const added = {}\n+  let hasNew = false\n+  for (const [id, fileData] of Object.entries(files)) {\n+    if (!knownFileIds.has(id)) {\n+      knownFileIds.add(id)\n+      added[id] = fileData\n+      hasNew = true\n+    }\n+  }\n+  return hasNew ? added : undefined\n+}\n+\n /**\n@@ -34,28 +77,13 @@ export const useSceneRelay = ({\n \n-  // Merge a remote scene (live update or initial handshake) into the canvas.\n+  // Merge a remote scene (live update or initial handshake) into the canvas and\n+  // watermark from the version the canvas settled on, so the onChange this\n+  // triggers is recognised as remote and not echoed back.\n   const applyRemoteScene = useCallback(\n     payload => {\n-      const api = apiRef.current\n-      if (!api || !payload) return\n-      const remote = restoreElements(payload.elements || [], null)\n-      const reconciled = reconcileElements(\n-        api.getSceneElements(),\n-        remote,\n-        api.getAppState()\n+      const version = applyRemoteSceneToApi(\n+        apiRef.current,\n+        payload,\n+        knownFileIdsRef.current\n       )\n-      const fileEntries = payload.files ? Object.entries(payload.files) : []\n-      if (fileEntries.length) {\n-        // Add the images first so the elements referencing them resolve, and\n-        // mark them known only once addFiles accepted them — otherwise a throw\n-        // on malformed data would suppress them forever.\n-        api.addFiles(fileEntries.map(([, fileData]) => fileData))\n-        fileEntries.forEach(([id]) => knownFileIdsRef.current.add(id))\n-      }\n-      api.updateScene({\n-        elements: reconciled,\n-        captureUpdate: CaptureUpdateAction.NEVER\n-      })\n-      // Watermark from the version the canvas actually settled on, so the\n-      // onChange this triggers is recognised as remote and not echoed back.\n-      lastBroadcastVersionRef.current = getSceneVersion(api.getSceneElements())\n+      if (version !== null) lastBroadcastVersionRef.current = version\n     },\n@@ -64,19 +92,6 @@ export const useSceneRelay = ({\n \n-  // Embedded images added since the last broadcast, so steady-state element\n-  // updates stay light while new images still propagate as they appear.\n-  const collectNewFiles = useCallback(() => {\n-    const api = apiRef.current\n-    if (!api) return undefined\n-    const files = api.getFiles() || {}\n-    const added = {}\n-    let hasNew = false\n-    for (const [id, fileData] of Object.entries(files)) {\n-      if (!knownFileIdsRef.current.has(id)) {\n-        knownFileIdsRef.current.add(id)\n-        added[id] = fileData\n-        hasNew = true\n-      }\n-    }\n-    return hasNew ? added : undefined\n-  }, [apiRef])\n+  const collectNewFiles = useCallback(\n+    () => pickNewFiles(apiRef.current, knownFileIdsRef.current),\n+    [apiRef]\n+  )\n \n","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":41,"what-changed":"getActionDisabledState has a cyclomatic complexity of 14, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"method":"getActionDisabledState","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"src/modules/services/components/FilePicker/constraints.js","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"javascript","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":61,"what-changed":"getActionDisabledState has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"},{"method":"getActionDisabledState","why-it-occurs":"A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health.\n\nA bumpy code road represents a lack of encapsulation which becomes an obstacle to comprehension. In imperative languages there’s also an increased risk for feature entanglement, which leads to complex state management. CodeScene considers the following rules for the code health impact: 1) The deeper the nested conditional logic of each bump, the higher the tax on our working memory. 2) The more bumps inside a function, the more expensive it is to refactor as each bump represents a missing abstraction. 3) The larger each bump – that is, the more lines of code it spans – the harder it is to build up a mental model of the function. The nesting depth for what is considered a bump is  levels of conditionals.","name":"Bumpy Road Ahead","file":"src/modules/services/components/FilePicker/constraints.js","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":41,"what-changed":"getActionDisabledState has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"introduced"},{"why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","name":"Code Duplication","file":"src/modules/services/components/FilePicker/constraints.spec.jsx","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":83,"what-changed":"The module contains 2 functions with similar structure: 'should disable when allowedMimeTypes is set and the file mime does not match','should disable when the file is larger than maxFileSize'","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"},{"method":"matchMimeType","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"src/modules/services/components/FilePicker/helpers.js","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"javascript","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":35,"what-changed":"matchMimeType has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"},{"why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","name":"Code Duplication","file":"src/modules/services/components/Picker.spec.jsx","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":239,"what-changed":"The module contains 3 functions with similar structure: 'should return a DOWNLOAD_LINK_FAILED error code when temporary link generation fails','should return a SHARING_LINK_FAILED error code when public link generation fails','should return an ITEM_NOT_FOUND error code when metadata loading fails'","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"},{"why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","name":"Code Duplication","file":"e2e/tests/file-picker.spec.ts","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":183,"what-changed":"The module contains 2 functions with similar structure: 'File Picker'.'download-only config hides public link and returns a download link','File Picker'.'sharing-only config hides download link and returns a sharing link'","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","change-type":"introduced"}]},"positive-impact-count":0,"repo":"twake-drive","code-health":9.76267112908335,"version":"3.0","authors":["doubleface"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2026-07-03T14:31:01.000Z","project-name":"twake-drive","repository":"https://github.com/linagora/twake-drive.git"}}