Rename Jotai state hooks and utilities to consistent Atom-based naming (#18209)

## Summary

Rename all Jotai-based state management hooks and utilities to a
consistent naming convention that:
1. Removes legacy Recoil naming (`useRecoilXxxV2`, `createXxxV2`)
2. Always includes `Atom` in the name to distinguish from jotai native
hooks
3. Follows a consistent ordering: `Atom` → `Component` → `Family` →
`Type` (`State`/`Selector`)
4. Includes the type qualifier (`State` or `Selector`) in all
value-reading hooks to avoid naming conflicts with jotai's native
`useAtomValue`

## Naming Convention

**Hooks**:
`use[Set]Atom[Component][Family][State|Selector][Value|State|CallbackState]`
**Utils**: `createAtom[Component][Family][State|Selector]`

## Changes

### Hooks renamed (definition files + all usages across ~1,500 files):

| Old Name (Recoil) | Intermediate (Atom) | Final Name |
|---|---|---|
| `useRecoilValueV2` | `useAtomValue` | **`useAtomStateValue`** |
| `useRecoilStateV2` | `useAtomState` | `useAtomState` |
| `useSetRecoilStateV2` | `useSetAtomState` | `useSetAtomState` |
| `useFamilyRecoilValueV2` | `useFamilyAtomValue` |
**`useAtomFamilyStateValue`** |
| `useSetFamilyRecoilStateV2` | `useSetFamilyAtomState` |
**`useSetAtomFamilyState`** |
| `useFamilySelectorValueV2` | `useFamilySelectorValue` |
**`useAtomFamilySelectorValue`** |
| `useFamilySelectorStateV2` | `useFamilySelectorState` |
**`useAtomFamilySelectorState`** |
| `useRecoilComponentValueV2` | `useAtomComponentValue` |
**`useAtomComponentStateValue`** |
| `useRecoilComponentStateV2` | `useAtomComponentState` |
`useAtomComponentState` |
| `useSetRecoilComponentStateV2` | `useSetAtomComponentState` |
`useSetAtomComponentState` |
| `useRecoilComponentFamilyValueV2` | `useAtomComponentFamilyValue` |
**`useAtomComponentFamilyStateValue`** |
| `useRecoilComponentFamilyStateV2` | `useAtomComponentFamilyState` |
`useAtomComponentFamilyState` |
| `useSetRecoilComponentFamilyStateV2` |
`useSetAtomComponentFamilyState` | `useSetAtomComponentFamilyState` |
| `useRecoilComponentSelectorValueV2` | `useAtomComponentSelectorValue`
| `useAtomComponentSelectorValue` |
| `useRecoilComponentFamilySelectorValueV2` |
`useAtomComponentFamilySelectorValue` |
`useAtomComponentFamilySelectorValue` |
| `useRecoilComponentStateCallbackStateV2` |
`useAtomComponentStateCallbackState` |
`useAtomComponentStateCallbackState` |
| `useRecoilComponentSelectorCallbackStateV2` |
`useAtomComponentSelectorCallbackState` |
`useAtomComponentSelectorCallbackState` |
| `useRecoilComponentFamilyStateCallbackStateV2` |
`useAtomComponentFamilyStateCallbackState` |
`useAtomComponentFamilyStateCallbackState` |
| `useRecoilComponentFamilySelectorCallbackStateV2` |
`useAtomComponentFamilySelectorCallbackState` |
`useAtomComponentFamilySelectorCallbackState` |

### Utilities renamed:

| Old Name (Recoil) | Final Name |
|---|---|
| `createStateV2` | **`createAtomState`** |
| `createFamilyStateV2` | **`createAtomFamilyState`** |
| `createSelectorV2` | **`createAtomSelector`** |
| `createFamilySelectorV2` | **`createAtomFamilySelector`** |
| `createWritableSelectorV2` | **`createAtomWritableSelector`** |
| `createWritableFamilySelectorV2` |
**`createAtomWritableFamilySelector`** |
| `createComponentStateV2` | **`createAtomComponentState`** |
| `createComponentFamilyStateV2` | **`createAtomComponentFamilyState`**
|
| `createComponentSelectorV2` | **`createAtomComponentSelector`** |
| `createComponentFamilySelectorV2` |
**`createAtomComponentFamilySelector`** |

## Details

- All definition files renamed to match new convention
- All import paths and usages updated across the entire `twenty-front`
package
- Jotai's native `useAtomValue` is aliased as `useJotaiAtomValue` in the
wrapper hook to avoid collision
- Legacy Recoil files in `state/utils/` and `component-state/utils/`
left untouched (separate naming scope)
- Typecheck passes cleanly
This commit is contained in:
Charles Bochet
2026-02-25 01:55:46 +01:00
committed by GitHub
parent eaf9fe27b2
commit d81f006979
1890 changed files with 6399 additions and 6420 deletions
@@ -31,8 +31,8 @@ import { isAttachmentPreviewEnabledStateV2 } from '@/client-config/states/isAtta
import { clientConfigApiStatusState } from '@/client-config/states/clientConfigApiStatusState';
import { getClientConfig } from '@/client-config/utils/getClientConfig';
import { allowRequestsToTwentyIconsState } from '@/client-config/states/allowRequestsToTwentyIcons';
import { useSetRecoilStateV2 } from '@/ui/utilities/state/jotai/hooks/useSetRecoilStateV2';
import { useRecoilStateV2 } from '@/ui/utilities/state/jotai/hooks/useRecoilStateV2';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { useStore } from 'jotai';
type UseClientConfigResult = {
@@ -45,91 +45,87 @@ type UseClientConfigResult = {
export const useClientConfig = (): UseClientConfigResult => {
const store = useStore();
const setIsAnalyticsEnabled = useSetRecoilStateV2(isAnalyticsEnabledState);
const setDomainConfiguration = useSetRecoilStateV2(domainConfigurationState);
const setAuthProviders = useSetRecoilStateV2(authProvidersState);
const setAiModels = useSetRecoilStateV2(aiModelsState);
const setIsAnalyticsEnabled = useSetAtomState(isAnalyticsEnabledState);
const setDomainConfiguration = useSetAtomState(domainConfigurationState);
const setAuthProviders = useSetAtomState(authProvidersState);
const setAiModels = useSetAtomState(aiModelsState);
const setIsDeveloperDefaultSignInPrefilled = useSetRecoilStateV2(
const setIsDeveloperDefaultSignInPrefilled = useSetAtomState(
isDeveloperDefaultSignInPrefilledState,
);
const setIsMultiWorkspaceEnabled = useSetRecoilStateV2(
const setIsMultiWorkspaceEnabled = useSetAtomState(
isMultiWorkspaceEnabledState,
);
const setIsEmailVerificationRequired = useSetRecoilStateV2(
const setIsEmailVerificationRequired = useSetAtomState(
isEmailVerificationRequiredState,
);
const setBilling = useSetRecoilStateV2(billingState);
const setSupportChat = useSetRecoilStateV2(supportChatState);
const setBilling = useSetAtomState(billingState);
const setSupportChat = useSetAtomState(supportChatState);
const setSentryConfig = useSetRecoilStateV2(sentryConfigState);
const [clientConfigApiStatus, setClientConfigApiStatus] = useRecoilStateV2(
const setSentryConfig = useSetAtomState(sentryConfigState);
const [clientConfigApiStatus, setClientConfigApiStatus] = useAtomState(
clientConfigApiStatusState,
);
const setCaptcha = useSetRecoilStateV2(captchaState);
const setCaptcha = useSetAtomState(captchaState);
const setChromeExtensionId = useSetRecoilStateV2(chromeExtensionIdState);
const setChromeExtensionId = useSetAtomState(chromeExtensionIdState);
const setApiConfig = useSetRecoilStateV2(apiConfigState);
const setApiConfig = useSetAtomState(apiConfigState);
const setCanManageFeatureFlags = useSetRecoilStateV2(
canManageFeatureFlagsState,
);
const setCanManageFeatureFlags = useSetAtomState(canManageFeatureFlagsState);
const setLabPublicFeatureFlags = useSetRecoilStateV2(
const setLabPublicFeatureFlags = useSetAtomState(
labPublicFeatureFlagsStateV2,
);
const setMicrosoftMessagingEnabled = useSetRecoilStateV2(
const setMicrosoftMessagingEnabled = useSetAtomState(
isMicrosoftMessagingEnabledState,
);
const setMicrosoftCalendarEnabled = useSetRecoilStateV2(
const setMicrosoftCalendarEnabled = useSetAtomState(
isMicrosoftCalendarEnabledState,
);
const setGoogleMessagingEnabled = useSetRecoilStateV2(
const setGoogleMessagingEnabled = useSetAtomState(
isGoogleMessagingEnabledState,
);
const setGoogleCalendarEnabled = useSetRecoilStateV2(
const setGoogleCalendarEnabled = useSetAtomState(
isGoogleCalendarEnabledState,
);
const setIsAttachmentPreviewEnabled = useSetRecoilStateV2(
const setIsAttachmentPreviewEnabled = useSetAtomState(
isAttachmentPreviewEnabledState,
);
const setIsConfigVariablesInDbEnabled = useSetRecoilStateV2(
const setIsConfigVariablesInDbEnabled = useSetAtomState(
isConfigVariablesInDbEnabledState,
);
const setCalendarBookingPageId = useSetRecoilStateV2(
calendarBookingPageIdState,
);
const setCalendarBookingPageId = useSetAtomState(calendarBookingPageIdState);
const setIsImapSmtpCaldavEnabled = useSetRecoilStateV2(
const setIsImapSmtpCaldavEnabled = useSetAtomState(
isImapSmtpCaldavEnabledState,
);
const setIsEmailingDomainsEnabled = useSetRecoilStateV2(
const setIsEmailingDomainsEnabled = useSetAtomState(
isEmailingDomainsEnabledState,
);
const setAllowRequestsToTwentyIcons = useSetRecoilStateV2(
const setAllowRequestsToTwentyIcons = useSetAtomState(
allowRequestsToTwentyIconsState,
);
const setIsCloudflareIntegrationEnabled = useSetRecoilStateV2(
const setIsCloudflareIntegrationEnabled = useSetAtomState(
isCloudflareIntegrationEnabledState,
);
const setIsClickHouseConfigured = useSetRecoilStateV2(
const setIsClickHouseConfigured = useSetAtomState(
isClickHouseConfiguredState,
);
const setAppVersion = useSetRecoilStateV2(appVersionState);
const setAppVersion = useSetAtomState(appVersionState);
const fetchClientConfig = useCallback(async () => {
setClientConfigApiStatus((prev) => ({