resetProToOpusDefault.ts
migrations/resetProToOpusDefault.ts
No strong subsystem tag
52
Lines
1550
Bytes
1
Exports
5
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with general runtime concerns. It contains 52 lines, 5 detected imports, and 1 detected exports.
Important relationships
- migrations/migrateAutoUpdatesToSettings.ts
- migrations/migrateBypassPermissionsAcceptedToSettings.ts
- migrations/migrateEnableAllProjectMcpServersToSettings.ts
- migrations/migrateFennecToOpus.ts
- migrations/migrateLegacyOpusToCurrent.ts
- migrations/migrateOpusToOpus1m.ts
- migrations/migrateReplBridgeEnabledToRemoteControlAtStartup.ts
- migrations/migrateSonnet1mToSonnet45.ts
Detected exports
resetProToOpusDefault
Keywords
currentlogeventutilssaveglobalconfigmodelsettingsopuspromigrationcompleteconfigtengu_reset_pro_to_opus_defaultskipped
Detected imports
src/services/analytics/index.js../utils/auth.js../utils/config.js../utils/model/providers.js../utils/settings/settings.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { logEvent } from 'src/services/analytics/index.js'
import { isProSubscriber } from '../utils/auth.js'
import { getGlobalConfig, saveGlobalConfig } from '../utils/config.js'
import { getAPIProvider } from '../utils/model/providers.js'
import { getSettings_DEPRECATED } from '../utils/settings/settings.js'
export function resetProToOpusDefault(): void {
const config = getGlobalConfig()
if (config.opusProMigrationComplete) {
return
}
const apiProvider = getAPIProvider()
// Pro users on firstParty get auto-migrated to Opus 4.5 default
if (apiProvider !== 'firstParty' || !isProSubscriber()) {
saveGlobalConfig(current => ({
...current,
opusProMigrationComplete: true,
}))
logEvent('tengu_reset_pro_to_opus_default', { skipped: true })
return
}
const settings = getSettings_DEPRECATED()
// Only show notification if user was on default (no custom model setting)
if (settings?.model === undefined) {
const opusProMigrationTimestamp = Date.now()
saveGlobalConfig(current => ({
...current,
opusProMigrationComplete: true,
opusProMigrationTimestamp,
}))
logEvent('tengu_reset_pro_to_opus_default', {
skipped: false,
had_custom_model: false,
})
} else {
// User has a custom model setting, just mark migration complete
saveGlobalConfig(current => ({
...current,
opusProMigrationComplete: true,
}))
logEvent('tengu_reset_pro_to_opus_default', {
skipped: false,
had_custom_model: true,
})
}
}