feat: migrate from aiErrorAssist naming for disabling AI features to aiFeatures.enabled to avoid confusion (#31273)

feat: keep aiErrorAssistant as setting on user object until migration is run
GitOrigin-RevId: df53914163566065d0b91b8d130476fbcdf1ea96
This commit is contained in:
Jimmy Domagala-Tang
2026-02-12 09:38:27 -05:00
committed by Copybot
parent df8190ec8c
commit 551d7b3908
10 changed files with 40 additions and 28 deletions
@@ -472,7 +472,7 @@ const _ProjectController = {
user: (async () => {
const user = await User.findById(
userId,
'email first_name last_name referal_id signUpDate featureSwitches features featuresEpoch refProviders alphaProgram betaProgram isAdmin ace labsProgram labsExperiments completedTutorials writefull aiErrorAssistant'
'email first_name last_name referal_id signUpDate featureSwitches features featuresEpoch refProviders alphaProgram betaProgram isAdmin ace labsProgram labsExperiments completedTutorials writefull aiFeatures aiErrorAssistant'
).exec()
// Handle case of deleted user
if (!user) {
@@ -844,13 +844,10 @@ const _ProjectController = {
}
const hasPaidSubscription = isPaidSubscription(subscription)
const hasManuallyCollectedSubscription =
subscription?.collectionMethod === 'manual'
const assistantDisabled = user.aiErrorAssistant?.enabled === false // the assistant has been manually disabled by the user
const canUseErrorAssistant =
(!hasManuallyCollectedSubscription ||
fullFeatureSet?.aiErrorAssistant) &&
!assistantDisabled
// todo: assist clean-up: remove other case once migration finishes
const aiFeaturesDisabled =
user.aiFeatures?.enabled === false ||
user.aiErrorAssistant?.enabled === false // the assistant has been manually disabled by the user
const addonPrices =
isOverleafAssistBundleEnabled &&
@@ -958,7 +955,7 @@ const _ProjectController = {
showSymbolPalette,
symbolPaletteAvailable: Features.hasFeature('symbol-palette'),
userRestrictions: Array.from(req.userRestrictions || []),
showAiErrorAssistant: aiFeaturesAllowed && canUseErrorAssistant,
showAiFeatures: aiFeaturesAllowed && !aiFeaturesDisabled,
detachRole,
metadata: { viewport: false },
showUpgradePrompt,