migrateSonnet1mToSonnet45.ts
migrations/migrateSonnet1mToSonnet45.ts
No strong subsystem tag
49
Lines
1582
Bytes
1
Exports
3
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 49 lines, 3 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/migrateSonnet45ToSonnet46.ts
Detected exports
migrateSonnet1mToSonnet45
Keywords
sonnetmodelconfiguserssettingssonnet-4-5-20250929usersettingsoverridegetmainloopmodeloverridesetmainloopmodeloverride
Detected imports
../bootstrap/state.js../utils/config.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 {
getMainLoopModelOverride,
setMainLoopModelOverride,
} from '../bootstrap/state.js'
import { getGlobalConfig, saveGlobalConfig } from '../utils/config.js'
import {
getSettingsForSource,
updateSettingsForSource,
} from '../utils/settings/settings.js'
/**
* Migrate users who had "sonnet[1m]" saved to the explicit "sonnet-4-5-20250929[1m]".
*
* The "sonnet" alias now resolves to Sonnet 4.6, so users who previously set
* "sonnet[1m]" (targeting Sonnet 4.5 with 1M context) need to be pinned to the
* explicit version to preserve their intended model.
*
* This is needed because Sonnet 4.6 1M was offered to a different group of users than
* Sonnet 4.5 1M, so we needed to pin existing sonnet[1m] users to Sonnet 4.5 1M.
*
* Reads from userSettings specifically (not merged settings) so we don't
* promote a project-scoped "sonnet[1m]" to the global default. Runs once,
* tracked by a completion flag in global config.
*/
export function migrateSonnet1mToSonnet45(): void {
const config = getGlobalConfig()
if (config.sonnet1m45MigrationComplete) {
return
}
const model = getSettingsForSource('userSettings')?.model
if (model === 'sonnet[1m]') {
updateSettingsForSource('userSettings', {
model: 'sonnet-4-5-20250929[1m]',
})
}
// Also migrate the in-memory override if already set
const override = getMainLoopModelOverride()
if (override === 'sonnet[1m]') {
setMainLoopModelOverride('sonnet-4-5-20250929[1m]')
}
saveGlobalConfig(current => ({
...current,
sonnet1m45MigrationComplete: true,
}))
}